summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2017-05-12 10:12:19 -0700
committerRoshan Pius <rpius@google.com>2017-05-12 11:37:39 -0700
commit3af7d54afce3e72a8ccf037dd8e4fa30c8ccf878 (patch)
treea776962d3765668fa58ac2e2d1407fdbc0fe674b /service
parenta7bd6d6f01838d87ea310aade60456ec639c1577 (diff)
SupplicantP2pIfaceHal: Restore listenChannel behaviour
Bug: 38246261 Test: Manual tests with curator app. Test: Unit tests. Change-Id: I05e6d8d98e7875d1789e27fe0a34062784c69081
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java68
1 files changed, 45 insertions, 23 deletions
diff --git a/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java b/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java
index fe91b27d4..f944e6cba 100644
--- a/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java
+++ b/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java
@@ -62,6 +62,7 @@ public class SupplicantP2pIfaceHal {
private static final String TAG = "SupplicantP2pIfaceHal";
private static final int RESULT_NOT_VALID = -1;
private static final int DEFAULT_GROUP_OWNER_INTENT = 6;
+ private static final int DEFAULT_OPERATING_CLASS = 81;
/**
* Regex pattern for extracting the wps device type bytes.
* Matches a strings like the following: "<categ>-<OUI>-<subcateg>";
@@ -1148,39 +1149,60 @@ public class SupplicantP2pIfaceHal {
/**
- * Set P2P Listen channel.
+ * Set P2P Listen channel and operating chanel.
*
- * When specifying a social channel on the 2.4 GHz band (1/6/11) there is no
- * need to specify the operating class since it defaults to 81. When
- * specifying a social channel on the 60 GHz band (2), specify the 60 GHz
- * operating class (180).
- *
- * @param channel Wifi channel. eg, 1, 6, 11.
- * @param operatingClass Operating Class indicates the channel set of the AP
- * indicated by this BSSID
+ * @param listenChannel Wifi channel. eg, 1, 6, 11.
+ * @param operatingChannel Wifi channel. eg, 1, 6, 11.
*
* @return true, if operation was successful.
*/
- public boolean setListenChannel(int channel, int operatingClass) {
+ public boolean setListenChannel(int listenChannel, int operatingChannel) {
synchronized (mLock) {
if (!checkSupplicantP2pIfaceAndLogFailure("setListenChannel")) return false;
- // Verify that the integers are not negative. Leave actual parameter validation to
- // supplicant.
- if (channel < 0 || operatingClass < 0) {
- Log.e(TAG, "Invalid values supplied to setListenChannel: " + channel + ", "
- + operatingClass);
+
+ if (listenChannel >= 1 && listenChannel <= 11) {
+ SupplicantResult<Void> result = new SupplicantResult(
+ "setListenChannel(" + listenChannel + ", " + DEFAULT_OPERATING_CLASS + ")");
+ try {
+ result.setResult(mISupplicantP2pIface.setListenChannel(
+ listenChannel, DEFAULT_OPERATING_CLASS));
+ } catch (RemoteException e) {
+ Log.e(TAG, "ISupplicantP2pIface exception: " + e);
+ supplicantServiceDiedHandler();
+ }
+ if (!result.isSuccess()) {
+ return false;
+ }
+ } else if (listenChannel != 0) {
+ // listenChannel == 0 does not set any listen channel.
return false;
}
- SupplicantResult<Void> result = new SupplicantResult(
- "setListenChannel(" + channel + ", " + operatingClass + ")");
- try {
- result.setResult(mISupplicantP2pIface.setListenChannel(channel, operatingClass));
- } catch (RemoteException e) {
- Log.e(TAG, "ISupplicantP2pIface exception: " + e);
- supplicantServiceDiedHandler();
+ if (operatingChannel >= 0 && operatingChannel <= 165) {
+ ArrayList<ISupplicantP2pIface.FreqRange> ranges = new ArrayList<>();
+ // operatingChannel == 0 enables all freqs.
+ if (operatingChannel >= 1 && operatingChannel <= 165) {
+ int freq = (operatingChannel <= 14 ? 2407 : 5000) + operatingChannel * 5;
+ ISupplicantP2pIface.FreqRange range1 = new ISupplicantP2pIface.FreqRange();
+ range1.min = 1000;
+ range1.max = freq - 5;
+ ISupplicantP2pIface.FreqRange range2 = new ISupplicantP2pIface.FreqRange();
+ range2.min = freq + 5;
+ range2.max = 6000;
+ ranges.add(range1);
+ ranges.add(range2);
+ }
+ SupplicantResult<Void> result = new SupplicantResult(
+ "setDisallowedFrequencies(" + ranges + ")");
+ try {
+ result.setResult(mISupplicantP2pIface.setDisallowedFrequencies(ranges));
+ } catch (RemoteException e) {
+ Log.e(TAG, "ISupplicantP2pIface exception: " + e);
+ supplicantServiceDiedHandler();
+ }
+ return result.isSuccess();
}
- return result.isSuccess();
+ return false;
}
}