Fields Summary |
---|
public static final int | WIFI_BAND_UNSPECIFIEDno band specified; use channel list instead |
public static final int | WIFI_BAND_24_GHZ2.4 GHz band |
public static final int | WIFI_BAND_5_GHZ5 GHz band excluding DFS channels |
public static final int | WIFI_BAND_5_GHZ_DFS_ONLYDFS channels from 5 GHz band only |
public static final int | WIFI_BAND_5_GHZ_WITH_DFS5 GHz band including DFS channels |
public static final int | WIFI_BAND_BOTHBoth 2.4 GHz band and 5 GHz band; no DFS channels |
public static final int | WIFI_BAND_BOTH_WITH_DFSBoth 2.4 GHz band and 5 GHz band; with DFS channels |
public static final int | MIN_SCAN_PERIOD_MSMinimum supported scanning period |
public static final int | MAX_SCAN_PERIOD_MSMaximum supported scanning period |
public static final int | REASON_SUCCEEDEDNo Error |
public static final int | REASON_UNSPECIFIEDUnknown error |
public static final int | REASON_INVALID_LISTENERInvalid listener |
public static final int | REASON_INVALID_REQUESTInvalid request |
public static final int | REASON_NOT_AUTHORIZEDInvalid request |
public static final String | GET_AVAILABLE_CHANNELS_EXTRA |
public static final int | REPORT_EVENT_AFTER_BUFFER_FULLreports {@link ScanListener#onResults} when underlying buffers are full |
public static final int | REPORT_EVENT_AFTER_EACH_SCANreports {@link ScanListener#onResults} after each scan |
public static final int | REPORT_EVENT_FULL_SCAN_RESULTreports {@link ScanListener#onFullResult} whenever each beacon is discovered |
private static final String | TAG |
private static final boolean | DBG |
private static final int | BASE |
public static final int | CMD_SCAN |
public static final int | CMD_START_BACKGROUND_SCAN |
public static final int | CMD_STOP_BACKGROUND_SCAN |
public static final int | CMD_GET_SCAN_RESULTS |
public static final int | CMD_SCAN_RESULT |
public static final int | CMD_SET_HOTLIST |
public static final int | CMD_RESET_HOTLIST |
public static final int | CMD_AP_FOUND |
public static final int | CMD_AP_LOST |
public static final int | CMD_START_TRACKING_CHANGE |
public static final int | CMD_STOP_TRACKING_CHANGE |
public static final int | CMD_CONFIGURE_WIFI_CHANGE |
public static final int | CMD_WIFI_CHANGE_DETECTED |
public static final int | CMD_WIFI_CHANGES_STABILIZED |
public static final int | CMD_OP_SUCCEEDED |
public static final int | CMD_OP_FAILED |
public static final int | CMD_PERIOD_CHANGED |
public static final int | CMD_FULL_SCAN_RESULT |
private android.content.Context | mContext |
private IWifiScanner | mService |
private static final int | INVALID_KEY |
private static int | sListenerKey |
private static final android.util.SparseArray | sListenerMap |
private static final Object | sListenerMapLock |
private static com.android.internal.util.AsyncChannel | sAsyncChannel |
private static CountDownLatch | sConnected |
private static final Object | sThreadRefLock |
private static int | sThreadRefCount |
private static android.os.HandlerThread | sHandlerThread |
Methods Summary |
---|
public void | configureWifiChange(int rssiSampleSize, int lostApSampleSize, int unchangedSampleSize, int minApsBreachingThreshold, int periodInMs, android.net.wifi.WifiScanner$BssidInfo[] bssidInfos)configure WifiChange detection
/* sample size for RSSI averaging */
/* samples to confirm AP's loss */
/* samples to confirm no change */
/* change threshold to trigger event */
/* period of scan */
/* signal thresholds to crosss */
validateChannel();
WifiChangeSettings settings = new WifiChangeSettings();
settings.rssiSampleSize = rssiSampleSize;
settings.lostApSampleSize = lostApSampleSize;
settings.unchangedSampleSize = unchangedSampleSize;
settings.minApsBreachingThreshold = minApsBreachingThreshold;
settings.periodInMs = periodInMs;
settings.bssidInfos = bssidInfos;
configureWifiChange(settings);
|
public void | configureWifiChange(android.net.wifi.WifiScanner$WifiChangeSettings settings)
validateChannel();
sAsyncChannel.sendMessage(CMD_CONFIGURE_WIFI_CHANGE, 0, 0, settings);
|
public java.util.List | getAvailableChannels(int band)gives you all the possible channels; channel is specified as an
integer with frequency in MHz i.e. channel 1 is 2412
try {
Bundle bundle = mService.getAvailableChannels(band);
return bundle.getIntegerArrayList(GET_AVAILABLE_CHANNELS_EXTRA);
} catch (RemoteException e) {
return null;
}
|
private static java.lang.Object | getListener(int key)
if (key == INVALID_KEY) return null;
synchronized (sListenerMapLock) {
Object listener = sListenerMap.get(key);
return listener;
}
|
private static int | getListenerKey(java.lang.Object listener)
if (listener == null) return INVALID_KEY;
synchronized (sListenerMapLock) {
int index = sListenerMap.indexOfValue(listener);
if (index == -1) {
return INVALID_KEY;
} else {
return sListenerMap.keyAt(index);
}
}
|
public ScanResult[] | getScanResults()retrieves currently available scan results
validateChannel();
Message reply = sAsyncChannel.sendMessageSynchronously(CMD_GET_SCAN_RESULTS, 0);
ScanResult[] results = (ScanResult[]) reply.obj;
return results;
|
private void | init()
synchronized (sThreadRefLock) {
if (++sThreadRefCount == 1) {
Messenger messenger = null;
try {
messenger = mService.getMessenger();
} catch (RemoteException e) {
/* do nothing */
} catch (SecurityException e) {
/* do nothing */
}
if (messenger == null) {
sAsyncChannel = null;
return;
}
sHandlerThread = new HandlerThread("WifiScanner");
sAsyncChannel = new AsyncChannel();
sConnected = new CountDownLatch(1);
sHandlerThread.start();
Handler handler = new ServiceHandler(sHandlerThread.getLooper());
sAsyncChannel.connect(mContext, handler, messenger);
try {
sConnected.await();
} catch (InterruptedException e) {
Log.e(TAG, "interrupted wait at init");
}
}
}
|
private static int | putListener(java.lang.Object listener)
if (listener == null) return INVALID_KEY;
int key;
synchronized (sListenerMapLock) {
do {
key = sListenerKey++;
} while (key == INVALID_KEY);
sListenerMap.put(key, listener);
}
return key;
|
private static java.lang.Object | removeListener(int key)
if (key == INVALID_KEY) return null;
synchronized (sListenerMapLock) {
Object listener = sListenerMap.get(key);
sListenerMap.remove(key);
return listener;
}
|
private static int | removeListener(java.lang.Object listener)
int key = getListenerKey(listener);
if (key == INVALID_KEY) return key;
synchronized (sListenerMapLock) {
sListenerMap.remove(key);
return key;
}
|
public void | startBackgroundScan(android.net.wifi.WifiScanner$ScanSettings settings, android.net.wifi.WifiScanner$ScanListener listener)start wifi scan in background
validateChannel();
sAsyncChannel.sendMessage(CMD_START_BACKGROUND_SCAN, 0, putListener(listener), settings);
|
public void | startTrackingBssids(android.net.wifi.WifiScanner$BssidInfo[] bssidInfos, int apLostThreshold, android.net.wifi.WifiScanner$BssidListener listener)set interesting access points to find
validateChannel();
HotlistSettings settings = new HotlistSettings();
settings.bssidInfos = bssidInfos;
sAsyncChannel.sendMessage(CMD_SET_HOTLIST, 0, putListener(listener), settings);
|
public void | startTrackingWifiChange(android.net.wifi.WifiScanner$WifiChangeListener listener)track changes in wifi environment
validateChannel();
sAsyncChannel.sendMessage(CMD_START_TRACKING_CHANGE, 0, putListener(listener));
|
public void | stopBackgroundScan(android.net.wifi.WifiScanner$ScanListener listener)stop an ongoing wifi scan
validateChannel();
sAsyncChannel.sendMessage(CMD_STOP_BACKGROUND_SCAN, 0, removeListener(listener));
|
public void | stopTrackingBssids(android.net.wifi.WifiScanner$BssidListener listener)remove tracking of interesting access points
validateChannel();
sAsyncChannel.sendMessage(CMD_RESET_HOTLIST, 0, removeListener(listener));
|
public void | stopTrackingWifiChange(android.net.wifi.WifiScanner$WifiChangeListener listener)stop tracking changes in wifi environment
validateChannel();
sAsyncChannel.sendMessage(CMD_STOP_TRACKING_CHANGE, 0, removeListener(listener));
|
private void | validateChannel()
if (sAsyncChannel == null) throw new IllegalStateException(
"No permission to access and change wifi or a bad initialization");
|