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

Commit 35feb779 authored by Wale Ogunwale's avatar Wale Ogunwale Committed by Android (Google) Code Review
Browse files

Merge "Moved mRecentTasks to ActivityManagerTaskService (4/n)"

parents ecfbc638 16e505a3
Loading
Loading
Loading
Loading
+20 −34
Original line number Diff line number Diff line
@@ -685,11 +685,6 @@ public class ActivityManagerService extends IActivityManager.Stub
     */
    private AppTimeTracker mCurAppTimeTracker;
    /**
     * List of intents that were used to start the most recent tasks.
     */
    private final RecentTasks mRecentTasks;
    /**
     * The package name of the DeviceOwner. This package is not permitted to have its data cleared.
     */
@@ -2902,7 +2897,6 @@ public class ActivityManagerService extends IActivityManager.Stub
        mProcessCpuThread = null;
        mProcessStats = null;
        mProviderMap = null;
        mRecentTasks = null;
        mServices = null;
        mStackSupervisor = null;
        mSystemThread = null;
@@ -3008,8 +3002,6 @@ public class ActivityManagerService extends IActivityManager.Stub
        mTaskChangeNotificationController =
                new TaskChangeNotificationController(this, mStackSupervisor, mHandler);
        mActivityStartController = new ActivityStartController(this);
        mRecentTasks = createRecentTasks();
        mStackSupervisor.setRecentTasks(mRecentTasks);
        mLockTaskController = new LockTaskController(mContext, mStackSupervisor, mHandler);
        mLifecycleManager = new ClientLifecycleManager();
@@ -3071,14 +3063,6 @@ public class ActivityManagerService extends IActivityManager.Stub
        return supervisor;
    }
    protected RecentTasks createRecentTasks() {
        return new RecentTasks(this, mStackSupervisor);
    }
    RecentTasks getRecentTasks() {
        return mRecentTasks;
    }
    public void setSystemServiceManager(SystemServiceManager mgr) {
        mSystemServiceManager = mgr;
    }
@@ -3108,7 +3092,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    }
    void onUserStoppedLocked(int userId) {
        mRecentTasks.unloadUserDataFromMemoryLocked(userId);
        mActivityTaskManager.getRecentTasks().unloadUserDataFromMemoryLocked(userId);
        mAllowAppSwitchUids.remove(userId);
    }
@@ -5603,7 +5587,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                if (appInfo != null) {
                    forceStopPackageLocked(packageName, appInfo.uid, "clear data");
                    mRecentTasks.removeTasksByPackageName(packageName, resolvedUserId);
                    mActivityTaskManager.getRecentTasks().removeTasksByPackageName(packageName, resolvedUserId);
                }
            }
@@ -6221,7 +6205,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
        // Clean-up disabled tasks
        mRecentTasks.cleanupDisabledPackageTasksLocked(packageName, disabledClasses, userId);
        mActivityTaskManager.getRecentTasks().cleanupDisabledPackageTasksLocked(packageName, disabledClasses, userId);
        // Clean-up disabled services.
        mServices.bringDownDisabledPackageServicesLocked(
@@ -7833,7 +7817,7 @@ public class ActivityManagerService extends IActivityManager.Stub
     * This can be called with or without the global lock held.
     */
    void enforceCallerIsRecentsOrHasPermission(String permission, String func) {
        if (!mRecentTasks.isCallerRecents(Binder.getCallingUid())) {
        if (!mActivityTaskManager.getRecentTasks().isCallerRecents(Binder.getCallingUid())) {
            enforceCallingPermission(permission, func);
        }
    }
@@ -9296,7 +9280,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    }
    boolean isGetTasksAllowed(String caller, int callingPid, int callingUid) {
        if (mRecentTasks.isCallerRecents(callingUid)) {
        if (mActivityTaskManager.getRecentTasks().isCallerRecents(callingUid)) {
            // Always allow the recents component to get tasks
            return true;
        }
@@ -11011,7 +10995,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    /** Pokes the task persister. */
    void notifyTaskPersisterLocked(TaskRecord task, boolean flush) {
        mRecentTasks.notifyTaskPersisterLocked(task, flush);
        mActivityTaskManager.getRecentTasks().notifyTaskPersisterLocked(task, flush);
    }
    @Override
@@ -11162,7 +11146,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            return true;
        }
        if (mRecentTasks.isCallerRecents(sourceUid)) {
        if (mActivityTaskManager.getRecentTasks().isCallerRecents(sourceUid)) {
            return true;
        }
@@ -12362,7 +12346,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            mVrController.onSystemReady();
            // Make sure we have the current profile info, since it is needed for security checks.
            mUserController.onSystemReady();
            mRecentTasks.onSystemReadyLocked();
            mActivityTaskManager.getRecentTasks().onSystemReadyLocked();
            mAppOpsService.systemReady();
            mSystemReady = true;
        }
@@ -13387,8 +13371,8 @@ public class ActivityManagerService extends IActivityManager.Stub
                }
            } else if ("recents".equals(cmd) || "r".equals(cmd)) {
                synchronized (this) {
                    if (mRecentTasks != null) {
                        mRecentTasks.dump(pw, true /* dumpAll */, dumpPackage);
                    if (mActivityTaskManager.getRecentTasks() != null) {
                        mActivityTaskManager.getRecentTasks().dump(pw, true /* dumpAll */, dumpPackage);
                    }
                }
            } else if ("binder-proxies".equals(cmd)) {
@@ -13591,8 +13575,8 @@ public class ActivityManagerService extends IActivityManager.Stub
                if (dumpAll) {
                    pw.println("-------------------------------------------------------------------------------");
                }
                if (mRecentTasks != null) {
                    mRecentTasks.dump(pw, dumpAll, dumpPackage);
                if (mActivityTaskManager.getRecentTasks() != null) {
                    mActivityTaskManager.getRecentTasks().dump(pw, dumpAll, dumpPackage);
                }
                pw.println();
                if (dumpAll) {
@@ -13668,8 +13652,8 @@ public class ActivityManagerService extends IActivityManager.Stub
                if (dumpAll) {
                    pw.println("-------------------------------------------------------------------------------");
                }
                if (mRecentTasks != null) {
                    mRecentTasks.dump(pw, dumpAll, dumpPackage);
                if (mActivityTaskManager.getRecentTasks() != null) {
                    mActivityTaskManager.getRecentTasks().dump(pw, dumpAll, dumpPackage);
                }
                pw.println();
                if (dumpAll) {
@@ -18615,14 +18599,16 @@ public class ActivityManagerService extends IActivityManager.Stub
                                    forceStopPackageLocked(list[i], -1, false, true, true,
                                            false, false, userId, "storage unmount");
                                }
                                mRecentTasks.cleanupLocked(UserHandle.USER_ALL);
                                mActivityTaskManager.getRecentTasks().cleanupLocked(
                                        UserHandle.USER_ALL);
                                sendPackageBroadcastLocked(
                                        ApplicationThreadConstants.EXTERNAL_STORAGE_UNAVAILABLE,
                                        list, userId);
                            }
                            break;
                        case Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE:
                            mRecentTasks.cleanupLocked(UserHandle.USER_ALL);
                            mActivityTaskManager.getRecentTasks().cleanupLocked(
                                    UserHandle.USER_ALL);
                            break;
                        case Intent.ACTION_PACKAGE_REMOVED:
                        case Intent.ACTION_PACKAGE_CHANGED:
@@ -18655,7 +18641,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                                        removeUriPermissionsForPackageLocked(ssp, userId, true,
                                                false);
                                        mRecentTasks.removeTasksByPackageName(ssp, userId);
                                        mActivityTaskManager.getRecentTasks().removeTasksByPackageName(ssp, userId);
                                        mServices.forceStopPackageLocked(ssp, userId);
                                        mAppWarnings.onPackageUninstalled(ssp);
@@ -18685,7 +18671,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                                    Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
                            synchronized(ActivityManagerService.this) {
                                mRecentTasks.onPackagesSuspendedChanged(
                                mActivityTaskManager.getRecentTasks().onPackagesSuspendedChanged(
                                        packageNames, suspended, userHandle);
                            }
                            break;
+1 −1
Original line number Diff line number Diff line
@@ -2760,7 +2760,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
    int runWrite(PrintWriter pw) {
        mInternal.enforceCallingPermission(android.Manifest.permission.SET_ACTIVITY_WATCHER,
                "registerUidObserver()");
        mInternal.getRecentTasks().flush();
        mInternal.mActivityTaskManager.getRecentTasks().flush();
        pw.println("All tasks persisted.");
        return 0;
    }
+4 −4
Original line number Diff line number Diff line
@@ -1099,7 +1099,7 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
            return true;
        }
        // Allow the recents component to launch the home activity.
        final RecentTasks recentTasks = mStackSupervisor.mService.getRecentTasks();
        final RecentTasks recentTasks = mStackSupervisor.mService.mActivityTaskManager.getRecentTasks();
        if (recentTasks != null && recentTasks.isCallerRecents(uid)) {
            return true;
        }
@@ -1131,8 +1131,8 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
                // We only allow home activities to be resizeable if they explicitly requested it.
                info.resizeMode = RESIZE_MODE_UNRESIZEABLE;
            }
        } else if (realActivity.getClassName().contains(LEGACY_RECENTS_PACKAGE_NAME) ||
                service.getRecentTasks().isRecentsComponent(realActivity, appInfo.uid)) {
        } else if (realActivity.getClassName().contains(LEGACY_RECENTS_PACKAGE_NAME)
                || service.mActivityTaskManager.getRecentTasks().isRecentsComponent(realActivity, appInfo.uid)) {
            activityType = ACTIVITY_TYPE_RECENTS;
        } else if (options != null && options.getLaunchActivityType() == ACTIVITY_TYPE_ASSISTANT
                && canLaunchAssistActivity(launchedFromPackage)) {
@@ -2280,7 +2280,7 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
            final File iconFile = new File(TaskPersister.getUserImagesDir(task.userId),
                    iconFilename);
            final String iconFilePath = iconFile.getAbsolutePath();
            service.getRecentTasks().saveImage(icon, iconFilePath);
            service.mActivityTaskManager.getRecentTasks().saveImage(icon, iconFilePath);
            _taskDescription.setIconFilename(iconFilePath);
        }
        taskDescription = _taskDescription;
+2 −2
Original line number Diff line number Diff line
@@ -1746,8 +1746,8 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
            String resultWho, int requestCode, int callingPid, int callingUid,
            String callingPackage, boolean ignoreTargetSecurity, boolean launchingInTask,
            ProcessRecord callerApp, ActivityRecord resultRecord, ActivityStack resultStack) {
        final boolean isCallerRecents = mService.getRecentTasks() != null &&
                mService.getRecentTasks().isCallerRecents(callingUid);
        final boolean isCallerRecents = mService.mActivityTaskManager.getRecentTasks() != null
                && mService.mActivityTaskManager.getRecentTasks().isCallerRecents(callingUid);
        final int startAnyPerm = mService.checkPermission(START_ANY_ACTIVITY, callingPid,
                callingUid);
        if (startAnyPerm == PERMISSION_GRANTED || (isCallerRecents && launchingInTask)) {
+23 −12
Original line number Diff line number Diff line
@@ -173,12 +173,13 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
    private static final String TAG_VISIBILITY = TAG + POSTFIX_VISIBILITY;
    private static final String TAG_LOCKTASK = TAG + POSTFIX_LOCKTASK;

    private Context mContext;
    private ActivityManagerService mAm;
    Context mContext;
    ActivityManagerService mAm;
    /* Global service lock used by the package the owns this service. */
    Object mGlobalLock;
    private ActivityStackSupervisor mStackSupervisor;

    ActivityStackSupervisor mStackSupervisor;
    /** List of intents that were used to start the most recent tasks. */
    private RecentTasks mRecentTasks;
    /** State of external calls telling us if the device is awake or asleep. */
    private boolean mKeyguardShown = false;

@@ -232,6 +233,16 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        mAm = am;
        mGlobalLock = mAm;
        mStackSupervisor = mAm.mStackSupervisor;
        mRecentTasks = createRecentTasks();
        mStackSupervisor.setRecentTasks(mRecentTasks);
    }

    protected RecentTasks createRecentTasks() {
        return new RecentTasks(this, mStackSupervisor);
    }

    RecentTasks getRecentTasks() {
        return mRecentTasks;
    }

    private void start() {
@@ -653,8 +664,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        final long origId = Binder.clearCallingIdentity();
        try {
            synchronized (mGlobalLock) {
                final ComponentName recentsComponent = mAm.getRecentTasks().getRecentsComponent();
                final int recentsUid = mAm.getRecentTasks().getRecentsComponentUid();
                final ComponentName recentsComponent = mRecentTasks.getRecentsComponent();
                final int recentsUid = mRecentTasks.getRecentsComponentUid();

                // Start a new recents animation
                final RecentsAnimation anim = new RecentsAnimation(mAm, mStackSupervisor,
@@ -1640,7 +1651,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                == PackageManager.PERMISSION_GRANTED;

        synchronized (mGlobalLock) {
            return mAm.getRecentTasks().getRecentTasks(maxNum, flags, allowed, detailed, userId,
            return mRecentTasks.getRecentTasks(maxNum, flags, allowed, detailed, userId,
                    callingUid);
        }
    }
@@ -1833,7 +1844,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        long ident = Binder.clearCallingIdentity();
        try {
            synchronized (mGlobalLock) {
                return mAm.getRecentTasks().getAppTasksList(callingUid, callingPackage);
                return mRecentTasks.getAppTasksList(callingUid, callingPackage);
            }
        } finally {
            Binder.restoreCallingIdentity(ident);
@@ -2000,7 +2011,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                final TaskRecord task = stack.createTaskRecord(
                        mStackSupervisor.getNextTaskIdForUserLocked(r.userId), ainfo, intent,
                        null /* voiceSession */, null /* voiceInteractor */, !ON_TOP);
                if (!mAm.getRecentTasks().addToBottom(task)) {
                if (!mRecentTasks.addToBottom(task)) {
                    // The app has too many tasks already and we can't add any more
                    stack.removeTask(task, "addAppTask", REMOVE_TASK_MODE_DESTROYING);
                    return INVALID_TASK_ID;
@@ -2153,7 +2164,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
            throw new IllegalArgumentException("Bad file path: " + filePath
                    + " passed for userId " + userId);
        }
        return mAm.getRecentTasks().getTaskDescriptionIcon(filePath);
        return mRecentTasks.getTaskDescriptionIcon(filePath);
    }

    @Override
@@ -3535,12 +3546,12 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {

        @Override
        public boolean isCallerRecents(int callingUid) {
            return mAm.getRecentTasks().isCallerRecents(callingUid);
            return getRecentTasks().isCallerRecents(callingUid);
        }

        @Override
        public boolean isRecentsComponentHomeActivity(int userId) {
            return mAm.getRecentTasks().isRecentsComponentHomeActivity(userId);
            return getRecentTasks().isRecentsComponentHomeActivity(userId);
        }

        @Override
Loading