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

Commit 3cc97f8d authored by Tammo Spalink's avatar Tammo Spalink
Browse files

Add Phone.getPhoneType() operation.

This routine returns integer values defined in the Phone interface,
derived from RILConstants values.  Direct references to the
RILConstants are replaced by references to these new ones for
consistency.

API CHANGE:
  unhide TelephonyManager.PHONE_TYPE_CDMA

Addresses issue:
http://buganizer/issue?id=1905415

Change-Id: Icfec6d457231b098c031677a66770b5e57be4a44
parent 7c5c6076
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -125112,6 +125112,17 @@
 visibility="public"
>
</field>
<field name="PHONE_TYPE_CDMA"
 type="int"
 transient="false"
 volatile="false"
 value="2"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="PHONE_TYPE_GSM"
 type="int"
 transient="false"
+14 −10
Original line number Diff line number Diff line
@@ -26,11 +26,10 @@ import android.provider.Settings;
import android.telephony.cdma.CdmaCellLocation;
import android.telephony.gsm.GsmCellLocation;
import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.Phone;

/**
 * Abstract class that represents the location of the device.  Currently the only
 * subclass is {@link android.telephony.gsm.GsmCellLocation}.  {@more}
 * Abstract class that represents the location of the device.  {@more}
 */
public abstract class CellLocation {

@@ -64,11 +63,13 @@ public abstract class CellLocation {
    public static CellLocation newFromBundle(Bundle bundle) {
        // TelephonyManager.getDefault().getPhoneType() handles the case when
        // ITelephony interface is not up yet.
        int type = TelephonyManager.getDefault().getPhoneType();
        if (type == RILConstants.CDMA_PHONE) {
        switch(TelephonyManager.getDefault().getPhoneType()) {
        case Phone.PHONE_TYPE_CDMA:
            return new CdmaCellLocation(bundle);
        } else {
        case Phone.PHONE_TYPE_GSM:
            return new GsmCellLocation(bundle);
        default:
            return null;
        }
    }

@@ -78,17 +79,20 @@ public abstract class CellLocation {
    public abstract void fillInNotifierBundle(Bundle bundle);

    /**
     * Return a new CellLocation object representing an unknown location.
     * Return a new CellLocation object representing an unknown
     * location, or null for unknown/none phone radio types.
     *
     */
    public static CellLocation getEmpty() {
        // TelephonyManager.getDefault().getPhoneType() handles the case when
        // ITelephony interface is not up yet.
        int type = TelephonyManager.getDefault().getPhoneType();
        if (type == RILConstants.CDMA_PHONE) {
        switch(TelephonyManager.getDefault().getPhoneType()) {
        case Phone.PHONE_TYPE_CDMA:
            return new CdmaCellLocation();
        } else {
        case Phone.PHONE_TYPE_GSM:
            return new GsmCellLocation();
        default:
            return null;
        }
    }
}
+7 −21
Original line number Diff line number Diff line
@@ -263,22 +263,12 @@ public class TelephonyManager {
       }
    }

    /**
     * No phone module
     *
     */
    public static final int PHONE_TYPE_NONE = RILConstants.NO_PHONE;

    /**
     * GSM phone
     */
    public static final int PHONE_TYPE_GSM = RILConstants.GSM_PHONE;

    /**
     * CDMA phone
     * @hide
     */
    public static final int PHONE_TYPE_CDMA = RILConstants.CDMA_PHONE;
    /** No phone radio. */
    public static final int PHONE_TYPE_NONE = Phone.PHONE_TYPE_NONE;
    /** Phone radio is GSM. */
    public static final int PHONE_TYPE_GSM = Phone.PHONE_TYPE_GSM;
    /** Phone radio is CDMA. */
    public static final int PHONE_TYPE_CDMA = Phone.PHONE_TYPE_CDMA;

    /**
     * Returns a constant indicating the device phone type.
@@ -291,11 +281,7 @@ public class TelephonyManager {
        try{
            ITelephony telephony = getITelephony();
            if (telephony != null) {
                if(telephony.getActivePhoneType() == RILConstants.CDMA_PHONE) {
                    return PHONE_TYPE_CDMA;
                } else {
                    return PHONE_TYPE_GSM;
                }
                return telephony.getActivePhoneType();
            } else {
                // This can happen when the ITelephony interface is not up yet.
                return getPhoneTypeFromProperty();
+2 −2
Original line number Diff line number Diff line
@@ -676,7 +676,7 @@ public abstract class BaseCommands implements CommandsInterface {
                mRadioTechnologyChangedRegistrants.notifyRegistrants();
            }

            if (mState.isGsm() && !oldState.isOn() && (mPhoneType == RILConstants.CDMA_PHONE)) {
            if (mState.isGsm() && !oldState.isOn() && (mPhoneType == Phone.PHONE_TYPE_CDMA)) {
                Log.d(LOG_TAG,"Notifying: radio technology change CDMA OFF to GSM");
                mRadioTechnologyChangedRegistrants.notifyRegistrants();
            }
@@ -686,7 +686,7 @@ public abstract class BaseCommands implements CommandsInterface {
                mRadioTechnologyChangedRegistrants.notifyRegistrants();
            }

            if (mState.isCdma() && !oldState.isOn() && (mPhoneType == RILConstants.GSM_PHONE)) {
            if (mState.isCdma() && !oldState.isOn() && (mPhoneType == Phone.PHONE_TYPE_GSM)) {
                Log.d(LOG_TAG,"Notifying: radio technology change GSM OFF to CDMA");
                mRadioTechnologyChangedRegistrants.notifyRegistrants();
            }
+1 −0
Original line number Diff line number Diff line
@@ -1256,6 +1256,7 @@ public interface CommandsInterface {

    /** Set the Phone type created */
    void setPhoneType(int phoneType);

    /**
     *  Query the CDMA roaming preference setting
     *
Loading