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
This commit is contained in:
@@ -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
|
||||
|
@@ -19,6 +19,7 @@ package com.android.settings.wifi.dpp;
|
||||
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 @@ import java.util.List;
|
||||
* {@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 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
|
||||
/** 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 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
|
||||
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");
|
||||
|
@@ -70,7 +70,7 @@ public class WifiDppUtils {
|
||||
/** 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";
|
||||
|
||||
|
@@ -28,6 +28,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
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 @@ public class WifiDppChooseSavedWifiNetworkFragmentTest {
|
||||
|
||||
@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());
|
||||
|
@@ -21,6 +21,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
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 @@ public class WifiDppConfiguratorActivityTest {
|
||||
|
||||
@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 @@ public class WifiDppConfiguratorActivityTest {
|
||||
|
||||
@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);
|
||||
|
@@ -31,6 +31,7 @@ import android.content.Context;
|
||||
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 @@ public class WifiNetworkListFragmentTest {
|
||||
.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 @@ public class WifiNetworkListFragmentTest {
|
||||
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(
|
||||
|
Reference in New Issue
Block a user