diff options
author | Sarah Chin <sarahchin@google.com> | 2021-09-08 16:12:28 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2021-09-08 16:12:28 +0000 |
commit | 69e29e00df3dd5eb2b674c24a12391d72012dd8b (patch) | |
tree | a9f31ecb8903bddd04d1b456ac36b1487d2fbd0f | |
parent | b4bba0e395afca2cbea1c01e6cbf8716209a1b54 (diff) | |
parent | 3250a7fec4434739403361e0f726e546d33c103b (diff) | |
download | cts-android-s-beta-5.tar.gz |
Merge "Add CTS for requestModemActivityInfo"android-s-beta-5android-s-beta-5
-rw-r--r-- | tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java b/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java index 7ec5f67edcb..b95ccb018bf 100644 --- a/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java +++ b/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java @@ -68,6 +68,7 @@ import android.telephony.CellIdentityNr; import android.telephony.CellInfo; import android.telephony.CellLocation; import android.telephony.DataThrottlingRequest; +import android.telephony.ModemActivityInfo; import android.telephony.NetworkRegistrationInfo; import android.telephony.PhoneCapability; import android.telephony.PhoneStateListener; @@ -114,6 +115,7 @@ import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.LinkedBlockingQueue; @@ -3001,6 +3003,40 @@ public class TelephonyManagerTest { } @Test + public void testRequestModemActivityInfo() throws Exception { + if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) { + return; + } + + InstrumentationRegistry.getInstrumentation().getUiAutomation() + .adoptShellPermissionIdentity("android.permission.MODIFY_PHONE_STATE"); + try { + // Get one instance of activity info and make sure it's valid + CompletableFuture<ModemActivityInfo> future1 = new CompletableFuture<>(); + mTelephonyManager.requestModemActivityInfo(getContext().getMainExecutor(), + future1::complete); + ModemActivityInfo activityInfo1 = future1.get(TOLERANCE, TimeUnit.MILLISECONDS); + assertNotNull(activityInfo1); + assertTrue("first activity info is" + activityInfo1, activityInfo1.isValid()); + + // Wait a bit, then get another instance to make sure that some info has accumulated + CompletableFuture<ModemActivityInfo> future2 = new CompletableFuture<>(); + mTelephonyManager.requestModemActivityInfo(getContext().getMainExecutor(), + future2::complete); + ModemActivityInfo activityInfo2 = future2.get(TOLERANCE, TimeUnit.MILLISECONDS); + assertNotNull(activityInfo2); + assertTrue("second activity info is" + activityInfo2, activityInfo2.isValid()); + + ModemActivityInfo diff = activityInfo1.getDelta(activityInfo2); + assertNotNull(diff); + assertTrue("diff is" + diff, diff.isValid() || diff.isEmpty()); + } finally { + InstrumentationRegistry.getInstrumentation().getUiAutomation() + .dropShellPermissionIdentity(); + } + } + + @Test public void testGetSupportedModemCount() { if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) { return; |