From fd3b95c1f7b2e80c46026a1d4174454df57e7f07 Mon Sep 17 00:00:00 2001 From: Lorenzo Colitti Date: Thu, 8 Apr 2021 20:58:40 +0900 Subject: [PATCH] Ensure the HostsideVpnTests passes with keyguard locked. The test app used in CtsHostsideNetworkTests already dismisses the keyguard for its own activity, but that doesn't work for the VPN tests. This is because as soon as the VPN dialog appears, the test activity is no longer in the foreground and the keyguard comes back. As a result, the test cannot click on the VPN dialog. Test: test-only change Change-Id: I7be1d7fb46a2f9547bc5325d75b5bd5546e6dc18 --- .../app/src/com/android/cts/net/hostside/MyActivity.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/cts/hostside/app/src/com/android/cts/net/hostside/MyActivity.java b/tests/cts/hostside/app/src/com/android/cts/net/hostside/MyActivity.java index 0d0bc58504..55eec1190d 100644 --- a/tests/cts/hostside/app/src/com/android/cts/net/hostside/MyActivity.java +++ b/tests/cts/hostside/app/src/com/android/cts/net/hostside/MyActivity.java @@ -17,6 +17,7 @@ package com.android.cts.net.hostside; import android.app.Activity; +import android.app.KeyguardManager; import android.content.Intent; import android.os.Bundle; import android.view.WindowManager; @@ -34,6 +35,11 @@ public class MyActivity extends Activity { getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); + + // Dismiss the keyguard so that the tests can click on the VPN confirmation dialog. + // FLAG_DISMISS_KEYGUARD is not sufficient to do this because as soon as the dialog appears, + // this activity goes into the background and the keyguard reappears. + getSystemService(KeyguardManager.class).requestDismissKeyguard(this, null /* callback */); } @Override