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

Commit fcd88f46 authored by Scott Mertz's avatar Scott Mertz Committed by Gerrit Code Review
Browse files

am: clear protected apps from recents

Remove newly protected apps from recent tasks if any activity
in the stack is a restricted component.

FEIJ-1361
Change-Id: Ifd337bfe8356613d098ff00c575db117d35f2017
parent 95ae413f
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -9069,6 +9069,27 @@ public final class ActivityManagerService extends ActivityManagerNative
        }
    }
    private void cleanupProtectedComponentTasksLocked() {
        for (int i = mRecentTasks.size() - 1; i >= 0; i--) {
            TaskRecord tr = mRecentTasks.get(i);
            for (int j = tr.mActivities.size() - 1; j >= 0; j--) {
                ActivityRecord r = tr.mActivities.get(j);
                ComponentName cn = r.realActivity;
                try {
                    boolean isProtected = AppGlobals.getPackageManager()
                        .isComponentProtected(null, -1, cn, getCurrentUserIdLocked());
                    if (isProtected) {
                        removeTaskByIdLocked(tr.taskId, false);
                    }
                } catch (RemoteException re) {
                }
            }
        }
    }
    /**
     * Removes the task with the specified task id.
     *
@@ -12068,6 +12089,7 @@ public final class ActivityManagerService extends ActivityManagerNative
            mRecentTasks.clear();
            mRecentTasks.addAll(mTaskPersister.restoreTasksLocked());
            cleanupProtectedComponentTasksLocked();
            mRecentTasks.cleanupLocked(UserHandle.USER_ALL);
            mTaskPersister.startPersisting();
@@ -17111,6 +17133,14 @@ public final class ActivityManagerService extends ActivityManagerNative
                    ProxyInfo proxy = intent.getParcelableExtra(Proxy.EXTRA_PROXY_INFO);
                    mHandler.sendMessage(mHandler.obtainMessage(UPDATE_HTTP_PROXY_MSG, proxy));
                    break;
                case cyanogenmod.content.Intent.ACTION_PROTECTED_CHANGED:
                    final boolean state =
                            intent.getBooleanExtra(
                                    cyanogenmod.content.Intent.EXTRA_PROTECTED_STATE, false);
                    if (state == PackageManager.COMPONENT_PROTECTED_STATUS) {
                        cleanupProtectedComponentTasksLocked();
                    }
                    break;
            }
        }
+2 −1
Original line number Diff line number Diff line
@@ -17302,7 +17302,8 @@ public class PackageManagerService extends IPackageManager.Stub {
        //If this component is launched from the system or a uid of a protected component, allow it.
        boolean fromProtectedComponentUid = false;
        for (String protectedComponentManager : protectedComponentManagers) {
            if (callingUid == getPackageUid(protectedComponentManager, userId)) {
            int packageUid = getPackageUid(protectedComponentManager, userId);
            if (packageUid != -1 && callingUid == packageUid) {
                fromProtectedComponentUid = true;
            }
        }