Loading packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java +1 −2 Original line number Diff line number Diff line Loading @@ -68,7 +68,6 @@ import android.view.accessibility.AccessibilityManager; import com.android.internal.app.AssistUtils; import com.android.internal.os.BackgroundThread; import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.UiOffloadThread; import com.android.systemui.recents.Recents; import com.android.systemui.recents.RecentsImpl; Loading Loading @@ -372,7 +371,7 @@ public class SystemServicesProxy { if (mIam == null) return false; try { return mIam.isInLockTaskMode(); return mIam.getLockTaskModeState() == ActivityManager.LOCK_TASK_MODE_PINNED; } catch (RemoteException e) { return false; } Loading services/core/java/com/android/server/am/LockTaskController.java +31 −16 Original line number Diff line number Diff line Loading @@ -250,7 +250,24 @@ public class LockTaskController { } /** * @return whether the requested task is allowed to be launched. * @return whether the requested task is allowed to be locked (either whitelisted, or declares * lockTaskMode="always" in the manifest). */ boolean isTaskWhitelisted(TaskRecord task) { switch(task.mLockTaskAuth) { case LOCK_TASK_AUTH_WHITELISTED: case LOCK_TASK_AUTH_LAUNCHABLE: case LOCK_TASK_AUTH_LAUNCHABLE_PRIV: return true; case LOCK_TASK_AUTH_PINNABLE: case LOCK_TASK_AUTH_DONT_LOCK: default: return false; } } /** * @return whether the requested task is disallowed to be launched. */ boolean isLockTaskModeViolation(TaskRecord task) { return isLockTaskModeViolation(task, false); Loading @@ -258,7 +275,7 @@ public class LockTaskController { /** * @param isNewClearTask whether the task would be cleared as part of the operation. * @return whether the requested task is allowed to be launched. * @return whether the requested task is disallowed to be launched. */ boolean isLockTaskModeViolation(TaskRecord task, boolean isNewClearTask) { if (isLockTaskModeViolationInternal(task, isNewClearTask)) { Loading @@ -275,21 +292,18 @@ public class LockTaskController { // If the task is already at the top and won't be cleared, then allow the operation return false; } final int lockTaskAuth = task.mLockTaskAuth; switch (lockTaskAuth) { case LOCK_TASK_AUTH_DONT_LOCK: return !mLockTaskModeTasks.isEmpty(); case LOCK_TASK_AUTH_LAUNCHABLE_PRIV: case LOCK_TASK_AUTH_LAUNCHABLE: case LOCK_TASK_AUTH_WHITELISTED: // Allow recents activity if enabled by policy if (task.isActivityTypeRecents() && isRecentsAllowed(task.userId)) { return false; case LOCK_TASK_AUTH_PINNABLE: // Pinnable tasks can't be launched on top of locktask tasks. return !mLockTaskModeTasks.isEmpty(); default: Slog.w(TAG, "isLockTaskModeViolation: invalid lockTaskAuth value=" + lockTaskAuth); return true; } return !(isTaskWhitelisted(task) || mLockTaskModeTasks.isEmpty()); } private boolean isRecentsAllowed(int userId) { return (getLockTaskFeaturesForUser(userId) & DevicePolicyManager.LOCK_TASK_FEATURE_RECENTS) != 0; } /** Loading Loading @@ -491,6 +505,7 @@ public class LockTaskController { } if (mLockTaskModeTasks.isEmpty()) { mSupervisor.mRecentTasks.onLockTaskModeStateChanged(lockTaskModeState, task.userId); // Start lock task on the handler thread mHandler.post(() -> performStartLockTask( task.intent.getComponent().getPackageName(), Loading services/core/java/com/android/server/am/RecentTasks.java +12 −0 Original line number Diff line number Diff line Loading @@ -502,6 +502,18 @@ class RecentTasks { } } void onLockTaskModeStateChanged(int lockTaskModeState, int userId) { if (lockTaskModeState != ActivityManager.LOCK_TASK_MODE_LOCKED) { return; } for (int i = mTasks.size() - 1; i >= 0; --i) { final TaskRecord tr = mTasks.get(i); if (tr.userId == userId && !mService.mLockTaskController.isTaskWhitelisted(tr)) { remove(tr); } } } void removeTasksByPackageName(String packageName, int userId) { for (int i = mTasks.size() - 1; i >= 0; --i) { final TaskRecord tr = mTasks.get(i); Loading services/tests/servicestests/src/com/android/server/am/LockTaskControllerTest.java +5 −1 Original line number Diff line number Diff line Loading @@ -90,6 +90,7 @@ public class LockTaskControllerTest { @Mock private LockPatternUtils mLockPatternUtils; @Mock private LockTaskNotify mLockTaskNotify; @Mock private StatusBarManagerInternal mStatusBarManagerInternal; @Mock private RecentTasks mRecentTasks; private LockTaskController mLockTaskController; private Context mContext; Loading @@ -110,9 +111,10 @@ public class LockTaskControllerTest { Looper.prepare(); } mSupervisor.mRecentTasks = mRecentTasks; mLockTaskController = new LockTaskController(mContext, mSupervisor, new ImmediatelyExecuteHandler()); mLockTaskController.setWindowManager(mWindowManager); mLockTaskController.mStatusBarService = mStatusBarService; mLockTaskController.mDevicePolicyManager = mDevicePolicyManager; Loading Loading @@ -601,6 +603,8 @@ public class LockTaskControllerTest { eq(mContext.getPackageName())); verify(mStatusBarService).disable2(eq(statusBarMask2), any(IBinder.class), eq(mContext.getPackageName())); // THEN recents should have been notified verify(mRecentTasks).onLockTaskModeStateChanged(anyInt(), eq(TEST_USER_ID)); // THEN the DO/PO should be informed about the operation verify(mDevicePolicyManager).notifyLockTaskModeChanged(true, TEST_PACKAGE_NAME, TEST_USER_ID); Loading Loading
packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java +1 −2 Original line number Diff line number Diff line Loading @@ -68,7 +68,6 @@ import android.view.accessibility.AccessibilityManager; import com.android.internal.app.AssistUtils; import com.android.internal.os.BackgroundThread; import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.UiOffloadThread; import com.android.systemui.recents.Recents; import com.android.systemui.recents.RecentsImpl; Loading Loading @@ -372,7 +371,7 @@ public class SystemServicesProxy { if (mIam == null) return false; try { return mIam.isInLockTaskMode(); return mIam.getLockTaskModeState() == ActivityManager.LOCK_TASK_MODE_PINNED; } catch (RemoteException e) { return false; } Loading
services/core/java/com/android/server/am/LockTaskController.java +31 −16 Original line number Diff line number Diff line Loading @@ -250,7 +250,24 @@ public class LockTaskController { } /** * @return whether the requested task is allowed to be launched. * @return whether the requested task is allowed to be locked (either whitelisted, or declares * lockTaskMode="always" in the manifest). */ boolean isTaskWhitelisted(TaskRecord task) { switch(task.mLockTaskAuth) { case LOCK_TASK_AUTH_WHITELISTED: case LOCK_TASK_AUTH_LAUNCHABLE: case LOCK_TASK_AUTH_LAUNCHABLE_PRIV: return true; case LOCK_TASK_AUTH_PINNABLE: case LOCK_TASK_AUTH_DONT_LOCK: default: return false; } } /** * @return whether the requested task is disallowed to be launched. */ boolean isLockTaskModeViolation(TaskRecord task) { return isLockTaskModeViolation(task, false); Loading @@ -258,7 +275,7 @@ public class LockTaskController { /** * @param isNewClearTask whether the task would be cleared as part of the operation. * @return whether the requested task is allowed to be launched. * @return whether the requested task is disallowed to be launched. */ boolean isLockTaskModeViolation(TaskRecord task, boolean isNewClearTask) { if (isLockTaskModeViolationInternal(task, isNewClearTask)) { Loading @@ -275,21 +292,18 @@ public class LockTaskController { // If the task is already at the top and won't be cleared, then allow the operation return false; } final int lockTaskAuth = task.mLockTaskAuth; switch (lockTaskAuth) { case LOCK_TASK_AUTH_DONT_LOCK: return !mLockTaskModeTasks.isEmpty(); case LOCK_TASK_AUTH_LAUNCHABLE_PRIV: case LOCK_TASK_AUTH_LAUNCHABLE: case LOCK_TASK_AUTH_WHITELISTED: // Allow recents activity if enabled by policy if (task.isActivityTypeRecents() && isRecentsAllowed(task.userId)) { return false; case LOCK_TASK_AUTH_PINNABLE: // Pinnable tasks can't be launched on top of locktask tasks. return !mLockTaskModeTasks.isEmpty(); default: Slog.w(TAG, "isLockTaskModeViolation: invalid lockTaskAuth value=" + lockTaskAuth); return true; } return !(isTaskWhitelisted(task) || mLockTaskModeTasks.isEmpty()); } private boolean isRecentsAllowed(int userId) { return (getLockTaskFeaturesForUser(userId) & DevicePolicyManager.LOCK_TASK_FEATURE_RECENTS) != 0; } /** Loading Loading @@ -491,6 +505,7 @@ public class LockTaskController { } if (mLockTaskModeTasks.isEmpty()) { mSupervisor.mRecentTasks.onLockTaskModeStateChanged(lockTaskModeState, task.userId); // Start lock task on the handler thread mHandler.post(() -> performStartLockTask( task.intent.getComponent().getPackageName(), Loading
services/core/java/com/android/server/am/RecentTasks.java +12 −0 Original line number Diff line number Diff line Loading @@ -502,6 +502,18 @@ class RecentTasks { } } void onLockTaskModeStateChanged(int lockTaskModeState, int userId) { if (lockTaskModeState != ActivityManager.LOCK_TASK_MODE_LOCKED) { return; } for (int i = mTasks.size() - 1; i >= 0; --i) { final TaskRecord tr = mTasks.get(i); if (tr.userId == userId && !mService.mLockTaskController.isTaskWhitelisted(tr)) { remove(tr); } } } void removeTasksByPackageName(String packageName, int userId) { for (int i = mTasks.size() - 1; i >= 0; --i) { final TaskRecord tr = mTasks.get(i); Loading
services/tests/servicestests/src/com/android/server/am/LockTaskControllerTest.java +5 −1 Original line number Diff line number Diff line Loading @@ -90,6 +90,7 @@ public class LockTaskControllerTest { @Mock private LockPatternUtils mLockPatternUtils; @Mock private LockTaskNotify mLockTaskNotify; @Mock private StatusBarManagerInternal mStatusBarManagerInternal; @Mock private RecentTasks mRecentTasks; private LockTaskController mLockTaskController; private Context mContext; Loading @@ -110,9 +111,10 @@ public class LockTaskControllerTest { Looper.prepare(); } mSupervisor.mRecentTasks = mRecentTasks; mLockTaskController = new LockTaskController(mContext, mSupervisor, new ImmediatelyExecuteHandler()); mLockTaskController.setWindowManager(mWindowManager); mLockTaskController.mStatusBarService = mStatusBarService; mLockTaskController.mDevicePolicyManager = mDevicePolicyManager; Loading Loading @@ -601,6 +603,8 @@ public class LockTaskControllerTest { eq(mContext.getPackageName())); verify(mStatusBarService).disable2(eq(statusBarMask2), any(IBinder.class), eq(mContext.getPackageName())); // THEN recents should have been notified verify(mRecentTasks).onLockTaskModeStateChanged(anyInt(), eq(TEST_USER_ID)); // THEN the DO/PO should be informed about the operation verify(mDevicePolicyManager).notifyLockTaskModeChanged(true, TEST_PACKAGE_NAME, TEST_USER_ID); Loading