Merge "Start home on empty display when user unlock the device"

This commit is contained in:
TreeHugger Robot
2020-11-26 06:29:10 +00:00
committed by Android (Google) Code Review
3 changed files with 30 additions and 8 deletions

View File

@@ -1056,7 +1056,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
}
@Override
public void onUserUnlocking(@NonNull TargetUser user) {
public void onUserUnlocked(@NonNull TargetUser user) {
synchronized (mService.getGlobalLock()) {
mService.mTaskSupervisor.onUserUnlocked(user.getUserIdentifier());
}

View File

@@ -186,7 +186,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
private static final int RESTART_ACTIVITY_PROCESS_TIMEOUT_MSG = FIRST_SUPERVISOR_STACK_MSG + 13;
private static final int REPORT_MULTI_WINDOW_MODE_CHANGED_MSG = FIRST_SUPERVISOR_STACK_MSG + 14;
private static final int REPORT_PIP_MODE_CHANGED_MSG = FIRST_SUPERVISOR_STACK_MSG + 15;
private static final int REPORT_HOME_CHANGED_MSG = FIRST_SUPERVISOR_STACK_MSG + 16;
private static final int START_HOME_MSG = FIRST_SUPERVISOR_STACK_MSG + 16;
private static final int TOP_RESUMED_STATE_LOSS_TIMEOUT_MSG = FIRST_SUPERVISOR_STACK_MSG + 17;
// Used to indicate that windows of activities should be preserved during the resize.
@@ -446,6 +446,9 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
// unlocked.
mPersisterQueue.startPersisting();
mLaunchParamsPersister.onUnlockUser(userId);
// Need to launch home again for those displays that do not have encryption aware home app.
scheduleStartHome("userUnlocked");
}
public ActivityMetricsLogger getActivityMetricsLogger() {
@@ -956,13 +959,17 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
void updateHomeProcess(WindowProcessController app) {
if (app != null && mService.mHomeProcess != app) {
if (!mHandler.hasMessages(REPORT_HOME_CHANGED_MSG)) {
mHandler.sendEmptyMessage(REPORT_HOME_CHANGED_MSG);
}
scheduleStartHome("homeChanged");
mService.mHomeProcess = app;
}
}
private void scheduleStartHome(String reason) {
if (!mHandler.hasMessages(START_HOME_MSG)) {
mHandler.obtainMessage(START_HOME_MSG, reason).sendToTarget();
}
}
private void logIfTransactionTooLarge(Intent intent, Bundle icicle) {
int extrasSize = 0;
if (intent != null) {
@@ -2473,11 +2480,11 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
handleLaunchTaskBehindCompleteLocked(r);
}
} break;
case REPORT_HOME_CHANGED_MSG: {
mHandler.removeMessages(REPORT_HOME_CHANGED_MSG);
case START_HOME_MSG: {
mHandler.removeMessages(START_HOME_MSG);
// Start home activities on displays with no activities.
mRootWindowContainer.startHomeOnEmptyDisplays("homeChanged");
mRootWindowContainer.startHomeOnEmptyDisplays((String) msg.obj);
} break;
case TOP_RESUMED_STATE_LOSS_TIMEOUT_MSG: {
final ActivityRecord r = (ActivityRecord) msg.obj;

View File

@@ -34,6 +34,7 @@ import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.timeout;
import android.app.WaitResult;
import android.content.pm.ActivityInfo;
@@ -45,6 +46,8 @@ import androidx.test.filters.MediumTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.concurrent.TimeUnit;
/**
* Tests for the {@link ActivityTaskSupervisor} class.
*
@@ -190,4 +193,16 @@ public class ActivityTaskSupervisorTests extends WindowTestsBase {
assertThat(allowedOnUntrusted).isFalse();
}
/**
* We need to launch home again after user unlocked for those displays that do not have
* encryption aware home app.
*/
@Test
public void testStartHomeAfterUserUnlocked() {
mSupervisor.onUserUnlocked(0);
waitHandlerIdle(mAtm.mH);
verify(mRootWindowContainer, timeout(TimeUnit.SECONDS.toMillis(10)))
.startHomeOnEmptyDisplays("userUnlocked");
}
}