Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0df2d7e2 authored by Michael W's avatar Michael W
Browse files

PM: Allow disabling components per-device

* Introduce a new overlayable string-array
  "config_deviceDisabledComponents"
* This is equally used to disable components per-device, e.g.
  NearbyMessagingService
* At the same time, rename config_disabledComponents to
  config_globallyDisabledComponents to reflect the difference

Change-Id: Ieeec0788b063a33e8a2830dd95b239c99a58466f
parent 5cd43b35
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -23,8 +23,13 @@
         true will use SystemClock.elapsedRealtimeNanos() to set timestamp. -->
    <bool name="config_useSystemClockforRotationSensor">false</bool>

    <!-- The list of components which should be automatically disabled. -->
    <string-array name="config_disabledComponents" translatable="false">
    <!-- The list of components which should be automatically disabled for a specific device.
         Note: this MUST not be used to randomly disable components, ask for approval first! -->
    <string-array name="config_deviceDisabledComponents" translatable="false">
    </string-array>

    <!-- The list of components which should be automatically disabled for all devices. -->
    <string-array name="config_globallyDisabledComponents" translatable="false">
    </string-array>

    <!-- The list of components which should be forced to be enabled. -->
+2 −1
Original line number Diff line number Diff line
@@ -28,7 +28,8 @@
    <java-symbol type="bool" name="config_useSystemClockforRotationSensor" />

    <!-- Package Manager -->
    <java-symbol type="array" name="config_disabledComponents" />
    <java-symbol type="array" name="config_deviceDisabledComponents" />
    <java-symbol type="array" name="config_globallyDisabledComponents" />
    <java-symbol type="array" name="config_forceEnabledComponents" />

    <!-- Privacy Guard -->
+21 −14
Original line number Diff line number Diff line
@@ -3183,20 +3183,10 @@ public class PackageManagerService extends IPackageManager.Stub
            // Disable components marked for disabling at build-time
            mDisabledComponentsList = new ArrayList<ComponentName>();
            for (String name : mContext.getResources().getStringArray(
                    com.android.internal.R.array.config_disabledComponents)) {
                ComponentName cn = ComponentName.unflattenFromString(name);
                mDisabledComponentsList.add(cn);
                Slog.v(TAG, "Disabling " + 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 disable " + name);
                    continue;
                }
                pkgSetting.disableComponentLPw(className, UserHandle.USER_OWNER);
            }
            disableComponents(mContext.getResources().getStringArray(
                    com.android.internal.R.array.config_deviceDisabledComponents));
            disableComponents(mContext.getResources().getStringArray(
                    com.android.internal.R.array.config_globallyDisabledComponents));
            // Enable components marked for forced-enable at build-time
            for (String name : mContext.getResources().getStringArray(
@@ -3329,6 +3319,23 @@ 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
        for (String name : components) {
            ComponentName cn = ComponentName.unflattenFromString(name);
            mDisabledComponentsList.add(cn);
            Slog.v(TAG, "Disabling " + 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 disable " + name);
                continue;
            }
            pkgSetting.disableComponentLPw(className, UserHandle.USER_OWNER);
        }
    }
    /**
     * Uncompress and install stub applications.
     * <p>In order to save space on the system partition, some applications are shipped in a