Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 424bd06d authored by Android Build Merger (Role)'s avatar Android Build Merger (Role) Committed by Android (Google) Code Review
Browse files

Merge "Merge "Remove RuntimeException throws from TelephonyManager" into...

Merge "Merge "Remove RuntimeException throws from TelephonyManager" into pi-dev am: 85c0e878 am: 6ccb1923"
parents 8cd8da30 2f7a515b
Loading
Loading
Loading
Loading
+12 −23
Original line number Diff line number Diff line
@@ -2802,18 +2802,17 @@ public class TelephonyManager {
     * @return ImsiEncryptionInfo Carrier specific information that will be used to encrypt the
     *         IMSI and IMPI. This includes the public key and the key identifier. This information
     *         will be stored in the device keystore. The system will return a null when no key was
     *         found, and the carrier does not require a key. The system will throw the following
     *         exceptions:
     *         1. IllegalArgumentException when an invalid key is sent.
     *         2. RuntimeException if the key is required but not found; and also if there was an
     *         internal exception.
     *         found, and the carrier does not require a key. The system will throw
     *         IllegalArgumentException when an invalid key is sent or when key is required but
     *         not found.
     * @hide
     */
    public ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int keyType) {
        try {
            IPhoneSubInfo info = getSubscriberInfo();
            if (info == null) {
                throw new RuntimeException("IMSI error: Subscriber Info is null");
                Rlog.e(TAG,"IMSI error: Subscriber Info is null");
                return null;
            }
            int subId = getSubId(SubscriptionManager.getDefaultDataSubscriptionId());
            if (keyType != KEY_TYPE_EPDG && keyType != KEY_TYPE_WLAN) {
@@ -2821,20 +2820,18 @@ public class TelephonyManager {
            }
            ImsiEncryptionInfo imsiEncryptionInfo = info.getCarrierInfoForImsiEncryption(
                    subId, keyType, mContext.getOpPackageName());
            if (imsiEncryptionInfo  == null
                    && isImsiEncryptionRequired(subId, keyType)) {
            if (imsiEncryptionInfo == null && isImsiEncryptionRequired(subId, keyType)) {
                Rlog.e(TAG, "IMSI error: key is required but not found");
                throw new RuntimeException("IMSI error: key is required but not found");
                throw new IllegalArgumentException("IMSI error: key is required but not found");
            }
            return imsiEncryptionInfo;
        } catch (RemoteException ex) {
            Rlog.e(TAG, "getCarrierInfoForImsiEncryption RemoteException" + ex);
            throw new RuntimeException("IMSI error: Remote Exception");
        } catch (NullPointerException ex) {
            // This could happen before phone restarts due to crashing
            Rlog.e(TAG, "getCarrierInfoForImsiEncryption NullPointerException" + ex);
            throw new RuntimeException("IMSI error: Null Pointer exception");
        }
        return null;
    }

    /**
@@ -2850,17 +2847,16 @@ public class TelephonyManager {
        try {
            IPhoneSubInfo info = getSubscriberInfo();
            if (info == null) {
                throw new RuntimeException("IMSI error: Subscriber Info is null");
                Rlog.e(TAG, "IMSI error: Subscriber Info is null");
                return;
            }
            int subId = getSubId(SubscriptionManager.getDefaultDataSubscriptionId());
            info.resetCarrierKeysForImsiEncryption(subId, mContext.getOpPackageName());
        } catch (RemoteException ex) {
            Rlog.e(TAG, "getCarrierInfoForImsiEncryption RemoteException" + ex);
            throw new RuntimeException("IMSI error: Remote Exception");
        } catch (NullPointerException ex) {
            // This could happen before phone restarts due to crashing
            Rlog.e(TAG, "getCarrierInfoForImsiEncryption NullPointerException" + ex);
            throw new RuntimeException("IMSI error: Null Pointer exception");
        }
    }

@@ -3845,8 +3841,6 @@ public class TelephonyManager {
     *
     * @throws SecurityException if the caller does not have carrier privileges or is not the
     *         current default dialer
     *
     * @throws IllegalStateException if telephony service is unavailable.
     */
    public void sendDialerSpecialCode(String inputCode) {
        try {
@@ -3854,10 +3848,8 @@ public class TelephonyManager {
            telephony.sendDialerSpecialCode(mContext.getOpPackageName(), inputCode);
        } catch (RemoteException ex) {
            // This could happen if binder process crashes.
            ex.rethrowFromSystemServer();
        } catch (NullPointerException ex) {
            // This could happen before phone restarts due to crashing
            throw new IllegalStateException("Telephony service unavailable");
        }
    }

@@ -4982,10 +4974,10 @@ public class TelephonyManager {
        String v = android.provider.Settings.Global.getString(cr, name);

        if (index == Integer.MAX_VALUE) {
            throw new RuntimeException("putIntAtIndex index == MAX_VALUE index=" + index);
            throw new IllegalArgumentException("putIntAtIndex index == MAX_VALUE index=" + index);
        }
        if (index < 0) {
            throw new RuntimeException("putIntAtIndex index < 0 index=" + index);
            throw new IllegalArgumentException("putIntAtIndex index < 0 index=" + index);
        }
        if (v != null) {
            valArray = v.split(",");
@@ -7281,7 +7273,6 @@ public class TelephonyManager {
            }
        } catch (RemoteException ex) {
            // This could happen if binder process crashes.
            ex.rethrowAsRuntimeException();
        }
        return UNKNOWN_CARRIER_ID;
    }
@@ -7306,7 +7297,6 @@ public class TelephonyManager {
            }
        } catch (RemoteException ex) {
            // This could happen if binder process crashes.
            ex.rethrowAsRuntimeException();
        }
        return null;
    }
@@ -7826,7 +7816,6 @@ public class TelephonyManager {
            }
        } catch (RemoteException ex) {
            // This could happen if binder process crashes.
            ex.rethrowAsRuntimeException();
        }
    }
}