summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-01-10 07:58:40 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-01-10 07:58:40 +0000
commit754475229c25766f0278b410b3f364a86049f531 (patch)
tree3400368f63b82f2e1ffcb9bf570ee16f0cfe2cd5 /service
parent0899cadb4c3f6c60270a1ae6612c4ac9a6be8ce7 (diff)
parent7c045dc803fbbe100420c23c120097197ae1d724 (diff)
Merge "p2p: Integrate check and get methods for P2pIfaceV1_2"
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java31
1 files changed, 19 insertions, 12 deletions
diff --git a/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java b/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java
index 3e3962807..c48a6c358 100644
--- a/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java
+++ b/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java
@@ -512,14 +512,20 @@ public class SupplicantP2pIfaceHal {
}
/**
- * Returns false if SupplicantP2pIface is null, and logs failure to call methodStr
+ * Returns SupplicantP2pIface on success, logs failure to call methodStr
+ * and returns false otherwise
*/
- private boolean checkSupplicantP2pIfaceAndLogFailureV1_2(String method) {
- if (getP2pIfaceMockableV1_2() == null) {
- Log.e(TAG, "Can't call " + method + ": ISupplicantP2pIface is null");
- return false;
+ private android.hardware.wifi.supplicant.V1_2.ISupplicantP2pIface
+ getSupplicantP2pIfaceAndLogFailureV1_2(String method) {
+ synchronized (mLock) {
+ android.hardware.wifi.supplicant.V1_2.ISupplicantP2pIface p2pIfaceV12 =
+ getP2pIfaceMockableV1_2();
+ if (p2pIfaceV12 == null) {
+ Log.e(TAG, "Can't call " + method + ": ISupplicantP2pIface is null");
+ return null;
+ }
+ return p2pIfaceV12;
}
- return true;
}
private int wpsInfoToConfigMethod(int info) {
@@ -1195,7 +1201,10 @@ public class SupplicantP2pIfaceHal {
public boolean groupAdd(String networkName, String passphrase,
boolean isPersistent, int freq, String peerAddress, boolean join) {
synchronized (mLock) {
- if (!checkSupplicantP2pIfaceAndLogFailureV1_2("groupAdd_1_2")) return false;
+ android.hardware.wifi.supplicant.V1_2.ISupplicantP2pIface ifaceV12 =
+ getSupplicantP2pIfaceAndLogFailureV1_2("groupAdd_1_2");
+ if (ifaceV12 == null) return false;
+
java.util.ArrayList<Byte> ssid = NativeUtil.decodeSsid("\"" + networkName + "\"");
byte[] macAddress = null;
try {
@@ -1205,8 +1214,6 @@ public class SupplicantP2pIfaceHal {
return false;
}
- android.hardware.wifi.supplicant.V1_2.ISupplicantP2pIface ifaceV12 =
- getP2pIfaceMockableV1_2();
SupplicantResult<Void> result =
new SupplicantResult("groupAdd(" + networkName + ", "
+ (TextUtils.isEmpty(passphrase) ? "<Empty>" : "<Non-Empty>")
@@ -2369,10 +2376,10 @@ public class SupplicantP2pIfaceHal {
*/
public boolean setMacRandomization(boolean enable) {
synchronized (mLock) {
- if (!checkSupplicantP2pIfaceAndLogFailureV1_2("setMacRandomization")) return false;
-
android.hardware.wifi.supplicant.V1_2.ISupplicantP2pIface ifaceV12 =
- getP2pIfaceMockableV1_2();
+ getSupplicantP2pIfaceAndLogFailureV1_2("setMacRandomization");
+ if (ifaceV12 == null) return false;
+
SupplicantResult<Void> result = new SupplicantResult(
"setMacRandomization(" + enable + ")");
try {