Change action WIFI_DPP_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK to

PROCESS_WIFI_DPP_QR_CODE for more intuitive naming.

This change also caches the Wi-Fi DPP QR code in activity for
fragment to use.

Bug: 118794978
Test: manual test
Change-Id: I4bdb021883cb21ce7cc56edf656d1eee079359e5
This commit is contained in:
Arc Wang
2019-01-03 18:09:06 +08:00
parent 1c9fc3e9eb
commit 8e580952c3
3 changed files with 41 additions and 8 deletions

View File

@@ -3050,7 +3050,7 @@
<intent-filter>
<action android:name="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER"/>
<action android:name="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR"/>
<action android:name="android.settings.WIFI_DPP_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK"/>
<action android:name="android.settings.PROCESS_WIFI_DPP_QR_CODE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>

View File

@@ -44,7 +44,7 @@ import com.android.settings.R;
* {@code WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY}
* {@code WifiDppUtils.EXTRA_WIFI_HIDDEN_SSID}
*
* For intent action {@code ACTION_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK}, specify Wi-Fi (DPP)
* For intent action {@code ACTION_PROCESS_WIFI_DPP_QR_CODE}, specify Wi-Fi (DPP)
* QR code in {@code WifiDppUtils.EXTRA_QR_CODE}
*/
public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
@@ -58,8 +58,8 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
"android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER";
public static final String ACTION_CONFIGURATOR_QR_CODE_GENERATOR =
"android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR";
public static final String ACTION_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK =
"android.settings.WIFI_DPP_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK";
public static final String ACTION_PROCESS_WIFI_DPP_QR_CODE =
"android.settings.PROCESS_WIFI_DPP_QR_CODE";
private FragmentManager mFragmentManager;
@@ -72,6 +72,9 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
/** The information from Wi-Fi DPP QR code */
private String mInformation;
/** The Wi-Fi DPP QR code from intent ACTION_PROCESS_WIFI_DPP_QR_CODE */
private WifiQrCode mWifiDppQrCode;
@Override
public int getMetricsCategory() {
return MetricsProto.MetricsEvent.SETTINGS_WIFI_DPP_CONFIGURATOR;
@@ -115,8 +118,14 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
showQrCodeGeneratorFragment();
}
break;
case ACTION_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK:
case ACTION_PROCESS_WIFI_DPP_QR_CODE:
String qrCode = intent.getStringExtra(WifiDppUtils.EXTRA_QR_CODE);
mWifiDppQrCode = getValidWiFiDppQrCodeOrNull(qrCode);
if (mWifiDppQrCode == null) {
cancelActivity = true;
} else {
showChooseSavedWifiNetworkFragment(/* addToBackStack */ false);
}
break;
default:
cancelActivity = true;
@@ -199,6 +208,21 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
fragmentTransaction.commit();
}
private WifiQrCode getValidWiFiDppQrCodeOrNull(String qrCode) {
WifiQrCode wifiQrCode;
try {
wifiQrCode = new WifiQrCode(qrCode);
} catch(IllegalArgumentException e) {
return null;
}
if (WifiQrCode.SCHEME_DPP.equals(wifiQrCode.getScheme())) {
return wifiQrCode;
}
return null;
}
@Override
public WifiNetworkConfig getWifiNetworkConfig() {
return mWifiNetworkConfig;
@@ -212,6 +236,10 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
return mInformation;
}
public WifiQrCode getWifiDppQrCode() {
return mWifiDppQrCode;
}
@Override
public boolean setWifiNetworkConfig(WifiNetworkConfig config) {
if(!WifiNetworkConfig.isValidConfig(config)) {

View File

@@ -38,6 +38,7 @@ public class WifiDppConfiguratorActivityTest {
Intent intent = new Intent(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_SCANNER);
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SECURITY, "WEP");
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SSID, "GoogleGuest");
intent.putExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY, "password");
mActivityRule.launchActivity(intent);
@@ -50,6 +51,7 @@ public class WifiDppConfiguratorActivityTest {
WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_GENERATOR);
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SECURITY, "WEP");
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SSID, "GoogleGuest");
intent.putExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY, "password");
mActivityRule.launchActivity(intent);
@@ -59,7 +61,10 @@ public class WifiDppConfiguratorActivityTest {
@Test
public void launchActivity_chooseSavedWifiNetwork_shouldNotAutoFinish() {
Intent intent = new Intent(
WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK);
WifiDppConfiguratorActivity.ACTION_PROCESS_WIFI_DPP_QR_CODE);
String qrCode = "DPP:I:SN=4774LH2b4044;M:010203040506;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcD"
+ "IgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=;;";
intent.putExtra(WifiDppUtils.EXTRA_QR_CODE, qrCode);
mActivityRule.launchActivity(intent);