Merge "Avoid locking profile task when it is already lock" into rvc-dev
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
package com.android.server.wm;
|
package com.android.server.wm;
|
||||||
|
|
||||||
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
|
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
|
||||||
|
import static android.app.KeyguardManager.ACTION_CONFIRM_DEVICE_CREDENTIAL_WITH_USER;
|
||||||
import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT;
|
import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT;
|
||||||
import static android.app.WindowConfiguration.ACTIVITY_TYPE_DREAM;
|
import static android.app.WindowConfiguration.ACTIVITY_TYPE_DREAM;
|
||||||
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
|
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
|
||||||
@@ -3365,6 +3366,15 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
|
|||||||
mService.deferWindowLayout();
|
mService.deferWindowLayout();
|
||||||
try {
|
try {
|
||||||
forAllLeafTasks(task -> {
|
forAllLeafTasks(task -> {
|
||||||
|
final ActivityRecord top = task.topRunningActivity();
|
||||||
|
if (top != null && !top.finishing
|
||||||
|
&& ACTION_CONFIRM_DEVICE_CREDENTIAL_WITH_USER.equals(top.intent.getAction())
|
||||||
|
&& top.packageName.equals(
|
||||||
|
mService.getSysUiServiceComponentLocked().getPackageName())) {
|
||||||
|
// Do nothing since the task is already secure by sysui.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (task.getActivity(activity -> !activity.finishing && activity.mUserId == userId)
|
if (task.getActivity(activity -> !activity.finishing && activity.mUserId == userId)
|
||||||
!= null) {
|
!= null) {
|
||||||
mService.getTaskChangeNotificationController().notifyTaskProfileLocked(
|
mService.getTaskChangeNotificationController().notifyTaskProfileLocked(
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.server.wm;
|
package com.android.server.wm;
|
||||||
|
|
||||||
|
import static android.app.KeyguardManager.ACTION_CONFIRM_DEVICE_CREDENTIAL_WITH_USER;
|
||||||
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
|
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
|
||||||
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
|
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
|
||||||
import static android.view.Display.DEFAULT_DISPLAY;
|
import static android.view.Display.DEFAULT_DISPLAY;
|
||||||
@@ -25,6 +26,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE;
|
|||||||
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;
|
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;
|
||||||
import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
|
import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
|
||||||
|
|
||||||
|
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
|
||||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
|
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
|
||||||
import static com.android.server.wm.ActivityStack.ActivityState.FINISHING;
|
import static com.android.server.wm.ActivityStack.ActivityState.FINISHING;
|
||||||
import static com.android.server.wm.ActivityStack.ActivityState.PAUSED;
|
import static com.android.server.wm.ActivityStack.ActivityState.PAUSED;
|
||||||
@@ -37,11 +39,15 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
import static org.mockito.Mockito.clearInvocations;
|
||||||
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
import android.app.WindowConfiguration;
|
import android.app.WindowConfiguration;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.platform.test.annotations.Presubmit;
|
import android.platform.test.annotations.Presubmit;
|
||||||
@@ -194,6 +200,8 @@ public class RootWindowContainerTests extends WindowTestsBase {
|
|||||||
.setUid(UserHandle.PER_USER_RANGE + 1)
|
.setUid(UserHandle.PER_USER_RANGE + 1)
|
||||||
.setTask(task)
|
.setTask(task)
|
||||||
.build();
|
.build();
|
||||||
|
doReturn(true).when(topActivity).okToShowLocked();
|
||||||
|
topActivity.intent.setAction(Intent.ACTION_MAIN);
|
||||||
|
|
||||||
// Make sure the listeners will be notified for putting the task to locked state
|
// Make sure the listeners will be notified for putting the task to locked state
|
||||||
TaskChangeNotificationController controller =
|
TaskChangeNotificationController controller =
|
||||||
@@ -201,6 +209,23 @@ public class RootWindowContainerTests extends WindowTestsBase {
|
|||||||
spyOn(controller);
|
spyOn(controller);
|
||||||
mWm.mRoot.lockAllProfileTasks(0);
|
mWm.mRoot.lockAllProfileTasks(0);
|
||||||
verify(controller).notifyTaskProfileLocked(eq(task.mTaskId), eq(0));
|
verify(controller).notifyTaskProfileLocked(eq(task.mTaskId), eq(0));
|
||||||
|
|
||||||
|
// Create the work lock activity on top of the task
|
||||||
|
final ActivityRecord workLockActivity =
|
||||||
|
new ActivityTestsBase.ActivityBuilder(mWm.mAtmService)
|
||||||
|
.setStack(stack)
|
||||||
|
.setUid(UserHandle.PER_USER_RANGE + 1)
|
||||||
|
.setTask(task)
|
||||||
|
.build();
|
||||||
|
doReturn(true).when(workLockActivity).okToShowLocked();
|
||||||
|
workLockActivity.intent.setAction(ACTION_CONFIRM_DEVICE_CREDENTIAL_WITH_USER);
|
||||||
|
doReturn(workLockActivity.mActivityComponent).when(
|
||||||
|
mWm.mAtmService).getSysUiServiceComponentLocked();
|
||||||
|
|
||||||
|
// Make sure the listener won't be notified again.
|
||||||
|
clearInvocations(controller);
|
||||||
|
mWm.mRoot.lockAllProfileTasks(0);
|
||||||
|
verify(controller, never()).notifyTaskProfileLocked(eq(task.mTaskId), anyInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user