diff options
author | Andres Morales <anmorales@google.com> | 2014-06-25 22:23:22 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-06-25 17:34:05 +0000 |
commit | d96e4948daf687f3f631ba8d93c89026fd3ce272 (patch) | |
tree | c10c482755a6b793dc826c1fbbedaf757f8fd109 /wifi/java | |
parent | 533226a318d74f9ee20a5ec80cd0c7c06dc91467 (diff) | |
parent | 9740e468bc895cbc08c71aecc35fc56c3faafa06 (diff) | |
download | frameworks_base-d96e4948daf687f3f631ba8d93c89026fd3ce272.zip frameworks_base-d96e4948daf687f3f631ba8d93c89026fd3ce272.tar.gz frameworks_base-d96e4948daf687f3f631ba8d93c89026fd3ce272.tar.bz2 |
Merge "interface for nfc handover supplicant commands"
Diffstat (limited to 'wifi/java')
-rw-r--r-- | wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl | 1 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/p2p/WifiP2pManager.java | 117 |
2 files changed, 116 insertions, 2 deletions
diff --git a/wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl b/wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl index 1c9c40d..ee2e895 100644 --- a/wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl +++ b/wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl @@ -26,6 +26,7 @@ import android.os.Messenger; interface IWifiP2pManager { Messenger getMessenger(); + Messenger getP2pStateMachineMessenger(); void setMiracastMode(int mode); } diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java index 3ed2406..6409450 100644 --- a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java +++ b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java @@ -276,6 +276,13 @@ public class WifiP2pManager { public static final String WIFI_P2P_PERSISTENT_GROUPS_CHANGED_ACTION = "android.net.wifi.p2p.PERSISTENT_GROUPS_CHANGED"; + /** + * The lookup key for a handover message returned by the WifiP2pService. + * @hide + */ + public static final String EXTRA_HANDOVER_MESSAGE = + "android.net.wifi.p2p.EXTRA_HANDOVER_MESSAGE"; + IWifiP2pManager mService; private static final int BASE = Protocol.BASE_WIFI_P2P_MANAGER; @@ -446,6 +453,21 @@ public class WifiP2pManager { /** @hide */ public static final int SET_CHANNEL_SUCCEEDED = BASE + 73; + /** @hide */ + public static final int GET_HANDOVER_REQUEST = BASE + 75; + /** @hide */ + public static final int GET_HANDOVER_SELECT = BASE + 76; + /** @hide */ + public static final int RESPONSE_GET_HANDOVER_MESSAGE = BASE + 77; + /** @hide */ + public static final int INITIATOR_REPORT_NFC_HANDOVER = BASE + 78; + /** @hide */ + public static final int RESPONDER_REPORT_NFC_HANDOVER = BASE + 79; + /** @hide */ + public static final int REPORT_NFC_HANDOVER_SUCCEEDED = BASE + 80; + /** @hide */ + public static final int REPORT_NFC_HANDOVER_FAILED = BASE + 81; + /** * Create a new WifiP2pManager instance. Applications use @@ -627,6 +649,14 @@ public class WifiP2pManager { } /** + * Interface for callback invocation when Handover Request or Select Message is available + * @hide + */ + public interface HandoverMessageListener { + public void onHandoverMessageAvailable(String handoverMessage); + } + + /** * A channel that connects the application to the Wifi p2p framework. * Most p2p operations require a Channel as an argument. An instance of Channel is obtained * by doing a call on {@link #initialize} @@ -687,6 +717,7 @@ public class WifiP2pManager { case START_LISTEN_FAILED: case STOP_LISTEN_FAILED: case SET_CHANNEL_FAILED: + case REPORT_NFC_HANDOVER_FAILED: if (listener != null) { ((ActionListener) listener).onFailure(message.arg1); } @@ -712,6 +743,7 @@ public class WifiP2pManager { case START_LISTEN_SUCCEEDED: case STOP_LISTEN_SUCCEEDED: case SET_CHANNEL_SUCCEEDED: + case REPORT_NFC_HANDOVER_SUCCEEDED: if (listener != null) { ((ActionListener) listener).onSuccess(); } @@ -745,7 +777,17 @@ public class WifiP2pManager { onPersistentGroupInfoAvailable(groups); } break; - default: + case RESPONSE_GET_HANDOVER_MESSAGE: + Bundle handoverBundle = (Bundle) message.obj; + if (listener != null) { + String handoverMessage = handoverBundle != null + ? handoverBundle.getString(EXTRA_HANDOVER_MESSAGE) + : null; + ((HandoverMessageListener) listener) + .onHandoverMessageAvailable(handoverMessage); + } + break; + default: Log.d(TAG, "Ignored " + message); break; } @@ -841,7 +883,20 @@ public class WifiP2pManager { * @return Channel instance that is necessary for performing any further p2p operations */ public Channel initialize(Context srcContext, Looper srcLooper, ChannelListener listener) { - Messenger messenger = getMessenger(); + return initalizeChannel(srcContext, srcLooper, listener, getMessenger()); + } + + /** + * Registers the application with the Wi-Fi framework. Enables system-only functionality. + * @hide + */ + public Channel initializeInternal(Context srcContext, Looper srcLooper, + ChannelListener listener) { + return initalizeChannel(srcContext, srcLooper, listener, getP2pStateMachineMessenger()); + } + + private Channel initalizeChannel(Context srcContext, Looper srcLooper, ChannelListener listener, + Messenger messenger) { if (messenger == null) return null; Channel c = new Channel(srcContext, srcLooper, listener); @@ -1327,4 +1382,62 @@ public class WifiP2pManager { } } + /** + * Get a reference to P2pStateMachine handler. This is used to establish + * a priveleged AsyncChannel communication with WifiP2pService. + * + * @return Messenger pointing to the WifiP2pService handler + * @hide + */ + public Messenger getP2pStateMachineMessenger() { + try { + return mService.getP2pStateMachineMessenger(); + } catch (RemoteException e) { + return null; + } + } + + /** + * Get a handover request message for use in WFA NFC Handover transfer. + * @hide + */ + public void getNfcHandoverRequest(Channel c, HandoverMessageListener listener) { + checkChannel(c); + c.mAsyncChannel.sendMessage(GET_HANDOVER_REQUEST, 0, c.putListener(listener)); + } + + + /** + * Get a handover select message for use in WFA NFC Handover transfer. + * @hide + */ + public void getNfcHandoverSelect(Channel c, HandoverMessageListener listener) { + checkChannel(c); + c.mAsyncChannel.sendMessage(GET_HANDOVER_SELECT, 0, c.putListener(listener)); + } + + /** + * @hide + */ + public void initiatorReportNfcHandover(Channel c, String handoverSelect, + ActionListener listener) { + checkChannel(c); + Bundle bundle = new Bundle(); + bundle.putString(EXTRA_HANDOVER_MESSAGE, handoverSelect); + c.mAsyncChannel.sendMessage(INITIATOR_REPORT_NFC_HANDOVER, 0, + c.putListener(listener), bundle); + } + + + /** + * @hide + */ + public void responderReportNfcHandover(Channel c, String handoverRequest, + ActionListener listener) { + checkChannel(c); + Bundle bundle = new Bundle(); + bundle.putString(EXTRA_HANDOVER_MESSAGE, handoverRequest); + c.mAsyncChannel.sendMessage(RESPONDER_REPORT_NFC_HANDOVER, 0, + c.putListener(listener), bundle); + } } |