OSDN Git Service

Update documentation and cleanup to unhide API
authorIrfan Sheriff <isheriff@google.com>
Wed, 7 Sep 2011 04:48:04 +0000 (21:48 -0700)
committerIrfan Sheriff <isheriff@google.com>
Wed, 7 Sep 2011 07:18:48 +0000 (00:18 -0700)
Bug: 5247957
Change-Id: I3ef8ac013eec32eb540178ea5febec3d4c0a3428

wifi/java/android/net/wifi/WifiNative.java
wifi/java/android/net/wifi/Wps.java
wifi/java/android/net/wifi/p2p/WifiP2pConfig.java
wifi/java/android/net/wifi/p2p/WifiP2pDevice.java
wifi/java/android/net/wifi/p2p/WifiP2pDeviceList.java
wifi/java/android/net/wifi/p2p/WifiP2pGroup.java
wifi/java/android/net/wifi/p2p/WifiP2pInfo.java
wifi/java/android/net/wifi/p2p/WifiP2pManager.java
wifi/java/android/net/wifi/p2p/WifiP2pService.java

index 1a7638d..6cc09e9 100644 (file)
@@ -261,10 +261,10 @@ public class WifiNative {
     public static String p2pConnect(WifiP2pConfig config, boolean joinExistingGroup) {
         if (config == null) return null;
         List<String> args = new ArrayList<String>();
-        Wps wpsConfig = config.wpsConfig;
+        Wps wps = config.wps;
         args.add(config.deviceAddress);
 
-        switch (wpsConfig.setup) {
+        switch (wps.setup) {
             case PBC:
                 args.add("pbc");
                 break;
@@ -274,11 +274,11 @@ public class WifiNative {
                 args.add("display");
                 break;
             case KEYPAD:
-                args.add(wpsConfig.pin);
+                args.add(wps.pin);
                 args.add("keypad");
                 break;
             case LABEL:
-                args.add(wpsConfig.pin);
+                args.add(wps.pin);
                 args.add("label");
             default:
                 break;
index 175c7b5..6d00696 100644 (file)
@@ -27,10 +27,12 @@ import java.util.BitSet;
 /**
  * A class representing Wi-Fi Protected Setup
  * @hide
+ *
+ * {@see WifiP2pConfig}
  */
 public class Wps implements Parcelable {
 
-    /* Wi-Fi Protected Setup. www.wi-fi.org/wifi-protected-setup has details */
+    /** Wi-Fi Protected Setup. www.wi-fi.org/wifi-protected-setup has details */
     public enum Setup {
         /* Push button configuration */
         PBC,
@@ -49,6 +51,7 @@ public class Wps implements Parcelable {
     /** @hide */
     public String BSSID;
 
+    /** Passed with pin method configuration */
     public String pin;
 
     /** @hide */
@@ -60,7 +63,6 @@ public class Wps implements Parcelable {
     /** @hide */
     public LinkProperties linkProperties;
 
-    /** @hide */
     public Wps() {
         setup = Setup.INVALID;
         BSSID = null;
index 3fb67f9..e359ce5 100644 (file)
@@ -22,20 +22,22 @@ import android.os.Parcelable;
 import android.os.Parcel;
 
 /**
- * A class representing a Wi-Fi P2p configuration
+ * A class representing a Wi-Fi P2p configuration for setting up a connection
  * @hide
+ *
+ * {@see WifiP2pManager}
  */
 public class WifiP2pConfig implements Parcelable {
 
     /**
-     * Device address
+     * The device MAC address uniquely identifies a Wi-Fi p2p device
      */
     public String deviceAddress;
 
     /**
-     * WPS configuration
+     * Wi-Fi Protected Setup information
      */
-    public Wps wpsConfig;
+    public Wps wps;
 
     /**
      * This is an integer value between 0 and 15 where 0 indicates the least
@@ -61,11 +63,11 @@ public class WifiP2pConfig implements Parcelable {
 
     public WifiP2pConfig() {
         //set defaults
-        wpsConfig = new Wps();
-        wpsConfig.setup = Setup.PBC;
+        wps = new Wps();
+        wps.setup = Setup.PBC;
     }
 
-    /* P2P-GO-NEG-REQUEST 42:fc:89:a8:96:09 dev_passwd_id=4 */
+    /** P2P-GO-NEG-REQUEST 42:fc:89:a8:96:09 dev_passwd_id=4 {@hide}*/
     public WifiP2pConfig(String supplicantEvent) throws IllegalArgumentException {
         String[] tokens = supplicantEvent.split(" ");
 
@@ -74,7 +76,7 @@ public class WifiP2pConfig implements Parcelable {
         }
 
         deviceAddress = tokens[1];
-        wpsConfig = new Wps();
+        wps = new Wps();
 
         if (tokens.length > 2) {
             String[] nameVal = tokens[2].split("=");
@@ -87,28 +89,29 @@ public class WifiP2pConfig implements Parcelable {
             //As defined in wps/wps_defs.h
             switch (devPasswdId) {
                 case 0x00:
-                    wpsConfig.setup = Setup.LABEL;
+                    wps.setup = Setup.LABEL;
                     break;
                 case 0x01:
-                    wpsConfig.setup = Setup.KEYPAD;
+                    wps.setup = Setup.KEYPAD;
                     break;
                 case 0x04:
-                    wpsConfig.setup = Setup.PBC;
+                    wps.setup = Setup.PBC;
                     break;
                 case 0x05:
-                    wpsConfig.setup = Setup.DISPLAY;
+                    wps.setup = Setup.DISPLAY;
                     break;
                 default:
-                    wpsConfig.setup = Setup.PBC;
+                    wps.setup = Setup.PBC;
                     break;
             }
         }
     }
 
+    /** @hide */
     public String toString() {
         StringBuffer sbuf = new StringBuffer();
         sbuf.append("\n address: ").append(deviceAddress);
-        sbuf.append("\n wps: ").append(wpsConfig);
+        sbuf.append("\n wps: ").append(wps);
         sbuf.append("\n groupOwnerIntent: ").append(groupOwnerIntent);
         sbuf.append("\n persist: ").append(persist.toString());
         return sbuf.toString();
@@ -129,7 +132,7 @@ public class WifiP2pConfig implements Parcelable {
     /** Implement the Parcelable interface {@hide} */
     public void writeToParcel(Parcel dest, int flags) {
         dest.writeString(deviceAddress);
-        dest.writeParcelable(wpsConfig, flags);
+        dest.writeParcelable(wps, flags);
         dest.writeInt(groupOwnerIntent);
         dest.writeString(persist.name());
     }
@@ -140,7 +143,7 @@ public class WifiP2pConfig implements Parcelable {
             public WifiP2pConfig createFromParcel(Parcel in) {
                 WifiP2pConfig config = new WifiP2pConfig();
                 config.deviceAddress = in.readString();
-                config.wpsConfig = (Wps) in.readParcelable(null);
+                config.wps = (Wps) in.readParcelable(null);
                 config.groupOwnerIntent = in.readInt();
                 config.persist = Persist.valueOf(in.readString());
                 return config;
index 7908726..99c585f 100644 (file)
@@ -25,17 +25,20 @@ import java.util.regex.Pattern;
 /**
  * A class representing a Wi-Fi p2p device
  * @hide
+ *
+ * {@see WifiP2pManager}
  */
 public class WifiP2pDevice implements Parcelable {
 
     private static final String TAG = "WifiP2pDevice";
+
     /**
-     * Device name
+     * The device name is a user friendly string to identify a Wi-Fi p2p device
      */
     public String deviceName;
 
     /**
-     * Device MAC address
+     * The device MAC address uniquely identifies a Wi-Fi p2p device
      */
     public String deviceAddress;
 
@@ -46,35 +49,30 @@ public class WifiP2pDevice implements Parcelable {
      * P2P Interface Address and the group interface will be created with
      * address as the local address in case of successfully completed
      * negotiation.
+     * @hide
      */
     public String interfaceAddress;
 
     /**
-     * Primary device type
+     * Primary device type identifies the type of device. For example, an application
+     * could filter the devices discovered to only display printers if the purpose is to
+     * enable a printing action from the user. See the Wi-Fi Direct technical specification
+     * for the full list of standard device types supported.
      */
     public String primaryDeviceType;
 
     /**
-     * Secondary device type
+     * Secondary device type is an optional attribute that can be provided by a device in
+     * addition to the primary device type.
      */
     public String secondaryDeviceType;
 
 
     // These definitions match the ones in wpa_supplicant
     /* WPS config methods supported */
-    private static final int WPS_CONFIG_USBA            = 0x0001;
-    private static final int WPS_CONFIG_ETHERNET        = 0x0002;
-    private static final int WPS_CONFIG_LABEL           = 0x0004;
     private static final int WPS_CONFIG_DISPLAY         = 0x0008;
-    private static final int WPS_CONFIG_EXT_NFC_TOKEN   = 0x0010;
-    private static final int WPS_CONFIG_INT_NFC_TOKEN   = 0x0020;
-    private static final int WPS_CONFIG_NFC_INTERFACE   = 0x0040;
     private static final int WPS_CONFIG_PUSHBUTTON      = 0x0080;
     private static final int WPS_CONFIG_KEYPAD          = 0x0100;
-    private static final int WPS_CONFIG_VIRT_PUSHBUTTON = 0x0280;
-    private static final int WPS_CONFIG_PHY_PUSHBUTTON  = 0x0480;
-    private static final int WPS_CONFIG_VIRT_DISPLAY    = 0x2008;
-    private static final int WPS_CONFIG_PHY_DISPLAY     = 0x4008;
 
     /* Device Capability bitmap */
     private static final int DEVICE_CAPAB_SERVICE_DISCOVERY         = 1;
@@ -95,19 +93,23 @@ public class WifiP2pDevice implements Parcelable {
 
     /**
      * WPS config methods supported
+     * @hide
      */
     public int wpsConfigMethodsSupported;
 
     /**
      * Device capability
+     * @hide
      */
     public int deviceCapability;
 
     /**
      * Group capability
+     * @hide
      */
     public int groupCapability;
 
+    /** Device connection status */
     public enum Status {
         CONNECTED,
         INVITED,
@@ -118,7 +120,7 @@ public class WifiP2pDevice implements Parcelable {
 
     public Status status = Status.UNAVAILABLE;
 
-    public WifiP2pDevice() {
+    WifiP2pDevice() {
     }
 
     /**
@@ -144,6 +146,7 @@ public class WifiP2pDevice implements Parcelable {
      *  group_capab=0x0
      *
      *  Note: The events formats can be looked up in the wpa_supplicant code
+     * @hide
      */
     public WifiP2pDevice(String string) throws IllegalArgumentException {
         String[] tokens = string.split(" ");
@@ -198,11 +201,33 @@ public class WifiP2pDevice implements Parcelable {
         }
     }
 
+    /** Returns true if WPS push button configuration is supported */
+    public boolean wpsPbcSupported() {
+        return (wpsConfigMethodsSupported & WPS_CONFIG_PUSHBUTTON) != 0;
+    }
+
+    /** Returns true if WPS keypad configuration is supported */
+    public boolean wpsKeypadSupported() {
+        return (wpsConfigMethodsSupported & WPS_CONFIG_KEYPAD) != 0;
+    }
+
+    /** Returns true if WPS display configuration is supported */
+    public boolean wpsDisplaySupported() {
+        return (wpsConfigMethodsSupported & WPS_CONFIG_DISPLAY) != 0;
+    }
+
+    /** Returns true if the device is capable of service discovery */
+    public boolean isServiceDiscoveryCapable() {
+        return (deviceCapability & DEVICE_CAPAB_SERVICE_DISCOVERY) != 0;
+    }
+
+    /** Returns true if the device is a group owner */
     public boolean isGroupOwner() {
         return (groupCapability & GROUP_CAPAB_GROUP_OWNER) != 0;
     }
 
     @Override
+    /** @hide */
     public boolean equals(Object obj) {
         if (this == obj) return true;
         if (!(obj instanceof WifiP2pDevice)) return false;
@@ -214,6 +239,7 @@ public class WifiP2pDevice implements Parcelable {
         return other.deviceAddress.equals(deviceAddress);
     }
 
+    /** @hide */
     public String toString() {
         StringBuffer sbuf = new StringBuffer();
         sbuf.append("Device: ").append(deviceName);
index aa3554c..242bce0 100644 (file)
@@ -28,22 +28,25 @@ import java.util.Collections;
 /**
  * A class representing a Wi-Fi P2p device list
  * @hide
+ *
+ * {@see WifiP2pManager}
  */
 public class WifiP2pDeviceList implements Parcelable {
 
     private Collection<WifiP2pDevice> mDevices;
 
-    public WifiP2pDeviceList() {
+    WifiP2pDeviceList() {
         mDevices = new ArrayList<WifiP2pDevice>();
     }
 
-    //copy constructor
+    /** copy constructor {@hide} */
     public WifiP2pDeviceList(WifiP2pDeviceList source) {
         if (source != null) {
             mDevices = source.getDeviceList();
         }
     }
 
+    /** @hide */
     public WifiP2pDeviceList(ArrayList<WifiP2pDevice> devices) {
         mDevices = new ArrayList<WifiP2pDevice>();
         for (WifiP2pDevice device : devices) {
@@ -51,12 +54,14 @@ public class WifiP2pDeviceList implements Parcelable {
         }
     }
 
+    /** @hide */
     public boolean clear() {
         if (mDevices.isEmpty()) return false;
         mDevices.clear();
         return true;
     }
 
+    /** @hide */
     public void update(WifiP2pDevice device) {
         if (device == null) return;
         for (WifiP2pDevice d : mDevices) {
@@ -75,15 +80,18 @@ public class WifiP2pDeviceList implements Parcelable {
         mDevices.add(device);
     }
 
+    /** @hide */
     public boolean remove(WifiP2pDevice device) {
         if (device == null) return false;
         return mDevices.remove(device);
     }
 
+    /** Get the list of devices */
     public Collection<WifiP2pDevice> getDeviceList() {
         return Collections.unmodifiableCollection(mDevices);
     }
 
+    /** @hide */
     public String toString() {
         StringBuffer sbuf = new StringBuffer();
         for (WifiP2pDevice device : mDevices) {
index e35d360..48f210b 100644 (file)
@@ -27,6 +27,8 @@ import java.util.Collections;
 /**
  * A class representing a Wi-Fi P2p group
  * @hide
+ *
+ * {@see WifiP2pManager}
  */
 public class WifiP2pGroup implements Parcelable {
 
index a02175e..81b7708 100644 (file)
@@ -23,15 +23,20 @@ import java.net.InetAddress;
 import java.net.UnknownHostException;
 
 /**
- * A class representing connection info on Wi-fi P2p
+ * A class representing connection information about a Wi-Fi p2p group
  * @hide
+ *
+ * {@see WifiP2pManager}
  */
 public class WifiP2pInfo implements Parcelable {
 
+    /** Indicates if a p2p group has been successfully formed */
     public boolean groupFormed;
 
+    /** Indicates if the current device is the group owner */
     public boolean isGroupOwner;
 
+    /** Group owner address */
     public InetAddress groupOwnerAddress;
 
     /** @hide */
index 11de9c4..10a316e 100644 (file)
@@ -64,7 +64,7 @@ import com.android.internal.util.Protocol;
  * use {@link #requestConnectionInfo} to fetch the connection details. Connection information
  * can be obtained with {@link #connectionInfoInResponse} on a {@link #RESPONSE_CONNECTION_INFO}
  * message. The connection info {@link WifiP2pInfo} contains the address of the group owner
- * {@link WifiP2pInfo#groupOwnerAddress} and a flag {@link #WifiP2pInfo#isGroupOwner} to indicate
+ * {@link WifiP2pInfo#groupOwnerAddress} and a flag {@link WifiP2pInfo#isGroupOwner} to indicate
  * if the current device is a p2p group owner. A p2p client can thus communicate with
  * the p2p group owner through a socket connection.
  *
@@ -85,6 +85,7 @@ import com.android.internal.util.Protocol;
  * {@see WifiP2pGroup}
  * {@see WifiP2pDevice}
  * {@see WifiP2pDeviceList}
+ * {@see android.net.wifi.Wps}
  * @hide
  */
 public class WifiP2pManager {
index 0ef2e13..361cac5 100644 (file)
@@ -1034,7 +1034,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
 
     private void notifyP2pGoNegotationRequest(WifiP2pConfig config) {
         Resources r = Resources.getSystem();
-        Wps wpsConfig = config.wpsConfig;
+        Wps wps = config.wps;
         final View textEntryView = LayoutInflater.from(mContext)
                 .inflate(R.layout.wifi_p2p_go_negotiation_request_alert, null);
         final EditText pin = (EditText) textEntryView .findViewById(R.id.wifi_p2p_wps_pin);
@@ -1047,10 +1047,10 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
                             if (DBG) logd(getName() + " connect " + pin.getText());
 
                             if (pin.getVisibility() == View.GONE) {
-                                mSavedGoNegotiationConfig.wpsConfig.setup = Setup.PBC;
+                                mSavedGoNegotiationConfig.wps.setup = Setup.PBC;
                             } else {
-                                mSavedGoNegotiationConfig.wpsConfig.setup = Setup.KEYPAD;
-                                mSavedGoNegotiationConfig.wpsConfig.pin = pin.getText().toString();
+                                mSavedGoNegotiationConfig.wps.setup = Setup.KEYPAD;
+                                mSavedGoNegotiationConfig.wps.pin = pin.getText().toString();
                             }
                             sendMessage(WifiP2pManager.CONNECT, mSavedGoNegotiationConfig);
                             mSavedGoNegotiationConfig = null;
@@ -1065,7 +1065,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
                     })
             .create();
 
-        if (wpsConfig.setup == Setup.PBC) {
+        if (wps.setup == Setup.PBC) {
             pin.setVisibility(View.GONE);
             dialog.setMessage(r.getString(R.string.wifi_p2p_pbc_go_negotiation_request_message,
                         config.deviceAddress));