diff options
author | repo sync <isheriff@google.com> | 2011-08-18 13:43:52 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-08-18 13:43:52 -0700 |
commit | a8993e10f9aca690722512d147d2f98ed29a3d75 (patch) | |
tree | fa68efa86a8ee58b73d26b7d4a1a01c8682b27fb | |
parent | 843c3545d5f92c5d9dbf99f7a7366297ad9799d5 (diff) | |
parent | 2b8edd0c485f74067605c19983e3e7f44b20ec50 (diff) | |
download | frameworks_base-a8993e10f9aca690722512d147d2f98ed29a3d75.zip frameworks_base-a8993e10f9aca690722512d147d2f98ed29a3d75.tar.gz frameworks_base-a8993e10f9aca690722512d147d2f98ed29a3d75.tar.bz2 |
Merge "Use supplicant control channel interface for p2p"
-rw-r--r-- | wifi/java/android/net/wifi/WifiNative.java | 81 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/p2p/WifiP2pConfig.java | 4 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/p2p/WifiP2pService.java | 4 |
3 files changed, 29 insertions, 60 deletions
diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java index 3b043b3..bfc4d5e 100644 --- a/wifi/java/android/net/wifi/WifiNative.java +++ b/wifi/java/android/net/wifi/WifiNative.java @@ -203,70 +203,42 @@ public class WifiNative { private native static boolean doBooleanCommand(String command); - //STOPSHIP: remove this after native interface works and replace all - //calls to doBooleanTempCommand() with doBooleanCommand() - private static boolean doBooleanTempCommand(String command) { - try { - String str = "/system/bin/wpa_cli " + command; - Log.e("WifiNative", "===> " + str); - Runtime.getRuntime() - .exec(str).waitFor(); - } catch (Exception e) { - Log.e("WifiNative", "exception with doBooleanTempCommand"); - return false; - } - return true; - } - - private static String doStringTempCommand(String command) { - String lines[] = null; - try { - String str = "/system/bin/wpa_cli " + command; - Log.e("WifiNative", "===> " + str); - Process p = Runtime.getRuntime() - .exec(str); - InputStream in = p.getInputStream(); - p.waitFor(); - byte[] bytes=new byte[in.available()]; - in.read(bytes); - String s = new String(bytes); - Log.e("WifiNative", "====> doString: " + s); - lines = s.split("\\r?\\n"); - } catch (Exception e) { - Log.e("WifiNative", "exception with doBooleanTempCommand"); - return null; - } - return lines[1]; - } - private native static int doIntCommand(String command); private native static String doStringCommand(String command); + public static boolean wpsPbc() { + return doBooleanCommand("WPS_PBC"); + } + + public static boolean wpsPin(String pin) { + return doBooleanCommand("WPS_PIN any " + pin); + } + public static boolean p2pFind() { - return doBooleanTempCommand("p2p_find"); + return doBooleanCommand("P2P_FIND"); } public static boolean p2pFind(int timeout) { if (timeout <= 0) { return p2pFind(); } - return doBooleanTempCommand("p2p_find " + timeout); + return doBooleanCommand("P2P_FIND " + timeout); } public static boolean p2pListen() { - return doBooleanTempCommand("p2p_listen"); + return doBooleanCommand("P2P_LISTEN"); } public static boolean p2pListen(int timeout) { if (timeout <= 0) { return p2pListen(); } - return doBooleanTempCommand("p2p_listen " + timeout); + return doBooleanCommand("P2P_LISTEN " + timeout); } public static boolean p2pFlush() { - return doBooleanTempCommand("p2p_flush"); + return doBooleanCommand("P2P_FLUSH"); } /* p2p_connect <peer device address> <pbc|pin|PIN#> [label|display|keypad] @@ -300,41 +272,36 @@ public class WifiNative { if (config.isPersistent) args.add("persistent"); if (config.joinExistingGroup) args.add("join"); - args.add("go_intent=" + config.groupOwnerIntent); + int groupOwnerIntent = config.groupOwnerIntent; + if (groupOwnerIntent < 0 || groupOwnerIntent > 15) { + groupOwnerIntent = 3; //default value + } + args.add("go_intent=" + groupOwnerIntent); if (config.channel > 0) args.add("freq=" + config.channel); - String command = "p2p_connect "; + String command = "P2P_CONNECT "; for (String s : args) command += s + " "; - return doStringTempCommand(command); + return doStringCommand(command); } public static boolean p2pGroupAdd() { - return doBooleanTempCommand("p2p_group_add"); + return doBooleanCommand("P2P_GROUP_ADD"); } public static boolean p2pGroupRemove(String iface) { if (iface == null) return false; - return doBooleanTempCommand("p2p_group_remove " + iface); + return doBooleanCommand("P2P_GROUP_REMOVE " + iface); } public static boolean p2pReject(String deviceAddress) { - return doBooleanTempCommand("p2p_reject " + deviceAddress); + return doBooleanCommand("P2P_REJECT " + deviceAddress); } /* Invite a peer to a group */ public static boolean p2pInvite(WifiP2pGroup group, String deviceAddress) { if (group == null || deviceAddress == null) return false; - return doBooleanTempCommand("p2p_invite group=" + group.getInterface() + return doBooleanCommand("P2P_INVITE group=" + group.getInterface() + " peer=" + deviceAddress + " go_dev_addr=" + group.getOwner().deviceAddress); } - - public static boolean p2pWpsPbc() { - return doBooleanTempCommand("wps_pbc"); - } - - public static boolean p2pWpsPin(String pin) { - return doBooleanTempCommand("wps_pin any " + pin); - } - } diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pConfig.java b/wifi/java/android/net/wifi/p2p/WifiP2pConfig.java index fff5ee3..b77fd76 100644 --- a/wifi/java/android/net/wifi/p2p/WifiP2pConfig.java +++ b/wifi/java/android/net/wifi/p2p/WifiP2pConfig.java @@ -46,8 +46,10 @@ public class WifiP2pConfig implements Parcelable { * This is an integer value between 0 and 15 where 0 indicates the least * inclination to be a group owner and 15 indicates the highest inclination * to be a group owner. + * + * A value of -1 indicates the system can choose an appropriate value. */ - public int groupOwnerIntent; + public int groupOwnerIntent = -1; public boolean isPersistent; diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pService.java b/wifi/java/android/net/wifi/p2p/WifiP2pService.java index 176191e..49ce124 100644 --- a/wifi/java/android/net/wifi/p2p/WifiP2pService.java +++ b/wifi/java/android/net/wifi/p2p/WifiP2pService.java @@ -767,10 +767,10 @@ public class WifiP2pService extends IWifiP2pManager.Stub { notifyP2pProvDiscPinRequest((WifiP2pDevice) message.obj); break; case WifiP2pManager.WPS_PBC: - WifiNative.p2pWpsPbc(); + WifiNative.wpsPbc(); break; case WifiP2pManager.WPS_PIN: - WifiNative.p2pWpsPin((String) message.obj); + WifiNative.wpsPin((String) message.obj); break; default: return NOT_HANDLED; |