OSDN Git Service

Allow shell to enable/disable individual component in test package
authorTony Mak <tonymak@google.com>
Tue, 8 Nov 2016 19:30:55 +0000 (19:30 +0000)
committerTony Mak <tonymak@google.com>
Tue, 8 Nov 2016 19:31:54 +0000 (19:31 +0000)
Test: cts-tradefed run cts --module DevicePolicyManager --test com.android.cts.devicepolicy.ManagedProfileTest#testAppLinks_enabledStatus

Bug: 32695379
Change-Id: I0fa22f50f1aa344195b7c6bc1e6ee97879d91c46

services/core/java/com/android/server/pm/PackageManagerService.java

index ca77335..f09d06e 100644 (file)
@@ -18088,8 +18088,10 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
         }
 
         synchronized (mPackages) {
-            if (uid == Process.SHELL_UID) {
+            if (uid == Process.SHELL_UID
+                    && (pkgSetting.pkgFlags & ApplicationInfo.FLAG_TEST_ONLY) == 0) {
                 // Shell can only change whole packages between ENABLED and DISABLED_USER states
+                // unless it is a test package.
                 int oldState = pkgSetting.getEnabled(userId);
                 if (className == null
                     &&