Loading services/core/java/com/android/server/pm/UserSystemPackageInstaller.java +5 −1 Original line number Diff line number Diff line Loading @@ -344,7 +344,7 @@ class UserSystemPackageInstaller { */ @NonNull private List<String> getPackagesWhitelistErrors(@PackageWhitelistMode int mode) { if ((!isEnforceMode(mode) || isImplicitWhitelistMode(mode)) && !isLogMode(mode)) { if ((!isEnforceMode(mode) || isImplicitWhitelistMode(mode))) { return Collections.emptyList(); } Loading Loading @@ -752,6 +752,10 @@ class UserSystemPackageInstaller { } else if (mode == USER_TYPE_PACKAGE_WHITELIST_MODE_DEVICE_DEFAULT) { mode = getDeviceDefaultWhitelistMode(); } if (criticalOnly) { // Flip-out log mode mode &= ~USER_TYPE_PACKAGE_WHITELIST_MODE_LOG; } Slog.v(TAG, "dumpPackageWhitelistProblems(): using mode " + modeToString(mode)); final List<String> errors = getPackagesWhitelistErrors(mode); Loading services/tests/servicestests/src/com/android/server/pm/UserManagerServiceTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -22,10 +22,14 @@ import android.os.FileUtils; import android.os.Parcelable; import android.os.UserHandle; import android.os.UserManager; import android.support.test.uiautomator.UiDevice; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; import android.text.TextUtils; import android.util.AtomicFile; import androidx.test.InstrumentationRegistry; import java.io.File; import java.io.IOException; import java.util.Arrays; Loading Loading @@ -74,6 +78,14 @@ public class UserManagerServiceTest extends AndroidTestCase { assertEquals(accountName, um.getUserAccount(tempUserId)); } public void testUserSystemPackageWhitelist() throws Exception { String cmd = "cmd user report-system-user-package-whitelist-problems --critical-only"; final String result = runShellCommand(cmd); if (!TextUtils.isEmpty(result)) { fail("Command '" + cmd + " reported errors:\n" + result); } } private Bundle createBundle() { Bundle result = new Bundle(); // Tests for 6 allowed types: Integer, Boolean, String, String[], Bundle and Parcelable[] Loading Loading @@ -118,4 +130,8 @@ public class UserManagerServiceTest extends AndroidTestCase { assertEquals(1, childBundle.getInt("bundle_int")); } private static String runShellCommand(String cmd) throws Exception { return UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) .executeShellCommand(cmd); } } Loading
services/core/java/com/android/server/pm/UserSystemPackageInstaller.java +5 −1 Original line number Diff line number Diff line Loading @@ -344,7 +344,7 @@ class UserSystemPackageInstaller { */ @NonNull private List<String> getPackagesWhitelistErrors(@PackageWhitelistMode int mode) { if ((!isEnforceMode(mode) || isImplicitWhitelistMode(mode)) && !isLogMode(mode)) { if ((!isEnforceMode(mode) || isImplicitWhitelistMode(mode))) { return Collections.emptyList(); } Loading Loading @@ -752,6 +752,10 @@ class UserSystemPackageInstaller { } else if (mode == USER_TYPE_PACKAGE_WHITELIST_MODE_DEVICE_DEFAULT) { mode = getDeviceDefaultWhitelistMode(); } if (criticalOnly) { // Flip-out log mode mode &= ~USER_TYPE_PACKAGE_WHITELIST_MODE_LOG; } Slog.v(TAG, "dumpPackageWhitelistProblems(): using mode " + modeToString(mode)); final List<String> errors = getPackagesWhitelistErrors(mode); Loading
services/tests/servicestests/src/com/android/server/pm/UserManagerServiceTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -22,10 +22,14 @@ import android.os.FileUtils; import android.os.Parcelable; import android.os.UserHandle; import android.os.UserManager; import android.support.test.uiautomator.UiDevice; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; import android.text.TextUtils; import android.util.AtomicFile; import androidx.test.InstrumentationRegistry; import java.io.File; import java.io.IOException; import java.util.Arrays; Loading Loading @@ -74,6 +78,14 @@ public class UserManagerServiceTest extends AndroidTestCase { assertEquals(accountName, um.getUserAccount(tempUserId)); } public void testUserSystemPackageWhitelist() throws Exception { String cmd = "cmd user report-system-user-package-whitelist-problems --critical-only"; final String result = runShellCommand(cmd); if (!TextUtils.isEmpty(result)) { fail("Command '" + cmd + " reported errors:\n" + result); } } private Bundle createBundle() { Bundle result = new Bundle(); // Tests for 6 allowed types: Integer, Boolean, String, String[], Bundle and Parcelable[] Loading Loading @@ -118,4 +130,8 @@ public class UserManagerServiceTest extends AndroidTestCase { assertEquals(1, childBundle.getInt("bundle_int")); } private static String runShellCommand(String cmd) throws Exception { return UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) .executeShellCommand(cmd); } }