diff options
author | 2025-02-25 09:21:43 -0800 | |
---|---|---|
committer | 2025-02-25 09:21:43 -0800 | |
commit | 59c2ef21a909c8efecba578d99918d4fbb644eba (patch) | |
tree | db9c1f6593e0099b3e6cb570daa1ffcb5eef3fc3 | |
parent | 5f968cbfa3b75ffe7de19760869b073683de37de (diff) | |
parent | 7168caa1315dc2b0b51ce03031085cf4ed891bd4 (diff) |
Merge "hasCarrierPrivileges: detailed messages about unexpected state" into main
-rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 16 |
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); |