Implement Wi-Fi DPP flow
1. As DPP configurator initiator. 2. As DPP enrollee initiator. 3. Pass whole DPP url to DPP API due to API cahnged. Bug: 122331217 Test: manual test Change-Id: I8005b78b82453badf253dbde8022ff20722b39fd
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.settings.wifi.dpp;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.provider.Settings;
|
||||
import android.app.ActionBar;
|
||||
import android.app.Activity;
|
||||
@@ -32,6 +34,8 @@ import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.core.InstrumentedActivity;
|
||||
import com.android.settings.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* To provision "this" device with specified Wi-Fi network.
|
||||
*
|
||||
@@ -49,6 +53,39 @@ public class WifiDppEnrolleeActivity extends InstrumentedActivity implements
|
||||
|
||||
private FragmentManager mFragmentManager;
|
||||
|
||||
private class DppStatusCallback extends android.net.wifi.DppStatusCallback {
|
||||
@Override
|
||||
public void onEnrolleeSuccess(int newNetworkId) {
|
||||
// Connect to the new network.
|
||||
final WifiManager wifiManager = getSystemService(WifiManager.class);
|
||||
final List<WifiConfiguration> wifiConfigs = wifiManager.getPrivilegedConfiguredNetworks();
|
||||
for (WifiConfiguration wifiConfig : wifiConfigs) {
|
||||
if (wifiConfig.networkId == newNetworkId) {
|
||||
wifiManager.connect(wifiConfig, WifiDppEnrolleeActivity.this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Log.e(TAG, "Invalid networkId " + newNetworkId);
|
||||
WifiDppEnrolleeActivity.this.onFailure(WifiManager.ERROR_AUTHENTICATING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfiguratorSuccess(int code) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int code) {
|
||||
//TODO(b/122429170): Show DPP enrollee error state UI
|
||||
Log.d(TAG, "DppStatusCallback.onFailure " + code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgress(int code) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.SETTINGS_WIFI_DPP_ENROLLEE;
|
||||
@@ -108,8 +145,9 @@ public class WifiDppEnrolleeActivity extends InstrumentedActivity implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScanWifiDppSuccess(String publicKey, String information) {
|
||||
// TODO(b/1023597): starts DPP enrollee handshake here
|
||||
public void onScanWifiDppSuccess(String uri) {
|
||||
final WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
|
||||
wifiManager.startDppAsEnrolleeInitiator(uri, /* handler */ null, new DppStatusCallback());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user