Loading AndroidManifest.xml +1 −1 Original line number Diff line number Diff line Loading @@ -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> Loading src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java +34 −6 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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; Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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; Loading @@ -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)) { Loading tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java +6 −1 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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); Loading @@ -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); Loading Loading
AndroidManifest.xml +1 −1 Original line number Diff line number Diff line Loading @@ -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> Loading
src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java +34 −6 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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; Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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; Loading @@ -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)) { Loading
tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java +6 −1 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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); Loading @@ -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); Loading