Loading services/core/java/com/android/server/wm/ActivityStartInterceptor.java +4 −1 Original line number Diff line number Diff line Loading @@ -399,8 +399,11 @@ class ActivityStartInterceptor { * @return The intercepting intent if needed. */ private Intent interceptWithConfirmCredentialsIfNeeded(ActivityInfo aInfo, int userId) { if (!mService.mAmInternal.shouldConfirmCredentials(userId)) { return null; } if ((aInfo.flags & ActivityInfo.FLAG_SHOW_WHEN_LOCKED) != 0 || !mService.mAmInternal.shouldConfirmCredentials(userId)) { && (mUserManager.isUserUnlocked(userId) || aInfo.directBootAware)) { return null; } final IntentSender target = createIntentSenderForOriginalIntent(mCallingUid, Loading services/tests/wmtests/src/com/android/server/wm/ActivityStartInterceptorTest.java +51 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import static com.android.server.pm.PackageManagerService.PLATFORM_PACKAGE_NAME; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.nullable; Loading Loading @@ -275,10 +276,59 @@ public class ActivityStartInterceptorTest { // THEN calling intercept returns true mInterceptor.intercept(null, null, mAInfo, null, null, null, 0, 0, null); // THEN the returned intent is the quiet mode intent // THEN the returned intent is the confirm credentials intent assertTrue(CONFIRM_CREDENTIALS_INTENT.filterEquals(mInterceptor.mIntent)); } @Test public void testLockedManagedProfileShowWhenLocked() { Intent originalIntent = new Intent(); // GIVEN that the user is locked but its storage is unlocked and the activity has // showWhenLocked flag when(mAmInternal.shouldConfirmCredentials(TEST_USER_ID)).thenReturn(true); when(mUserManager.isUserUnlocked(eq(TEST_USER_ID))).thenReturn(true); mAInfo.flags |= ActivityInfo.FLAG_SHOW_WHEN_LOCKED; // THEN calling intercept returns true mInterceptor.intercept(originalIntent, null, mAInfo, null, null, null, 0, 0, null); // THEN the returned intent is original intent assertSame(originalIntent, mInterceptor.mIntent); } @Test public void testLockedManagedProfileShowWhenLockedEncryptedStorage() { // GIVEN that the user storage is locked, activity has showWhenLocked flag but no // directBootAware flag when(mAmInternal.shouldConfirmCredentials(TEST_USER_ID)).thenReturn(true); when(mUserManager.isUserUnlocked(eq(TEST_USER_ID))).thenReturn(false); mAInfo.flags |= ActivityInfo.FLAG_SHOW_WHEN_LOCKED; mAInfo.directBootAware = false; // THEN calling intercept returns true mInterceptor.intercept(null, null, mAInfo, null, null, null, 0, 0, null); // THEN the returned intent is the confirm credentials intent assertTrue(CONFIRM_CREDENTIALS_INTENT.filterEquals(mInterceptor.mIntent)); } @Test public void testLockedManagedProfileShowWhenLockedEncryptedStorageDirectBootAware() { Intent originalIntent = new Intent(); // GIVEN that the user storage is locked, activity has showWhenLocked flag and // directBootAware flag when(mAmInternal.shouldConfirmCredentials(TEST_USER_ID)).thenReturn(true); when(mUserManager.isUserUnlocked(eq(TEST_USER_ID))).thenReturn(false); mAInfo.flags |= ActivityInfo.FLAG_SHOW_WHEN_LOCKED; mAInfo.directBootAware = true; // THEN calling intercept returns true mInterceptor.intercept(originalIntent, null, mAInfo, null, null, null, 0, 0, null); // THEN the returned intent is original intent assertSame(originalIntent, mInterceptor.mIntent); } @Test public void testHarmfulAppWarning() throws RemoteException { // GIVEN the package we're about to launch has a harmful app warning set Loading Loading
services/core/java/com/android/server/wm/ActivityStartInterceptor.java +4 −1 Original line number Diff line number Diff line Loading @@ -399,8 +399,11 @@ class ActivityStartInterceptor { * @return The intercepting intent if needed. */ private Intent interceptWithConfirmCredentialsIfNeeded(ActivityInfo aInfo, int userId) { if (!mService.mAmInternal.shouldConfirmCredentials(userId)) { return null; } if ((aInfo.flags & ActivityInfo.FLAG_SHOW_WHEN_LOCKED) != 0 || !mService.mAmInternal.shouldConfirmCredentials(userId)) { && (mUserManager.isUserUnlocked(userId) || aInfo.directBootAware)) { return null; } final IntentSender target = createIntentSenderForOriginalIntent(mCallingUid, Loading
services/tests/wmtests/src/com/android/server/wm/ActivityStartInterceptorTest.java +51 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import static com.android.server.pm.PackageManagerService.PLATFORM_PACKAGE_NAME; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.nullable; Loading Loading @@ -275,10 +276,59 @@ public class ActivityStartInterceptorTest { // THEN calling intercept returns true mInterceptor.intercept(null, null, mAInfo, null, null, null, 0, 0, null); // THEN the returned intent is the quiet mode intent // THEN the returned intent is the confirm credentials intent assertTrue(CONFIRM_CREDENTIALS_INTENT.filterEquals(mInterceptor.mIntent)); } @Test public void testLockedManagedProfileShowWhenLocked() { Intent originalIntent = new Intent(); // GIVEN that the user is locked but its storage is unlocked and the activity has // showWhenLocked flag when(mAmInternal.shouldConfirmCredentials(TEST_USER_ID)).thenReturn(true); when(mUserManager.isUserUnlocked(eq(TEST_USER_ID))).thenReturn(true); mAInfo.flags |= ActivityInfo.FLAG_SHOW_WHEN_LOCKED; // THEN calling intercept returns true mInterceptor.intercept(originalIntent, null, mAInfo, null, null, null, 0, 0, null); // THEN the returned intent is original intent assertSame(originalIntent, mInterceptor.mIntent); } @Test public void testLockedManagedProfileShowWhenLockedEncryptedStorage() { // GIVEN that the user storage is locked, activity has showWhenLocked flag but no // directBootAware flag when(mAmInternal.shouldConfirmCredentials(TEST_USER_ID)).thenReturn(true); when(mUserManager.isUserUnlocked(eq(TEST_USER_ID))).thenReturn(false); mAInfo.flags |= ActivityInfo.FLAG_SHOW_WHEN_LOCKED; mAInfo.directBootAware = false; // THEN calling intercept returns true mInterceptor.intercept(null, null, mAInfo, null, null, null, 0, 0, null); // THEN the returned intent is the confirm credentials intent assertTrue(CONFIRM_CREDENTIALS_INTENT.filterEquals(mInterceptor.mIntent)); } @Test public void testLockedManagedProfileShowWhenLockedEncryptedStorageDirectBootAware() { Intent originalIntent = new Intent(); // GIVEN that the user storage is locked, activity has showWhenLocked flag and // directBootAware flag when(mAmInternal.shouldConfirmCredentials(TEST_USER_ID)).thenReturn(true); when(mUserManager.isUserUnlocked(eq(TEST_USER_ID))).thenReturn(false); mAInfo.flags |= ActivityInfo.FLAG_SHOW_WHEN_LOCKED; mAInfo.directBootAware = true; // THEN calling intercept returns true mInterceptor.intercept(originalIntent, null, mAInfo, null, null, null, 0, 0, null); // THEN the returned intent is original intent assertSame(originalIntent, mInterceptor.mIntent); } @Test public void testHarmfulAppWarning() throws RemoteException { // GIVEN the package we're about to launch has a harmful app warning set Loading