Merge change 6661 into donut
* changes: wifi: WifiManager.startScan() will now do passive scans by default.
This commit is contained in:
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
|
static jboolean sScanModeActive = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The following remembers the jfieldID's of the fields
|
* The following remembers the jfieldID's of the fields
|
||||||
* of the DhcpInfo Java object, so that we don't have
|
* of the DhcpInfo Java object, so that we don't have
|
||||||
@@ -254,27 +256,29 @@ static jboolean android_net_wifi_reassociateCommand(JNIEnv* env, jobject clazz)
|
|||||||
return doBooleanCommand("REASSOCIATE", "OK");
|
return doBooleanCommand("REASSOCIATE", "OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean android_net_wifi_scanCommand(JNIEnv* env, jobject clazz)
|
static jboolean doSetScanMode(jboolean setActive)
|
||||||
|
{
|
||||||
|
return doBooleanCommand((setActive ? "DRIVER SCAN-ACTIVE" : "DRIVER SCAN-PASSIVE"), "OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
static jboolean android_net_wifi_scanCommand(JNIEnv* env, jobject clazz, jboolean forceActive)
|
||||||
{
|
{
|
||||||
jboolean result;
|
jboolean result;
|
||||||
|
|
||||||
// Ignore any error from setting the scan mode.
|
// Ignore any error from setting the scan mode.
|
||||||
// The scan will still work.
|
// The scan will still work.
|
||||||
(void)doBooleanCommand("DRIVER SCAN-ACTIVE", "OK");
|
if (forceActive && !sScanModeActive)
|
||||||
|
doSetScanMode(true);
|
||||||
result = doBooleanCommand("SCAN", "OK");
|
result = doBooleanCommand("SCAN", "OK");
|
||||||
(void)doBooleanCommand("DRIVER SCAN-PASSIVE", "OK");
|
if (forceActive && !sScanModeActive)
|
||||||
|
doSetScanMode(sScanModeActive);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean android_net_wifi_setScanModeCommand(JNIEnv* env, jobject clazz, jboolean setActive)
|
static jboolean android_net_wifi_setScanModeCommand(JNIEnv* env, jobject clazz, jboolean setActive)
|
||||||
{
|
{
|
||||||
jboolean result;
|
sScanModeActive = setActive;
|
||||||
// Ignore any error from setting the scan mode.
|
return doSetScanMode(setActive);
|
||||||
// The scan will still work.
|
|
||||||
if (setActive) {
|
|
||||||
return doBooleanCommand("DRIVER SCAN-ACTIVE", "OK");
|
|
||||||
} else {
|
|
||||||
return doBooleanCommand("DRIVER SCAN-PASSIVE", "OK");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean android_net_wifi_startDriverCommand(JNIEnv* env, jobject clazz)
|
static jboolean android_net_wifi_startDriverCommand(JNIEnv* env, jobject clazz)
|
||||||
@@ -509,7 +513,7 @@ static JNINativeMethod gWifiMethods[] = {
|
|||||||
{ "disconnectCommand", "()Z", (void *)android_net_wifi_disconnectCommand },
|
{ "disconnectCommand", "()Z", (void *)android_net_wifi_disconnectCommand },
|
||||||
{ "reconnectCommand", "()Z", (void *)android_net_wifi_reconnectCommand },
|
{ "reconnectCommand", "()Z", (void *)android_net_wifi_reconnectCommand },
|
||||||
{ "reassociateCommand", "()Z", (void *)android_net_wifi_reassociateCommand },
|
{ "reassociateCommand", "()Z", (void *)android_net_wifi_reassociateCommand },
|
||||||
{ "scanCommand", "()Z", (void*) android_net_wifi_scanCommand },
|
{ "scanCommand", "(Z)Z", (void*) android_net_wifi_scanCommand },
|
||||||
{ "setScanModeCommand", "(Z)Z", (void*) android_net_wifi_setScanModeCommand },
|
{ "setScanModeCommand", "(Z)Z", (void*) android_net_wifi_setScanModeCommand },
|
||||||
{ "startDriverCommand", "()Z", (void*) android_net_wifi_startDriverCommand },
|
{ "startDriverCommand", "()Z", (void*) android_net_wifi_startDriverCommand },
|
||||||
{ "stopDriverCommand", "()Z", (void*) android_net_wifi_stopDriverCommand },
|
{ "stopDriverCommand", "()Z", (void*) android_net_wifi_stopDriverCommand },
|
||||||
|
|||||||
@@ -436,7 +436,7 @@ public class WifiService extends IWifiManager.Stub {
|
|||||||
* see {@link android.net.wifi.WifiManager#startScan()}
|
* see {@link android.net.wifi.WifiManager#startScan()}
|
||||||
* @return {@code true} if the operation succeeds
|
* @return {@code true} if the operation succeeds
|
||||||
*/
|
*/
|
||||||
public boolean startScan() {
|
public boolean startScan(boolean forceActive) {
|
||||||
enforceChangePermission();
|
enforceChangePermission();
|
||||||
synchronized (mWifiStateTracker) {
|
synchronized (mWifiStateTracker) {
|
||||||
switch (mWifiStateTracker.getSupplicantState()) {
|
switch (mWifiStateTracker.getSupplicantState()) {
|
||||||
@@ -450,7 +450,7 @@ public class WifiService extends IWifiManager.Stub {
|
|||||||
WifiStateTracker.SUPPL_SCAN_HANDLING_LIST_ONLY);
|
WifiStateTracker.SUPPL_SCAN_HANDLING_LIST_ONLY);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return WifiNative.scanCommand();
|
return WifiNative.scanCommand(forceActive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ interface IWifiManager
|
|||||||
|
|
||||||
boolean pingSupplicant();
|
boolean pingSupplicant();
|
||||||
|
|
||||||
boolean startScan();
|
boolean startScan(boolean forceActive);
|
||||||
|
|
||||||
List<ScanResult> getScanResults();
|
List<ScanResult> getScanResults();
|
||||||
|
|
||||||
|
|||||||
@@ -478,7 +478,25 @@ public class WifiManager {
|
|||||||
*/
|
*/
|
||||||
public boolean startScan() {
|
public boolean startScan() {
|
||||||
try {
|
try {
|
||||||
return mService.startScan();
|
return mService.startScan(false);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request a scan for access points. Returns immediately. The availability
|
||||||
|
* of the results is made known later by means of an asynchronous event sent
|
||||||
|
* on completion of the scan.
|
||||||
|
* This is a variant of startScan that forces an active scan, even if passive
|
||||||
|
* scans are the current default
|
||||||
|
* @return {@code true} if the operation succeeded, i.e., the scan was initiated
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public boolean startScanActive() {
|
||||||
|
try {
|
||||||
|
return mService.startScan(true);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class WifiNative {
|
|||||||
|
|
||||||
public native static boolean pingCommand();
|
public native static boolean pingCommand();
|
||||||
|
|
||||||
public native static boolean scanCommand();
|
public native static boolean scanCommand(boolean forceActive);
|
||||||
|
|
||||||
public native static boolean setScanModeCommand(boolean setActive);
|
public native static boolean setScanModeCommand(boolean setActive);
|
||||||
|
|
||||||
|
|||||||
@@ -1121,7 +1121,7 @@ public class WifiStateTracker extends NetworkStateTracker {
|
|||||||
} else {
|
} else {
|
||||||
// In some situations, supplicant needs to be kickstarted to
|
// In some situations, supplicant needs to be kickstarted to
|
||||||
// start the background scanning
|
// start the background scanning
|
||||||
WifiNative.scanCommand();
|
WifiNative.scanCommand(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user