diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-21 16:38:29 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-21 16:38:29 +0000 |
commit | 31f08ce2b14d44c32f46e509e2154430f0192374 (patch) | |
tree | fca972cff84aafa3853f433d484ea88fba55bb89 | |
parent | b3139b76d8c21c6b6893f0a851c74e29718a527e (diff) | |
parent | 7a465726efef11293971ef6946cd8c31561cc4d1 (diff) | |
download | cts-android13-frc-art-release.tar.gz |
Snap for 8748865 from 7a465726efef11293971ef6946cd8c31561cc4d1 to tm-frc-art-releaset_frc_art_330443060android13-frc-art-release
Change-Id: I71b817ea0184ea17375c917e7d001fd274952daa
6 files changed, 60 insertions, 59 deletions
diff --git a/tests/framework/base/windowmanager/src/android/server/wm/KeyguardLockedTests.java b/tests/framework/base/windowmanager/src/android/server/wm/KeyguardLockedTests.java index 784003b2452..08b8204cd98 100644 --- a/tests/framework/base/windowmanager/src/android/server/wm/KeyguardLockedTests.java +++ b/tests/framework/base/windowmanager/src/android/server/wm/KeyguardLockedTests.java @@ -174,20 +174,6 @@ public class KeyguardLockedTests extends KeyguardTestBase { } @Test - public void testDismissKeyguardIfInsecure_notAllowed() { - final LockScreenSession lockScreenSession = createManagedLockScreenSession(); - lockScreenSession.setLockCredential().gotoKeyguard(); - - mWmState.assertKeyguardShowingAndNotOccluded(); - launchActivityWithDismissKeyguardIfInsecure(SHOW_WHEN_LOCKED_ACTIVITY); - mWmState.computeState(SHOW_WHEN_LOCKED_ACTIVITY); - mWmState.assertVisibility(SHOW_WHEN_LOCKED_ACTIVITY, true); - - // Make sure we stay on Keyguard. - mWmState.assertKeyguardShowingAndOccluded(); - } - - @Test public void testDismissKeyguardActivity_method() { final LockScreenSession lockScreenSession = createManagedLockScreenSession(); lockScreenSession.setLockCredential(); diff --git a/tests/framework/base/windowmanager/src/android/server/wm/KeyguardTransitionTests.java b/tests/framework/base/windowmanager/src/android/server/wm/KeyguardTransitionTests.java index bac67d28dc0..b585c048c4b 100644 --- a/tests/framework/base/windowmanager/src/android/server/wm/KeyguardTransitionTests.java +++ b/tests/framework/base/windowmanager/src/android/server/wm/KeyguardTransitionTests.java @@ -106,15 +106,6 @@ public class KeyguardTransitionTests extends ActivityManagerTestBase { } @Test - public void testDismissKeyguardIfInsecure() { - createManagedLockScreenSession().gotoKeyguard(); - launchActivityWithDismissKeyguardIfInsecure(SHOW_WHEN_LOCKED_NO_PREVIEW_ACTIVITY); - mWmState.computeState(SHOW_WHEN_LOCKED_NO_PREVIEW_ACTIVITY); - assertEquals("Picked wrong transition", TRANSIT_KEYGUARD_GOING_AWAY, - mWmState.getDefaultDisplayLastTransition()); - } - - @Test public void testNewActivityDuringOccluded() { final LockScreenSession lockScreenSession = createManagedLockScreenSession(); launchActivity(SHOW_WHEN_LOCKED_NO_PREVIEW_ACTIVITY); @@ -126,18 +117,6 @@ public class KeyguardTransitionTests extends ActivityManagerTestBase { } @Test - public void testNewDismissKeyguardIfInsecureActivityDuringOccluded() { - final LockScreenSession lockScreenSession = createManagedLockScreenSession(); - launchActivity(SHOW_WHEN_LOCKED_NO_PREVIEW_ACTIVITY); - lockScreenSession.gotoKeyguard(SHOW_WHEN_LOCKED_NO_PREVIEW_ACTIVITY); - launchActivityWithDismissKeyguardIfInsecure( - SHOW_WHEN_LOCKED_WITH_DIALOG_NO_PREVIEW_ACTIVITY); - mWmState.computeState(SHOW_WHEN_LOCKED_WITH_DIALOG_NO_PREVIEW_ACTIVITY); - assertEquals("Picked wrong transition", TRANSIT_ACTIVITY_OPEN, - mWmState.getDefaultDisplayLastTransition()); - } - - @Test public void testOccludeManifestAttr() { final LockScreenSession lockScreenSession = createManagedLockScreenSession(); lockScreenSession.gotoKeyguard(); diff --git a/tests/inputmethod/mockime/src/com/android/cts/mockime/ImeSettings.java b/tests/inputmethod/mockime/src/com/android/cts/mockime/ImeSettings.java index be709b454c6..cfc30ec673e 100644 --- a/tests/inputmethod/mockime/src/com/android/cts/mockime/ImeSettings.java +++ b/tests/inputmethod/mockime/src/com/android/cts/mockime/ImeSettings.java @@ -61,6 +61,11 @@ public class ImeSettings { private static final String STRICT_MODE_ENABLED = "StrictModeEnabled"; private static final String VERIFY_CONTEXT_APIS_IN_ON_CREATE = "VerifyContextApisInOnCreate"; + /** + * Simulate the manifest flag enableOnBackInvokedCallback being true for the IME. + */ + private static final String ON_BACK_CALLBACK_ENABLED = "onBackCallbackEnabled"; + @NonNull private final PersistableBundle mBundle; @@ -182,6 +187,10 @@ public class ImeSettings { return mBundle.getBoolean(VERIFY_CONTEXT_APIS_IN_ON_CREATE, false); } + public boolean isOnBackCallbackEnabled() { + return mBundle.getBoolean(ON_BACK_CALLBACK_ENABLED, false); + } + static Bundle serializeToBundle(@NonNull String eventCallbackActionName, @Nullable Builder builder) { final Bundle result = new Bundle(); @@ -363,5 +372,15 @@ public class ImeSettings { mBundle.putBoolean(VERIFY_CONTEXT_APIS_IN_ON_CREATE, enabled); return this; } + + /** + * Sets whether the IME's + * {@link android.content.pm.ApplicationInfo#isOnBackInvokedCallbackEnabled()} + * should be set to {@code true}. + */ + public Builder setOnBackCallbackEnabled(boolean enabled) { + mBundle.putBoolean(ON_BACK_CALLBACK_ENABLED, enabled); + return this; + } } } diff --git a/tests/inputmethod/mockime/src/com/android/cts/mockime/MockIme.java b/tests/inputmethod/mockime/src/com/android/cts/mockime/MockIme.java index fc4c05e31a2..528da58c7b7 100644 --- a/tests/inputmethod/mockime/src/com/android/cts/mockime/MockIme.java +++ b/tests/inputmethod/mockime/src/com/android/cts/mockime/MockIme.java @@ -426,10 +426,6 @@ public final class MockIme extends InputMethodService { return e; } } - case "setEnableOnBackInvokedCallback": - boolean isEnabled = command.getExtras().getBoolean("isEnabled"); - getApplicationInfo().setEnableOnBackInvokedCallback(isEnabled); - return ImeEvent.RETURN_VALUE_UNAVAILABLE; case "getDisplayId": return getDisplay().getDisplayId(); case "verifyLayoutInflaterContext": @@ -679,6 +675,10 @@ public final class MockIme extends InputMethodService { .build()); } + if (mSettings.isOnBackCallbackEnabled()) { + getApplicationInfo().setEnableOnBackInvokedCallback(true); + } + getTracer().onCreate(() -> { super.onCreate(); mHandlerThread.start(); diff --git a/tests/inputmethod/src/android/view/inputmethod/cts/KeyboardVisibilityControlTest.java b/tests/inputmethod/src/android/view/inputmethod/cts/KeyboardVisibilityControlTest.java index ac95dc89c94..d79dccae84c 100644 --- a/tests/inputmethod/src/android/view/inputmethod/cts/KeyboardVisibilityControlTest.java +++ b/tests/inputmethod/src/android/view/inputmethod/cts/KeyboardVisibilityControlTest.java @@ -51,6 +51,7 @@ import static org.junit.Assume.assumeTrue; import android.app.AlertDialog; import android.app.Instrumentation; import android.app.compat.CompatChanges; +import android.content.Context; import android.content.pm.PackageManager; import android.graphics.Color; import android.os.SystemClock; @@ -245,27 +246,38 @@ public class KeyboardVisibilityControlTest extends EndToEndImeTestBase { } private void verifyHideImeBackPressed( - boolean appRequestsLegacy, boolean imeRequestsLegacy) throws Exception { + boolean appRequestsBackCallback, boolean imeRequestsBackCallback) throws Exception { final Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); - final InputMethodManager imm = InstrumentationRegistry.getInstrumentation() - .getTargetContext().getSystemService(InputMethodManager.class); + final Context context = instrumentation.getTargetContext(); + final InputMethodManager imm = context.getSystemService(InputMethodManager.class); + + // Whether 'OnBackInvokedCallback' or 'onBackPressed' (legacy back) is used is defined by + // the 'enableOnBackInvokedCallback' flag in the Application manifest. + // Registering a callback is only authorized if the flag is set to true. Since the + // WindowOnBackDispatcher is created at the same time as the ViewRootImpl, for test purpose, + // we need to manually set the flag on ApplicationInfo before the window is created which + // happens during the MockIme creation and TestActivity creation. try (MockImeSession imeSession = MockImeSession.create( instrumentation.getContext(), instrumentation.getUiAutomation(), - new ImeSettings.Builder())) { + new ImeSettings.Builder() + .setOnBackCallbackEnabled(imeRequestsBackCallback) + )) { final ImeEventStream stream = imeSession.openEventStream(); final String marker = getTestMarker(); + + if (appRequestsBackCallback) { + context.getApplicationInfo().setEnableOnBackInvokedCallback(true); + } + final EditText editText = launchTestActivity(marker); final TestActivity testActivity = (TestActivity) editText.getContext(); - if (appRequestsLegacy) { - testActivity.getApplicationInfo().setEnableOnBackInvokedCallback(true); + + if (!appRequestsBackCallback) { testActivity.setIgnoreBackKey(true); } - if (imeRequestsLegacy) { - imeSession.callSetEnableOnBackInvokedCallback(true); - } expectEvent(stream, editorMatcher("onStartInput", marker), TIMEOUT); notExpectEvent(stream, editorMatcher("onStartInputView", marker), TIMEOUT); @@ -296,22 +308,26 @@ public class KeyboardVisibilityControlTest extends EndToEndImeTestBase { @Test public void testHideImeAfterBackPressed_legacyAppLegacyIme() throws Exception { - verifyHideImeBackPressed(true /* appRequestsLegacy */, true /* imeRequestsLegacy */); + verifyHideImeBackPressed(false/* appRequestsBackCallback */, + false/* imeRequestsBackCallback */); } @Test public void testHideImeAfterBackPressed_migratedAppLegacyIme() throws Exception { - verifyHideImeBackPressed(false /* appRequestsLegacy */, true /* imeRequestsLegacy */); + verifyHideImeBackPressed(true/* appRequestsBackCallback */, + false/* imeRequestsBackCallback */); } @Test public void testHideImeAfterBackPressed_migratedAppMigratedIme() throws Exception { - verifyHideImeBackPressed(false /* appRequestsLegacy */, false /* imeRequestsLegacy */); + verifyHideImeBackPressed(true/* appRequestsBackCallback */, + true/* imeRequestsBackCallback */); } @Test public void testHideImeAfterBackPressed_legacyAppMigratedIme() throws Exception { - verifyHideImeBackPressed(true /* appRequestsLegacy */, false /* imeRequestsLegacy */); + verifyHideImeBackPressed(false/* appRequestsBackCallback */, + true/* imeRequestsBackCallback */); } @Test diff --git a/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java b/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java index ae87bdc7d91..f864e52812d 100644 --- a/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java +++ b/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java @@ -1489,6 +1489,7 @@ public class KeyAttestationTest { public static void verifyCertificateChain(Certificate[] certChain, boolean expectStrongBox) throws GeneralSecurityException { assertNotNull(certChain); + boolean strongBoxSubjectFound = false; for (int i = 1; i < certChain.length; ++i) { try { PublicKey pubKey = certChain[i].getPublicKey(); @@ -1515,19 +1516,19 @@ public class KeyAttestationTest { if (i == 1) { // First cert should have subject "CN=Android Keystore Key". assertEquals(signedCertSubject, new X500Name("CN=Android Keystore Key")); - } else { - // Only strongbox implementations should have strongbox in the subject line - assertEquals(expectStrongBox, signedCertSubject.toString() - .toLowerCase() - .contains("strongbox")); + } else if (signedCertSubject.toString().toLowerCase().contains("strongbox")) { + strongBoxSubjectFound = true; } } catch (InvalidKeyException | CertificateException | NoSuchAlgorithmException | NoSuchProviderException | SignatureException e) { throw new GeneralSecurityException("Using StrongBox: " + expectStrongBox + "\n" - + "Failed to verify certificate " - + certChain[i - 1] + " with public key " + certChain[i].getPublicKey(), e); + + "Failed to verify certificate " + certChain[i - 1] + + " with public key " + certChain[i].getPublicKey(), + e); } } + // At least one intermediate in a StrongBox chain must have "strongbox" in the subject. + assertEquals(expectStrongBox, strongBoxSubjectFound); } private void testDeviceIdAttestationFailure(int idType, |