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

Commit 7fae515a authored by Nathan Harold's avatar Nathan Harold Committed by android-build-merger
Browse files

Use the SubId in the TM.getNetworkType if Valid

am: f36fee3c

Change-Id: Ifbb85e8c2c2bdde49e9d25f6e24f03780a21f17b
parents 6ad48bd2 f36fee3c
Loading
Loading
Loading
Loading
+3 −31
Original line number Diff line number Diff line
@@ -2446,21 +2446,7 @@ public class TelephonyManager {
     * @return the NETWORK_TYPE_xxxx for current data connection.
     */
    public @NetworkType int getNetworkType() {
       try {
           ITelephony telephony = getITelephony();
           if (telephony != null) {
               return telephony.getNetworkType();
            } else {
                // This can happen when the ITelephony interface is not up yet.
                return NETWORK_TYPE_UNKNOWN;
            }
        } catch(RemoteException ex) {
            // This shouldn't happen in the normal case
            return NETWORK_TYPE_UNKNOWN;
        } catch (NullPointerException ex) {
            // This could happen before phone restarts due to crashing
            return NETWORK_TYPE_UNKNOWN;
        }
        return getDataNetworkType();
    }

    /**
@@ -2491,23 +2477,9 @@ public class TelephonyManager {
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
    @UnsupportedAppUsage
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
    public int getNetworkType(int subId) {
        try {
            ITelephony telephony = getITelephony();
            if (telephony != null) {
                return telephony.getNetworkTypeForSubscriber(subId, getOpPackageName());
            } else {
                // This can happen when the ITelephony interface is not up yet.
                return NETWORK_TYPE_UNKNOWN;
            }
        } catch (RemoteException ex) {
            // This shouldn't happen in the normal case
            return NETWORK_TYPE_UNKNOWN;
        } catch (NullPointerException ex) {
            // This could happen before phone restarts due to crashing
            return NETWORK_TYPE_UNKNOWN;
        }
        return getDataNetworkType(subId);
    }

    /**