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

Commit f9e4ad62 authored by Pawit Pornkitprasan's avatar Pawit Pornkitprasan Committed by Ricardo Cerqueira
Browse files

PackageManager: allow build-time disabling of components

Allow components to be specified as disabled at build time
(applied on boot).

This allows stock OTA components to be marked as disabled in
CM builds.

Change-Id: I6e4499cc40a779792a5ea97a10137399dad7d69f
parent 39e05c74
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1150,4 +1150,8 @@
    <!-- True if the pie service should be started at system start. This is must be true
         to support pie controls. -->
    <bool name="config_allowPieService">true</bool>

    <!-- The list of components which should be automatically disabled. -->
    <string-array name="config_disabledComponents" translatable="false">
    </string-array>
</resources>
+3 −0
Original line number Diff line number Diff line
@@ -2014,4 +2014,7 @@
  <java-symbol type="string" name="privacy_guard_notification" />
  <java-symbol type="string" name="privacy_guard_notification_detail" />
  <java-symbol type="drawable" name="stat_notify_privacy_guard" />

  <!-- Package Manager -->
  <java-symbol type="array" name="config_disabledComponents" />
</resources>
+15 −0
Original line number Diff line number Diff line
@@ -1323,6 +1323,21 @@ public class PackageManagerService extends IPackageManager.Stub {
                            ? (UPDATE_PERMISSIONS_REPLACE_PKG|UPDATE_PERMISSIONS_REPLACE_ALL)
                            : 0));

            // Disable components marked for disabling at build-time
            for (String name : mContext.getResources().getStringArray(
                    com.android.internal.R.array.config_disabledComponents)) {
                ComponentName cn = ComponentName.unflattenFromString(name);
                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);
            }

            // can downgrade to reader
            mSettings.writeLPr();