summaryrefslogtreecommitdiff
path: root/wifi/java
diff options
context:
space:
mode:
authorlesl <lesl@google.com>2020-12-19 23:53:59 +0800
committerlesl <lesl@google.com>2020-12-23 12:42:19 +0800
commite5436af58ca25daef3f22d707346fb368238e69c (patch)
treec393e42bda2af40a29227550040e1a62fe72c344 /wifi/java
parent54028c118f7383e5e949afe6775068ff57608955 (diff)
wifi: Add callback onConnectedClientsOrInfoChanged handling
Now service will only send onConnectedClientsOrInfoChanged to Manager side. Add callback handling to dispatch correct callback base on below scenarios. 1. onInfoChanged(SoftApInfo) will send when a. registration (non bridged) b. non bridged and info changed 2. onInfoChanged(List) will send when a. registration b. info changed 3. onConnectedClientsChanged(List<WifiClient>) will send a. registration b. clients changed 4. onConnectedClientsChanged(SoftApInfo, List<WifiClient>) will send a. when registration and client connected b. client changed on specific instance. It will also need to handle when info changed(dismisssed), it means that an instance shutdown. It needs to send empty list if previous instance has client connected. AP+AP Part 6 includes: Support dual SoftApInfo callback a. New callback onInfoChanged(List<SoftApInfo>) & onConnectedClientsChanged(SoftApInfo, List<WifiClient>) b. Callback refactoring c. Support shutdown idle instance in bridged mode Bug: 162686273 Bug: 175351193 Test: FrameworksWifiApiTests Test: Manual Test, check the log and check SystemUI to confirm clients update correctly. Change-Id: Id587125edbb1167f58bba6b50a708be12888490f
Diffstat (limited to 'wifi/java')
-rw-r--r--wifi/java/android/net/wifi/WifiManager.java80
1 files changed, 70 insertions, 10 deletions
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index b5baee5b42a6..d7fcd54c9534 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -4039,7 +4039,7 @@ public class WifiManager {
* Note: this API is only valid when the Soft AP is configured as a single AP
* - not as a bridged AP (2 Soft APs). When the Soft AP is configured as bridged AP
* this callback will not be triggered - use the
- * {@link #onInfoListChanged(List<SoftApInfo>)} callback in bridged AP mode.
+ * {@link #onInfoChanged(List<SoftApInfo>)} callback in bridged AP mode.
*
* @param softApInfo is the softap information. {@link SoftApInfo}
*/
@@ -4105,6 +4105,7 @@ public class WifiManager {
private final Executor mExecutor;
private final SoftApCallback mCallback;
private Map<String, List<WifiClient>> mCurrentClients = new HashMap<>();
+ private Map<String, SoftApInfo> mCurrentInfos = new HashMap<>();
private List<WifiClient> getConnectedClientList(Map<String, List<WifiClient>> clientsMap) {
List<WifiClient> connectedClientList = new ArrayList<>();
@@ -4132,22 +4133,81 @@ public class WifiManager {
});
}
- // TODO: b/175351193, integrate callbacks to simplify the logic.
@Override
public void onConnectedClientsOrInfoChanged(Map<String, SoftApInfo> infos,
Map<String, List<WifiClient>> clients, boolean isBridged, boolean isRegistration) {
if (mVerboseLoggingEnabled) {
- Log.v(TAG, "SoftApCallbackProxy: onConnectedClientsChanged: clients="
- + clients + " infos" + infos + "isBridged is " + isBridged
- + "isRegistration is " + isRegistration);
+ Log.v(TAG, "SoftApCallbackProxy: onConnectedClientsOrInfoChanged: clients: "
+ + clients + ", infos: " + infos + ", isBridged is " + isBridged
+ + ", isRegistration is " + isRegistration);
+ }
+
+ List<SoftApInfo> changedInfoList = new ArrayList<>(infos.values());
+ Map<SoftApInfo, List<WifiClient>> changedInfoClients = new HashMap<>();
+ boolean isInfoChanged = infos.size() != mCurrentInfos.size();
+ for (SoftApInfo info : mCurrentInfos.values()) {
+ String changedInstance = info.getApInstanceIdentifier();
+ if (!changedInfoList.contains(info)) {
+ isInfoChanged = true;
+ if (mCurrentClients.getOrDefault(changedInstance,
+ Collections.emptyList()).size() > 0) {
+ Log.d(TAG, "SoftApCallbackProxy: info changed on client connected"
+ + " instance(Shut Down case)");
+ //Here should notify client changed on old info
+ changedInfoClients.put(info, Collections.emptyList());
+ }
+ } else {
+ // info doesn't change, check client list
+ List<WifiClient> changedClientList = clients.getOrDefault(
+ changedInstance, Collections.emptyList());
+ if (changedClientList.size()
+ != mCurrentClients
+ .getOrDefault(changedInstance, Collections.emptyList()).size()) {
+ // Here should notify client changed on new info(same as old info)
+ changedInfoClients.put(info, changedClientList);
+ Log.d(TAG, "SoftApCallbackProxy: client changed on " + info
+ + " list: " + changedClientList);
+ }
+ }
+ }
+
+ if (!isInfoChanged && changedInfoClients.isEmpty()
+ && !isRegistration) {
+ Log.v(TAG, "SoftApCallbackProxy: No changed & Not Registration,"
+ + " don't need to notify the client");
+ return;
}
- // TODO: b/175351193 Now handle onConnectedClientsChanged in single AP mode first
- boolean shouldSendOnConnectedClientsChanged = isRegistration
- || (getConnectedClientList(mCurrentClients).size()
- != getConnectedClientList(clients).size());
mCurrentClients = clients;
+ mCurrentInfos = infos;
Binder.clearCallingIdentity();
- if (shouldSendOnConnectedClientsChanged) {
+ // Notify the clients changed first for old info shutdown case
+ for (SoftApInfo changedInfo : changedInfoClients.keySet()) {
+ Log.v(TAG, "send onConnectedClientsChanged, changedInfo is " + changedInfo);
+ mExecutor.execute(() -> {
+ mCallback.onConnectedClientsChanged(
+ changedInfo, changedInfoClients.get(changedInfo));
+ });
+ }
+
+ if (isInfoChanged || isRegistration) {
+ if (!isBridged) {
+ SoftApInfo newInfo = changedInfoList.isEmpty()
+ ? new SoftApInfo() : changedInfoList.get(0);
+ Log.v(TAG, "SoftApCallbackProxy: send InfoChanged, newInfo: " + newInfo);
+ mExecutor.execute(() -> {
+ mCallback.onInfoChanged(newInfo);
+ });
+ }
+ Log.v(TAG, "SoftApCallbackProxy: send InfoChanged, changedInfoList: "
+ + changedInfoList);
+ mExecutor.execute(() -> {
+ mCallback.onInfoChanged(changedInfoList);
+ });
+ }
+
+ if (isRegistration || !changedInfoClients.isEmpty()) {
+ Log.v(TAG, "SoftApCallbackProxy: send onConnectedClientsChanged(clients): "
+ + getConnectedClientList(clients));
mExecutor.execute(() -> {
mCallback.onConnectedClientsChanged(getConnectedClientList(clients));
});