• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.android.settings.wifi.tether;
2 
3 import android.net.wifi.WifiManager;
4 import android.os.Handler;
5 
6 /**
7  * Wrapper for {@link android.net.wifi.WifiManager.SoftApCallback} to pass the robo test
8  */
9 public class WifiTetherSoftApManager {
10 
11     private WifiManager mWifiManager;
12     private WifiTetherSoftApCallback mWifiTetherSoftApCallback;
13 
14     private WifiManager.SoftApCallback mSoftApCallback = new WifiManager.SoftApCallback() {
15         @Override
16         public void onStateChanged(int state, int failureReason) {
17             mWifiTetherSoftApCallback.onStateChanged(state, failureReason);
18         }
19 
20         @Override
21         public void onNumClientsChanged(int numClients) {
22             mWifiTetherSoftApCallback.onNumClientsChanged(numClients);
23         }
24     };
25     private Handler mHandler;
26 
WifiTetherSoftApManager(WifiManager wifiManager, WifiTetherSoftApCallback wifiTetherSoftApCallback)27     WifiTetherSoftApManager(WifiManager wifiManager,
28             WifiTetherSoftApCallback wifiTetherSoftApCallback) {
29         mWifiManager = wifiManager;
30         mWifiTetherSoftApCallback = wifiTetherSoftApCallback;
31         mHandler = new Handler();
32     }
33 
registerSoftApCallback()34     public void registerSoftApCallback() {
35         mWifiManager.registerSoftApCallback(mSoftApCallback, mHandler);
36     }
37 
unRegisterSoftApCallback()38     public void unRegisterSoftApCallback() {
39         mWifiManager.unregisterSoftApCallback(mSoftApCallback);
40     }
41 
42     public interface WifiTetherSoftApCallback {
onStateChanged(int state, int failureReason)43         void onStateChanged(int state, int failureReason);
44 
onNumClientsChanged(int numClients)45         void onNumClientsChanged(int numClients);
46     }
47 }
48