OSDN Git Service

Let debug builds set SubscriptionPlan owners.
authorJeff Sharkey <jsharkey@android.com>
Wed, 14 Feb 2018 21:26:10 +0000 (14:26 -0700)
committerJeff Sharkey <jsharkey@android.com>
Wed, 14 Feb 2018 21:26:13 +0000 (14:26 -0700)
Examine system property to decide if a test app should be granted
the ability to manage SubscriptionPlan details for a specific subId.

This doesn't give the testing app any access to existing plans
defined by other carrier apps, it only allows the testing app to
provide plans for testing purposes.  Purposefully ignored on
end-user builds.

Test: builds, boots
Bug: 73173096
Change-Id: I926ec0f88b7c2c282a1ec4410eaab92e1e1090dd

services/core/java/com/android/server/net/NetworkPolicyManagerService.java

index f346629..e2b2d46 100644 (file)
@@ -145,6 +145,7 @@ import android.net.TrafficStats;
 import android.net.wifi.WifiConfiguration;
 import android.net.wifi.WifiManager;
 import android.os.Binder;
+import android.os.Build;
 import android.os.Environment;
 import android.os.Handler;
 import android.os.HandlerThread;
@@ -2759,6 +2760,13 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
             return;
         }
 
+        // Fourth check: is caller a testing app on a debug build?
+        final boolean enableDebug = Build.IS_USERDEBUG || Build.IS_ENG;
+        if (enableDebug && callingPackage
+                .equals(SystemProperties.get("fw.sub_plan_owner." + subId, null))) {
+            return;
+        }
+
         // Final check: does the caller hold a permission?
         mContext.enforceCallingOrSelfPermission(MANAGE_SUBSCRIPTION_PLANS, TAG);
     }