p2p: do P2P factory reset for Network Reset

Bug: 109866998
Test: * manual trigger network reset in below conditions:
        * trigger network reset with P2P on
        * trigger network reset with WiFi on, P2P off
        * trigger network reset with WiFi off
        * trigger network reset with WiFi off then do reboot
      * check groups shown in WiFi Direct page
      * use wpa_cli -i p2p0 list_network
Test: RobotTest - make ROBOTEST_FILTER=ResetNetworkConfirmTest

Change-Id: If5292e34cb9702d4319a4c9bbd867e0e5ed716a2
This commit is contained in:
Jimmy Chen
2018-10-11 18:03:51 +08:00
parent c32de1a2d9
commit d62453d3de
3 changed files with 93 additions and 1 deletions

View File

@@ -26,6 +26,7 @@ import android.net.ConnectivityManager;
import android.net.NetworkPolicyManager;
import android.net.Uri;
import android.net.wifi.WifiManager;
import android.net.wifi.p2p.WifiP2pManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.RecoverySystem;
@@ -129,6 +130,8 @@ public class ResetNetworkConfirm extends InstrumentedFragment {
wifiManager.factoryReset();
}
p2pFactoryReset(context);
TelephonyManager telephonyManager = (TelephonyManager)
context.getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager != null) {
@@ -180,6 +183,20 @@ public class ResetNetworkConfirm extends InstrumentedFragment {
}
}
@VisibleForTesting
void p2pFactoryReset(Context context) {
WifiP2pManager wifiP2pManager = (WifiP2pManager)
context.getSystemService(Context.WIFI_P2P_SERVICE);
if (wifiP2pManager != null) {
WifiP2pManager.Channel channel = wifiP2pManager.initialize(
context.getApplicationContext(), context.getMainLooper(),
null /* listener */);
if (channel != null) {
wifiP2pManager.factoryReset(channel, null /* listener */);
}
}
}
/**
* Restore APN settings to default.
*/