aboutsummaryrefslogtreecommitdiff
path: root/java/test/settings/src/com/google/android/chre/test/setting/ContextHubWwanSettingsTestExecutor.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/test/settings/src/com/google/android/chre/test/setting/ContextHubWwanSettingsTestExecutor.java')
-rw-r--r--java/test/settings/src/com/google/android/chre/test/setting/ContextHubWwanSettingsTestExecutor.java43
1 files changed, 4 insertions, 39 deletions
diff --git a/java/test/settings/src/com/google/android/chre/test/setting/ContextHubWwanSettingsTestExecutor.java b/java/test/settings/src/com/google/android/chre/test/setting/ContextHubWwanSettingsTestExecutor.java
index 02a33989..cf044915 100644
--- a/java/test/settings/src/com/google/android/chre/test/setting/ContextHubWwanSettingsTestExecutor.java
+++ b/java/test/settings/src/com/google/android/chre/test/setting/ContextHubWwanSettingsTestExecutor.java
@@ -16,10 +16,6 @@
package com.google.android.chre.test.setting;
import android.app.Instrumentation;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
import android.hardware.location.NanoAppBinary;
import androidx.test.InstrumentationRegistry;
@@ -29,9 +25,6 @@ import com.google.android.utils.chre.ChreTestUtil;
import org.junit.Assert;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
/**
* A test to check for behavior when WWAN settings are changed.
*/
@@ -42,19 +35,6 @@ public class ContextHubWwanSettingsTestExecutor {
private final Instrumentation mInstrumentation = InstrumentationRegistry.getInstrumentation();
- private class AirplaneModeListener {
- protected CountDownLatch mAirplaneModeLatch = new CountDownLatch(1);
-
- protected BroadcastReceiver mAirplaneModeReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(intent.getAction())) {
- mAirplaneModeLatch.countDown();
- }
- }
- };
- }
-
public ContextHubWwanSettingsTestExecutor(NanoAppBinary binary) {
mExecutor = new ContextHubSettingsTestExecutor(binary);
}
@@ -92,6 +72,7 @@ public class ContextHubWwanSettingsTestExecutor {
ChreTestUtil.executeShellCommand(
mInstrumentation, "cmd connectivity airplane-mode disable");
}
+ Assert.assertTrue(isAirplaneModeOn() == enable);
}
/**
@@ -99,27 +80,11 @@ public class ContextHubWwanSettingsTestExecutor {
* @param enableFeature True for enable.
*/
private void runTest(boolean enableFeature) {
- Context context = InstrumentationRegistry.getTargetContext();
- AirplaneModeListener listener = new AirplaneModeListener();
- context.registerReceiver(
- listener.mAirplaneModeReceiver,
- new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED));
-
- boolean airplaneModeExpected = !enableFeature;
- setAirplaneMode(airplaneModeExpected);
-
- if (isAirplaneModeOn() != airplaneModeExpected) {
- try {
- listener.mAirplaneModeLatch.await(5, TimeUnit.SECONDS);
- } catch (InterruptedException e) {
- Assert.fail(e.getMessage());
- }
- }
- context.unregisterReceiver(listener.mAirplaneModeReceiver);
- Assert.assertTrue(isAirplaneModeOn() == airplaneModeExpected);
+ setAirplaneMode(!enableFeature);
+ // Wait for the setting to propagate
try {
- Thread.sleep(5000); // wait for setting to propagate
+ Thread.sleep(10000);
} catch (InterruptedException e) {
Assert.fail(e.getMessage());
}