mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-12-25 23:49:32 -05:00
125 lines
5.6 KiB
Diff
125 lines
5.6 KiB
Diff
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||
|
From: Milton Wu <mingjuwu@google.com>
|
||
|
Date: Mon, 8 Aug 2022 09:05:00 +0000
|
||
|
Subject: [PATCH] Add FLAG_SECURE for ChooseLockPassword and Pattern
|
||
|
|
||
|
Prevent ChooseLockPassword and ChooseLockPatten being projected to
|
||
|
remote views, add FLAG_SECURE for these screens.
|
||
|
|
||
|
Bug: 179725730
|
||
|
Test: Check these 2 screens not projected to chromecast
|
||
|
Test: robo test for SetupChooseLockPatternTest ChooseLockPatternTest
|
||
|
SetupChooseLockPasswordTest ChooseLockPasswordTest
|
||
|
Change-Id: I7449a24427c966c1aa4280a7b7e7e70b60997cca
|
||
|
---
|
||
|
.../settings/password/ChooseLockPassword.java | 2 ++
|
||
|
.../settings/password/ChooseLockPattern.java | 2 ++
|
||
|
.../password/ChooseLockPasswordTest.java | 18 ++++++++++++++++++
|
||
|
.../password/ChooseLockPatternTest.java | 10 ++++++++++
|
||
|
4 files changed, 32 insertions(+)
|
||
|
|
||
|
diff --git a/src/com/android/settings/password/ChooseLockPassword.java b/src/com/android/settings/password/ChooseLockPassword.java
|
||
|
index e60b4e6d0e5..f883a7e9198 100644
|
||
|
--- a/src/com/android/settings/password/ChooseLockPassword.java
|
||
|
+++ b/src/com/android/settings/password/ChooseLockPassword.java
|
||
|
@@ -49,6 +49,7 @@ import android.view.LayoutInflater;
|
||
|
import android.view.View;
|
||
|
import android.view.View.OnClickListener;
|
||
|
import android.view.ViewGroup;
|
||
|
+import android.view.WindowManager;
|
||
|
import android.view.inputmethod.EditorInfo;
|
||
|
import android.widget.Button;
|
||
|
import android.widget.LinearLayout;
|
||
|
@@ -166,6 +167,7 @@ public class ChooseLockPassword extends SettingsActivity {
|
||
|
setTitle(msg);
|
||
|
LinearLayout layout = (LinearLayout) findViewById(R.id.content_parent);
|
||
|
layout.setFitsSystemWindows(false);
|
||
|
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
||
|
}
|
||
|
|
||
|
public static class ChooseLockPasswordFragment extends InstrumentedFragment
|
||
|
diff --git a/src/com/android/settings/password/ChooseLockPattern.java b/src/com/android/settings/password/ChooseLockPattern.java
|
||
|
index 0811a951bc2..d81d520d42e 100644
|
||
|
--- a/src/com/android/settings/password/ChooseLockPattern.java
|
||
|
+++ b/src/com/android/settings/password/ChooseLockPattern.java
|
||
|
@@ -31,6 +31,7 @@ import android.view.View;
|
||
|
import android.view.ViewGroup;
|
||
|
import android.widget.LinearLayout;
|
||
|
import android.widget.ScrollView;
|
||
|
+import android.view.WindowManager;
|
||
|
import android.widget.TextView;
|
||
|
|
||
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||
|
@@ -146,6 +147,7 @@ public class ChooseLockPattern extends SettingsActivity {
|
||
|
: R.string.lockpassword_choose_your_screen_lock_header);
|
||
|
LinearLayout layout = (LinearLayout) findViewById(R.id.content_parent);
|
||
|
layout.setFitsSystemWindows(false);
|
||
|
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java
|
||
|
index 75b6bb4b14a..35847d2e43f 100644
|
||
|
--- a/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java
|
||
|
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java
|
||
|
@@ -16,6 +16,8 @@
|
||
|
|
||
|
package com.android.settings.password;
|
||
|
|
||
|
+import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
||
|
+
|
||
|
import static com.google.common.truth.Truth.assertThat;
|
||
|
import static org.robolectric.RuntimeEnvironment.application;
|
||
|
|
||
|
@@ -121,6 +123,22 @@ public class ChooseLockPasswordTest {
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
+
|
||
|
+ @Test
|
||
|
+ public void activity_shouldHaveSecureFlag() {
|
||
|
+ PasswordPolicy policy = new PasswordPolicy();
|
||
|
+ policy.quality = PASSWORD_QUALITY_ALPHABETIC;
|
||
|
+ policy.length = 10;
|
||
|
+
|
||
|
+ Intent intent = createIntentForPasswordValidation(
|
||
|
+ /* minMetrics */ policy.getMinMetrics(),
|
||
|
+ /* minComplexity= */ PASSWORD_COMPLEXITY_NONE,
|
||
|
+ /* passwordType= */ PASSWORD_QUALITY_ALPHABETIC);
|
||
|
+ ChooseLockPassword activity = buildChooseLockPasswordActivity(intent);
|
||
|
+ final int flags = activity.getWindow().getAttributes().flags;
|
||
|
+ assertThat(flags & FLAG_SECURE).isEqualTo(FLAG_SECURE);
|
||
|
+ }
|
||
|
+
|
||
|
public void assertThat_chooseLockIconChanged_WhenFingerprintExtraSet() {
|
||
|
ShadowDrawable drawable = setActivityAndGetIconDrawable(true);
|
||
|
assertThat(drawable.getCreatedFromResId()).isEqualTo(R.drawable.ic_fingerprint_header);
|
||
|
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
|
||
|
index e07351cd34a..c53dd2ec0a2 100644
|
||
|
--- a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
|
||
|
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
|
||
|
@@ -16,6 +16,8 @@
|
||
|
|
||
|
package com.android.settings.password;
|
||
|
|
||
|
+import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
||
|
+
|
||
|
import static com.google.common.truth.Truth.assertThat;
|
||
|
import static org.robolectric.RuntimeEnvironment.application;
|
||
|
|
||
|
@@ -118,6 +120,14 @@ public class ChooseLockPatternTest {
|
||
|
assertThat(iconView.getVisibility()).isEqualTo(View.GONE);
|
||
|
}
|
||
|
|
||
|
+ @Test
|
||
|
+ public void activity_shouldHaveSecureFlag() {
|
||
|
+ final ChooseLockPattern activity = Robolectric.buildActivity(
|
||
|
+ ChooseLockPattern.class, new IntentBuilder(application).build()).setup().get();
|
||
|
+ final int flags = activity.getWindow().getAttributes().flags;
|
||
|
+ assertThat(flags & FLAG_SECURE).isEqualTo(FLAG_SECURE);
|
||
|
+ }
|
||
|
+
|
||
|
private ChooseLockPattern createActivity(boolean addFingerprintExtra) {
|
||
|
return Robolectric.buildActivity(
|
||
|
ChooseLockPattern.class,
|