Change Easy Connect intent naming
1. From ACTION_PROCESS_WIFI_EASY_CONNECT_QR_CODE to ACTION_PROCESS_WIFI_EASY_CONNECT_URI
2. Remove EXTRA_QR_CODE and use data Uri to specify Easy Connect bootstrapping information string
Bug: 125874365
Test: atest AvailableIntentsTest
WifiDppChooseSavedWifiNetworkFragmentTest
WifiDppConfiguratorActivityTest
WifiNetworkListFragmentTest
Change-Id: I706513520daa10197a27f596fa08ca58980205d8
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6724ff5..d22b36e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -3091,9 +3091,13 @@
<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.PROCESS_WIFI_EASY_CONNECT_QR_CODE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
+ <intent-filter>
+ <action android:name="android.settings.PROCESS_WIFI_EASY_CONNECT_URI"/>
+ <category android:name="android.intent.category.DEFAULT"/>
+ <data android:scheme="DPP"/>
+ </intent-filter>
</activity>
<activity
diff --git a/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java b/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
index 1770a02..6f0bc7d 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
@@ -19,6 +19,7 @@
import android.app.ActionBar;
import android.app.settings.SettingsEnums;
import android.content.Intent;
+import android.net.Uri;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
@@ -50,8 +51,8 @@
* {@code WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY}
* {@code WifiDppUtils.EXTRA_WIFI_HIDDEN_SSID}
*
- * For intent action {@link Settings#ACTION_PROCESS_WIFI_EASY_CONNECT_QR_CODE}, specify Wi-Fi (DPP)
- * QR code in {@code WifiDppUtils.EXTRA_QR_CODE}
+ * For intent action {@link Settings#ACTION_PROCESS_WIFI_EASY_CONNECT_URI}, specify Wi-Fi
+ * Easy Connect bootstrapping information string in Intent's data URI.
*/
public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
WifiNetworkConfig.Retriever,
@@ -80,7 +81,7 @@
/** The Wi-Fi network which will be configured */
private WifiNetworkConfig mWifiNetworkConfig;
- /** The Wi-Fi DPP QR code from intent ACTION_PROCESS_WIFI_EASY_CONNECT_QR_CODE */
+ /** The Wi-Fi DPP QR code from intent ACTION_PROCESS_WIFI_EASY_CONNECT_URI */
private WifiQrCode mWifiDppQrCode;
/** Secret extra that allows fake networks to show in UI for testing purposes */
@@ -144,10 +145,11 @@
showQrCodeGeneratorFragment();
}
break;
- case Settings.ACTION_PROCESS_WIFI_EASY_CONNECT_QR_CODE:
- String qrCode = intent.getStringExtra(Settings.EXTRA_QR_CODE);
+ case Settings.ACTION_PROCESS_WIFI_EASY_CONNECT_URI:
+ final Uri uri = intent.getData();
+ final String uriString = (uri == null) ? null : uri.toString();
mIsTest = intent.getBooleanExtra(WifiDppUtils.EXTRA_TEST, false);
- mWifiDppQrCode = WifiQrCode.getValidWifiDppQrCodeOrNull(qrCode);
+ mWifiDppQrCode = WifiQrCode.getValidWifiDppQrCodeOrNull(uriString);
final boolean isDppSupported = WifiDppUtils.isWifiDppEnabled(this);
if (!isDppSupported) {
Log.d(TAG, "Device doesn't support Wifi DPP");
diff --git a/src/com/android/settings/wifi/dpp/WifiDppUtils.java b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
index 24cd1d7..d4c0340 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppUtils.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
@@ -70,7 +70,7 @@
/** The data corresponding to {@code WifiConfiguration} networkId */
public static final String EXTRA_WIFI_NETWORK_ID = "networkId";
- /** Used by {@link android.provider.Settings#ACTION_PROCESS_WIFI_EASY_CONNECT_QR_CODE} to
+ /** Used by {@link android.provider.Settings#ACTION_PROCESS_WIFI_EASY_CONNECT_URI} to
* indicate test mode UI should be shown. Test UI does not make API calls. Value is a boolean.*/
public static final String EXTRA_TEST = "test";
diff --git a/tests/unit/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragmentTest.java b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragmentTest.java
index 6ad6377..33491b6 100644
--- a/tests/unit/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragmentTest.java
+++ b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragmentTest.java
@@ -28,6 +28,7 @@
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
+import android.net.Uri;
import android.provider.Settings;
import androidx.fragment.app.FragmentManager;
@@ -89,8 +90,8 @@
@Test
public void clickCancelButton_processWifiDppQrCodeIntent_shouldFinish() {
- final Intent intent = new Intent(Settings.ACTION_PROCESS_WIFI_EASY_CONNECT_QR_CODE);
- intent.putExtra(Settings.EXTRA_QR_CODE, VALID_WIFI_DPP_QR_CODE);
+ final Intent intent = new Intent(Settings.ACTION_PROCESS_WIFI_EASY_CONNECT_URI);
+ intent.setData(Uri.parse(VALID_WIFI_DPP_QR_CODE));
final WifiDppConfiguratorActivity hostActivity = mActivityRule.launchActivity(intent);
onView(withText(resourceString(CANCEL))).perform(click());
diff --git a/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
index a425177..405ed4a 100644
--- a/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
+++ b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
@@ -21,6 +21,7 @@
import android.app.Instrumentation;
import android.content.Intent;
import android.content.pm.ActivityInfo;
+import android.net.Uri;
import android.os.RemoteException;
import android.provider.Settings;
import android.support.test.uiautomator.UiDevice;
@@ -78,8 +79,8 @@
@Test
public void launchActivity_chooseSavedWifiNetwork_shouldNotAutoFinish() {
- Intent intent = new Intent(Settings.ACTION_PROCESS_WIFI_EASY_CONNECT_QR_CODE);
- intent.putExtra(Settings.EXTRA_QR_CODE, VALID_WIFI_DPP_QR_CODE);
+ final Intent intent = new Intent(Settings.ACTION_PROCESS_WIFI_EASY_CONNECT_URI);
+ intent.setData(Uri.parse(VALID_WIFI_DPP_QR_CODE));
mActivityRule.launchActivity(intent);
@@ -145,10 +146,10 @@
@Test
public void rotateScreen_shouldGetCorrectWifiNetworkConfig() {
- WifiNetworkConfig wifiNetworkConfig = new WifiNetworkConfig("WPA", "WifiSsid", "password",
- /* hiddenSsid */ false, /* networkId */ 0);
- Intent intent = new Intent(Settings.ACTION_PROCESS_WIFI_EASY_CONNECT_QR_CODE);
- intent.putExtra(Settings.EXTRA_QR_CODE, VALID_WIFI_DPP_QR_CODE);
+ final WifiNetworkConfig wifiNetworkConfig = new WifiNetworkConfig("WPA", "WifiSsid",
+ "password", /* hiddenSsid */ false, /* networkId */ 0);
+ final Intent intent = new Intent(Settings.ACTION_PROCESS_WIFI_EASY_CONNECT_URI);
+ intent.setData(Uri.parse(VALID_WIFI_DPP_QR_CODE));
// setWifiNetworkConfig and check if getWifiNetworkConfig correctly after rotation
mActivityRule.launchActivity(intent);
diff --git a/tests/unit/src/com/android/settings/wifi/dpp/WifiNetworkListFragmentTest.java b/tests/unit/src/com/android/settings/wifi/dpp/WifiNetworkListFragmentTest.java
index c1c1d54..832f153 100644
--- a/tests/unit/src/com/android/settings/wifi/dpp/WifiNetworkListFragmentTest.java
+++ b/tests/unit/src/com/android/settings/wifi/dpp/WifiNetworkListFragmentTest.java
@@ -31,6 +31,7 @@
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
+import android.net.Uri;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
@@ -100,12 +101,10 @@
.post(() -> mWifiNetworkListFragment.onWifiStateChanged(state));
}
- /** Launch the activity via an Intent with a String extra. */
- private void launchActivity(String extraName, String extraValue) {
- final Intent intent = new Intent(Settings.ACTION_PROCESS_WIFI_EASY_CONNECT_QR_CODE);
- if (extraName != null && extraValue != null) {
- intent.putExtra(extraName, extraValue);
- }
+ /** Launch the activity via an Intent with data Uri */
+ private void launchActivity(String uriString) {
+ final Intent intent = new Intent(Settings.ACTION_PROCESS_WIFI_EASY_CONNECT_URI);
+ intent.setData(Uri.parse(uriString));
mActivityRule.launchActivity(intent);
verify(mWifiTracker).getManager();
@@ -166,7 +165,7 @@
setupConnectedAccessPoint();
when(mWifiTracker.isConnected()).thenReturn(true);
- launchActivity(Settings.EXTRA_QR_CODE, TEST_DPP_URL);
+ launchActivity(TEST_DPP_URL);
callOnWifiStateChanged(WifiManager.WIFI_STATE_ENABLED);
onView(withText(resourceString(WIFI_DISPLAY_STATUS_CONNECTED))).check(