Ensure the HostsideVpnTests passes with keyguard locked. am: fd3b95c1f7 am: 16d841048e

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1669608

Change-Id: I689f8a5e5028069753d377979eee14f97e611681
This commit is contained in:
Lorenzo Colitti
2021-04-09 16:45:29 +00:00
committed by Automerger Merge Worker

View File

@@ -17,6 +17,7 @@
package com.android.cts.net.hostside; package com.android.cts.net.hostside;
import android.app.Activity; import android.app.Activity;
import android.app.KeyguardManager;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.WindowManager; import android.view.WindowManager;
@@ -34,6 +35,11 @@ public class MyActivity extends Activity {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); | 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 @Override