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

Commit 3a67e251 authored by Irfan Sheriff's avatar Irfan Sheriff
Browse files

Expose more details in broadcasts

Expose details in broadcasts and do the necessary clean up alongside

Change-Id: I9011d51675a233aa3542f097c8a489c2095103b1
parent 6f0c7b50
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -13560,6 +13560,7 @@ package android.net.wifi.p2p {
    ctor public WifiP2pDeviceList();
    ctor public WifiP2pDeviceList(android.net.wifi.p2p.WifiP2pDeviceList);
    method public int describeContents();
    method public android.net.wifi.p2p.WifiP2pDevice get(java.lang.String);
    method public java.util.Collection<android.net.wifi.p2p.WifiP2pDevice> getDeviceList();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator CREATOR;
@@ -13615,7 +13616,9 @@ package android.net.wifi.p2p {
    field public static final int ERROR = 0; // 0x0
    field public static final java.lang.String EXTRA_DISCOVERY_STATE = "discoveryState";
    field public static final java.lang.String EXTRA_NETWORK_INFO = "networkInfo";
    field public static final java.lang.String EXTRA_P2P_DEVICE_LIST = "wifiP2pDeviceList";
    field public static final java.lang.String EXTRA_WIFI_P2P_DEVICE = "wifiP2pDevice";
    field public static final java.lang.String EXTRA_WIFI_P2P_GROUP = "p2pGroupInfo";
    field public static final java.lang.String EXTRA_WIFI_P2P_INFO = "wifiP2pInfo";
    field public static final java.lang.String EXTRA_WIFI_STATE = "wifi_p2p_state";
    field public static final int NO_SERVICE_REQUESTS = 3; // 0x3
@@ -41391,8 +41394,8 @@ package java.util.zip {
  public class ZipFile {
    ctor public ZipFile(java.io.File) throws java.io.IOException, java.util.zip.ZipException;
    ctor public ZipFile(java.io.File, int) throws java.io.IOException;
    ctor public ZipFile(java.lang.String) throws java.io.IOException;
    ctor public ZipFile(java.io.File, int) throws java.io.IOException;
    method public void close() throws java.io.IOException;
    method public java.util.Enumeration<? extends java.util.zip.ZipEntry> entries();
    method public java.util.zip.ZipEntry getEntry(java.lang.String);
+23 −2
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import java.util.regex.Matcher;
/**
 * A class representing a Wi-Fi p2p device
 *
 * Note that the operations are not thread safe
 * {@see WifiP2pManager}
 */
public class WifiP2pDevice implements Parcelable {
@@ -260,9 +261,29 @@ public class WifiP2pDevice implements Parcelable {
        return (groupCapability & GROUP_CAPAB_GROUP_LIMIT) != 0;
    }

    /** @hide */
    /**
     * Update device details. This will be throw an exception if the device address
     * does not match.
     * @param device to be updated
     * @throws IllegalArgumentException if the device is null or device address does not match
     * @hide
     */
    public void update(WifiP2pDevice device) {
        if (device == null || device.deviceAddress == null) return;
        updateSupplicantDetails(device);
        status = device.status;
    }

    /** Updates details obtained from supplicant @hide */
    void updateSupplicantDetails(WifiP2pDevice device) {
        if (device == null) {
            throw new IllegalArgumentException("device is null");
        }
        if (device.deviceAddress == null) {
            throw new IllegalArgumentException("deviceAddress is null");
        }
        if (!deviceAddress.equals(device.deviceAddress)) {
            throw new IllegalArgumentException("deviceAddress does not match");
        }
        deviceName = device.deviceName;
        primaryDeviceType = device.primaryDeviceType;
        secondaryDeviceType = device.secondaryDeviceType;
+32 −5
Original line number Diff line number Diff line
@@ -58,15 +58,27 @@ public class WifiP2pDeviceList implements Parcelable {
        }
    }

    /** @hide */
    /** Clear the list @hide */
    public boolean clear() {
        if (mDevices.isEmpty()) return false;
        mDevices.clear();
        return true;
    }

    /** @hide */
    /**
     * Add/update a device to the list. If the device is not found, a new device entry
     * is created. If the device is already found, the device details are updated
     * @param device to be updated
     * @hide
     */
    public void update(WifiP2pDevice device) {
        if (device == null || device.deviceAddress == null) return;
        updateSupplicantDetails(device);
        mDevices.get(device.deviceAddress).status = device.status;
    }

    /** Only updates details fetched from the supplicant @hide */
    void updateSupplicantDetails(WifiP2pDevice device) {
        if (device == null || device.deviceAddress == null) return;
        WifiP2pDevice d = mDevices.get(device.deviceAddress);
        if (d != null) {
@@ -84,7 +96,7 @@ public class WifiP2pDeviceList implements Parcelable {
    }

    /** @hide */
    public void updateGroupCapability(String deviceAddress, int groupCapab) {
    void updateGroupCapability(String deviceAddress, int groupCapab) {
        if (TextUtils.isEmpty(deviceAddress)) return;
        WifiP2pDevice d = mDevices.get(deviceAddress);
        if (d != null) {
@@ -93,7 +105,7 @@ public class WifiP2pDeviceList implements Parcelable {
    }

    /** @hide */
    public void updateStatus(String deviceAddress, int status) {
    void updateStatus(String deviceAddress, int status) {
        if (TextUtils.isEmpty(deviceAddress)) return;
        WifiP2pDevice d = mDevices.get(deviceAddress);
        if (d != null) {
@@ -101,7 +113,11 @@ public class WifiP2pDeviceList implements Parcelable {
        }
    }

    /** @hide */
    /**
     * Fetch a device from the list
     * @param deviceAddress is the address of the device
     * @return WifiP2pDevice device found, or null if none found
     */
    public WifiP2pDevice get(String deviceAddress) {
        if (deviceAddress == null) return null;

@@ -114,6 +130,17 @@ public class WifiP2pDeviceList implements Parcelable {
        return mDevices.remove(device.deviceAddress) != null;
    }

    /**
     * Remove a device from the list
     * @param deviceAddress is the address of the device
     * @return WifiP2pDevice device removed, or null if none removed
     * @hide
     */
    public WifiP2pDevice remove(String deviceAddress) {
        if (deviceAddress == null) return null;
        return mDevices.remove(deviceAddress);
    }

    /** Returns true if any device the list was removed @hide */
    public boolean remove(WifiP2pDeviceList list) {
        boolean ret = false;
+3 −1
Original line number Diff line number Diff line
@@ -27,7 +27,9 @@ import java.util.regex.Pattern;
import java.util.regex.Matcher;

/**
 * A class representing a Wi-Fi P2p group
 * A class representing a Wi-Fi P2p group. A p2p group consists of a single group
 * owner and one or more clients. In the case of a group with only two devices, one
 * will be the group owner and the other will be a group client.
 *
 * {@see WifiP2pManager}
 */
+24 −17
Original line number Diff line number Diff line
@@ -171,10 +171,12 @@ public class WifiP2pManager {
     * Broadcast intent action indicating that the state of Wi-Fi p2p connectivity
     * has changed. One extra {@link #EXTRA_WIFI_P2P_INFO} provides the p2p connection info in
     * the form of a {@link WifiP2pInfo} object. Another extra {@link #EXTRA_NETWORK_INFO} provides
     * the network info in the form of a {@link android.net.NetworkInfo}.
     * the network info in the form of a {@link android.net.NetworkInfo}. A third extra provides
     * the details of the group.
     *
     * @see #EXTRA_WIFI_P2P_INFO
     * @see #EXTRA_NETWORK_INFO
     * @see #EXTRA_WIFI_P2P_GROUP
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String WIFI_P2P_CONNECTION_CHANGED_ACTION =
@@ -188,41 +190,46 @@ public class WifiP2pManager {

    /**
     * The lookup key for a {@link android.net.NetworkInfo} object associated with the
     * Wi-Fi network. Retrieve with
     * p2p network. Retrieve with
     * {@link android.content.Intent#getParcelableExtra(String)}.
     */
    public static final String EXTRA_NETWORK_INFO = "networkInfo";

    /**
     * The lookup key for a {@link android.net.LinkProperties} object associated with the
     * network. Retrieve with
     * The lookup key for a {@link android.net.wifi.p2p.WifiP2pGroup} object
     * associated with the p2p network. Retrieve with
     * {@link android.content.Intent#getParcelableExtra(String)}.
     * @hide
     */
    public static final String EXTRA_LINK_PROPERTIES = "linkProperties";

    /**
     * The lookup key for a {@link android.net.LinkCapabilities} object associated with the
     * network. Retrieve with
     * {@link android.content.Intent#getParcelableExtra(String)}.
     * @hide
     */
    public static final String EXTRA_LINK_CAPABILITIES = "linkCapabilities";
    public static final String EXTRA_WIFI_P2P_GROUP = "p2pGroupInfo";

    /**
     * Broadcast intent action indicating that the available peer list has changed. Fetch
     * the changed list of peers with {@link #requestPeers}
     * Broadcast intent action indicating that the available peer list has changed. This
     * can be sent as a result of peers being found, lost or updated.
     *
     * <p> An extra {@link #EXTRA_P2P_DEVICE_LIST} provides the full list of
     * current peers. The full list of peers can also be obtained any time with
     * {@link #requestPeers}.
     *
     * @see #EXTRA_P2P_DEVICE_LIST
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String WIFI_P2P_PEERS_CHANGED_ACTION =
        "android.net.wifi.p2p.PEERS_CHANGED";

     /**
      * The lookup key for a {@link android.net.wifi.p2p.WifiP2pDeviceList} object representing
      * the new peer list when {@link #WIFI_P2P_PEERS_CHANGED_ACTION} broadcast is sent.
      *
      * <p>Retrieve with {@link android.content.Intent#getParcelableExtra(String)}.
      */
     public static final String EXTRA_P2P_DEVICE_LIST = "wifiP2pDeviceList";

    /**
     * Broadcast intent action indicating that peer discovery has either started or stopped.
     * One extra {@link #EXTRA_DISCOVERY_STATE} indicates whether discovery has started
     * or stopped.
     *
     * Note that discovery will be stopped during a connection setup. If the application tries
     * <p>Note that discovery will be stopped during a connection setup. If the application tries
     * to re-initiate discovery during this time, it can fail.
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Loading