summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael W <baddaemon87@gmail.com>2019-11-01 10:11:29 (GMT)
committerMichael W <baddaemon87@gmail.com>2019-11-17 16:33:54 (GMT)
commiteae2c874a66f5b1d1567a260ee0047c7453391d0 (patch)
treee50e3d76618c6fe2e94dbf5dca7fafd17c2db313
parentf11d05f8f922d8a20312f6c8a3e09d37d334d217 (diff)
downloadframeworks_base-eae2c874a66f5b1d1567a260ee0047c7453391d0.zip
frameworks_base-eae2c874a66f5b1d1567a260ee0047c7453391d0.tar.gz
frameworks_base-eae2c874a66f5b1d1567a260ee0047c7453391d0.tar.bz2
PackageManager: Refactor en-/disabling of components
* Don't use the same code twice, make it reusable Change-Id: I9fc388f56cea413654a390cb0ccd15a706fb3ad8
-rw-r--r--services/core/java/com/android/server/pm/PackageManagerService.java41
1 files changed, 18 insertions, 23 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 8c176ae..7edf729 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -3183,25 +3183,14 @@ public class PackageManagerService extends IPackageManager.Stub
// Disable components marked for disabling at build-time
mDisabledComponentsList = new ArrayList<ComponentName>();
- disableComponents(mContext.getResources().getStringArray(
- com.android.internal.R.array.config_deviceDisabledComponents));
- disableComponents(mContext.getResources().getStringArray(
- com.android.internal.R.array.config_globallyDisabledComponents));
+ enableComponents(mContext.getResources().getStringArray(
+ com.android.internal.R.array.config_deviceDisabledComponents), false);
+ enableComponents(mContext.getResources().getStringArray(
+ com.android.internal.R.array.config_globallyDisabledComponents), false);
// Enable components marked for forced-enable at build-time
- for (String name : mContext.getResources().getStringArray(
- com.android.internal.R.array.config_forceEnabledComponents)) {
- ComponentName cn = ComponentName.unflattenFromString(name);
- Slog.v(TAG, "Enabling " + name);
- String className = cn.getClassName();
- PackageSetting pkgSetting = mSettings.mPackages.get(cn.getPackageName());
- if (pkgSetting == null || pkgSetting.pkg == null
- || !pkgSetting.pkg.hasComponentClassName(className)) {
- Slog.w(TAG, "Unable to enable " + name);
- continue;
- }
- pkgSetting.enableComponentLPw(className, UserHandle.USER_OWNER);
- }
+ enableComponents(mContext.getResources().getStringArray(
+ com.android.internal.R.array.config_forceEnabledComponents), true);
// If this is first boot after an OTA, and a normal boot, then
// we need to clear code cache directories.
@@ -3319,20 +3308,26 @@ public class PackageManagerService extends IPackageManager.Stub
Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
}
- private void disableComponents(String[] components) {
- // Disable components marked for disabling at build-time
+ private void enableComponents(String[] components, boolean enable) {
+ // Disable or enable components marked at build-time
for (String name : components) {
ComponentName cn = ComponentName.unflattenFromString(name);
- mDisabledComponentsList.add(cn);
- Slog.v(TAG, "Disabling " + name);
+ if (!enable) {
+ mDisabledComponentsList.add(cn);
+ }
+ Slog.v(TAG, "Changing enabled state of " + name + " to " + enable);
String className = cn.getClassName();
PackageSetting pkgSetting = mSettings.mPackages.get(cn.getPackageName());
if (pkgSetting == null || pkgSetting.pkg == null
|| !pkgSetting.pkg.hasComponentClassName(className)) {
- Slog.w(TAG, "Unable to disable " + name);
+ Slog.w(TAG, "Unable to change enabled state of " + name + " to " + enable);
continue;
}
- pkgSetting.disableComponentLPw(className, UserHandle.USER_OWNER);
+ if (enable) {
+ pkgSetting.enableComponentLPw(className, UserHandle.USER_OWNER);
+ } else {
+ pkgSetting.disableComponentLPw(className, UserHandle.USER_OWNER);
+ }
}
}