Merge "Disallow screenshot on Wi-Fi QR code settings" into tm-qpr-dev am: d2635580fb am: 34471a7160

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/20309947

Change-Id: I27396019f31117f69f9088174ed52c6ce3526556
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java b/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
index e6f0b31..6c9d498 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
@@ -28,6 +28,7 @@
 import android.provider.Settings;
 import android.util.EventLog;
 import android.util.Log;
+import android.view.WindowManager;
 
 import androidx.annotation.VisibleForTesting;
 import androidx.fragment.app.FragmentTransaction;
@@ -99,6 +100,7 @@
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+        getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
 
         if (savedInstanceState != null) {
             String qrCode = savedInstanceState.getString(KEY_QR_CODE);
diff --git a/tests/robotests/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java b/tests/robotests/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
index d8605de..88fa83a 100644
--- a/tests/robotests/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
@@ -16,6 +16,10 @@
 
 package com.android.settings.wifi.dpp;
 
+import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
+
+import static com.google.common.truth.Truth.assertThat;
+
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
@@ -73,6 +77,12 @@
     }
 
     @Test
+    public void launchActivity_shouldAddFlagSecure() {
+        assertThat(mActivity.getWindow().getAttributes().flags & FLAG_SECURE)
+                .isEqualTo(FLAG_SECURE);
+    }
+
+    @Test
     public void handleIntent_isGuestUser_shouldFinish() {
         when(mUserManager.isGuestUser()).thenReturn(true);