Update device ID access tests to include getNai
Bug: 131188555
Test: atest TelephonyManagerTest
Change-Id: I3940b82e12612381f8a9be5024af488a8a4cf3fc
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 739076f..f9cc32e 100644
--- a/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java
@@ -449,7 +449,7 @@
mTelephonyManager.getPhoneCount();
mTelephonyManager.getDataEnabled();
mTelephonyManager.getNetworkSpecifier();
- mTelephonyManager.getNai();
+ ShellIdentityUtils.invokeMethodWithShellPermissions(mTelephonyManager, (tm) -> tm.getNai());
TelecomManager telecomManager = getContext().getSystemService(TelecomManager.class);
PhoneAccountHandle defaultAccount = telecomManager
.getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_TEL);
diff --git a/tests/tests/telephony3/src/android/telephony3/cts/TelephonyManagerTest.java b/tests/tests/telephony3/src/android/telephony3/cts/TelephonyManagerTest.java
index cd960b8..57f2e9b 100644
--- a/tests/tests/telephony3/src/android/telephony3/cts/TelephonyManagerTest.java
+++ b/tests/tests/telephony3/src/android/telephony3/cts/TelephonyManagerTest.java
@@ -23,7 +23,6 @@
import android.content.Context;
import android.os.Build;
import android.telephony.TelephonyManager;
-import android.util.Log;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
@@ -76,6 +75,10 @@
"An app targeting pre-Q with the READ_PHONE_STATE permission granted must "
+ "receive null when invoking getSimSerialNumber",
mTelephonyManager.getSimSerialNumber());
+ assertNull(
+ "An app targeting pre-Q with the READ_PHONE_STATE permission granted must "
+ + "receive null when invoking getNai",
+ mTelephonyManager.getNai());
// Since Build.getSerial is not documented to return null in previous releases this test
// verifies that the Build.UNKNOWN value is returned when the caller does not have
// permission to access the device identifier.