Merge "Use multiple actions to launch Wi-Fi DPP configurator with different mode."
This commit is contained in:
@@ -3036,7 +3036,14 @@
|
|||||||
</provider>
|
</provider>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".wifi.dpp.WifiDppConfiguratorActivity"/>
|
android:name=".wifi.dpp.WifiDppConfiguratorActivity">
|
||||||
|
<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"/>
|
||||||
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity android:name=".homepage.contextualcards.ContextualCardFeedbackDialog"
|
<activity android:name=".homepage.contextualcards.ContextualCardFeedbackDialog"
|
||||||
android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.Alert" />
|
android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.Alert" />
|
||||||
|
@@ -18,6 +18,7 @@ package com.android.settings.wifi.dpp;
|
|||||||
|
|
||||||
import android.app.ActionBar;
|
import android.app.ActionBar;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@@ -30,32 +31,22 @@ import com.android.internal.logging.nano.MetricsProto;
|
|||||||
import com.android.settings.core.InstrumentedActivity;
|
import com.android.settings.core.InstrumentedActivity;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
public class WifiDppConfiguratorActivity extends InstrumentedActivity {
|
public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
|
||||||
|
WifiNetworkConfig.Retriever {
|
||||||
private static final String TAG = "WifiDppConfiguratorActivity";
|
private static final String TAG = "WifiDppConfiguratorActivity";
|
||||||
|
|
||||||
|
public static final String ACTION_CONFIGURATOR_QR_CODE_SCANNER =
|
||||||
|
"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";
|
||||||
|
|
||||||
private FragmentManager mFragmentManager;
|
private FragmentManager mFragmentManager;
|
||||||
private FragmentTransaction mFragmentTransaction;
|
private FragmentTransaction mFragmentTransaction;
|
||||||
|
|
||||||
public static final String EXTRA_LAUNCH_MODE =
|
/** The Wi-Fi network which will be configured */
|
||||||
"com.android.settings.wifi.dpp.EXTRA_LAUNCH_MODE";
|
private WifiNetworkConfig mWifiNetworkConfig;
|
||||||
public static final String EXTRA_SSID = "com.android.settings.wifi.dpp.EXTRA_SSID";
|
|
||||||
|
|
||||||
public enum LaunchMode {
|
|
||||||
LAUNCH_MODE_QR_CODE_SCANNER(1),
|
|
||||||
LAUNCH_MODE_QR_CODE_GENERATOR(2),
|
|
||||||
LAUNCH_MODE_CHOOSE_SAVED_WIFI_NETWORK(3),
|
|
||||||
LAUNCH_MODE_NOT_DEFINED(-1);
|
|
||||||
|
|
||||||
private int mMode;
|
|
||||||
|
|
||||||
LaunchMode(int mode) {
|
|
||||||
this.mMode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMode() {
|
|
||||||
return mMode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
@@ -71,37 +62,59 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity {
|
|||||||
mFragmentManager = getSupportFragmentManager();
|
mFragmentManager = getSupportFragmentManager();
|
||||||
mFragmentTransaction = getSupportFragmentManager().beginTransaction();
|
mFragmentTransaction = getSupportFragmentManager().beginTransaction();
|
||||||
|
|
||||||
final int launchMode = getIntent().getIntExtra(EXTRA_LAUNCH_MODE,
|
Intent intent = getIntent();
|
||||||
LaunchMode.LAUNCH_MODE_NOT_DEFINED.getMode());
|
boolean cancelActivity = false;
|
||||||
if (launchMode == LaunchMode.LAUNCH_MODE_QR_CODE_SCANNER.getMode()) {
|
WifiNetworkConfig config;
|
||||||
addQrCodeScannerFragment();
|
switch (intent.getAction()) {
|
||||||
} else if (launchMode == LaunchMode.LAUNCH_MODE_QR_CODE_GENERATOR.getMode()) {
|
case ACTION_CONFIGURATOR_QR_CODE_SCANNER:
|
||||||
addQrCodeGeneratorFragment();
|
config = WifiNetworkConfig.getValidConfigOrNull(intent);
|
||||||
} else if (launchMode == LaunchMode.LAUNCH_MODE_CHOOSE_SAVED_WIFI_NETWORK.getMode()) {
|
if (config == null) {
|
||||||
addChooseSavedWifiNetworkFragment();
|
cancelActivity = true;
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Launch with an invalid mode extra");
|
mWifiNetworkConfig = config;
|
||||||
|
addQrCodeScannerFragment(/* addToBackStack= */ false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ACTION_CONFIGURATOR_QR_CODE_GENERATOR:
|
||||||
|
config = WifiNetworkConfig.getValidConfigOrNull(intent);
|
||||||
|
if (config == null) {
|
||||||
|
cancelActivity = true;
|
||||||
|
} else {
|
||||||
|
mWifiNetworkConfig = config;
|
||||||
|
addQrCodeGeneratorFragment();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ACTION_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK:
|
||||||
|
addChooseSavedWifiNetworkFragment(/* addToBackStack */ false);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
cancelActivity = true;
|
||||||
|
Log.e(TAG, "Launch with an invalid action");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cancelActivity) {
|
||||||
setResult(Activity.RESULT_CANCELED);
|
setResult(Activity.RESULT_CANCELED);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addQrCodeScannerFragment() {
|
private void addQrCodeScannerFragment(boolean addToBackStack) {
|
||||||
final WifiDppQrCodeScannerFragment fragment = new WifiDppQrCodeScannerFragment();
|
WifiDppQrCodeScannerFragment fragment = new WifiDppQrCodeScannerFragment();
|
||||||
mFragmentTransaction.add(R.id.fragment_container, fragment);
|
mFragmentTransaction.add(R.id.fragment_container, fragment);
|
||||||
mFragmentTransaction.addToBackStack(/* name */ null);
|
if (addToBackStack) {
|
||||||
|
mFragmentTransaction.addToBackStack(/* name */ null);
|
||||||
|
}
|
||||||
mFragmentTransaction.commit();
|
mFragmentTransaction.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addQrCodeGeneratorFragment() {
|
private void addQrCodeGeneratorFragment() {
|
||||||
final WifiDppQrCodeGeneratorFragment fragment = new WifiDppQrCodeGeneratorFragment();
|
WifiDppQrCodeGeneratorFragment fragment = new WifiDppQrCodeGeneratorFragment();
|
||||||
mFragmentTransaction.add(R.id.fragment_container, fragment);
|
mFragmentTransaction.add(R.id.fragment_container, fragment);
|
||||||
mFragmentTransaction.addToBackStack(/* name */ null);
|
|
||||||
mFragmentTransaction.commit();
|
mFragmentTransaction.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addChooseSavedWifiNetworkFragment() {
|
private void addChooseSavedWifiNetworkFragment(boolean addToBackStack) {
|
||||||
final ActionBar action = getActionBar();
|
ActionBar action = getActionBar();
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
action.hide();
|
action.hide();
|
||||||
}
|
}
|
||||||
@@ -109,13 +122,15 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity {
|
|||||||
WifiDppChooseSavedWifiNetworkFragment fragment =
|
WifiDppChooseSavedWifiNetworkFragment fragment =
|
||||||
new WifiDppChooseSavedWifiNetworkFragment();
|
new WifiDppChooseSavedWifiNetworkFragment();
|
||||||
mFragmentTransaction.add(R.id.fragment_container, fragment);
|
mFragmentTransaction.add(R.id.fragment_container, fragment);
|
||||||
mFragmentTransaction.addToBackStack(/* name */ null);
|
if (addToBackStack) {
|
||||||
|
mFragmentTransaction.addToBackStack(/* name */ null);
|
||||||
|
}
|
||||||
mFragmentTransaction.commit();
|
mFragmentTransaction.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
final Fragment fragment = mFragmentManager.findFragmentById(R.id.fragment_container);
|
Fragment fragment = mFragmentManager.findFragmentById(R.id.fragment_container);
|
||||||
if (fragment != null) {
|
if (fragment != null) {
|
||||||
// Remove it to prevent stacking multiple fragments after screen rotated.
|
// Remove it to prevent stacking multiple fragments after screen rotated.
|
||||||
mFragmentManager.beginTransaction().remove(fragment).commit();
|
mFragmentManager.beginTransaction().remove(fragment).commit();
|
||||||
@@ -123,4 +138,19 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity {
|
|||||||
|
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WifiNetworkConfig getWifiNetworkConfig() {
|
||||||
|
return mWifiNetworkConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setWifiNetworkConfig(WifiNetworkConfig config) {
|
||||||
|
if(!WifiNetworkConfig.isValidConfig(config)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
mWifiNetworkConfig = new WifiNetworkConfig(config);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,6 +30,7 @@ import android.widget.TextView;
|
|||||||
import com.android.internal.logging.nano.MetricsProto;
|
import com.android.internal.logging.nano.MetricsProto;
|
||||||
|
|
||||||
import com.android.settings.core.InstrumentedFragment;
|
import com.android.settings.core.InstrumentedFragment;
|
||||||
|
import com.android.settings.wifi.qrcode.QrDecorateView;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,7 +47,7 @@ public abstract class WifiDppQrCodeBaseFragment extends InstrumentedFragment {
|
|||||||
private TextView mDescription;
|
private TextView mDescription;
|
||||||
|
|
||||||
private SurfaceView mPreviewView; //optional, for WifiDppQrCodeScannerFragment
|
private SurfaceView mPreviewView; //optional, for WifiDppQrCodeScannerFragment
|
||||||
private ImageView mDecorateViiew; //optional, for WifiDppQrCodeScannerFragment
|
private QrDecorateView mDecorateViiew; //optional, for WifiDppQrCodeScannerFragment
|
||||||
private TextView mErrorMessage; //optional, for WifiDppQrCodeScannerFragment
|
private TextView mErrorMessage; //optional, for WifiDppQrCodeScannerFragment
|
||||||
|
|
||||||
private ImageView mBarcodeView; //optional, for WifiDppQrCodeGeneratorFragment
|
private ImageView mBarcodeView; //optional, for WifiDppQrCodeGeneratorFragment
|
||||||
|
@@ -49,15 +49,12 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
|
|||||||
|
|
||||||
setTitle(getString(R.string.wifi_dpp_add_device_to_network));
|
setTitle(getString(R.string.wifi_dpp_add_device_to_network));
|
||||||
|
|
||||||
String ssid = null;
|
WifiNetworkConfig wifiNetworkConfig = ((WifiNetworkConfig.Retriever) getActivity())
|
||||||
final Intent intent = getActivity().getIntent();
|
.getWifiNetworkConfig();
|
||||||
if (intent != null) {
|
if (!WifiNetworkConfig.isValidConfig(wifiNetworkConfig)) {
|
||||||
ssid = intent.getStringExtra(WifiDppConfiguratorActivity.EXTRA_SSID);
|
throw new IllegalArgumentException("Invalid Wi-Fi network for configuring");
|
||||||
}
|
}
|
||||||
if (TextUtils.isEmpty(ssid)) {
|
setDescription(getString(R.string.wifi_dpp_center_qr_code, wifiNetworkConfig.getSsid()));
|
||||||
throw new IllegalArgumentException("Invalid SSID");
|
|
||||||
}
|
|
||||||
setDescription(getString(R.string.wifi_dpp_center_qr_code, ssid));
|
|
||||||
|
|
||||||
hideRightButton();
|
hideRightButton();
|
||||||
|
|
||||||
|
57
src/com/android/settings/wifi/dpp/WifiDppUtils.java
Normal file
57
src/com/android/settings/wifi/dpp/WifiDppUtils.java
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.wifi.dpp;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Here are the items shared by both WifiDppConfiguratorActivity & WifiDppEnrolleeActivity
|
||||||
|
*/
|
||||||
|
public class WifiDppUtils {
|
||||||
|
/** The data is from {@code com.android.settingslib.wifi.AccessPoint.securityToString} */
|
||||||
|
public static final String EXTRA_WIFI_SECURITY = "security";
|
||||||
|
|
||||||
|
/** The data corresponding to {@code WifiConfiguration} SSID */
|
||||||
|
public static final String EXTRA_WIFI_SSID = "ssid";
|
||||||
|
|
||||||
|
/** The data corresponding to {@code WifiConfiguration} preSharedKey */
|
||||||
|
public static final String EXTRA_WIFI_PRE_SHARED_KEY = "preSharedKey";
|
||||||
|
|
||||||
|
/** The data corresponding to {@code WifiConfiguration} hiddenSSID */
|
||||||
|
public static final String EXTRA_WIFI_HIDDEN_SSID = "hiddenSsid";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Acceptable QR code string may be a standard W-Fi DPP bootstrapping information or the Wi-Fi
|
||||||
|
* Network config format described in
|
||||||
|
* https://github.com/zxing/zxing/wiki/Barcode-Contents#wi-fi-network-config-android-ios-11
|
||||||
|
*
|
||||||
|
* Wi-Fi Network config format example:
|
||||||
|
*
|
||||||
|
* WIFI:T:WPA;S:mynetwork;P:mypass;;
|
||||||
|
*
|
||||||
|
* parameter Example Description
|
||||||
|
* T WPA Authentication type; can be WEP or WPA, or 'nopass' for no password. Or,
|
||||||
|
* omit for no password.
|
||||||
|
* S mynetwork Network SSID. Required. Enclose in double quotes if it is an ASCII name,
|
||||||
|
* but could be interpreted as hex (i.e. "ABCD")
|
||||||
|
* P mypass Password, ignored if T is "nopass" (in which case it may be omitted).
|
||||||
|
* Enclose in double quotes if it is an ASCII name, but could be interpreted as
|
||||||
|
* hex (i.e. "ABCD")
|
||||||
|
* H true Optional. True if the network SSID is hidden.
|
||||||
|
*/
|
||||||
|
public static final String EXTRA_QR_CODE = "qrCode";
|
||||||
|
}
|
118
src/com/android/settings/wifi/dpp/WifiNetworkConfig.java
Normal file
118
src/com/android/settings/wifi/dpp/WifiNetworkConfig.java
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.wifi.dpp;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the Wi-Fi Network config parameters described in
|
||||||
|
* https://github.com/zxing/zxing/wiki/Barcode-Contents#wi-fi-network-config-android-ios-11
|
||||||
|
*
|
||||||
|
* Checks below members of {@code WifiDppUtils} for more information.
|
||||||
|
* EXTRA_WIFI_SECURITY / EXTRA_WIFI_SSID / EXTRA_WIFI_PRE_SHARED_KEY / EXTRA_WIFI_HIDDEN_SSID /
|
||||||
|
* EXTRA_QR_CODE
|
||||||
|
*/
|
||||||
|
public class WifiNetworkConfig {
|
||||||
|
private String mSecurity;
|
||||||
|
private String mSsid;
|
||||||
|
private String mPreSharedKey;
|
||||||
|
private boolean mHiddenSsid;
|
||||||
|
|
||||||
|
private WifiNetworkConfig(String security, String ssid, String preSharedKey,
|
||||||
|
boolean hiddenSsid) {
|
||||||
|
mSecurity = security;
|
||||||
|
mSsid = ssid;
|
||||||
|
mPreSharedKey = preSharedKey;
|
||||||
|
mHiddenSsid = hiddenSsid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WifiNetworkConfig(WifiNetworkConfig config) {
|
||||||
|
mSecurity = new String(config.mSecurity);
|
||||||
|
mSsid = new String(config.mSsid);
|
||||||
|
mPreSharedKey = new String(config.mPreSharedKey);
|
||||||
|
mHiddenSsid = config.mHiddenSsid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wi-Fi DPP activities should implement this interface for fragments to retrieve the
|
||||||
|
* WifiNetworkConfig for configuration
|
||||||
|
*/
|
||||||
|
public interface Retriever {
|
||||||
|
public WifiNetworkConfig getWifiNetworkConfig();
|
||||||
|
public boolean setWifiNetworkConfig(WifiNetworkConfig config);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve WifiNetworkConfig from below 2 intents
|
||||||
|
*
|
||||||
|
* android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR
|
||||||
|
* android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER
|
||||||
|
*/
|
||||||
|
public static WifiNetworkConfig getValidConfigOrNull(Intent intent) {
|
||||||
|
String security = intent.getStringExtra(WifiDppUtils.EXTRA_WIFI_SECURITY);
|
||||||
|
String ssid = intent.getStringExtra(WifiDppUtils.EXTRA_WIFI_SSID);
|
||||||
|
String preSharedKey = intent.getStringExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY);
|
||||||
|
boolean hiddenSsid = intent.getBooleanExtra(WifiDppUtils.EXTRA_WIFI_HIDDEN_SSID, false);
|
||||||
|
|
||||||
|
if (!isValidConfig(security, ssid, hiddenSsid)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ssid == null) {
|
||||||
|
ssid = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return new WifiNetworkConfig(security, ssid, preSharedKey, hiddenSsid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isValidConfig(WifiNetworkConfig config) {
|
||||||
|
if (config == null) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return isValidConfig(config.mSecurity, config.mSsid, config.mHiddenSsid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isValidConfig(String security, String ssid, boolean hiddenSsid) {
|
||||||
|
if (TextUtils.isEmpty(security)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hiddenSsid && TextUtils.isEmpty(ssid)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSecurity() {
|
||||||
|
return new String(mSecurity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSsid() {
|
||||||
|
return new String(mSsid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPreSharedKey() {
|
||||||
|
return new String(mPreSharedKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getHiddenSsid() {
|
||||||
|
return mHiddenSsid;
|
||||||
|
}
|
||||||
|
}
|
@@ -35,43 +35,42 @@ public class WifiDppConfiguratorActivityTest {
|
|||||||
new ActivityTestRule<>(WifiDppConfiguratorActivity.class);
|
new ActivityTestRule<>(WifiDppConfiguratorActivity.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void launchActivity_modeQrCodeScanner_shouldNotAutoFinish() {
|
public void launchActivity_qrCodeScanner_shouldNotAutoFinish() {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_SCANNER);
|
||||||
intent.putExtra(WifiDppConfiguratorActivity.EXTRA_LAUNCH_MODE,
|
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SECURITY, "WEP");
|
||||||
WifiDppConfiguratorActivity.LaunchMode.LAUNCH_MODE_QR_CODE_SCANNER.getMode());
|
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SSID, "GoogleGuest");
|
||||||
|
|
||||||
mActivityRule.launchActivity(intent);
|
mActivityRule.launchActivity(intent);
|
||||||
|
|
||||||
assertThat(mActivityRule.getActivity().isFinishing()).isEqualTo(false);
|
assertThat(mActivityRule.getActivity().isFinishing()).isEqualTo(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void launchActivity_modeQrCodeGenerator_shouldNotAutoFinish() {
|
public void launchActivity_qrCodeGenerator_shouldNotAutoFinish() {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent(
|
||||||
intent.putExtra(WifiDppConfiguratorActivity.EXTRA_LAUNCH_MODE,
|
WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_GENERATOR);
|
||||||
WifiDppConfiguratorActivity.LaunchMode.LAUNCH_MODE_QR_CODE_GENERATOR.getMode());
|
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SECURITY, "WEP");
|
||||||
|
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SSID, "GoogleGuest");
|
||||||
|
|
||||||
mActivityRule.launchActivity(intent);
|
mActivityRule.launchActivity(intent);
|
||||||
|
|
||||||
assertThat(mActivityRule.getActivity().isFinishing()).isEqualTo(false);
|
assertThat(mActivityRule.getActivity().isFinishing()).isEqualTo(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void launchActivity_modeChooseSavedWifiNetwork_shouldNotAutoFinish() {
|
public void launchActivity_chooseSavedWifiNetwork_shouldNotAutoFinish() {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent(
|
||||||
intent.putExtra(WifiDppConfiguratorActivity.EXTRA_LAUNCH_MODE,
|
WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK);
|
||||||
WifiDppConfiguratorActivity.LaunchMode
|
|
||||||
.LAUNCH_MODE_CHOOSE_SAVED_WIFI_NETWORK.getMode());
|
|
||||||
mActivityRule.launchActivity(intent);
|
mActivityRule.launchActivity(intent);
|
||||||
|
|
||||||
assertThat(mActivityRule.getActivity().isFinishing()).isEqualTo(false);
|
assertThat(mActivityRule.getActivity().isFinishing()).isEqualTo(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void launchActivity_noLaunchMode_shouldFinishActivityWithResultCodeCanceled() {
|
public void testActivity_shouldImplementsWifiNetworkConfigRetriever() {
|
||||||
// If we do not specify launch mode, the activity will finish itself right away
|
WifiDppConfiguratorActivity activity = mActivityRule.getActivity();
|
||||||
Intent intent = new Intent();
|
|
||||||
mActivityRule.launchActivity(intent);
|
|
||||||
|
|
||||||
assertThat(mActivityRule.getActivityResult().getResultCode()).
|
assertThat(activity instanceof WifiNetworkConfig.Retriever).isEqualTo(true);
|
||||||
isEqualTo(Activity.RESULT_CANCELED);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,6 +28,8 @@ import android.content.pm.ActivityInfo;
|
|||||||
import android.support.test.rule.ActivityTestRule;
|
import android.support.test.rule.ActivityTestRule;
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -41,20 +43,12 @@ public class WifiDppQrCodeScannerFragmentTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_SCANNER);
|
||||||
intent.putExtra(WifiDppConfiguratorActivity.EXTRA_LAUNCH_MODE,
|
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SECURITY, "WEP");
|
||||||
WifiDppConfiguratorActivity.LaunchMode.LAUNCH_MODE_QR_CODE_SCANNER.getMode());
|
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SSID, "GoogleGuest");
|
||||||
mActivityRule.launchActivity(intent);
|
mActivityRule.launchActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void leftButton_shouldFinishActivityWithResultCodeCanceled() {
|
|
||||||
onView(withText("Cancel")).perform(click());
|
|
||||||
|
|
||||||
assertThat(mActivityRule.getActivityResult().getResultCode()).
|
|
||||||
isEqualTo(Activity.RESULT_CANCELED);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void rotateScreen_shouldNotCrash() {
|
public void rotateScreen_shouldNotCrash() {
|
||||||
mActivityRule.getActivity().setRequestedOrientation(
|
mActivityRule.getActivity().setRequestedOrientation(
|
||||||
|
Reference in New Issue
Block a user