summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2017-03-22 11:15:50 -0700
committerRoshan Pius <rpius@google.com>2017-03-27 10:15:21 -0700
commit7adcbd6f7b0baef1e4186376b0b43789303856cf (patch)
treeed330d3dbd11c6109c7bf5176cba94f2262e6f0d /service
parentcdd56a55709407c9efe2a24b4ed25666e2e8318e (diff)
Add try/catch blocks for incoming HAL params
Add try/catch blocks for handling exceptions raised during handling incoming params to the HAL calling code. While there, Rename SupplicantStaIfaceHal.addNetwork to SupplicantStaIfaceHal.addNetworkAndSaveConfig Bug: 36510794 Bug: 36510113 Test: Compiles & able to connect to wifi networks Change-Id: Idc52d6ea63c4c23e9a3c8f12827f7b6ef1ea07b8
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/SupplicantStaIfaceHal.java101
-rw-r--r--service/java/com/android/server/wifi/SupplicantStaNetworkHal.java154
-rw-r--r--service/java/com/android/server/wifi/WifiVendorHal.java20
-rw-r--r--service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java70
4 files changed, 225 insertions, 120 deletions
diff --git a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
index 2432db6be..09ce833fb 100644
--- a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
+++ b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
@@ -354,7 +354,7 @@ public class SupplicantStaIfaceHal {
* @param config Config corresponding to the network.
* @return SupplicantStaNetwork of the added network in wpa_supplicant.
*/
- private SupplicantStaNetworkHal addNetwork(WifiConfiguration config) {
+ private SupplicantStaNetworkHal addNetworkAndSaveConfig(WifiConfiguration config) {
logi("addSupplicantStaNetwork via HIDL");
if (config == null) {
loge("Cannot add NULL network!");
@@ -365,7 +365,13 @@ public class SupplicantStaIfaceHal {
loge("Failed to add a network!");
return null;
}
- if (!network.saveWifiConfiguration(config)) {
+ boolean saveSuccess = false;
+ try {
+ saveSuccess = network.saveWifiConfiguration(config);
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Exception while saving config params: " + config, e);
+ }
+ if (!saveSuccess) {
loge("Failed to save variables for: " + config.configKey());
if (!removeAllNetworks()) {
loge("Failed to remove all networks on failure.");
@@ -395,7 +401,7 @@ public class SupplicantStaIfaceHal {
loge("Failed to remove existing networks");
return false;
}
- mCurrentNetwork = addNetwork(config);
+ mCurrentNetwork = addNetworkAndSaveConfig(config);
if (mCurrentNetwork == null) {
loge("Failed to add/save network configuration: " + config.configKey());
return false;
@@ -754,21 +760,26 @@ public class SupplicantStaIfaceHal {
* @return true if request is sent successfully, false otherwise.
*/
public boolean setWpsDeviceType(String typeStr) {
- Matcher match = WPS_DEVICE_TYPE_PATTERN.matcher(typeStr);
- if (!match.find() || match.groupCount() != 3) {
- Log.e(TAG, "Malformed WPS device type " + typeStr);
+ try {
+ Matcher match = WPS_DEVICE_TYPE_PATTERN.matcher(typeStr);
+ if (!match.find() || match.groupCount() != 3) {
+ Log.e(TAG, "Malformed WPS device type " + typeStr);
+ return false;
+ }
+ short categ = Short.parseShort(match.group(1));
+ byte[] oui = NativeUtil.hexStringToByteArray(match.group(2));
+ short subCateg = Short.parseShort(match.group(3));
+
+ byte[] bytes = new byte[8];
+ ByteBuffer byteBuffer = ByteBuffer.wrap(bytes).order(ByteOrder.BIG_ENDIAN);
+ byteBuffer.putShort(categ);
+ byteBuffer.put(oui);
+ byteBuffer.putShort(subCateg);
+ return setWpsDeviceType(bytes);
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Illegal argument " + typeStr, e);
return false;
}
- short categ = Short.parseShort(match.group(1));
- byte[] oui = NativeUtil.hexStringToByteArray(match.group(2));
- short subCateg = Short.parseShort(match.group(3));
-
- byte[] bytes = new byte[8];
- ByteBuffer byteBuffer = ByteBuffer.wrap(bytes).order(ByteOrder.BIG_ENDIAN);
- byteBuffer.putShort(categ);
- byteBuffer.put(oui);
- byteBuffer.putShort(subCateg);
- return setWpsDeviceType(bytes);
}
private boolean setWpsDeviceType(byte[/* 8 */] type) {
@@ -978,7 +989,12 @@ public class SupplicantStaIfaceHal {
* @return true if request is sent successfully, false otherwise.
*/
public boolean initiateTdlsDiscover(String macAddress) {
- return initiateTdlsDiscover(NativeUtil.macAddressToByteArray(macAddress));
+ try {
+ return initiateTdlsDiscover(NativeUtil.macAddressToByteArray(macAddress));
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Illegal argument " + macAddress, e);
+ return false;
+ }
}
/** See ISupplicantStaIface.hal for documentation */
private boolean initiateTdlsDiscover(byte[/* 6 */] macAddress) {
@@ -1002,7 +1018,12 @@ public class SupplicantStaIfaceHal {
* @return true if request is sent successfully, false otherwise.
*/
public boolean initiateTdlsSetup(String macAddress) {
- return initiateTdlsSetup(NativeUtil.macAddressToByteArray(macAddress));
+ try {
+ return initiateTdlsSetup(NativeUtil.macAddressToByteArray(macAddress));
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Illegal argument " + macAddress, e);
+ return false;
+ }
}
/** See ISupplicantStaIface.hal for documentation */
private boolean initiateTdlsSetup(byte[/* 6 */] macAddress) {
@@ -1025,7 +1046,12 @@ public class SupplicantStaIfaceHal {
* @return true if request is sent successfully, false otherwise.
*/
public boolean initiateTdlsTeardown(String macAddress) {
- return initiateTdlsTeardown(NativeUtil.macAddressToByteArray(macAddress));
+ try {
+ return initiateTdlsTeardown(NativeUtil.macAddressToByteArray(macAddress));
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Illegal argument " + macAddress, e);
+ return false;
+ }
}
/** See ISupplicantStaIface.hal for documentation */
@@ -1053,8 +1079,13 @@ public class SupplicantStaIfaceHal {
*/
public boolean initiateAnqpQuery(String bssid, ArrayList<Short> infoElements,
ArrayList<Integer> hs20SubTypes) {
- return initiateAnqpQuery(
- NativeUtil.macAddressToByteArray(bssid), infoElements, hs20SubTypes);
+ try {
+ return initiateAnqpQuery(
+ NativeUtil.macAddressToByteArray(bssid), infoElements, hs20SubTypes);
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Illegal argument " + bssid, e);
+ return false;
+ }
}
/** See ISupplicantStaIface.hal for documentation */
@@ -1082,7 +1113,12 @@ public class SupplicantStaIfaceHal {
* @return true if request is sent successfully, false otherwise.
*/
public boolean initiateHs20IconQuery(String bssid, String fileName) {
- return initiateHs20IconQuery(NativeUtil.macAddressToByteArray(bssid), fileName);
+ try {
+ return initiateHs20IconQuery(NativeUtil.macAddressToByteArray(bssid), fileName);
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Illegal argument " + bssid, e);
+ return false;
+ }
}
/** See ISupplicantStaIface.hal for documentation */
@@ -1308,7 +1344,12 @@ public class SupplicantStaIfaceHal {
*/
public boolean startWpsRegistrar(String bssidStr, String pin) {
if (TextUtils.isEmpty(bssidStr) || TextUtils.isEmpty(pin)) return false;
- return startWpsRegistrar(NativeUtil.macAddressToByteArray(bssidStr), pin);
+ try {
+ return startWpsRegistrar(NativeUtil.macAddressToByteArray(bssidStr), pin);
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Illegal argument " + bssidStr, e);
+ return false;
+ }
}
/** See ISupplicantStaIface.hal for documentation */
@@ -1333,7 +1374,12 @@ public class SupplicantStaIfaceHal {
* @return true if request is sent successfully, false otherwise.
*/
public boolean startWpsPbc(String bssidStr) {
- return startWpsPbc(NativeUtil.macAddressToByteArray(bssidStr));
+ try {
+ return startWpsPbc(NativeUtil.macAddressToByteArray(bssidStr));
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Illegal argument " + bssidStr, e);
+ return false;
+ }
}
/** See ISupplicantStaIface.hal for documentation */
@@ -1379,7 +1425,12 @@ public class SupplicantStaIfaceHal {
* @return new pin generated on success, null otherwise.
*/
public String startWpsPinDisplay(String bssidStr) {
- return startWpsPinDisplay(NativeUtil.macAddressToByteArray(bssidStr));
+ try {
+ return startWpsPinDisplay(NativeUtil.macAddressToByteArray(bssidStr));
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Illegal argument " + bssidStr, e);
+ return null;
+ }
}
/** See ISupplicantStaIface.hal for documentation */
diff --git a/service/java/com/android/server/wifi/SupplicantStaNetworkHal.java b/service/java/com/android/server/wifi/SupplicantStaNetworkHal.java
index 46f8c41b9..262725cc4 100644
--- a/service/java/com/android/server/wifi/SupplicantStaNetworkHal.java
+++ b/service/java/com/android/server/wifi/SupplicantStaNetworkHal.java
@@ -146,6 +146,7 @@ public class SupplicantStaNetworkHal {
* @param config WifiConfiguration object to be populated.
* @param networkExtras Map of network extras parsed from wpa_supplicant.
* @return true if succeeds, false otherwise.
+ * @throws IllegalArgumentException on malformed configuration params.
*/
public boolean loadWifiConfiguration(WifiConfiguration config,
Map<String, String> networkExtras) {
@@ -240,6 +241,7 @@ public class SupplicantStaNetworkHal {
*
* @param config WifiConfiguration object to be saved.
* @return true if succeeds, false otherwise.
+ * @throws IllegalArgumentException on malformed configuration params.
*/
public boolean saveWifiConfiguration(WifiConfiguration config) {
if (config == null) return false;
@@ -979,7 +981,12 @@ public class SupplicantStaNetworkHal {
* @return true if it succeeds, false otherwise.
*/
public boolean setBssid(String bssidStr) {
- return setBssid(NativeUtil.macAddressToByteArray(bssidStr));
+ try {
+ return setBssid(NativeUtil.macAddressToByteArray(bssidStr));
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Illegal argument " + bssidStr, e);
+ return false;
+ }
}
/** See ISupplicantStaNetwork.hal for documentation */
@@ -2082,36 +2089,41 @@ public class SupplicantStaNetworkHal {
* @return true if succeeds, false otherwise.
*/
public boolean sendNetworkEapSimGsmAuthResponse(String paramsStr) {
- Matcher match = GSM_AUTH_RESPONSE_PARAMS_PATTERN.matcher(paramsStr);
- ArrayList<ISupplicantStaNetwork.NetworkResponseEapSimGsmAuthParams> params =
- new ArrayList<>();
- while (match.find()) {
- if (match.groupCount() != 2) {
- Log.e(TAG, "Malformed gsm auth response params: " + paramsStr);
- return false;
- }
- ISupplicantStaNetwork.NetworkResponseEapSimGsmAuthParams param =
- new ISupplicantStaNetwork.NetworkResponseEapSimGsmAuthParams();
- byte[] kc = NativeUtil.hexStringToByteArray(match.group(1));
- if (kc == null || kc.length != param.kc.length) {
- Log.e(TAG, "Invalid kc value: " + match.group(1));
- return false;
+ try {
+ Matcher match = GSM_AUTH_RESPONSE_PARAMS_PATTERN.matcher(paramsStr);
+ ArrayList<ISupplicantStaNetwork.NetworkResponseEapSimGsmAuthParams> params =
+ new ArrayList<>();
+ while (match.find()) {
+ if (match.groupCount() != 2) {
+ Log.e(TAG, "Malformed gsm auth response params: " + paramsStr);
+ return false;
+ }
+ ISupplicantStaNetwork.NetworkResponseEapSimGsmAuthParams param =
+ new ISupplicantStaNetwork.NetworkResponseEapSimGsmAuthParams();
+ byte[] kc = NativeUtil.hexStringToByteArray(match.group(1));
+ if (kc == null || kc.length != param.kc.length) {
+ Log.e(TAG, "Invalid kc value: " + match.group(1));
+ return false;
+ }
+ byte[] sres = NativeUtil.hexStringToByteArray(match.group(2));
+ if (sres == null || sres.length != param.sres.length) {
+ Log.e(TAG, "Invalid sres value: " + match.group(2));
+ return false;
+ }
+ System.arraycopy(kc, 0, param.kc, 0, param.kc.length);
+ System.arraycopy(sres, 0, param.sres, 0, param.sres.length);
+ params.add(param);
}
- byte[] sres = NativeUtil.hexStringToByteArray(match.group(2));
- if (sres == null || sres.length != param.sres.length) {
- Log.e(TAG, "Invalid sres value: " + match.group(2));
+ // The number of kc/sres pairs can either be 2 or 3 depending on the request.
+ if (params.size() > 3 || params.size() < 2) {
+ Log.e(TAG, "Malformed gsm auth response params: " + paramsStr);
return false;
}
- System.arraycopy(kc, 0, param.kc, 0, param.kc.length);
- System.arraycopy(sres, 0, param.sres, 0, param.sres.length);
- params.add(param);
- }
- // The number of kc/sres pairs can either be 2 or 3 depending on the request.
- if (params.size() > 3 || params.size() < 2) {
- Log.e(TAG, "Malformed gsm auth response params: " + paramsStr);
+ return sendNetworkEapSimGsmAuthResponse(params);
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Illegal argument " + paramsStr, e);
return false;
}
- return sendNetworkEapSimGsmAuthResponse(params);
}
/** See ISupplicantStaNetwork.hal for documentation */
@@ -2151,35 +2163,41 @@ public class SupplicantStaNetworkHal {
* @return true if succeeds, false otherwise.
*/
public boolean sendNetworkEapSimUmtsAuthResponse(String paramsStr) {
- Matcher match = UMTS_AUTH_RESPONSE_PARAMS_PATTERN.matcher(paramsStr);
- if (!match.find() || match.groupCount() != 3) {
- Log.e(TAG, "Malformed umts auth response params: " + paramsStr);
- return false;
- }
- ISupplicantStaNetwork.NetworkResponseEapSimUmtsAuthParams params =
- new ISupplicantStaNetwork.NetworkResponseEapSimUmtsAuthParams();
- byte[] ik = NativeUtil.hexStringToByteArray(match.group(1));
- if (ik == null || ik.length != params.ik.length) {
- Log.e(TAG, "Invalid ik value: " + match.group(1));
- return false;
- }
- byte[] ck = NativeUtil.hexStringToByteArray(match.group(2));
- if (ck == null || ck.length != params.ck.length) {
- Log.e(TAG, "Invalid ck value: " + match.group(2));
- return false;
- }
- byte[] res = NativeUtil.hexStringToByteArray(match.group(3));
- if (res == null || res.length == 0) {
- Log.e(TAG, "Invalid res value: " + match.group(3));
+ try {
+ Matcher match = UMTS_AUTH_RESPONSE_PARAMS_PATTERN.matcher(paramsStr);
+ if (!match.find() || match.groupCount() != 3) {
+ Log.e(TAG, "Malformed umts auth response params: " + paramsStr);
+ return false;
+ }
+ ISupplicantStaNetwork.NetworkResponseEapSimUmtsAuthParams params =
+ new ISupplicantStaNetwork.NetworkResponseEapSimUmtsAuthParams();
+ byte[] ik = NativeUtil.hexStringToByteArray(match.group(1));
+ if (ik == null || ik.length != params.ik.length) {
+ Log.e(TAG, "Invalid ik value: " + match.group(1));
+ return false;
+ }
+ byte[] ck = NativeUtil.hexStringToByteArray(match.group(2));
+ if (ck == null || ck.length != params.ck.length) {
+ Log.e(TAG, "Invalid ck value: " + match.group(2));
+ return false;
+ }
+ byte[] res = NativeUtil.hexStringToByteArray(match.group(3));
+ if (res == null || res.length == 0) {
+ Log.e(TAG, "Invalid res value: " + match.group(3));
+ return false;
+ }
+ System.arraycopy(ik, 0, params.ik, 0, params.ik.length);
+ System.arraycopy(ck, 0, params.ck, 0, params.ck.length);
+ for (byte b : res) {
+ params.res.add(b);
+ }
+ return sendNetworkEapSimUmtsAuthResponse(params);
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Illegal argument " + paramsStr, e);
return false;
}
- System.arraycopy(ik, 0, params.ik, 0, params.ik.length);
- System.arraycopy(ck, 0, params.ck, 0, params.ck.length);
- for (byte b : res) {
- params.res.add(b);
- }
- return sendNetworkEapSimUmtsAuthResponse(params);
}
+
/** See ISupplicantStaNetwork.hal for documentation */
private boolean sendNetworkEapSimUmtsAuthResponse(
ISupplicantStaNetwork.NetworkResponseEapSimUmtsAuthParams params) {
@@ -2203,17 +2221,22 @@ public class SupplicantStaNetworkHal {
* @return true if succeeds, false otherwise.
*/
public boolean sendNetworkEapSimUmtsAutsResponse(String paramsStr) {
- Matcher match = UMTS_AUTS_RESPONSE_PARAMS_PATTERN.matcher(paramsStr);
- if (!match.find() || match.groupCount() != 1) {
- Log.e(TAG, "Malformed umts auts response params: " + paramsStr);
- return false;
- }
- byte[] auts = NativeUtil.hexStringToByteArray(match.group(1));
- if (auts == null || auts.length != 14) {
- Log.e(TAG, "Invalid auts value: " + match.group(1));
+ try {
+ Matcher match = UMTS_AUTS_RESPONSE_PARAMS_PATTERN.matcher(paramsStr);
+ if (!match.find() || match.groupCount() != 1) {
+ Log.e(TAG, "Malformed umts auts response params: " + paramsStr);
+ return false;
+ }
+ byte[] auts = NativeUtil.hexStringToByteArray(match.group(1));
+ if (auts == null || auts.length != 14) {
+ Log.e(TAG, "Invalid auts value: " + match.group(1));
+ return false;
+ }
+ return sendNetworkEapSimUmtsAutsResponse(auts);
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Illegal argument " + paramsStr, e);
return false;
}
- return sendNetworkEapSimUmtsAutsResponse(auts);
}
/** See ISupplicantStaNetwork.hal for documentation */
private boolean sendNetworkEapSimUmtsAutsResponse(byte[/* 14 */] auts) {
@@ -2251,8 +2274,13 @@ public class SupplicantStaNetworkHal {
* @return true if succeeds, false otherwise.
*/
public boolean sendNetworkEapIdentityResponse(String identityStr) {
- ArrayList<Byte> identity = NativeUtil.stringToByteArrayList(identityStr);
- return sendNetworkEapIdentityResponse(identity);
+ try {
+ ArrayList<Byte> identity = NativeUtil.stringToByteArrayList(identityStr);
+ return sendNetworkEapIdentityResponse(identity);
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Illegal argument " + identityStr, e);
+ return false;
+ }
}
/** See ISupplicantStaNetwork.hal for documentation */
private boolean sendNetworkEapIdentityResponse(ArrayList<Byte> identity) {
diff --git a/service/java/com/android/server/wifi/WifiVendorHal.java b/service/java/com/android/server/wifi/WifiVendorHal.java
index bca448fe1..8fb3bc3a0 100644
--- a/service/java/com/android/server/wifi/WifiVendorHal.java
+++ b/service/java/com/android/server/wifi/WifiVendorHal.java
@@ -1189,11 +1189,14 @@ public class WifiVendorHal {
static ArrayList<RttConfig> halRttConfigArrayFromFrameworkRttParamsArray(
RttManager.RttParams[] params) {
final int length = params.length;
- ArrayList<RttConfig> config = new ArrayList<RttConfig>(length);
+ ArrayList<RttConfig> configs = new ArrayList<RttConfig>(length);
for (int i = 0; i < length; i++) {
- config.add(halRttConfigFromFrameworkRttParams(params[i]));
+ RttConfig config = halRttConfigFromFrameworkRttParams(params[i]);
+ if (config != null) {
+ configs.add(config);
+ }
}
- return config;
+ return configs;
}
/**
@@ -1204,7 +1207,13 @@ public class WifiVendorHal {
* @return success indication
*/
public boolean requestRtt(RttManager.RttParams[] params, WifiNative.RttEventHandler handler) {
- ArrayList<RttConfig> rttConfigs = halRttConfigArrayFromFrameworkRttParamsArray(params);
+ ArrayList<RttConfig> rttConfigs;
+ try {
+ rttConfigs = halRttConfigArrayFromFrameworkRttParamsArray(params);
+ } catch (IllegalArgumentException e) {
+ mLog.err("Illegal argument for RTT request").c(e.toString()).flush();
+ return false;
+ }
synchronized (sLock) {
if (mIWifiRttController == null) return boolResult(false);
if (mRttCmdId != 0) return boolResult(false);
@@ -2286,6 +2295,9 @@ public class WifiVendorHal {
} catch (RemoteException e) {
handleRemoteException(e);
return false;
+ } catch (IllegalArgumentException e) {
+ mLog.err("Illegal argument for roaming configuration").c(e.toString()).flush();
+ return false;
}
return true;
}
diff --git a/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java b/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java
index 117dff6c0..fc63894b8 100644
--- a/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java
+++ b/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java
@@ -601,7 +601,7 @@ public class SupplicantP2pIfaceHal {
} catch (RemoteException e) {
Log.e(TAG, "ISupplicantP2pIface exception: " + e);
supplicantServiceDiedHandler();
- } catch (Exception e) {
+ } catch (IllegalArgumentException e) {
Log.e(TAG, "Could not decode SSID.", e);
return false;
}
@@ -1868,31 +1868,36 @@ public class SupplicantP2pIfaceHal {
* @return true if request is sent successfully, false otherwise.
*/
public boolean setWpsDeviceType(String typeStr) {
- Matcher match = WPS_DEVICE_TYPE_PATTERN.matcher(typeStr);
- if (!match.find() || match.groupCount() != 3) {
- Log.e(TAG, "Malformed WPS device type " + typeStr);
- return false;
- }
- short categ = Short.parseShort(match.group(1));
- byte[] oui = NativeUtil.hexStringToByteArray(match.group(2));
- short subCateg = Short.parseShort(match.group(3));
+ try {
+ Matcher match = WPS_DEVICE_TYPE_PATTERN.matcher(typeStr);
+ if (!match.find() || match.groupCount() != 3) {
+ Log.e(TAG, "Malformed WPS device type " + typeStr);
+ return false;
+ }
+ short categ = Short.parseShort(match.group(1));
+ byte[] oui = NativeUtil.hexStringToByteArray(match.group(2));
+ short subCateg = Short.parseShort(match.group(3));
- byte[] bytes = new byte[8];
- ByteBuffer byteBuffer = ByteBuffer.wrap(bytes).order(ByteOrder.BIG_ENDIAN);
- byteBuffer.putShort(categ);
- byteBuffer.put(oui);
- byteBuffer.putShort(subCateg);
- synchronized (mLock) {
- if (!checkSupplicantP2pIfaceAndLogFailure("setWpsDeviceType")) return false;
- SupplicantResult<Void> result = new SupplicantResult(
- "setWpsDeviceType(" + typeStr + ")");
- try {
- result.setResult(mISupplicantP2pIface.setWpsDeviceType(bytes));
- } catch (RemoteException e) {
- Log.e(TAG, "ISupplicantP2pIface exception: " + e);
- supplicantServiceDiedHandler();
+ byte[] bytes = new byte[8];
+ ByteBuffer byteBuffer = ByteBuffer.wrap(bytes).order(ByteOrder.BIG_ENDIAN);
+ byteBuffer.putShort(categ);
+ byteBuffer.put(oui);
+ byteBuffer.putShort(subCateg);
+ synchronized (mLock) {
+ if (!checkSupplicantP2pIfaceAndLogFailure("setWpsDeviceType")) return false;
+ SupplicantResult<Void> result = new SupplicantResult(
+ "setWpsDeviceType(" + typeStr + ")");
+ try {
+ result.setResult(mISupplicantP2pIface.setWpsDeviceType(bytes));
+ } catch (RemoteException e) {
+ Log.e(TAG, "ISupplicantP2pIface exception: " + e);
+ supplicantServiceDiedHandler();
+ }
+ return result.isSuccess();
}
- return result.isSuccess();
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Illegal argument " + typeStr, e);
+ return false;
}
}
@@ -1996,6 +2001,9 @@ public class SupplicantP2pIfaceHal {
} catch (RemoteException e) {
Log.e(TAG, "ISupplicantP2pIface exception: " + e);
supplicantServiceDiedHandler();
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Illegal argument " + selectMessage, e);
+ return false;
}
return result.isSuccess();
}
@@ -2019,6 +2027,9 @@ public class SupplicantP2pIfaceHal {
} catch (RemoteException e) {
Log.e(TAG, "ISupplicantP2pIface exception: " + e);
supplicantServiceDiedHandler();
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Illegal argument " + requestMessage, e);
+ return false;
}
return result.isSuccess();
}
@@ -2045,15 +2056,18 @@ public class SupplicantP2pIfaceHal {
}
SupplicantResult<Void> result = new SupplicantResult(
"setClientList(" + networkId + ", " + clientListStr + ")");
- ArrayList<byte[]> clients = new ArrayList<>();
- for (String clientStr : Arrays.asList(clientListStr.split("\\s+"))) {
- clients.add(NativeUtil.macAddressToByteArray(clientStr));
- }
try {
+ ArrayList<byte[]> clients = new ArrayList<>();
+ for (String clientStr : Arrays.asList(clientListStr.split("\\s+"))) {
+ clients.add(NativeUtil.macAddressToByteArray(clientStr));
+ }
result.setResult(network.setClientList(clients));
} catch (RemoteException e) {
Log.e(TAG, "ISupplicantP2pIface exception: " + e);
supplicantServiceDiedHandler();
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Illegal argument " + clientListStr, e);
+ return false;
}
return result.isSuccess();
}