summaryrefslogtreecommitdiff
path: root/telephony
diff options
context:
space:
mode:
author Tomasz Wasilczyk <twasilczyk@google.com> 2025-02-25 09:21:43 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2025-02-25 09:21:43 -0800
commit59c2ef21a909c8efecba578d99918d4fbb644eba (patch)
treedb9c1f6593e0099b3e6cb570daa1ffcb5eef3fc3 /telephony
parent5f968cbfa3b75ffe7de19760869b073683de37de (diff)
parent7168caa1315dc2b0b51ce03031085cf4ed891bd4 (diff)
Merge "hasCarrierPrivileges: detailed messages about unexpected state" into main
Diffstat (limited to 'telephony')
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 6e0304b58489..fbba999bfb36 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -10579,9 +10579,19 @@ public class TelephonyManager {
public boolean hasCarrierPrivileges(int subId) {
try {
ITelephony telephony = getITelephony();
- if (telephony != null) {
- return telephony.getCarrierPrivilegeStatus(subId)
- == CARRIER_PRIVILEGE_STATUS_HAS_ACCESS;
+ if (telephony == null) {
+ Rlog.e(TAG, "hasCarrierPrivileges: no Telephony service");
+ return false;
+ }
+ int status = telephony.getCarrierPrivilegeStatus(subId);
+ switch (status) {
+ case CARRIER_PRIVILEGE_STATUS_HAS_ACCESS:
+ return true;
+ case CARRIER_PRIVILEGE_STATUS_NO_ACCESS:
+ return false;
+ default:
+ Rlog.e(TAG, "hasCarrierPrivileges: " + status);
+ return false;
}
} catch (RemoteException ex) {
Rlog.e(TAG, "hasCarrierPrivileges RemoteException", ex);