DO NOT MERGE - Add flag to turn on/off the headless user specific blacklist/whitelist

Bug: 145626101
Test: manual: set config_systemUserPackagesBlacklistSupported
build and flash
Verify with: 1. adb shell dumpsys package packages
2. adb logcat | grep "blacklist"

Change-Id: I5b45fc86e4c5008933bf361d5bb32a2c17259655
(cherry picked from commit d1c59ec220e95f881feefb55eb099b6f602d4e05)
This commit is contained in:
Yan Zhu
2019-12-17 14:00:16 -08:00
parent f8c0b31524
commit 81ce02f510
3 changed files with 25 additions and 2 deletions

View File

@@ -1692,6 +1692,9 @@
This feature should be disabled for most devices. --> This feature should be disabled for most devices. -->
<integer name="config_virtualKeyQuietTimeMillis">0</integer> <integer name="config_virtualKeyQuietTimeMillis">0</integer>
<!-- Flag indicating whether system user specific blacklist/whitelist is supported -->
<bool name="config_systemUserPackagesBlacklistSupported">false</bool>
<!-- A list of potential packages, in priority order, that may contain an <!-- A list of potential packages, in priority order, that may contain an
ephemeral resolver. Each package will be be queried for a component ephemeral resolver. Each package will be be queried for a component
that has been granted the PACKAGE_EPHEMERAL_AGENT permission. that has been granted the PACKAGE_EPHEMERAL_AGENT permission.

View File

@@ -308,6 +308,7 @@
<java-symbol type="bool" name="config_sms_utf8_support" /> <java-symbol type="bool" name="config_sms_utf8_support" />
<java-symbol type="bool" name="config_suspendWhenScreenOffDueToProximity" /> <java-symbol type="bool" name="config_suspendWhenScreenOffDueToProximity" />
<java-symbol type="bool" name="config_swipeDisambiguation" /> <java-symbol type="bool" name="config_swipeDisambiguation" />
<java-symbol type="bool" name="config_systemUserPackagesBlacklistSupported" />
<java-symbol type="bool" name="config_syncstorageengine_masterSyncAutomatically" /> <java-symbol type="bool" name="config_syncstorageengine_masterSyncAutomatically" />
<java-symbol type="bool" name="config_ui_enableFadingMarquee" /> <java-symbol type="bool" name="config_ui_enableFadingMarquee" />
<java-symbol type="bool" name="config_enableHapticTextHandle" /> <java-symbol type="bool" name="config_enableHapticTextHandle" />

View File

@@ -2320,12 +2320,26 @@ public class PackageManagerService extends IPackageManager.Stub
return m; return m;
} }
private boolean isSystemUserPackagesBlacklistSupported() {
return Resources.getSystem().getBoolean(
R.bool.config_systemUserPackagesBlacklistSupported);
}
private void enableSystemUserPackages() { private void enableSystemUserPackages() {
boolean isHeadlessSystemUserMode = UserManager.isHeadlessSystemUserMode(); if (!isSystemUserPackagesBlacklistSupported()) {
if (!isHeadlessSystemUserMode && !UserManager.isSplitSystemUser()) { Log.i(TAG, "Skipping system user blacklist since "
+ "config_systemUserPackagesBlacklistSupported is false");
return; return;
} }
boolean isHeadlessSystemUserMode = UserManager.isHeadlessSystemUserMode();
if (!isHeadlessSystemUserMode && !UserManager.isSplitSystemUser()) {
Log.i(TAG, "Skipping system user blacklist on 'regular' device type");
return;
}
Log.i(TAG, "blacklisting packages for system user");
Set<String> enableApps = new ArraySet<>(); Set<String> enableApps = new ArraySet<>();
AppsQueryHelper queryHelper = new AppsQueryHelper(this); AppsQueryHelper queryHelper = new AppsQueryHelper(this);
List<String> allAps = queryHelper.queryApps(0, /* systemAppsOnly */ false, List<String> allAps = queryHelper.queryApps(0, /* systemAppsOnly */ false,
@@ -22296,6 +22310,11 @@ public class PackageManagerService extends IPackageManager.Stub
if (dumpState.isDumping(DumpState.DUMP_PACKAGES)) { if (dumpState.isDumping(DumpState.DUMP_PACKAGES)) {
mSettings.dumpPackagesLPr(pw, packageName, permissionNames, dumpState, checkin); mSettings.dumpPackagesLPr(pw, packageName, permissionNames, dumpState, checkin);
boolean systemUserPackagesBlacklistSupported =
isSystemUserPackagesBlacklistSupported();
pw.println("isSystemUserPackagesBlacklistSupported: "
+ systemUserPackagesBlacklistSupported);
} }
if (dumpState.isDumping(DumpState.DUMP_SHARED_USERS)) { if (dumpState.isDumping(DumpState.DUMP_SHARED_USERS)) {