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

Commit 0283544c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Allow background default container service in a less crashy way" into oc-dev

parents 448727bd 424b03f7
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -635,6 +635,11 @@ interface IActivityManager {
     */
     */
    int getLastResumedActivityUserId();
    int getLastResumedActivityUserId();


    /**
     * Add a bare uid to the background restrictions whitelist.  Only the system uid may call this.
     */
     void backgroundWhitelistUid(int uid);

    // WARNING: when these transactions are updated, check if they are any callers on the native
    // WARNING: when these transactions are updated, check if they are any callers on the native
    // side. If so, make sure they are using the correct transaction ids and arguments.
    // side. If so, make sure they are using the correct transaction ids and arguments.
    // If a transaction which will also be used on the native side is being inserted, add it
    // If a transaction which will also be used on the native side is being inserted, add it
+18 −0
Original line number Original line Diff line number Diff line
@@ -12143,6 +12143,24 @@ public class ActivityManagerService extends IActivityManager.Stub
        return false;
        return false;
    }
    }
    @Override
    public void backgroundWhitelistUid(final int uid) {
        if (Binder.getCallingUid() != Process.SYSTEM_UID) {
            throw new SecurityException("Only the OS may call backgroundWhitelistUid()");
        }
        if (DEBUG_BACKGROUND_CHECK) {
            Slog.i(TAG, "Adding uid " + uid + " to bg uid whitelist");
        }
        synchronized (this) {
            final int N = mBackgroundUidWhitelist.length;
            int[] newList = new int[N+1];
            System.arraycopy(mBackgroundUidWhitelist, 0, newList, 0, N);
            newList[N] = uid;
            mBackgroundUidWhitelist = newList;
        }
    }
    final ProcessRecord addAppLocked(ApplicationInfo info, String customProcess, boolean isolated,
    final ProcessRecord addAppLocked(ApplicationInfo info, String customProcess, boolean isolated,
            String abiOverride) {
            String abiOverride) {
        ProcessRecord app;
        ProcessRecord app;
+15 −0
Original line number Original line Diff line number Diff line
@@ -608,6 +608,10 @@ public class PackageManagerService extends IPackageManager.Stub {
    final boolean mIsPreNUpgrade;
    final boolean mIsPreNUpgrade;
    final boolean mIsPreNMR1Upgrade;
    final boolean mIsPreNMR1Upgrade;
    // Have we told the Activity Manager to whitelist the default container service by uid yet?
    @GuardedBy("mPackages")
    boolean mDefaultContainerWhitelisted = false;
    @GuardedBy("mPackages")
    @GuardedBy("mPackages")
    private boolean mDexOptDialogShown;
    private boolean mDexOptDialogShown;
@@ -13050,7 +13054,18 @@ public class PackageManagerService extends IPackageManager.Stub {
        intent.setComponent(DEFAULT_CONTAINER_COMPONENT);
        intent.setComponent(DEFAULT_CONTAINER_COMPONENT);
        IActivityManager am = ActivityManager.getService();
        IActivityManager am = ActivityManager.getService();
        if (am != null) {
        if (am != null) {
            int dcsUid = -1;
            synchronized (mPackages) {
                if (!mDefaultContainerWhitelisted) {
                    mDefaultContainerWhitelisted = true;
                    PackageSetting ps = mSettings.mPackages.get(DEFAULT_CONTAINER_PACKAGE);
                    dcsUid = UserHandle.getUid(UserHandle.USER_SYSTEM, ps.appId);
                }
            }
            try {
            try {
                if (dcsUid > 0) {
                    am.backgroundWhitelistUid(dcsUid);
                }
                am.startService(null, intent, null, -1, null, false, mContext.getOpPackageName(),
                am.startService(null, intent, null, -1, null, false, mContext.getOpPackageName(),
                        UserHandle.USER_SYSTEM);
                        UserHandle.USER_SYSTEM);
            } catch (RemoteException e) {
            } catch (RemoteException e) {