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

Commit 27c48ae4 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Removed references to ATMS.getLockTaskController() from AMS (34/n)

Should only be access from ATMS side.

Bug: 80414790
Test: Existing tests pass
Change-Id: I84d43fdb8654c7f19d39ec660d64b2dabef43b83
parent d4d67d03
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -177,6 +177,7 @@ interface IActivityTaskManager {
    void cancelRecentsAnimation(boolean restoreHomeStackPosition);
    void startLockTaskModeByToken(in IBinder token);
    void stopLockTaskModeByToken(in IBinder token);
    void updateLockTaskPackages(int userId, in String[] packages);
    boolean isInLockTaskMode();
    int getLockTaskModeState();
    void setTaskDescription(in IBinder token, in ActivityManager.TaskDescription values);
+1 −10
Original line number Diff line number Diff line
@@ -5815,16 +5815,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    @Override
    public void updateLockTaskPackages(int userId, String[] packages) {
        final int callingUid = Binder.getCallingUid();
        if (callingUid != 0 && callingUid != SYSTEM_UID) {
            enforceCallingPermission(android.Manifest.permission.UPDATE_LOCK_TASK_PACKAGES,
                    "updateLockTaskPackages()");
        }
        synchronized (this) {
            if (DEBUG_LOCKTASK) Slog.w(TAG_LOCKTASK, "Whitelisting " + userId + ":" +
                    Arrays.toString(packages));
            mActivityTaskManager.getLockTaskController().updateLockTaskPackages(userId, packages);
        }
        mActivityTaskManager.updateLockTaskPackages(userId, packages);
    }
    @Override
+35 −11
Original line number Diff line number Diff line
@@ -273,6 +273,7 @@ import java.io.StringWriter;
import java.lang.ref.WeakReference;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
@@ -2511,6 +2512,20 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        }
    }

    @Override
    public void updateLockTaskPackages(int userId, String[] packages) {
        final int callingUid = Binder.getCallingUid();
        if (callingUid != 0 && callingUid != SYSTEM_UID) {
            mAmInternal.enforceCallingPermission(Manifest.permission.UPDATE_LOCK_TASK_PACKAGES,
                    "updateLockTaskPackages()");
        }
        synchronized (this) {
            if (DEBUG_LOCKTASK) Slog.w(TAG_LOCKTASK, "Whitelisting " + userId + ":"
                    + Arrays.toString(packages));
            getLockTaskController().updateLockTaskPackages(userId, packages);
        }
    }

    @Override
    public boolean isInLockTaskMode() {
        return getLockTaskModeState() != LOCK_TASK_MODE_NONE;
@@ -4613,17 +4628,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        }
    }

    void updateUserConfiguration() {
        synchronized (mGlobalLock) {
            final Configuration configuration = new Configuration(getGlobalConfiguration());
            final int currentUserId = mAmInternal.getCurrentUserId();
            Settings.System.adjustConfigurationForUser(mContext.getContentResolver(), configuration,
                    currentUserId, Settings.System.canWrite(mContext));
            updateConfigurationLocked(configuration, null /* starting */, false /* initLocale */,
                    false /* persistent */, currentUserId, false /* deferResume */);
        }
    }

    private boolean updateConfigurationLocked(Configuration values, ActivityRecord starting,
            boolean initLocale, boolean persistent, int userId, boolean deferResume) {
        return updateConfigurationLocked(values, starting, initLocale, persistent, userId,
@@ -6767,5 +6771,25 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                return mPreviousProcess;
            }
        }

        @Override
        public void clearLockedTasks(String reason) {
            synchronized (mGlobalLock) {
                getLockTaskController().clearLockedTasks(reason);
            }
        }

        @Override
        public void updateUserConfiguration() {
            synchronized (mGlobalLock) {
                final Configuration configuration = new Configuration(getGlobalConfiguration());
                final int currentUserId = mAmInternal.getCurrentUserId();
                Settings.System.adjustConfigurationForUser(mContext.getContentResolver(),
                        configuration, currentUserId, Settings.System.canWrite(mContext));
                updateConfigurationLocked(configuration, null /* starting */,
                        false /* initLocale */, false /* persistent */, currentUserId,
                        false /* deferResume */);
            }
        }
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -78,7 +78,8 @@ import java.util.Arrays;
 * mode that can be launched via System UI as well as the fully locked mode that can be achieved
 * on fully managed devices.
 *
 * Note: All methods in this class should only be called with the ActivityManagerService lock held.
 * Note: All methods in this class should only be called with the ActivityTaskManagerService lock
 * held.
 *
 * @see Activity#startLockTask()
 * @see Activity#stopLockTask()
+3 −7
Original line number Diff line number Diff line
@@ -2189,7 +2189,7 @@ class UserController implements Handler.Callback {
        }

        void updateUserConfiguration() {
            mService.mActivityTaskManager.updateUserConfiguration();
            mService.mAtmInternal.updateUserConfiguration();
        }

        void clearBroadcastQueueForUser(int userId) {
@@ -2199,10 +2199,8 @@ class UserController implements Handler.Callback {
        }

        void loadUserRecents(int userId) {
            synchronized (mService) {
            mService.mAtmInternal.loadRecentTasksForUser(userId);
        }
        }

        void startPersistentApps(int matchFlags) {
            mService.startPersistentApps(matchFlags);
@@ -2254,9 +2252,7 @@ class UserController implements Handler.Callback {
        }

        protected void clearAllLockedTasks(String reason) {
            synchronized (mService) {
                mService.mActivityTaskManager.getLockTaskController().clearLockedTasks(reason);
            }
            mService.mAtmInternal.clearLockedTasks(reason);
        }

        protected boolean isCallerRecents(int callingUid) {
Loading