Merge "[DPP] Fix usage of "DPP" public API to "Easy Connect""
This commit is contained in:
@@ -45,7 +45,7 @@ public class WifiDppAddDeviceFragment extends WifiDppQrCodeBaseFragment {
|
|||||||
private Button mButtonLeft;
|
private Button mButtonLeft;
|
||||||
private Button mButtonRight;
|
private Button mButtonRight;
|
||||||
|
|
||||||
private class DppStatusCallback extends android.net.wifi.DppStatusCallback {
|
private class EasyConnectStatusCallback extends android.net.wifi.EasyConnectStatusCallback {
|
||||||
@Override
|
@Override
|
||||||
public void onEnrolleeSuccess(int newNetworkId) {
|
public void onEnrolleeSuccess(int newNetworkId) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
@@ -65,7 +65,7 @@ public class WifiDppAddDeviceFragment extends WifiDppQrCodeBaseFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(int code) {
|
public void onFailure(int code) {
|
||||||
Log.d(TAG, "DppStatusCallback.onFailure " + code);
|
Log.d(TAG, "EasyConnectStatusCallback.onFailure " + code);
|
||||||
|
|
||||||
// Update fail UI.
|
// Update fail UI.
|
||||||
mTitle.setText(R.string.wifi_dpp_could_not_add_device);
|
mTitle.setText(R.string.wifi_dpp_could_not_add_device);
|
||||||
@@ -149,8 +149,9 @@ public class WifiDppAddDeviceFragment extends WifiDppQrCodeBaseFragment {
|
|||||||
((WifiDppConfiguratorActivity) getActivity()).getWifiNetworkConfig().getNetworkId();
|
((WifiDppConfiguratorActivity) getActivity()).getWifiNetworkConfig().getNetworkId();
|
||||||
final WifiManager wifiManager = getContext().getSystemService(WifiManager.class);
|
final WifiManager wifiManager = getContext().getSystemService(WifiManager.class);
|
||||||
|
|
||||||
wifiManager.startDppAsConfiguratorInitiator(qrCode, networkId,
|
wifiManager.startEasyConnectAsConfiguratorInitiator(qrCode, networkId,
|
||||||
WifiManager.DPP_NETWORK_ROLE_STA, /* handler */ null, new DppStatusCallback());
|
WifiManager.EASY_CONNECT_NETWORK_ROLE_STA, /* handler */ null,
|
||||||
|
new EasyConnectStatusCallback());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Container Activity must implement this interface
|
// Container Activity must implement this interface
|
||||||
|
@@ -53,12 +53,13 @@ public class WifiDppEnrolleeActivity extends InstrumentedActivity implements
|
|||||||
|
|
||||||
private FragmentManager mFragmentManager;
|
private FragmentManager mFragmentManager;
|
||||||
|
|
||||||
private class DppStatusCallback extends android.net.wifi.DppStatusCallback {
|
private class EasyConnectStatusCallback extends android.net.wifi.EasyConnectStatusCallback {
|
||||||
@Override
|
@Override
|
||||||
public void onEnrolleeSuccess(int newNetworkId) {
|
public void onEnrolleeSuccess(int newNetworkId) {
|
||||||
// Connect to the new network.
|
// Connect to the new network.
|
||||||
final WifiManager wifiManager = getSystemService(WifiManager.class);
|
final WifiManager wifiManager = getSystemService(WifiManager.class);
|
||||||
final List<WifiConfiguration> wifiConfigs = wifiManager.getPrivilegedConfiguredNetworks();
|
final List<WifiConfiguration> wifiConfigs =
|
||||||
|
wifiManager.getPrivilegedConfiguredNetworks();
|
||||||
for (WifiConfiguration wifiConfig : wifiConfigs) {
|
for (WifiConfiguration wifiConfig : wifiConfigs) {
|
||||||
if (wifiConfig.networkId == newNetworkId) {
|
if (wifiConfig.networkId == newNetworkId) {
|
||||||
wifiManager.connect(wifiConfig, WifiDppEnrolleeActivity.this);
|
wifiManager.connect(wifiConfig, WifiDppEnrolleeActivity.this);
|
||||||
@@ -77,7 +78,7 @@ public class WifiDppEnrolleeActivity extends InstrumentedActivity implements
|
|||||||
@Override
|
@Override
|
||||||
public void onFailure(int code) {
|
public void onFailure(int code) {
|
||||||
//TODO(b/122429170): Show DPP enrollee error state UI
|
//TODO(b/122429170): Show DPP enrollee error state UI
|
||||||
Log.d(TAG, "DppStatusCallback.onFailure " + code);
|
Log.d(TAG, "EasyConnectStatusCallback.onFailure " + code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -147,8 +148,8 @@ public class WifiDppEnrolleeActivity extends InstrumentedActivity implements
|
|||||||
@Override
|
@Override
|
||||||
public void onScanWifiDppSuccess(WifiQrCode wifiQrCode) {
|
public void onScanWifiDppSuccess(WifiQrCode wifiQrCode) {
|
||||||
final WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
|
final WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
|
||||||
wifiManager.startDppAsEnrolleeInitiator(wifiQrCode.getQrCode(), /* handler */ null,
|
wifiManager.startEasyConnectAsEnrolleeInitiator(wifiQrCode.getQrCode(), /* handler */ null,
|
||||||
new DppStatusCallback());
|
new EasyConnectStatusCallback());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user