summaryrefslogtreecommitdiffstats
path: root/wifi/java/android
diff options
context:
space:
mode:
authorChong Zhang <chz@google.com>2013-05-03 15:55:36 -0700
committerChong Zhang <chz@google.com>2013-08-23 16:02:09 -0700
commit1f3ecaae6303d5ee6c5ca8499262c9962f036365 (patch)
tree610f36b3c049710713e921c1aa10938fa250f1d2 /wifi/java/android
parent570cd0f4c06a6e3de2af348040415ff2fcff57a1 (diff)
downloadframeworks_base-1f3ecaae6303d5ee6c5ca8499262c9962f036365.zip
frameworks_base-1f3ecaae6303d5ee6c5ca8499262c9962f036365.tar.gz
frameworks_base-1f3ecaae6303d5ee6c5ca8499262c9962f036365.tar.bz2
wifi-display: add certification options
When certification mode is enabled: - Pass wfd session info to wifi display settings - Allow sink to connect to source - Add interface in display manager for pausing/resuming session - Add interface in WifiP2pManager for setting lc, oc and starting autonomous GO Note that we're compliant regardless of certification mode, but some confusing options (eg. allowing incoming connection from sink) we want to hide when not being tested. Bug: 9371882 Change-Id: Icc7dcae4e046453796cfa03f5f197055fabf234b
Diffstat (limited to 'wifi/java/android')
-rw-r--r--wifi/java/android/net/wifi/WifiNative.java31
-rw-r--r--wifi/java/android/net/wifi/p2p/WifiP2pManager.java45
-rw-r--r--wifi/java/android/net/wifi/p2p/WifiP2pService.java73
3 files changed, 148 insertions, 1 deletions
diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java
index 79c1163..d3342dd 100644
--- a/wifi/java/android/net/wifi/WifiNative.java
+++ b/wifi/java/android/net/wifi/WifiNative.java
@@ -619,6 +619,37 @@ public class WifiNative {
return doBooleanCommand("P2P_LISTEN " + timeout);
}
+ public boolean p2pExtListen(boolean enable, int period, int interval) {
+ if (enable && interval < period) {
+ return false;
+ }
+ return doBooleanCommand("P2P_EXT_LISTEN"
+ + (enable ? (" " + period + " " + interval) : ""));
+ }
+
+ public boolean p2pSetChannel(int lc, int oc) {
+ if (DBG) Log.d(mTAG, "p2pSetChannel: lc="+lc+", oc="+oc);
+
+ if (lc >=1 && lc <= 11) {
+ if (!doBooleanCommand("P2P_SET listen_channel " + lc)) {
+ return false;
+ }
+ } else if (lc != 0) {
+ return false;
+ }
+
+ if (oc >= 1 && oc <= 165 ) {
+ int freq = (oc <= 14 ? 2407 : 5000) + oc * 5;
+ return doBooleanCommand("P2P_SET disallow_freq 1000-"
+ + (freq - 5) + "," + (freq + 5) + "-6000");
+ } else if (oc == 0) {
+ /* oc==0 disables "P2P_SET disallow_freq" (enables all freqs) */
+ return doBooleanCommand("P2P_SET disallow_freq \"\"");
+ }
+
+ return false;
+ }
+
public boolean p2pFlush() {
return doBooleanCommand("P2P_FLUSH");
}
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
index 737ab91..4988b92 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
@@ -30,6 +30,7 @@ import android.net.wifi.p2p.nsd.WifiP2pServiceResponse;
import android.net.wifi.p2p.nsd.WifiP2pUpnpServiceInfo;
import android.net.wifi.p2p.nsd.WifiP2pUpnpServiceResponse;
import android.os.Binder;
+import android.os.Bundle;
import android.os.IBinder;
import android.os.Handler;
import android.os.Looper;
@@ -430,6 +431,28 @@ public class WifiP2pManager {
/** @hide */
public static final int START_WPS_SUCCEEDED = BASE + 64;
+ /** @hide */
+ public static final int START_LISTEN = BASE + 65;
+ /** @hide */
+ public static final int START_LISTEN_FAILED = BASE + 66;
+ /** @hide */
+ public static final int START_LISTEN_SUCCEEDED = BASE + 67;
+
+ /** @hide */
+ public static final int STOP_LISTEN = BASE + 68;
+ /** @hide */
+ public static final int STOP_LISTEN_FAILED = BASE + 69;
+ /** @hide */
+ public static final int STOP_LISTEN_SUCCEEDED = BASE + 70;
+
+ /** @hide */
+ public static final int SET_CHANNEL = BASE + 71;
+ /** @hide */
+ public static final int SET_CHANNEL_FAILED = BASE + 72;
+ /** @hide */
+ public static final int SET_CHANNEL_SUCCEEDED = BASE + 73;
+
+
/**
* Create a new WifiP2pManager instance. Applications use
* {@link android.content.Context#getSystemService Context.getSystemService()} to retrieve
@@ -667,6 +690,9 @@ public class WifiP2pManager {
case DELETE_PERSISTENT_GROUP_FAILED:
case SET_WFD_INFO_FAILED:
case START_WPS_FAILED:
+ case START_LISTEN_FAILED:
+ case STOP_LISTEN_FAILED:
+ case SET_CHANNEL_FAILED:
if (listener != null) {
((ActionListener) listener).onFailure(message.arg1);
}
@@ -689,6 +715,9 @@ public class WifiP2pManager {
case DELETE_PERSISTENT_GROUP_SUCCEEDED:
case SET_WFD_INFO_SUCCEEDED:
case START_WPS_SUCCEEDED:
+ case START_LISTEN_SUCCEEDED:
+ case STOP_LISTEN_SUCCEEDED:
+ case SET_CHANNEL_SUCCEEDED:
if (listener != null) {
((ActionListener) listener).onSuccess();
}
@@ -955,6 +984,22 @@ public class WifiP2pManager {
c.mAsyncChannel.sendMessage(REMOVE_GROUP, 0, c.putListener(listener));
}
+ /** @hide */
+ public void listen(Channel c, boolean enable, ActionListener listener) {
+ checkChannel(c);
+ c.mAsyncChannel.sendMessage(enable ? START_LISTEN : STOP_LISTEN,
+ 0, c.putListener(listener));
+ }
+
+ /** @hide */
+ public void setWifiP2pChannels(Channel c, int lc, int oc, ActionListener listener) {
+ checkChannel(c);
+ Bundle p2pChannels = new Bundle();
+ p2pChannels.putInt("lc", lc);
+ p2pChannels.putInt("oc", oc);
+ c.mAsyncChannel.sendMessage(SET_CHANNEL, 0, c.putListener(listener), p2pChannels);
+ }
+
/**
* Start a Wi-Fi Protected Setup (WPS) session.
*
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pService.java b/wifi/java/android/net/wifi/p2p/WifiP2pService.java
index 63b94a2..05196b8 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pService.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pService.java
@@ -48,6 +48,7 @@ import android.net.wifi.p2p.nsd.WifiP2pServiceInfo;
import android.net.wifi.p2p.nsd.WifiP2pServiceRequest;
import android.net.wifi.p2p.nsd.WifiP2pServiceResponse;
import android.os.Binder;
+import android.os.Bundle;
import android.os.IBinder;
import android.os.INetworkManagementService;
import android.os.Handler;
@@ -628,6 +629,9 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
case DhcpStateMachine.CMD_ON_QUIT:
case WifiMonitor.P2P_PROV_DISC_FAILURE_EVENT:
case SET_MIRACAST_MODE:
+ case WifiP2pManager.START_LISTEN:
+ case WifiP2pManager.STOP_LISTEN:
+ case WifiP2pManager.SET_CHANNEL:
break;
case WifiStateMachine.CMD_ENABLE_P2P:
// Enable is lazy and has no response
@@ -729,7 +733,16 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
replyToMessage(message, WifiP2pManager.START_WPS_FAILED,
WifiP2pManager.P2P_UNSUPPORTED);
break;
- default:
+ case WifiP2pManager.START_LISTEN:
+ replyToMessage(message, WifiP2pManager.START_LISTEN_FAILED,
+ WifiP2pManager.P2P_UNSUPPORTED);
+ break;
+ case WifiP2pManager.STOP_LISTEN:
+ replyToMessage(message, WifiP2pManager.STOP_LISTEN_FAILED,
+ WifiP2pManager.P2P_UNSUPPORTED);
+ break;
+
+ default:
return NOT_HANDLED;
}
return HANDLED;
@@ -1022,6 +1035,35 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
case SET_MIRACAST_MODE:
mWifiNative.setMiracastMode(message.arg1);
break;
+ case WifiP2pManager.START_LISTEN:
+ if (DBG) logd(getName() + " start listen mode");
+ mWifiNative.p2pFlush();
+ if (mWifiNative.p2pExtListen(true, 500, 500)) {
+ replyToMessage(message, WifiP2pManager.START_LISTEN_SUCCEEDED);
+ } else {
+ replyToMessage(message, WifiP2pManager.START_LISTEN_FAILED);
+ }
+ break;
+ case WifiP2pManager.STOP_LISTEN:
+ if (DBG) logd(getName() + " stop listen mode");
+ if (mWifiNative.p2pExtListen(false, 0, 0)) {
+ replyToMessage(message, WifiP2pManager.STOP_LISTEN_SUCCEEDED);
+ } else {
+ replyToMessage(message, WifiP2pManager.STOP_LISTEN_FAILED);
+ }
+ mWifiNative.p2pFlush();
+ break;
+ case WifiP2pManager.SET_CHANNEL:
+ Bundle p2pChannels = (Bundle) message.obj;
+ int lc = p2pChannels.getInt("lc", 0);
+ int oc = p2pChannels.getInt("oc", 0);
+ if (DBG) logd(getName() + " set listen and operating channel");
+ if (mWifiNative.p2pSetChannel(lc, oc)) {
+ replyToMessage(message, WifiP2pManager.SET_CHANNEL_SUCCEEDED);
+ } else {
+ replyToMessage(message, WifiP2pManager.SET_CHANNEL_FAILED);
+ }
+ break;
default:
return NOT_HANDLED;
}
@@ -1171,6 +1213,35 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
mWifiNative.p2pGroupRemove(mGroup.getInterface());
}
break;
+ case WifiP2pManager.START_LISTEN:
+ if (DBG) logd(getName() + " start listen mode");
+ mWifiNative.p2pFlush();
+ if (mWifiNative.p2pExtListen(true, 500, 500)) {
+ replyToMessage(message, WifiP2pManager.START_LISTEN_SUCCEEDED);
+ } else {
+ replyToMessage(message, WifiP2pManager.START_LISTEN_FAILED);
+ }
+ break;
+ case WifiP2pManager.STOP_LISTEN:
+ if (DBG) logd(getName() + " stop listen mode");
+ if (mWifiNative.p2pExtListen(false, 0, 0)) {
+ replyToMessage(message, WifiP2pManager.STOP_LISTEN_SUCCEEDED);
+ } else {
+ replyToMessage(message, WifiP2pManager.STOP_LISTEN_FAILED);
+ }
+ mWifiNative.p2pFlush();
+ break;
+ case WifiP2pManager.SET_CHANNEL:
+ Bundle p2pChannels = (Bundle) message.obj;
+ int lc = p2pChannels.getInt("lc", 0);
+ int oc = p2pChannels.getInt("oc", 0);
+ if (DBG) logd(getName() + " set listen and operating channel");
+ if (mWifiNative.p2pSetChannel(lc, oc)) {
+ replyToMessage(message, WifiP2pManager.SET_CHANNEL_SUCCEEDED);
+ } else {
+ replyToMessage(message, WifiP2pManager.SET_CHANNEL_FAILED);
+ }
+ break;
default:
return NOT_HANDLED;
}