Loading services/core/java/com/android/server/am/ActivityManagerService.java +15 −0 Original line number Original line Diff line number Diff line Loading @@ -3098,6 +3098,15 @@ public final class ActivityManagerService extends ActivityManagerNative if (task == null) { if (task == null) { return; return; } } if (mUserController.shouldConfirmCredentials(task.userId)) { mActivityStarter.showConfirmDeviceCredential(task.userId); if (task.stack != null && task.stack.mStackId == FREEFORM_WORKSPACE_STACK_ID) { mStackSupervisor.moveTaskToStackLocked(task.taskId, FULLSCREEN_WORKSPACE_STACK_ID, !ON_TOP, !FORCE_FOCUS, "setFocusedTask", ANIMATE); } return; } final ActivityRecord r = task.topRunningActivityLocked(); final ActivityRecord r = task.topRunningActivityLocked(); if (setFocusedActivityLocked(r, "setFocusedTask")) { if (setFocusedActivityLocked(r, "setFocusedTask")) { mStackSupervisor.resumeFocusedStackTopActivityLocked(); mStackSupervisor.resumeFocusedStackTopActivityLocked(); Loading Loading @@ -11823,6 +11832,12 @@ public final class ActivityManagerService extends ActivityManagerNative final long ident = Binder.clearCallingIdentity(); final long ident = Binder.clearCallingIdentity(); try { try { final int currentUserId = mUserController.getCurrentUserIdLocked(); final int currentUserId = mUserController.getCurrentUserIdLocked(); // Drop locked freeform tasks out into the fullscreen stack. // TODO: Redact the tasks in place. It's much better to keep them on the screen // where they were before, but in an obscured state. mStackSupervisor.moveProfileTasksFromFreeformToFullscreenStackLocked(userId); if (mUserController.isLockScreenDisabled(currentUserId)) { if (mUserController.isLockScreenDisabled(currentUserId)) { // If there is no device lock, we will show the profile's credential page. // If there is no device lock, we will show the profile's credential page. mActivityStarter.showConfirmDeviceCredential(userId); mActivityStarter.showConfirmDeviceCredential(userId); Loading services/core/java/com/android/server/am/ActivityStackSupervisor.java +68 −11 Original line number Original line Diff line number Diff line Loading @@ -743,9 +743,11 @@ public final class ActivityStackSupervisor implements DisplayListener { if (!mService.mUserController.shouldConfirmCredentials(userId)) { if (!mService.mUserController.shouldConfirmCredentials(userId)) { return false; return false; } } final ActivityStack fullScreenStack = getStack(FULLSCREEN_WORKSPACE_STACK_ID); final ActivityStack[] activityStacks = { final ActivityStack dockedStack = getStack(DOCKED_STACK_ID); getStack(DOCKED_STACK_ID), final ActivityStack[] activityStacks = new ActivityStack[] {fullScreenStack, dockedStack}; getStack(FREEFORM_WORKSPACE_STACK_ID), getStack(FULLSCREEN_WORKSPACE_STACK_ID), }; for (final ActivityStack activityStack : activityStacks) { for (final ActivityStack activityStack : activityStacks) { if (activityStack == null) { if (activityStack == null) { continue; continue; Loading @@ -759,18 +761,37 @@ public final class ActivityStackSupervisor implements DisplayListener { if (activityStack.isDockedStack() && mIsDockMinimized) { if (activityStack.isDockedStack() && mIsDockMinimized) { continue; continue; } } if (activityStack.mStackId == FREEFORM_WORKSPACE_STACK_ID) { // TODO: Only the topmost task should trigger credential confirmation. But first, // there needs to be a way to block out locked task window surfaces. final List<TaskRecord> tasks = activityStack.getAllTasks(); final int size = tasks.size(); for (int i = 0; i < size; i++) { if (taskContainsActivityFromUser(tasks.get(i), userId)) { return true; } } } else { final TaskRecord topTask = activityStack.topTask(); final TaskRecord topTask = activityStack.topTask(); if (topTask == null) { if (topTask == null) { continue; continue; } } if (taskContainsActivityFromUser(topTask, userId)) { return true; } } } return false; } private boolean taskContainsActivityFromUser(TaskRecord task, @UserIdInt int userId) { // To handle the case that work app is in the task but just is not the top one. // To handle the case that work app is in the task but just is not the top one. for (int i = topTask.mActivities.size() - 1; i >= 0; i--) { for (int i = task.mActivities.size() - 1; i >= 0; i--) { final ActivityRecord activityRecord = topTask.mActivities.get(i); final ActivityRecord activityRecord = task.mActivities.get(i); if (activityRecord.userId == userId) { if (activityRecord.userId == userId) { return true; return true; } } } } } return false; return false; } } Loading Loading @@ -2164,6 +2185,32 @@ public final class ActivityStackSupervisor implements DisplayListener { } } } } /** * TODO: remove the need for this method. (b/30693465) * * @param userId user handle for the locked managed profile. Freeform tasks for this user will * be moved to another stack, so they are not shown in the background. */ void moveProfileTasksFromFreeformToFullscreenStackLocked(@UserIdInt int userId) { final ActivityStack stack = getStack(FREEFORM_WORKSPACE_STACK_ID); if (stack == null) { return; } mWindowManager.deferSurfaceLayout(); try { final ArrayList<TaskRecord> tasks = stack.getAllTasks(); final int size = tasks.size(); for (int i = size - 1; i >= 0; i--) { if (taskContainsActivityFromUser(tasks.get(i), userId)) { positionTaskInStackLocked(tasks.get(i).taskId, FULLSCREEN_WORKSPACE_STACK_ID, /* position */ 0); } } } finally { mWindowManager.continueSurfaceLayout(); } } void resizeDockedStackLocked(Rect dockedBounds, Rect tempDockedTaskBounds, void resizeDockedStackLocked(Rect dockedBounds, Rect tempDockedTaskBounds, Rect tempDockedTaskInsetBounds, Rect tempOtherTaskBounds, Rect tempOtherTaskInsetBounds, Rect tempDockedTaskInsetBounds, Rect tempOtherTaskBounds, Rect tempOtherTaskInsetBounds, boolean preserveWindows) { boolean preserveWindows) { Loading Loading @@ -2354,6 +2401,10 @@ public final class ActivityStackSupervisor implements DisplayListener { // Preferred stack is the docked stack, but the task can't go in the docked stack. // Preferred stack is the docked stack, but the task can't go in the docked stack. // Put it in the fullscreen stack. // Put it in the fullscreen stack. stackId = FULLSCREEN_WORKSPACE_STACK_ID; stackId = FULLSCREEN_WORKSPACE_STACK_ID; } else if (stackId == FREEFORM_WORKSPACE_STACK_ID && mService.mUserController.shouldConfirmCredentials(task.userId)) { // Task is barred from the freeform stack. Put it in the fullscreen stack. stackId = FULLSCREEN_WORKSPACE_STACK_ID; } } if (task.stack != null) { if (task.stack != null) { Loading Loading @@ -2426,6 +2477,12 @@ public final class ActivityStackSupervisor implements DisplayListener { Slog.w(TAG, "Can not move unresizeable task=" + task Slog.w(TAG, "Can not move unresizeable task=" + task + " to docked stack. Moving to stackId=" + stackId + " instead."); + " to docked stack. Moving to stackId=" + stackId + " instead."); } } if (stackId == FREEFORM_WORKSPACE_STACK_ID && mService.mUserController.shouldConfirmCredentials(task.userId)) { stackId = (prevStack != null) ? prevStack.mStackId : FULLSCREEN_WORKSPACE_STACK_ID; Slog.w(TAG, "Can not move locked profile task=" + task + " to freeform stack. Moving to stackId=" + stackId + " instead."); } // Temporarily disable resizeablility of task we are moving. We don't want it to be resized // Temporarily disable resizeablility of task we are moving. We don't want it to be resized // if a docked stack is created below which will lead to the stack we are moving from and // if a docked stack is created below which will lead to the stack we are moving from and Loading services/core/java/com/android/server/am/ActivityStarter.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -660,10 +660,15 @@ class ActivityStarter { ActivityStack targetStack; ActivityStack targetStack; ActivityStack fullscreenStack = ActivityStack fullscreenStack = mSupervisor.getStack(FULLSCREEN_WORKSPACE_STACK_ID); mSupervisor.getStack(FULLSCREEN_WORKSPACE_STACK_ID); ActivityStack freeformStack = mSupervisor.getStack(FREEFORM_WORKSPACE_STACK_ID); if (fullscreenStack != null && if (fullscreenStack != null && fullscreenStack.getStackVisibilityLocked(null) != ActivityStack.STACK_INVISIBLE) { fullscreenStack.getStackVisibilityLocked(null) != ActivityStack.STACK_INVISIBLE) { // Single window case and the case that the docked stack is shown with fullscreen stack. // Single window case and the case that the docked stack is shown with fullscreen stack. targetStack = fullscreenStack; targetStack = fullscreenStack; } else if (freeformStack != null && freeformStack.getStackVisibilityLocked(null) != ActivityStack.STACK_INVISIBLE) { targetStack = freeformStack; } else { } else { // The case that the docked stack is shown with recent. // The case that the docked stack is shown with recent. targetStack = mSupervisor.getStack(HOME_STACK_ID); targetStack = mSupervisor.getStack(HOME_STACK_ID); Loading services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +7 −0 Original line number Original line Diff line number Diff line Loading @@ -54,6 +54,7 @@ import android.app.admin.SecurityLog; import android.app.admin.SecurityLog.SecurityEvent; import android.app.admin.SecurityLog.SecurityEvent; import android.app.admin.SystemUpdatePolicy; import android.app.admin.SystemUpdatePolicy; import android.app.backup.IBackupManager; import android.app.backup.IBackupManager; import android.app.trust.TrustManager; import android.content.BroadcastReceiver; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ComponentName; import android.content.Context; import android.content.Context; Loading Loading @@ -1371,6 +1372,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { return TelephonyManager.from(mContext); return TelephonyManager.from(mContext); } } TrustManager getTrustManager() { return (TrustManager) mContext.getSystemService(Context.TRUST_SERVICE); } IWindowManager getIWindowManager() { IWindowManager getIWindowManager() { return IWindowManager.Stub return IWindowManager.Stub .asInterface(ServiceManager.getService(Context.WINDOW_SERVICE)); .asInterface(ServiceManager.getService(Context.WINDOW_SERVICE)); Loading Loading @@ -4207,6 +4212,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { mInjector.powerManagerGoToSleep(SystemClock.uptimeMillis(), mInjector.powerManagerGoToSleep(SystemClock.uptimeMillis(), PowerManager.GO_TO_SLEEP_REASON_DEVICE_ADMIN, 0); PowerManager.GO_TO_SLEEP_REASON_DEVICE_ADMIN, 0); mInjector.getIWindowManager().lockNow(null); mInjector.getIWindowManager().lockNow(null); } else { mInjector.getTrustManager().setDeviceLockedForUser(userToLock, true); } } } catch (RemoteException e) { } catch (RemoteException e) { } finally { } finally { Loading Loading
services/core/java/com/android/server/am/ActivityManagerService.java +15 −0 Original line number Original line Diff line number Diff line Loading @@ -3098,6 +3098,15 @@ public final class ActivityManagerService extends ActivityManagerNative if (task == null) { if (task == null) { return; return; } } if (mUserController.shouldConfirmCredentials(task.userId)) { mActivityStarter.showConfirmDeviceCredential(task.userId); if (task.stack != null && task.stack.mStackId == FREEFORM_WORKSPACE_STACK_ID) { mStackSupervisor.moveTaskToStackLocked(task.taskId, FULLSCREEN_WORKSPACE_STACK_ID, !ON_TOP, !FORCE_FOCUS, "setFocusedTask", ANIMATE); } return; } final ActivityRecord r = task.topRunningActivityLocked(); final ActivityRecord r = task.topRunningActivityLocked(); if (setFocusedActivityLocked(r, "setFocusedTask")) { if (setFocusedActivityLocked(r, "setFocusedTask")) { mStackSupervisor.resumeFocusedStackTopActivityLocked(); mStackSupervisor.resumeFocusedStackTopActivityLocked(); Loading Loading @@ -11823,6 +11832,12 @@ public final class ActivityManagerService extends ActivityManagerNative final long ident = Binder.clearCallingIdentity(); final long ident = Binder.clearCallingIdentity(); try { try { final int currentUserId = mUserController.getCurrentUserIdLocked(); final int currentUserId = mUserController.getCurrentUserIdLocked(); // Drop locked freeform tasks out into the fullscreen stack. // TODO: Redact the tasks in place. It's much better to keep them on the screen // where they were before, but in an obscured state. mStackSupervisor.moveProfileTasksFromFreeformToFullscreenStackLocked(userId); if (mUserController.isLockScreenDisabled(currentUserId)) { if (mUserController.isLockScreenDisabled(currentUserId)) { // If there is no device lock, we will show the profile's credential page. // If there is no device lock, we will show the profile's credential page. mActivityStarter.showConfirmDeviceCredential(userId); mActivityStarter.showConfirmDeviceCredential(userId); Loading
services/core/java/com/android/server/am/ActivityStackSupervisor.java +68 −11 Original line number Original line Diff line number Diff line Loading @@ -743,9 +743,11 @@ public final class ActivityStackSupervisor implements DisplayListener { if (!mService.mUserController.shouldConfirmCredentials(userId)) { if (!mService.mUserController.shouldConfirmCredentials(userId)) { return false; return false; } } final ActivityStack fullScreenStack = getStack(FULLSCREEN_WORKSPACE_STACK_ID); final ActivityStack[] activityStacks = { final ActivityStack dockedStack = getStack(DOCKED_STACK_ID); getStack(DOCKED_STACK_ID), final ActivityStack[] activityStacks = new ActivityStack[] {fullScreenStack, dockedStack}; getStack(FREEFORM_WORKSPACE_STACK_ID), getStack(FULLSCREEN_WORKSPACE_STACK_ID), }; for (final ActivityStack activityStack : activityStacks) { for (final ActivityStack activityStack : activityStacks) { if (activityStack == null) { if (activityStack == null) { continue; continue; Loading @@ -759,18 +761,37 @@ public final class ActivityStackSupervisor implements DisplayListener { if (activityStack.isDockedStack() && mIsDockMinimized) { if (activityStack.isDockedStack() && mIsDockMinimized) { continue; continue; } } if (activityStack.mStackId == FREEFORM_WORKSPACE_STACK_ID) { // TODO: Only the topmost task should trigger credential confirmation. But first, // there needs to be a way to block out locked task window surfaces. final List<TaskRecord> tasks = activityStack.getAllTasks(); final int size = tasks.size(); for (int i = 0; i < size; i++) { if (taskContainsActivityFromUser(tasks.get(i), userId)) { return true; } } } else { final TaskRecord topTask = activityStack.topTask(); final TaskRecord topTask = activityStack.topTask(); if (topTask == null) { if (topTask == null) { continue; continue; } } if (taskContainsActivityFromUser(topTask, userId)) { return true; } } } return false; } private boolean taskContainsActivityFromUser(TaskRecord task, @UserIdInt int userId) { // To handle the case that work app is in the task but just is not the top one. // To handle the case that work app is in the task but just is not the top one. for (int i = topTask.mActivities.size() - 1; i >= 0; i--) { for (int i = task.mActivities.size() - 1; i >= 0; i--) { final ActivityRecord activityRecord = topTask.mActivities.get(i); final ActivityRecord activityRecord = task.mActivities.get(i); if (activityRecord.userId == userId) { if (activityRecord.userId == userId) { return true; return true; } } } } } return false; return false; } } Loading Loading @@ -2164,6 +2185,32 @@ public final class ActivityStackSupervisor implements DisplayListener { } } } } /** * TODO: remove the need for this method. (b/30693465) * * @param userId user handle for the locked managed profile. Freeform tasks for this user will * be moved to another stack, so they are not shown in the background. */ void moveProfileTasksFromFreeformToFullscreenStackLocked(@UserIdInt int userId) { final ActivityStack stack = getStack(FREEFORM_WORKSPACE_STACK_ID); if (stack == null) { return; } mWindowManager.deferSurfaceLayout(); try { final ArrayList<TaskRecord> tasks = stack.getAllTasks(); final int size = tasks.size(); for (int i = size - 1; i >= 0; i--) { if (taskContainsActivityFromUser(tasks.get(i), userId)) { positionTaskInStackLocked(tasks.get(i).taskId, FULLSCREEN_WORKSPACE_STACK_ID, /* position */ 0); } } } finally { mWindowManager.continueSurfaceLayout(); } } void resizeDockedStackLocked(Rect dockedBounds, Rect tempDockedTaskBounds, void resizeDockedStackLocked(Rect dockedBounds, Rect tempDockedTaskBounds, Rect tempDockedTaskInsetBounds, Rect tempOtherTaskBounds, Rect tempOtherTaskInsetBounds, Rect tempDockedTaskInsetBounds, Rect tempOtherTaskBounds, Rect tempOtherTaskInsetBounds, boolean preserveWindows) { boolean preserveWindows) { Loading Loading @@ -2354,6 +2401,10 @@ public final class ActivityStackSupervisor implements DisplayListener { // Preferred stack is the docked stack, but the task can't go in the docked stack. // Preferred stack is the docked stack, but the task can't go in the docked stack. // Put it in the fullscreen stack. // Put it in the fullscreen stack. stackId = FULLSCREEN_WORKSPACE_STACK_ID; stackId = FULLSCREEN_WORKSPACE_STACK_ID; } else if (stackId == FREEFORM_WORKSPACE_STACK_ID && mService.mUserController.shouldConfirmCredentials(task.userId)) { // Task is barred from the freeform stack. Put it in the fullscreen stack. stackId = FULLSCREEN_WORKSPACE_STACK_ID; } } if (task.stack != null) { if (task.stack != null) { Loading Loading @@ -2426,6 +2477,12 @@ public final class ActivityStackSupervisor implements DisplayListener { Slog.w(TAG, "Can not move unresizeable task=" + task Slog.w(TAG, "Can not move unresizeable task=" + task + " to docked stack. Moving to stackId=" + stackId + " instead."); + " to docked stack. Moving to stackId=" + stackId + " instead."); } } if (stackId == FREEFORM_WORKSPACE_STACK_ID && mService.mUserController.shouldConfirmCredentials(task.userId)) { stackId = (prevStack != null) ? prevStack.mStackId : FULLSCREEN_WORKSPACE_STACK_ID; Slog.w(TAG, "Can not move locked profile task=" + task + " to freeform stack. Moving to stackId=" + stackId + " instead."); } // Temporarily disable resizeablility of task we are moving. We don't want it to be resized // Temporarily disable resizeablility of task we are moving. We don't want it to be resized // if a docked stack is created below which will lead to the stack we are moving from and // if a docked stack is created below which will lead to the stack we are moving from and Loading
services/core/java/com/android/server/am/ActivityStarter.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -660,10 +660,15 @@ class ActivityStarter { ActivityStack targetStack; ActivityStack targetStack; ActivityStack fullscreenStack = ActivityStack fullscreenStack = mSupervisor.getStack(FULLSCREEN_WORKSPACE_STACK_ID); mSupervisor.getStack(FULLSCREEN_WORKSPACE_STACK_ID); ActivityStack freeformStack = mSupervisor.getStack(FREEFORM_WORKSPACE_STACK_ID); if (fullscreenStack != null && if (fullscreenStack != null && fullscreenStack.getStackVisibilityLocked(null) != ActivityStack.STACK_INVISIBLE) { fullscreenStack.getStackVisibilityLocked(null) != ActivityStack.STACK_INVISIBLE) { // Single window case and the case that the docked stack is shown with fullscreen stack. // Single window case and the case that the docked stack is shown with fullscreen stack. targetStack = fullscreenStack; targetStack = fullscreenStack; } else if (freeformStack != null && freeformStack.getStackVisibilityLocked(null) != ActivityStack.STACK_INVISIBLE) { targetStack = freeformStack; } else { } else { // The case that the docked stack is shown with recent. // The case that the docked stack is shown with recent. targetStack = mSupervisor.getStack(HOME_STACK_ID); targetStack = mSupervisor.getStack(HOME_STACK_ID); Loading
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +7 −0 Original line number Original line Diff line number Diff line Loading @@ -54,6 +54,7 @@ import android.app.admin.SecurityLog; import android.app.admin.SecurityLog.SecurityEvent; import android.app.admin.SecurityLog.SecurityEvent; import android.app.admin.SystemUpdatePolicy; import android.app.admin.SystemUpdatePolicy; import android.app.backup.IBackupManager; import android.app.backup.IBackupManager; import android.app.trust.TrustManager; import android.content.BroadcastReceiver; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ComponentName; import android.content.Context; import android.content.Context; Loading Loading @@ -1371,6 +1372,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { return TelephonyManager.from(mContext); return TelephonyManager.from(mContext); } } TrustManager getTrustManager() { return (TrustManager) mContext.getSystemService(Context.TRUST_SERVICE); } IWindowManager getIWindowManager() { IWindowManager getIWindowManager() { return IWindowManager.Stub return IWindowManager.Stub .asInterface(ServiceManager.getService(Context.WINDOW_SERVICE)); .asInterface(ServiceManager.getService(Context.WINDOW_SERVICE)); Loading Loading @@ -4207,6 +4212,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { mInjector.powerManagerGoToSleep(SystemClock.uptimeMillis(), mInjector.powerManagerGoToSleep(SystemClock.uptimeMillis(), PowerManager.GO_TO_SLEEP_REASON_DEVICE_ADMIN, 0); PowerManager.GO_TO_SLEEP_REASON_DEVICE_ADMIN, 0); mInjector.getIWindowManager().lockNow(null); mInjector.getIWindowManager().lockNow(null); } else { mInjector.getTrustManager().setDeviceLockedForUser(userToLock, true); } } } catch (RemoteException e) { } catch (RemoteException e) { } finally { } finally { Loading