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

Commit 20016c9a authored by Pawit Pornkitprasan's avatar Pawit Pornkitprasan
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 7b670950
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1287,4 +1287,8 @@

    <!-- True if the Irda service should be started at system start -->
    <bool name="config_enableIrdaManagerService">false</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
@@ -2045,4 +2045,7 @@
  <!-- Irda Service -->
  <java-symbol type="bool" name="config_enableIrdaManagerService" />

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

</resources>
+15 −0
Original line number Diff line number Diff line
@@ -1418,6 +1418,21 @@ public class PackageManagerService extends IPackageManager.Stub {
                mSettings.readDefaultPreferredAppsLPw(this, 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();