Files
packages_apps_Settings/src/com/android/settings/wifi/tether/WifiTetherSoftApManager.java
James Mattis 90c23d2fe7 SoftApCallback using executor vs handler
Updating classes to support making SoftApCallback methods available to @SystemAPI including
the API for registration of a SoftApCallback which includes a change to
now use executor vs handler.

Bug: 143564153
Test: make RunSettingsRoboTests ROBOTEST_FILTER=WifiTetherPreferenceControllerTest
Also tested manually on a Pixel 3.

Change-Id: I952ad10dd88b7d97b3cd86b269b8f67b00b1fa15
Merged-In: I952ad10dd88b7d97b3cd86b269b8f67b00b1fa15
2019-11-13 21:39:26 -08:00

57 lines
1.7 KiB
Java

package com.android.settings.wifi.tether;
import android.net.wifi.WifiClient;
import android.net.wifi.WifiManager;
import android.os.Handler;
import android.os.HandlerExecutor;
import java.util.List;
/**
* Wrapper for {@link android.net.wifi.WifiManager.SoftApCallback} to pass the robo test
*/
public class WifiTetherSoftApManager {
private WifiManager mWifiManager;
private WifiTetherSoftApCallback mWifiTetherSoftApCallback;
private WifiManager.SoftApCallback mSoftApCallback = new WifiManager.SoftApCallback() {
@Override
public void onStateChanged(int state, int failureReason) {
mWifiTetherSoftApCallback.onStateChanged(state, failureReason);
}
@Override
public void onConnectedClientsChanged(List<WifiClient> clients) {
mWifiTetherSoftApCallback.onConnectedClientsChanged(clients);
}
};
private Handler mHandler;
WifiTetherSoftApManager(WifiManager wifiManager,
WifiTetherSoftApCallback wifiTetherSoftApCallback) {
mWifiManager = wifiManager;
mWifiTetherSoftApCallback = wifiTetherSoftApCallback;
mHandler = new Handler();
}
public void registerSoftApCallback() {
mWifiManager.registerSoftApCallback(mSoftApCallback, new HandlerExecutor(mHandler));
}
public void unRegisterSoftApCallback() {
mWifiManager.unregisterSoftApCallback(mSoftApCallback);
}
public interface WifiTetherSoftApCallback {
void onStateChanged(int state, int failureReason);
/**
* Called when the connected clients to soft AP changes.
*
* @param clients the currently connected clients
*/
void onConnectedClientsChanged(List<WifiClient> clients);
}
}