Merge "[DO NOT MERGE]Add check for slot index value" into pi-dev

This commit is contained in:
Andy Chou
2019-01-29 12:28:47 +00:00
committed by Android (Google) Code Review

View File

@@ -7581,6 +7581,9 @@ public class TelephonyManager {
@SystemApi
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public int setAllowedCarriers(int slotIndex, List<CarrierIdentifier> carriers) {
if (!SubscriptionManager.isValidPhoneId(slotIndex)) {
return -1;
}
try {
ITelephony service = getITelephony();
if (service != null) {
@@ -7608,15 +7611,17 @@ public class TelephonyManager {
@SystemApi
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
public List<CarrierIdentifier> getAllowedCarriers(int slotIndex) {
try {
ITelephony service = getITelephony();
if (service != null) {
return service.getAllowedCarriers(slotIndex);
if (SubscriptionManager.isValidPhoneId(slotIndex)) {
try {
ITelephony service = getITelephony();
if (service != null) {
return service.getAllowedCarriers(slotIndex);
}
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#getAllowedCarriers", e);
} catch (NullPointerException e) {
Log.e(TAG, "Error calling ITelephony#getAllowedCarriers", e);
}
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#getAllowedCarriers", e);
} catch (NullPointerException e) {
Log.e(TAG, "Error calling ITelephony#getAllowedCarriers", e);
}
return new ArrayList<CarrierIdentifier>(0);
}