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

Commit d95c06bd authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Switched TaskRecord.mService to ActivityTaskManagerService (6/n)

Objects that contain or represent activities like TaskRecord can
no longer rely on ActivityManagerService as it is going to be in a
different package.

Test: Existing tests pass
Test: go/wm-smoke-auto
Bug: 80414790

Change-Id: Ia17591f7d709839c18762d1eb2474b2e2f649dfc
parent d0412b33
Loading
Loading
Loading
Loading
+2 −19
Original line number Diff line number Diff line
@@ -680,11 +680,6 @@ public class ActivityManagerService extends IActivityManager.Stub
     */
    String mDeviceOwnerName;
    /**
     * The controller for all operations related to locktask.
     */
    private final LockTaskController mLockTaskController;
    final UserController mUserController;
    /**
@@ -2596,7 +2591,6 @@ public class ActivityManagerService extends IActivityManager.Stub
            mWindowManager = wm;
            mActivityTaskManager.setWindowManager(wm);
            mStackSupervisor.setWindowManager(wm);
            mLockTaskController.setWindowManager(wm);
        }
    }
@@ -2864,7 +2858,6 @@ public class ActivityManagerService extends IActivityManager.Stub
        mSystemThread = null;
        mUiHandler = injector.getUiHandler(null);
        mUserController = null;
        mLockTaskController = null;
        mProcStartHandlerThread = null;
        mProcStartHandler = null;
        mHiddenApiBlacklist = null;
@@ -2957,7 +2950,6 @@ public class ActivityManagerService extends IActivityManager.Stub
        mCompatModePackages = new CompatModePackages(this, systemDir, mHandler);
        mIntentFirewall = new IntentFirewall(new IntentFirewallInterface(), mHandler);
        mActivityStartController = new ActivityStartController(this);
        mLockTaskController = new LockTaskController(mContext, mStackSupervisor, mHandler);
        mProcessCpuThread = new Thread("CpuTracker") {
            @Override
@@ -9366,7 +9358,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        synchronized (this) {
            if (DEBUG_LOCKTASK) Slog.w(TAG_LOCKTASK, "Whitelisting " + userId + ":" +
                    Arrays.toString(packages));
            mLockTaskController.updateLockTaskPackages(userId, packages);
            mActivityTaskManager.getLockTaskController().updateLockTaskPackages(userId, packages);
        }
    }
@@ -10142,10 +10134,6 @@ public class ActivityManagerService extends IActivityManager.Stub
        return mActivityStartController;
    }
    LockTaskController getLockTaskController() {
        return mLockTaskController;
    }
    ClientLifecycleManager getLifecycleManager() {
        return mActivityTaskManager.getLifecycleManager();
    }
@@ -10913,11 +10901,6 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
    }
    /** Pokes the task persister. */
    void notifyTaskPersisterLocked(TaskRecord task, boolean flush) {
        mActivityTaskManager.getRecentTasks().notifyTaskPersisterLocked(task, flush);
    }
    @Override
    public void notifyCleartextNetwork(int uid, byte[] firstPacket) {
        mHandler.obtainMessage(NOTIFY_CLEARTEXT_NETWORK_MSG, uid, 0, firstPacket).sendToTarget();
@@ -10947,7 +10930,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        mBatteryStatsService.shutdown();
        synchronized (this) {
            mProcessStats.shutdownLocked();
            notifyTaskPersisterLocked(null, true);
            mActivityTaskManager.notifyTaskPersisterLocked(null, true);
        }
        return timedout;
+3 −3
Original line number Diff line number Diff line
@@ -3739,7 +3739,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
                }

                if (endTask) {
                    mService.getLockTaskController().clearLockedTask(task);
                    mService.mActivityTaskManager.getLockTaskController().clearLockedTask(task);
                }
            } else if (!r.isState(PAUSING)) {
                // If the activity is PAUSING, we will complete the finish once
@@ -4656,7 +4656,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai

        // In LockTask mode, moving a locked task to the back of the stack may expose unlocked
        // ones. Therefore we need to check if this operation is allowed.
        if (!mService.getLockTaskController().canMoveTaskToBack(tr)) {
        if (!mService.mActivityTaskManager.getLockTaskController().canMoveTaskToBack(tr)) {
            return false;
        }

@@ -5176,7 +5176,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
            boolean toTop, ActivityRecord activity, ActivityRecord source,
            ActivityOptions options) {
        final TaskRecord task = TaskRecord.create(
                mService, taskId, info, intent, voiceSession, voiceInteractor);
                mService.mActivityTaskManager, taskId, info, intent, voiceSession, voiceInteractor);
        // add the task to stack first, mTaskPositioner might need the stack association
        addTask(task, toTop, "createTaskRecord");
        final int displayId = mDisplayId != INVALID_DISPLAY ? mDisplayId : DEFAULT_DISPLAY;
+4 −4
Original line number Diff line number Diff line
@@ -1456,7 +1456,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
            mService.updateLruProcessLocked(app, true, null);
            mService.updateOomAdjLocked();

            final LockTaskController lockTaskController = mService.getLockTaskController();
            final LockTaskController lockTaskController = mService.mActivityTaskManager.getLockTaskController();
            if (task.mLockTaskAuth == LOCK_TASK_AUTH_LAUNCHABLE
                    || task.mLockTaskAuth == LOCK_TASK_AUTH_LAUNCHABLE_PRIV
                    || (task.mLockTaskAuth == LOCK_TASK_AUTH_WHITELISTED
@@ -3077,9 +3077,9 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
        if (tr != null) {
            tr.removeTaskActivitiesLocked(pauseImmediately, reason);
            cleanUpRemovedTaskLocked(tr, killProcess, removeFromRecents);
            mService.getLockTaskController().clearLockedTask(tr);
            mService.mActivityTaskManager.getLockTaskController().clearLockedTask(tr);
            if (tr.isPersistable) {
                mService.notifyTaskPersisterLocked(null, true);
                mService.mActivityTaskManager.notifyTaskPersisterLocked(null, true);
            }
            return true;
        }
@@ -4005,7 +4005,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
        pw.print(mRecentTasks.isRecentsComponentHomeActivity(mCurrentUser));

        getKeyguardController().dump(pw, prefix);
        mService.getLockTaskController().dump(pw, prefix);
        mService.mActivityTaskManager.getLockTaskController().dump(pw, prefix);
    }

    public void writeToProto(ProtoOutputStream proto, long fieldId) {
+4 −4
Original line number Diff line number Diff line
@@ -1257,7 +1257,7 @@ class ActivityStarter {
            // When the flags NEW_TASK and CLEAR_TASK are set, then the task gets reused but
            // still needs to be a lock task mode violation since the task gets cleared out and
            // the device would otherwise leave the locked task.
            if (mService.getLockTaskController().isLockTaskModeViolation(reusedActivity.getTask(),
            if (mService.mActivityTaskManager.getLockTaskController().isLockTaskModeViolation(reusedActivity.getTask(),
                    (mLaunchFlags & (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK))
                            == (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK))) {
                Slog.e(TAG, "startActivityUnchecked: Attempt to violate Lock Task Mode");
@@ -2070,7 +2070,7 @@ class ActivityStarter {
            mStartActivity.setTaskToAffiliateWith(taskToAffiliate);
        }

        if (mService.getLockTaskController().isLockTaskModeViolation(mStartActivity.getTask())) {
        if (mService.mActivityTaskManager.getLockTaskController().isLockTaskModeViolation(mStartActivity.getTask())) {
            Slog.e(TAG, "Attempted Lock Task Mode violation mStartActivity=" + mStartActivity);
            return START_RETURN_LOCK_TASK_MODE_VIOLATION;
        }
@@ -2093,7 +2093,7 @@ class ActivityStarter {
    }

    private int setTaskFromSourceRecord() {
        if (mService.getLockTaskController().isLockTaskModeViolation(mSourceRecord.getTask())) {
        if (mService.mActivityTaskManager.getLockTaskController().isLockTaskModeViolation(mSourceRecord.getTask())) {
            Slog.e(TAG, "Attempted Lock Task Mode violation mStartActivity=" + mStartActivity);
            return START_RETURN_LOCK_TASK_MODE_VIOLATION;
        }
@@ -2187,7 +2187,7 @@ class ActivityStarter {
    private int setTaskFromInTask() {
        // The caller is asking that the new activity be started in an explicit
        // task it has provided to us.
        if (mService.getLockTaskController().isLockTaskModeViolation(mInTask)) {
        if (mService.mActivityTaskManager.getLockTaskController().isLockTaskModeViolation(mInTask)) {
            Slog.e(TAG, "Attempted Lock Task Mode violation mStartActivity=" + mStartActivity);
            return START_RETURN_LOCK_TASK_MODE_VIOLATION;
        }
+16 −8
Original line number Diff line number Diff line
@@ -222,6 +222,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
    KeyguardController mKeyguardController;
    private final ClientLifecycleManager mLifecycleManager;
    private TaskChangeNotificationController mTaskChangeNotificationController;
    /** The controller for all operations related to locktask. */
    private LockTaskController mLockTaskController;

    boolean mSuppressResizeConfigChanges;

@@ -259,6 +261,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        mStackSupervisor = mAm.mStackSupervisor;
        mTaskChangeNotificationController =
                new TaskChangeNotificationController(mAm, mStackSupervisor, mH);
        mLockTaskController = new LockTaskController(mContext, mStackSupervisor, mH);
        mRecentTasks = createRecentTasks();
        mStackSupervisor.setRecentTasks(mRecentTasks);
        mVrController = new VrController(mAm);
@@ -267,6 +270,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {

    void setWindowManager(WindowManagerService wm) {
        mWindowManager = wm;
        mLockTaskController.setWindowManager(wm);
    }

    protected RecentTasks createRecentTasks() {
@@ -285,6 +289,10 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        return mTaskChangeNotificationController;
    }

    LockTaskController getLockTaskController() {
        return mLockTaskController;
    }

    private void start() {
        LocalServices.addService(ActivityTaskManagerInternal.class, new LocalService());
    }
@@ -769,7 +777,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
            }
            // Do not allow task to finish if last task in lockTask mode. Launchable priv-apps can
            // finish.
            if (mAm.getLockTaskController().activityBlockedFromFinish(r)) {
            if (getLockTaskController().activityBlockedFromFinish(r)) {
                return false;
            }

@@ -836,7 +844,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                // Do not allow task to finish if last task in lockTask mode. Launchable priv-apps
                // can finish.
                final TaskRecord task = r.getTask();
                if (mAm.getLockTaskController().activityBlockedFromFinish(r)) {
                if (getLockTaskController().activityBlockedFromFinish(r)) {
                    return false;
                }
                return task.getStack().finishActivityAffinityLocked(r);
@@ -1442,7 +1450,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                Slog.d(TAG, "Could not find task for id: "+ taskId);
                return;
            }
            if (mAm.getLockTaskController().isLockTaskModeViolation(task)) {
            if (getLockTaskController().isLockTaskModeViolation(task)) {
                Slog.e(TAG, "moveTaskToFront: Attempt to violate Lock Task Mode");
                return;
            }
@@ -1812,7 +1820,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
            // When a task is locked, dismiss the pinned stack if it exists
            mStackSupervisor.removeStacksInWindowingModes(WINDOWING_MODE_PINNED);

            mAm.getLockTaskController().startLockTaskMode(task, isSystemCaller, callingUid);
            getLockTaskController().startLockTaskMode(task, isSystemCaller, callingUid);
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
@@ -1823,7 +1831,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        long ident = Binder.clearCallingIdentity();
        try {
            synchronized (mGlobalLock) {
                mAm.getLockTaskController().stopLockTaskMode(task, isSystemCaller, callingUid);
                getLockTaskController().stopLockTaskMode(task, isSystemCaller, callingUid);
            }
            // Launch in-call UI if a call is ongoing. This is necessary to allow stopping the lock
            // task and jumping straight into a call in the case of emergency call back.
@@ -1844,7 +1852,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
    @Override
    public int getLockTaskModeState() {
        synchronized (mGlobalLock) {
            return mAm.getLockTaskController().getLockTaskModeState();
            return getLockTaskController().getLockTaskModeState();
        }
    }

@@ -2601,7 +2609,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
            if (r == null) {
                return;
            }
            mAm.getLockTaskController().showLockTaskToast();
            getLockTaskController().showLockTaskToast();
        }
    }

@@ -3319,7 +3327,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        synchronized (mGlobalLock) {
            if (DEBUG_LOCKTASK) Slog.w(TAG_LOCKTASK, "Allowing features " + userId + ":0x" +
                    Integer.toHexString(flags));
            mAm.getLockTaskController().updateLockTaskFeatures(userId, flags);
            getLockTaskController().updateLockTaskFeatures(userId, flags);
        }
    }

Loading