Implement receiver flow of WiFi sharing feature

1.Add a button to launch QR code scanner when add a network.
2.Scan button added in AddNetworkFragment / WifiDialog / WifiSettings.

Bug: 120630683
Test: make RunSettingsRoboTests
Change-Id: I340bfa2247e092f586dd90dfea37c355e681ffee
This commit is contained in:
Johnson Lu
2018-12-07 11:56:49 +08:00
parent 15cdfc4ec2
commit 5aef897e9b
8 changed files with 356 additions and 13 deletions

View File

@@ -16,7 +16,10 @@
package com.android.settings.wifi.dpp;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.util.FeatureFlagUtils;
/**
* Here are the items shared by both WifiDppConfiguratorActivity & WifiDppEnrolleeActivity
@@ -54,4 +57,46 @@ public class WifiDppUtils {
* H true Optional. True if the network SSID is hidden.
*/
public static final String EXTRA_QR_CODE = "qrCode";
/**
* Returns whether the user can share the network represented by this preference with QR code.
*/
public static boolean isSharingNetworkEnabled(Context context) {
return FeatureFlagUtils.isEnabled(context,
com.android.settings.core.FeatureFlags.WIFI_SHARING);
}
/**
* Returns an intent to launch QR code scanner.
*
* @param ssid The data corresponding to {@code WifiConfiguration} SSID
* @return Intent for launching QR code scanner
*/
public static Intent getConfiguratorQRCodeScannerIntent(String ssid) {
final Intent intent = new Intent(
WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_SCANNER);
if (!TextUtils.isEmpty(ssid)) {
intent.putExtra(EXTRA_WIFI_SSID, ssid);
}
return intent;
}
/**
* Returns an intent to launch QR code generator.
*
* @param ssid The data corresponding to {@code WifiConfiguration} SSID
* @param Security The data is from {@code AccessPoint.securityToString}
* @return Intent for launching QR code generator
*/
public static Intent getConfiguratorQRCodeGeneratorIntent(String ssid, String Security) {
final Intent intent = new Intent(
WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_GENERATOR);
if (!TextUtils.isEmpty(ssid)) {
intent.putExtra(EXTRA_WIFI_SSID, ssid);
}
if (!TextUtils.isEmpty(Security)) {
intent.putExtra(EXTRA_WIFI_SECURITY, Security);
}
return intent;
}
}