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

Commit 7d38883e authored by Chen Xu's avatar Chen Xu Committed by android-build-merger
Browse files

Merge "throw runtimeException for applicable TM APIs" into pi-dev

am: 17aa7519

Change-Id: I44ab8310928658c38bae9522b31515ee6c36d6d2
parents a1e6c8fd 17aa7519
Loading
Loading
Loading
Loading
+23 −5
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import android.os.BatteryStats;
import android.os.Bundle;
import android.os.Handler;
import android.os.PersistableBundle;
import android.os.Process;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.ServiceManager;
@@ -214,6 +215,10 @@ public class TelephonyManager {
        return ActivityThread.currentOpPackageName();
    }

    private boolean isSystemProcess() {
        return Process.myUid() == Process.SYSTEM_UID;
    }

    /**
     * Returns the multi SIM variant
     * Returns DSDS for Dual SIM Dual Standby
@@ -2866,15 +2871,18 @@ public class TelephonyManager {
            IPhoneSubInfo info = getSubscriberInfo();
            if (info == null) {
                Rlog.e(TAG, "IMSI error: Subscriber Info is null");
                if (!isSystemProcess()) {
                    throw new RuntimeException("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);
        } catch (NullPointerException ex) {
            // This could happen before phone restarts due to crashing
            Rlog.e(TAG, "getCarrierInfoForImsiEncryption NullPointerException" + ex);
            if (!isSystemProcess()) {
                ex.rethrowAsRuntimeException();
            }
        }
    }

@@ -3863,11 +3871,18 @@ public class TelephonyManager {
    public void sendDialerSpecialCode(String inputCode) {
        try {
            final ITelephony telephony = getITelephony();
            if (telephony == null) {
                if (!isSystemProcess()) {
                    throw new RuntimeException("Telephony service unavailable");
                }
                return;
            }
            telephony.sendDialerSpecialCode(mContext.getOpPackageName(), inputCode);
        } catch (RemoteException ex) {
            // This could happen if binder process crashes.
        } catch (NullPointerException ex) {
            // This could happen before phone restarts due to crashing
            if (!isSystemProcess()) {
                ex.rethrowAsRuntimeException();
            }
        }
    }

@@ -7863,6 +7878,9 @@ public class TelephonyManager {
            }
        } catch (RemoteException ex) {
            // This could happen if binder process crashes.
            if (!isSystemProcess()) {
                ex.rethrowAsRuntimeException();
            }
        }
    }
}