Merge "Ignore catalyst test in DisplayScreenTest" into main
diff --git a/res/values/strings.xml b/res/values/strings.xml
index a11acb0..1f9aa61 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -6957,6 +6957,8 @@
     <string name="vpn_disconnect">Disconnect</string>
     <!-- Field label to show the version number for a VPN app. [CHAR LIMIT=40] -->
     <string name="vpn_version">Version</string>
+    <!-- Field label to show the version number for a VPN app dialog. [CHAR LIMIT=40] -->
+    <string name="vpn_version_info">Version <xliff:g id="version" example="3.3.0">%s</xliff:g></string>
     <!-- Button label to forget a VPN profile [CHAR LIMIT=40] -->
     <string name="vpn_forget_long">Forget VPN</string>
     <!-- Dialog message title to set another VPN app to be always-on [CHAR LIMIT=40] -->
diff --git a/src/com/android/settings/fuelgauge/BatterySettingsMigrateChecker.java b/src/com/android/settings/fuelgauge/BatterySettingsMigrateChecker.java
index 066e0fc..3714a11 100644
--- a/src/com/android/settings/fuelgauge/BatterySettingsMigrateChecker.java
+++ b/src/com/android/settings/fuelgauge/BatterySettingsMigrateChecker.java
@@ -72,25 +72,22 @@
             Context context,
             @BatteryOptimizeUtils.OptimizationMode int optimizationMode,
             List<String> allowList) {
-        allowList.forEach(
-                packageName -> {
-                    final BatteryOptimizeUtils batteryOptimizeUtils =
-                            BatteryBackupHelper.newBatteryOptimizeUtils(
-                                    context,
-                                    packageName,
-                                    /* testOptimizeUtils */ sBatteryOptimizeUtils);
-                    if (batteryOptimizeUtils == null) {
-                        return;
-                    }
-                    if (batteryOptimizeUtils.getAppOptimizationMode() != optimizationMode) {
-                        Log.w(
-                                TAG,
-                                "Reset " + packageName + " battery mode into " + optimizationMode);
-                        batteryOptimizeUtils.setAppUsageState(
-                                optimizationMode,
-                                BatteryOptimizeHistoricalLogEntry.Action.FORCE_RESET);
-                    }
-                });
+        for (String packageName : allowList) {
+            final BatteryOptimizeUtils batteryOptimizeUtils =
+                    BatteryBackupHelper.newBatteryOptimizeUtils(
+                            context,
+                            packageName,
+                            /* testOptimizeUtils */ sBatteryOptimizeUtils);
+            if (batteryOptimizeUtils == null) {
+                continue;
+            }
+            if (batteryOptimizeUtils.getAppOptimizationMode() != optimizationMode) {
+                Log.w(TAG, "Reset " + packageName + " mode into " + optimizationMode);
+                batteryOptimizeUtils.setAppUsageState(
+                        optimizationMode,
+                        BatteryOptimizeHistoricalLogEntry.Action.FORCE_RESET);
+            }
+        }
     }
 
     static void verifySaverConfiguration(Context context) {
diff --git a/src/com/android/settings/privacy/EnableContentCaptureWithServiceSettingsPreferenceController.java b/src/com/android/settings/privacy/EnableContentCaptureWithServiceSettingsPreferenceController.java
index c8a5471..46aed3c 100644
--- a/src/com/android/settings/privacy/EnableContentCaptureWithServiceSettingsPreferenceController.java
+++ b/src/com/android/settings/privacy/EnableContentCaptureWithServiceSettingsPreferenceController.java
@@ -19,7 +19,6 @@
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
-import android.content.pm.UserInfo;
 import android.os.UserHandle;
 import android.os.UserManager;
 import android.text.TextUtils;
@@ -33,7 +32,6 @@
 import com.android.settings.dashboard.profileselector.ProfileSelectDialog;
 import com.android.settings.utils.ContentCaptureUtils;
 
-import java.util.ArrayList;
 import java.util.List;
 
 public final class EnableContentCaptureWithServiceSettingsPreferenceController
@@ -94,11 +92,7 @@
 
     private void show(Preference preference) {
         final UserManager userManager = UserManager.get(mContext);
-        final List<UserInfo> userInfos = userManager.getUsers();
-        final ArrayList<UserHandle> userHandles = new ArrayList<>(userInfos.size());
-        for (UserInfo info : userInfos) {
-            userHandles.add(info.getUserHandle());
-        }
+        final List<UserHandle> userHandles = userManager.getEnabledProfiles();
         final Intent intent = preference.getIntent().addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
         if (userHandles.size() == 1) {
             mContext.startActivityAsUser(intent, userHandles.get(0));
diff --git a/src/com/android/settings/vpn2/AppDialog.java b/src/com/android/settings/vpn2/AppDialog.java
index 815b28b..b122999 100644
--- a/src/com/android/settings/vpn2/AppDialog.java
+++ b/src/com/android/settings/vpn2/AppDialog.java
@@ -56,7 +56,7 @@
     @Override
     protected void onCreate(Bundle savedState) {
         setTitle(mLabel);
-        setMessage(getContext().getString(R.string.vpn_version, mPackageInfo.versionName));
+        setMessage(getContext().getString(R.string.vpn_version_info, mPackageInfo.versionName));
 
         createButtons();
         super.onCreate(savedState);
diff --git a/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java b/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java
index 4723b0e..118ff71 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java
@@ -262,16 +262,9 @@
                 continue;
             }
             canFindNetwork = true;
-            final int security =
-                    WifiDppUtils.getSecurityTypeFromWifiConfiguration(wifiConfiguration);
-            if (security == wifiEntry.getSecurity()) {
-                return REACHABLE_WIFI_NETWORK;
-            }
-
-            // Default security type of PSK/SAE transition mode WifiEntry is SECURITY_PSK and
-            // there is no way to know if a WifiEntry is of transition mode. Give it a chance.
-            if (security == WifiEntry.SECURITY_SAE
-                    && wifiEntry.getSecurity() == WifiEntry.SECURITY_PSK) {
+            int security = WifiDppUtils.getSecurityTypeFromWifiConfiguration(wifiConfiguration);
+            if (isSecurityMatched(security, wifiEntry.getSecurity())) {
+                Log.d(TAG, "WiFi DPP detects connection security for a matching WiFi network.");
                 return REACHABLE_WIFI_NETWORK;
             }
         }
@@ -284,6 +277,24 @@
     }
 
     @VisibleForTesting
+    boolean isSecurityMatched(int qrSecurity, int entrySecurity) {
+        if (qrSecurity == entrySecurity) {
+            return true;
+        }
+        // Default security type of PSK/SAE transition mode WifiEntry is SECURITY_PSK and
+        // there is no way to know if a WifiEntry is of transition mode. Give it a chance.
+        if (qrSecurity == WifiEntry.SECURITY_SAE && entrySecurity == WifiEntry.SECURITY_PSK) {
+            return true;
+        }
+        // If configured is no password, the Wi-Fi framework will attempt OPEN and OWE security.
+        return isNoPasswordSecurity(qrSecurity) && isNoPasswordSecurity(entrySecurity);
+    }
+
+    private boolean isNoPasswordSecurity(int security) {
+        return security == WifiEntry.SECURITY_NONE || security == WifiEntry.SECURITY_OWE;
+    }
+
+    @VisibleForTesting
     boolean canConnectWifi(String ssid) {
         final List<WifiEntry> wifiEntries = mWifiPickerTracker.getWifiEntries();
         for (WifiEntry wifiEntry : wifiEntries) {
diff --git a/tests/robotests/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragmentTest.java
index ff1125d..9f5fcf8 100644
--- a/tests/robotests/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragmentTest.java
@@ -16,6 +16,11 @@
 
 package com.android.settings.wifi.dpp;
 
+import static com.android.wifitrackerlib.WifiEntry.SECURITY_NONE;
+import static com.android.wifitrackerlib.WifiEntry.SECURITY_OWE;
+import static com.android.wifitrackerlib.WifiEntry.SECURITY_PSK;
+import static com.android.wifitrackerlib.WifiEntry.SECURITY_SAE;
+
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.anyInt;
@@ -148,4 +153,24 @@
         verify(mActivity).setResult(eq(Activity.RESULT_OK), any());
         verify(mActivity).finish();
     }
+
+    @Test
+    public void isSecurityMatched_securityNotMatch_returnFalse() {
+        assertThat(mFragment.isSecurityMatched(SECURITY_NONE, SECURITY_PSK)).isFalse();
+    }
+
+    @Test
+    public void isSecurityMatched_securityMatch_returnTrue() {
+        assertThat(mFragment.isSecurityMatched(SECURITY_PSK, SECURITY_PSK)).isTrue();
+    }
+
+    @Test
+    public void isSecurityMatched_tryPskSaeTransition_returnTrue() {
+        assertThat(mFragment.isSecurityMatched(SECURITY_SAE, SECURITY_PSK)).isTrue();
+    }
+
+    @Test
+    public void isSecurityMatched_noPasswordSecurity_returnTrue() {
+        assertThat(mFragment.isSecurityMatched(SECURITY_NONE, SECURITY_OWE)).isTrue();
+    }
 }