Fix Wi-Fi DPP fragment back stack problems

1. When a Wi-Fi network connected and receiving
   intent android.settings.PROCESS_WIFI_EASY_CONNECT_QR_CODE,
   show WifiDppAddDeviceFragment from WifiDppConfiguratorActivity
   instead of WifiNetworkListFragment

2. Only handle intent when savedInstanceState is null

3. To show a fragment
   I. do nothing when a fragment is already visible on screen,
   II. pop back stack if it's in back stack, we can do this because
   current fragment transactions are arranged in an order

Bug: 124194531
Test: atest WifiQrCodeTest
      atest WifiDppConfiguratorActivityTest
      atest WifiDppEnrolleeActivityTest
      atest WifiDppQrCodeGeneratorFragmentTest
      atest WifiDppQrCodeScannerFragmentTest
      atest WifiNetworkListFragmentTest
      atest WifiDppChooseSavedWifiNetworkFragmentTest

Change-Id: I1d44eeb3bdc7bfb2ec2e4d81efaab64b066651ad
This commit is contained in:
Arc Wang
2019-01-31 11:07:38 +08:00
parent fd9cdb50c5
commit 9d33313735
5 changed files with 114 additions and 49 deletions

View File

@@ -18,6 +18,7 @@ package com.android.settings.wifi.dpp;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.WifiConfiguration.KeyMgmt;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.text.TextUtils;
@@ -147,6 +148,17 @@ public class WifiDppUtils {
}
}
static String getSecurityString(WifiConfiguration config) {
if (config.allowedKeyManagement.get(KeyMgmt.SAE)) {
return WifiQrCode.SECURITY_SAE;
}
if (config.allowedKeyManagement.get(KeyMgmt.WPA_PSK)) {
return WifiQrCode.SECURITY_WPA_PSK;
}
return (config.wepKeys[0] == null) ?
WifiQrCode.SECURITY_NO_PASSWORD : WifiQrCode.SECURITY_WEP;
}
/**
* Returns an intent to launch QR code generator or scanner according to the Wi-Fi network
* security. It may return null if the security is not supported by QR code generator nor