Merge "Set device credential's Window flag to be SECURE." into oc-dr1-dev
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
index 2b2b38f..d2bd934 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
@@ -68,7 +68,7 @@
             LinearLayout layout = (LinearLayout) findViewById(R.id.content_parent);
             layout.setFitsSystemWindows(false);
         }
-
+        getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
         mIsKeyguardLocked = savedState == null
                 ? getSystemService(KeyguardManager.class).isKeyguardLocked()
                 : savedState.getBoolean(STATE_IS_KEYGUARD_LOCKED, false);
diff --git a/tests/app/src/com/android/settings/password/ChooseLockGenericTest.java b/tests/app/src/com/android/settings/password/ChooseLockGenericTest.java
index e2bd6ee..40b69a4 100644
--- a/tests/app/src/com/android/settings/password/ChooseLockGenericTest.java
+++ b/tests/app/src/com/android/settings/password/ChooseLockGenericTest.java
@@ -18,9 +18,7 @@
 
 import static android.support.test.InstrumentationRegistry.getInstrumentation;
 import static android.support.test.InstrumentationRegistry.getTargetContext;
-
 import static com.google.common.truth.Truth.assertThat;
-
 import static org.junit.Assert.assertTrue;
 
 import android.app.Activity;
@@ -39,6 +37,7 @@
 import android.support.test.uiautomator.UiObject;
 import android.support.test.uiautomator.UiSelector;
 import android.text.format.DateUtils;
+import android.view.WindowManager;
 
 import com.android.internal.widget.LockPatternUtils;
 
@@ -93,7 +92,9 @@
             // WHEN ChooseLockGeneric is launched with no extras.
             mChooseLockGenericActivityRule.launchActivity(null /* No extras */);
             // THEN ConfirmLockPassword.InternalActivity is shown.
-            assertThat(getCurrentActivity())
+            final Activity activity = getCurrentActivity();
+            assertThat(isSecureWindow(activity)).isTrue();
+            assertThat(activity)
                     .isInstanceOf(ConfirmLockPassword.InternalActivity.class);
         } finally {
             finishAllAppTasks();
@@ -110,7 +111,9 @@
             // WHEN ChooseLockGeneric is launched with extras to by-pass lock password confirmation.
             mChooseLockGenericActivityRule.launchActivity(PHISHING_ATTACK_INTENT);
             // THEN ConfirmLockPassword.InternalActivity is still shown.
-            assertThat(getCurrentActivity())
+            final Activity activity = getCurrentActivity();
+            assertThat(isSecureWindow(activity)).isTrue();
+            assertThat(activity)
                     .isInstanceOf(ConfirmLockPassword.InternalActivity.class);
         } finally {
             finishAllAppTasks();
@@ -217,4 +220,9 @@
         mDevice.pressEnter();
         mDevice.waitForIdle();
     }
+
+    private boolean isSecureWindow(Activity activity) {
+        return (activity.getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_SECURE)
+                != 0;
+    }
 }