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

Commit c375dd43 authored by Shishir Agrawal's avatar Shishir Agrawal Committed by Android (Google) Code Review
Browse files

Merge "Fixing few TelephonyManager calls to work when there is no SIM." into nyc-dev

parents 5961ab3a dc50a874
Loading
Loading
Loading
Loading
+36 −21
Original line number Original line Diff line number Diff line
@@ -717,16 +717,11 @@ public class TelephonyManager {
     */
     */
    /** {@hide} */
    /** {@hide} */
    public String getDeviceSoftwareVersion(int slotId) {
    public String getDeviceSoftwareVersion(int slotId) {
        // FIXME methods taking slot id should not use subscription, instead us Uicc directly
        ITelephony telephony = getITelephony();
        int[] subId = SubscriptionManager.getSubId(slotId);
        if (telephony == null) return null;
        if (subId == null || subId.length == 0) {

            return null;
        }
        try {
        try {
            IPhoneSubInfo info = getSubscriberInfo();
            return telephony.getDeviceSoftwareVersionForSlot(slotId, getOpPackageName());
            if (info == null)
                return null;
            return info.getDeviceSvnUsingSubId(subId[0], mContext.getOpPackageName());
        } catch (RemoteException ex) {
        } catch (RemoteException ex) {
            return null;
            return null;
        } catch (NullPointerException ex) {
        } catch (NullPointerException ex) {
@@ -798,12 +793,11 @@ public class TelephonyManager {
     */
     */
    /** {@hide} */
    /** {@hide} */
    public String getImei(int slotId) {
    public String getImei(int slotId) {
        int[] subId = SubscriptionManager.getSubId(slotId);
        ITelephony telephony = getITelephony();
        if (telephony == null) return null;

        try {
        try {
            IPhoneSubInfo info = getSubscriberInfo();
            return telephony.getImeiForSlot(slotId, getOpPackageName());
            if (info == null)
                return null;
            return info.getImeiForSubscriber(subId[0], mContext.getOpPackageName());
        } catch (RemoteException ex) {
        } catch (RemoteException ex) {
            return null;
            return null;
        } catch (NullPointerException ex) {
        } catch (NullPointerException ex) {
@@ -1014,22 +1008,32 @@ public class TelephonyManager {
        } else {
        } else {
            phoneId = SubscriptionManager.getPhoneId(subId);
            phoneId = SubscriptionManager.getPhoneId(subId);
        }
        }

        return getCurrentPhoneTypeForSlot(phoneId);
    }

    /**
     * See getCurrentPhoneType.
     *
     * @hide
     */
    public int getCurrentPhoneTypeForSlot(int slotId) {
        try{
        try{
            ITelephony telephony = getITelephony();
            ITelephony telephony = getITelephony();
            if (telephony != null && subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
            if (telephony != null) {
                return telephony.getActivePhoneTypeForSubscriber(subId);
                return telephony.getActivePhoneTypeForSlot(slotId);
            } else {
            } else {
                // This can happen when the ITelephony interface is not up yet.
                // This can happen when the ITelephony interface is not up yet.
                return getPhoneTypeFromProperty(phoneId);
                return getPhoneTypeFromProperty(slotId);
            }
            }
        } catch (RemoteException ex) {
        } catch (RemoteException ex) {
            // This shouldn't happen in the normal case, as a backup we
            // This shouldn't happen in the normal case, as a backup we
            // read from the system property.
            // read from the system property.
            return getPhoneTypeFromProperty(phoneId);
            return getPhoneTypeFromProperty(slotId);
        } catch (NullPointerException ex) {
        } catch (NullPointerException ex) {
            // This shouldn't happen in the normal case, as a backup we
            // This shouldn't happen in the normal case, as a backup we
            // read from the system property.
            // read from the system property.
            return getPhoneTypeFromProperty(phoneId);
            return getPhoneTypeFromProperty(slotId);
        }
        }
    }
    }


@@ -2555,11 +2559,21 @@ public class TelephonyManager {
     * @param subId whose call state is returned
     * @param subId whose call state is returned
     */
     */
    public int getCallState(int subId) {
    public int getCallState(int subId) {
        int phoneId = SubscriptionManager.getPhoneId(subId);
        return getCallStateForSlot(phoneId);
    }

    /**
     * See getCallState.
     *
     * @hide
     */
    public int getCallStateForSlot(int slotId) {
        try {
        try {
            ITelephony telephony = getITelephony();
            ITelephony telephony = getITelephony();
            if (telephony == null)
            if (telephony == null)
                return CALL_STATE_IDLE;
                return CALL_STATE_IDLE;
            return telephony.getCallStateForSubscriber(subId);
            return telephony.getCallStateForSlot(slotId);
        } catch (RemoteException ex) {
        } catch (RemoteException ex) {
            // the phone process is restarting.
            // the phone process is restarting.
            return CALL_STATE_IDLE;
            return CALL_STATE_IDLE;
@@ -2569,6 +2583,7 @@ public class TelephonyManager {
        }
        }
    }
    }



    /** Data connection activity: No traffic. */
    /** Data connection activity: No traffic. */
    public static final int DATA_ACTIVITY_NONE = 0x00000000;
    public static final int DATA_ACTIVITY_NONE = 0x00000000;
    /** Data connection activity: Currently receiving IP PPP traffic. */
    /** Data connection activity: Currently receiving IP PPP traffic. */
+25 −5
Original line number Original line Diff line number Diff line
@@ -360,9 +360,9 @@ interface ITelephony {
     int getCallState();
     int getCallState();


    /**
    /**
     * Returns the call state for a subId.
     * Returns the call state for a slot.
     */
     */
     int getCallStateForSubscriber(int subId);
     int getCallStateForSlot(int slotId);


     int getDataActivity();
     int getDataActivity();
     int getDataState();
     int getDataState();
@@ -375,12 +375,12 @@ interface ITelephony {
    int getActivePhoneType();
    int getActivePhoneType();


    /**
    /**
     * Returns the current active phone type as integer for particular subId.
     * Returns the current active phone type as integer for particular slot.
     * Returns TelephonyManager.PHONE_TYPE_CDMA if RILConstants.CDMA_PHONE
     * Returns TelephonyManager.PHONE_TYPE_CDMA if RILConstants.CDMA_PHONE
     * and TelephonyManager.PHONE_TYPE_GSM if RILConstants.GSM_PHONE
     * and TelephonyManager.PHONE_TYPE_GSM if RILConstants.GSM_PHONE
     * @param subId user preferred subId.
     * @param slotId - slot to query.
     */
     */
    int getActivePhoneTypeForSubscriber(int subId);
    int getActivePhoneTypeForSlot(int slotId);


    /**
    /**
     * Returns the CDMA ERI icon index to display
     * Returns the CDMA ERI icon index to display
@@ -991,6 +991,26 @@ interface ITelephony {
      */
      */
    String getDeviceId(String callingPackage);
    String getDeviceId(String callingPackage);


    /**
     * Returns the IMEI for the given slot.
     *
     * @param slotId - device slot.
     * @param callingPackage The package making the call.
     * <p>Requires Permission:
     *   {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
     */
    String getImeiForSlot(int slotId, String callingPackage);

    /**
     * Returns the device software version.
     *
     * @param slotId - device slot.
     * @param callingPackage The package making the call.
     * <p>Requires Permission:
     *   {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
     */
    String getDeviceSoftwareVersionForSlot(int slotId, String callingPackage);

    /**
    /**
     * Returns the subscription ID associated with the specified PhoneAccount.
     * Returns the subscription ID associated with the specified PhoneAccount.
     */
     */