Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 53f58bc1 authored by Jimmy Chen's avatar Jimmy Chen Committed by Android (Google) Code Review
Browse files

Merge "p2p: support factory reset for P2P group"

parents cd42d6eb c4240a7c
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -3832,6 +3832,14 @@ package android.net.wifi.aware {

}

package android.net.wifi.p2p {

  public class WifiP2pManager {
    method public void factoryReset(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pManager.ActionListener);
  }

}

package android.net.wifi.rtt {

  public static final class RangingRequest.Builder {
+10 −0
Original line number Diff line number Diff line
@@ -4895,6 +4895,7 @@ public final class Settings {
            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_NETWORK_SHOW_RSSI);
            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_WATCHDOG_ON);
            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED);
            MOVED_TO_GLOBAL.add(Settings.Global.WIFI_P2P_PENDING_FACTORY_RESET);
            MOVED_TO_GLOBAL.add(Settings.Global.WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON);
            MOVED_TO_GLOBAL.add(Settings.Global.PACKAGE_VERIFIER_ENABLE);
            MOVED_TO_GLOBAL.add(Settings.Global.PACKAGE_VERIFIER_TIMEOUT);
@@ -9994,6 +9995,15 @@ public final class Settings {
        public static final String WIFI_RTT_BACKGROUND_EXEC_GAP_MS =
                "wifi_rtt_background_exec_gap_ms";
        /**
         * Indicate whether factory reset request is pending.
         *
         * Type: int (0 for false, 1 for true)
         * @hide
         */
        public static final String WIFI_P2P_PENDING_FACTORY_RESET =
                "wifi_p2p_pending_factory_reset";
        /**
         * Whether soft AP will shut down after a timeout period when no devices are connected.
         *
+1 −0
Original line number Diff line number Diff line
@@ -497,6 +497,7 @@ public class SettingsBackupTest {
                    Settings.Global.WIFI_NUM_OPEN_NETWORKS_KEPT,
                    Settings.Global.WIFI_ON,
                    Settings.Global.WIFI_P2P_DEVICE_NAME,
                    Settings.Global.WIFI_P2P_PENDING_FACTORY_RESET,
                    Settings.Global.WIFI_REENABLE_DELAY_MS,
                    Settings.Global.WIFI_RTT_BACKGROUND_EXEC_GAP_MS,
                    Settings.Global.WIFI_SAVED_STATE,
+30 −1
Original line number Diff line number Diff line
@@ -16,9 +16,13 @@

package android.net.wifi.p2p;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
import android.annotation.SystemService;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.net.wifi.WpsInfo;
@@ -480,6 +484,12 @@ public class WifiP2pManager {
    /** @hide */
    public static final int REPORT_NFC_HANDOVER_FAILED              = BASE + 81;

    /** @hide */
    public static final int FACTORY_RESET                           = BASE + 82;
    /** @hide */
    public static final int FACTORY_RESET_FAILED                    = BASE + 83;
    /** @hide */
    public static final int FACTORY_RESET_SUCCEEDED                 = BASE + 84;

    /**
     * Create a new WifiP2pManager instance. Applications use
@@ -776,6 +786,7 @@ public class WifiP2pManager {
                    case STOP_LISTEN_FAILED:
                    case SET_CHANNEL_FAILED:
                    case REPORT_NFC_HANDOVER_FAILED:
                    case FACTORY_RESET_FAILED:
                        if (listener != null) {
                            ((ActionListener) listener).onFailure(message.arg1);
                        }
@@ -802,6 +813,7 @@ public class WifiP2pManager {
                    case STOP_LISTEN_SUCCEEDED:
                    case SET_CHANNEL_SUCCEEDED:
                    case REPORT_NFC_HANDOVER_SUCCEEDED:
                    case FACTORY_RESET_SUCCEEDED:
                        if (listener != null) {
                            ((ActionListener) listener).onSuccess();
                        }
@@ -1521,4 +1533,21 @@ public class WifiP2pManager {
        c.mAsyncChannel.sendMessage(RESPONDER_REPORT_NFC_HANDOVER, 0,
                c.putListener(listener), bundle);
    }

    /**
     * Removes all saved p2p groups.
     * @param c is the channel created at {@link #initialize}.
     * @param listener for callback on success or failure. Can be null.
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
    public void factoryReset(@NonNull Channel c, @Nullable ActionListener listener) {
        checkChannel(c);
        Bundle callingPackage = new Bundle();
        callingPackage.putString(CALLING_PACKAGE, c.mContext.getOpPackageName());
        c.mAsyncChannel.sendMessage(FACTORY_RESET, 0, c.putListener(listener),
                callingPackage);
    }

}