Merge "[AWARE][CTS] Check for location setting for test needing to disable Wi-Fi" into oc-dev
am: ba16d61c91 Change-Id: I40dce2dfc27cb8cbbbbc61bf19f12d096a469d55
This commit is contained in:
@@ -37,7 +37,9 @@ import android.net.wifi.aware.WifiAwareManager;
|
|||||||
import android.net.wifi.aware.WifiAwareSession;
|
import android.net.wifi.aware.WifiAwareSession;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.test.AndroidTestCase;
|
import android.test.AndroidTestCase;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -74,6 +76,13 @@ public class SingleDeviceTest extends AndroidTestCase {
|
|||||||
// used to store any WifiAwareSession allocated during tests - will clean-up after tests
|
// used to store any WifiAwareSession allocated during tests - will clean-up after tests
|
||||||
private List<WifiAwareSession> mSessions = new ArrayList<>();
|
private List<WifiAwareSession> mSessions = new ArrayList<>();
|
||||||
|
|
||||||
|
// Return true if location is enabled.
|
||||||
|
private boolean isLocationEnabled() {
|
||||||
|
return Settings.Secure.getInt(getContext().getContentResolver(),
|
||||||
|
Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF) !=
|
||||||
|
Settings.Secure.LOCATION_MODE_OFF;
|
||||||
|
}
|
||||||
|
|
||||||
private class WifiAwareBroadcastReceiver extends BroadcastReceiver {
|
private class WifiAwareBroadcastReceiver extends BroadcastReceiver {
|
||||||
private CountDownLatch mBlocker = new CountDownLatch(1);
|
private CountDownLatch mBlocker = new CountDownLatch(1);
|
||||||
|
|
||||||
@@ -422,6 +431,18 @@ public class SingleDeviceTest extends AndroidTestCase {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isLocationEnabled()) {
|
||||||
|
/* Can't execute this test with location on since it means that Aware will not get
|
||||||
|
* disabled even if we disable Wi-Fi (which when location is enabled does not correspond
|
||||||
|
* to disabling the Wi-Fi chip).
|
||||||
|
*
|
||||||
|
* Considering other tests may require locationing to be enable we can't also fail the
|
||||||
|
* test in such a case. Hence it is skipped.
|
||||||
|
*/
|
||||||
|
Log.d(TAG, "Skipping test since location scans are enabled");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
IntentFilter intentFilter = new IntentFilter();
|
IntentFilter intentFilter = new IntentFilter();
|
||||||
intentFilter.addAction(WifiAwareManager.ACTION_WIFI_AWARE_STATE_CHANGED);
|
intentFilter.addAction(WifiAwareManager.ACTION_WIFI_AWARE_STATE_CHANGED);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user