summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Les Lee <lesl@google.com> 2022-10-26 20:56:47 +0800
committer Les Lee <lesl@google.com> 2022-12-06 10:28:25 +0800
commit0a5d73b3be4a1a725e609582b80377dc1f151c2f (patch)
tree2012d38ef549687c7121e6ea9c15165e30e70ab6
parent533e83f22e6b31c81043867f1ee0436926edfe0a (diff)
mock wifi (nl80211-framework#2): new constructor for mocking WifiNl80211Manager
To mock WifiNl80211Manager, it requires to have a new constructor to inject the mocked IWificond binder for mocking WifiNl80211Manager instance. Bug: 251763354 Test: Manual test Change-Id: I427696a26d611a9405fba1f478acef0ac6755b27
-rw-r--r--core/api/system-current.txt1
-rw-r--r--wifi/java/src/android/net/wifi/nl80211/WifiNl80211Manager.java15
2 files changed, 16 insertions, 0 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index c10504d9ee05..9d36353d9f11 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -9313,6 +9313,7 @@ package android.net.wifi.nl80211 {
}
public class WifiNl80211Manager {
+ ctor public WifiNl80211Manager(@NonNull android.content.Context, @NonNull android.os.IBinder);
method public void abortScan(@NonNull String);
method public void enableVerboseLogging(boolean);
method @NonNull public int[] getChannelsMhzForBand(int);
diff --git a/wifi/java/src/android/net/wifi/nl80211/WifiNl80211Manager.java b/wifi/java/src/android/net/wifi/nl80211/WifiNl80211Manager.java
index d85a5bdc3e66..5da18dc8ccad 100644
--- a/wifi/java/src/android/net/wifi/nl80211/WifiNl80211Manager.java
+++ b/wifi/java/src/android/net/wifi/nl80211/WifiNl80211Manager.java
@@ -393,6 +393,21 @@ public class WifiNl80211Manager {
mEventHandler = new Handler(context.getMainLooper());
}
+ /**
+ * Construct WifiNl80211Manager with giving context and binder which is an interface of
+ * IWificond.
+ *
+ * @param context Android context.
+ * @param binder a binder of IWificond.
+ */
+ public WifiNl80211Manager(@NonNull Context context, @NonNull IBinder binder) {
+ this(context);
+ mWificond = IWificond.Stub.asInterface(binder);
+ if (mWificond == null) {
+ Log.e(TAG, "Failed to get reference to wificond");
+ }
+ }
+
/** @hide */
@VisibleForTesting
public WifiNl80211Manager(Context context, IWificond wificond) {