diff options
author | youngtaecha <youngtaecha@google.com> | 2023-11-09 05:04:55 +0000 |
---|---|---|
committer | Youngtae Cha <youngtaecha@google.com> | 2023-11-09 05:55:42 +0000 |
commit | ec8a74d4ee471658b24162e4320a6f047bef0f7b (patch) | |
tree | f3eb69f74cd4fe7176aa3ba38d8ab9dd5a4c4018 | |
parent | 25410eb3c4c93094741e1dea15c4fe2f1b52940e (diff) | |
download | CellBroadcastReceiver-ec8a74d4ee471658b24162e4320a6f047bef0f7b.tar.gz |
Set test roaming operator(00101) for the compliancetest.
Bug: 309166024,309166053
Test: atest CellBroadcastReceiverComplianceTests
Test: http://ab/I44800010214892867
Test: http://ab/I36500010215029688
Change-Id: Ib9212d4696d66902fc2dcca5475625ae728506e7
-rw-r--r-- | tests/compliancetests/src/com/android/cellbroadcastreceiver/compliancetests/CellBroadcastBaseTest.java | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/compliancetests/src/com/android/cellbroadcastreceiver/compliancetests/CellBroadcastBaseTest.java b/tests/compliancetests/src/com/android/cellbroadcastreceiver/compliancetests/CellBroadcastBaseTest.java index a0c47df05..070c5d064 100644 --- a/tests/compliancetests/src/com/android/cellbroadcastreceiver/compliancetests/CellBroadcastBaseTest.java +++ b/tests/compliancetests/src/com/android/cellbroadcastreceiver/compliancetests/CellBroadcastBaseTest.java @@ -93,6 +93,7 @@ public class CellBroadcastBaseTest { protected static String sPackageName = null; protected static IRadioMessagingImpl.CallBackWithExecutor sCallBackWithExecutor = null; + protected static String sBackUpRoamingNetwork = ""; protected static Context getContext() { return InstrumentationRegistry.getInstrumentation().getContext(); @@ -203,6 +204,10 @@ public class CellBroadcastBaseTest { sDevice = UiDevice.getInstance(sInstrumentation); sPackageName = CellBroadcastUtils .getDefaultCellBroadcastReceiverPackageName(getContext()); + + setTestRoamingOperator(true); + enableAirplaneMode(true); + enableAirplaneMode(false); } private static void waitForNotify() { @@ -216,6 +221,17 @@ public class CellBroadcastBaseTest { } } + private static void waitForNotify(int milliSeconds) { + while (sSetChannelIsDone.getCount() > 0) { + try { + sSetChannelIsDone.await(milliSeconds, TimeUnit.MILLISECONDS); + sSetChannelIsDone.countDown(); + } catch (InterruptedException e) { + // do nothing + } + } + } + @AfterClass public static void afterAllTests() throws Exception { logd("CellBroadcastBaseTest#afterAllTests()"); @@ -231,6 +247,8 @@ public class CellBroadcastBaseTest { assertTrue(sMockModemManager.disconnectMockModemService()); sMockModemManager = null; } + + setTestRoamingOperator(false); } @Rule @@ -308,6 +326,47 @@ public class CellBroadcastBaseTest { return result.toArray(new Object[]{}); } + protected static void enableDualSim(boolean enable) throws Exception { + if (enable) { + sDevice.executeShellCommand("root"); + sDevice.executeShellCommand("setprop persist.radio.multisim.config ss"); + sDevice.executeShellCommand("reboot"); + } else { + sDevice.executeShellCommand("root"); + sDevice.executeShellCommand("setprop persist.radio.multisim.config dsds"); + } + } + + protected static void enableAirplaneMode(boolean on) throws Exception { + if (on) { + logd("airplane mode on"); + sDevice.executeShellCommand("settings put global airplane_mode_on 1"); + sDevice.executeShellCommand("am broadcast -a android.intent.action.AIRPLANE_MODE"); + waitForNotify(2000); + } else { + logd("airplane mode off"); + sDevice.executeShellCommand("settings put global airplane_mode_on 0"); + sDevice.executeShellCommand("am broadcast -a android.intent.action.AIRPLANE_MODE"); + waitForNotify(2000); + } + } + + protected static void setTestRoamingOperator(boolean save) throws Exception { + if (save) { + logd("setTestRoamingOperator: 00101"); + sBackUpRoamingNetwork = sDevice.executeShellCommand( + "getprop persist.cellbroadcast.roaming_plmn_supported"); + logd("backup roaming network is " + sBackUpRoamingNetwork); + sDevice.executeShellCommand( + "setprop persist.cellbroadcast.roaming_plmn_supported 00101"); + } else { + logd("restore TestRoamingOperator: " + sBackUpRoamingNetwork); + sDevice.executeShellCommand( + "setprop persist.cellbroadcast.roaming_plmn_supported " + + sBackUpRoamingNetwork); + } + } + protected void setSimInfo(String carrierName, String inputMccMnc) throws Throwable { String mcc = inputMccMnc.substring(0, 3); String mnc = inputMccMnc.substring(3); |