diff options
| author | 2018-11-02 15:10:36 +0800 | |
|---|---|---|
| committer | 2018-11-15 12:04:56 +0800 | |
| commit | 7bfcf2cdd189350612b490dbe23c420e0531abe3 (patch) | |
| tree | 08c0f2c845fd1c78aeef9e107d6b95820b1a7dbb | |
| parent | bc4afc4f6076eadff2eaa2a48ee2954556d2fd21 (diff) | |
p2p: add new API for acts test
Bug: 118598975
Test: local ACTS test (topic: p2p_acts), included
1. Wpsinfo with PBC connection test,
ping test from gc to go, reconnect test
2. Wpsinfo with display connection test,
ping test from gc to go, reconnect test
Security Permission test:
Local Test Application test and confirm access deny
if application without NetowrkStack Permission
All of test cases are passed
Test Command: -tc WifiP2pManagerTest -ti 10 in shielding box
Change-Id: I963b54351f83747edf1d1d8a1db94af87728f37f
| -rw-r--r-- | wifi/java/android/net/wifi/p2p/WifiP2pManager.java | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java index e6892bea4595..f58a006278d2 100644 --- a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java +++ b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java @@ -491,6 +491,17 @@ public class WifiP2pManager { /** @hide */ public static final int FACTORY_RESET_SUCCEEDED = BASE + 84; + /** @hide */ + public static final int REQUEST_ONGOING_PEER_CONFIG = BASE + 85; + /** @hide */ + public static final int RESPONSE_ONGOING_PEER_CONFIG = BASE + 86; + /** @hide */ + public static final int SET_ONGOING_PEER_CONFIG = BASE + 87; + /** @hide */ + public static final int SET_ONGOING_PEER_CONFIG_FAILED = BASE + 88; + /** @hide */ + public static final int SET_ONGOING_PEER_CONFIG_SUCCEEDED = BASE + 89; + /** * Create a new WifiP2pManager instance. Applications use * {@link android.content.Context#getSystemService Context.getSystemService()} to retrieve @@ -680,6 +691,18 @@ public class WifiP2pManager { } /** + * Interface for callback invocation when ongoing peer info is available + * @hide + */ + public interface OngoingPeerInfoListener { + /** + * The requested ongoing WifiP2pConfig is available + * @param peerConfig WifiP2pConfig for current connecting session + */ + void onOngoingPeerAvailable(WifiP2pConfig peerConfig); + } + + /** * 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} @@ -787,6 +810,7 @@ public class WifiP2pManager { case SET_CHANNEL_FAILED: case REPORT_NFC_HANDOVER_FAILED: case FACTORY_RESET_FAILED: + case SET_ONGOING_PEER_CONFIG_FAILED: if (listener != null) { ((ActionListener) listener).onFailure(message.arg1); } @@ -814,6 +838,7 @@ public class WifiP2pManager { case SET_CHANNEL_SUCCEEDED: case REPORT_NFC_HANDOVER_SUCCEEDED: case FACTORY_RESET_SUCCEEDED: + case SET_ONGOING_PEER_CONFIG_SUCCEEDED: if (listener != null) { ((ActionListener) listener).onSuccess(); } @@ -857,6 +882,13 @@ public class WifiP2pManager { .onHandoverMessageAvailable(handoverMessage); } break; + case RESPONSE_ONGOING_PEER_CONFIG: + WifiP2pConfig peerConfig = (WifiP2pConfig) message.obj; + if (listener != null) { + ((OngoingPeerInfoListener) listener) + .onOngoingPeerAvailable(peerConfig); + } + break; default: Log.d(TAG, "Ignored " + message); break; @@ -1536,6 +1568,7 @@ public class WifiP2pManager { /** * 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 @@ -1550,4 +1583,37 @@ public class WifiP2pManager { callingPackage); } + /** + * Request saved WifiP2pConfig which used for an ongoing peer connection + * + * @param c is the channel created at {@link #initialize} + * @param listener for callback when ongoing peer config updated. Can't be null. + * + * @hide + */ + @RequiresPermission(android.Manifest.permission.NETWORK_STACK) + public void requestOngoingPeerConfig(@NonNull Channel c, + @NonNull OngoingPeerInfoListener listener) { + checkChannel(c); + c.mAsyncChannel.sendMessage(REQUEST_ONGOING_PEER_CONFIG, + Binder.getCallingUid(), c.putListener(listener)); + } + + /** + * Set saved WifiP2pConfig which used for an ongoing peer connection + * + * @param c is the channel created at {@link #initialize} + * @param config used for change an ongoing peer connection + * @param listener for callback when ongoing peer config updated. Can be null. + * + * @hide + */ + @RequiresPermission(android.Manifest.permission.NETWORK_STACK) + public void setOngoingPeerConfig(@NonNull Channel c, @NonNull WifiP2pConfig config, + @Nullable ActionListener listener) { + checkChannel(c); + checkP2pConfig(config); + c.mAsyncChannel.sendMessage(SET_ONGOING_PEER_CONFIG, 0, + c.putListener(listener), config); + } } |