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

Commit 83a6ec60 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 1791 into donut

* changes:
  Add a method to get the PhoneType in CellLocation.
parents eba1ffb1 9bfbfbd4
Loading
Loading
Loading
Loading
+69 −76
Original line number Diff line number Diff line
@@ -2061,13 +2061,6 @@ public final class Settings {
         */
        public static final String CDMA_SUBSCRIPTION_MODE = "subscription_mode";

        /**
         * represents current active phone class
         * 1 = GSM-Phone, 0 = CDMA-Phone
         * @hide
         */
        public static final String CURRENT_ACTIVE_PHONE = "current_active_phone";

        /**
         * The preferred network mode   7 = Global
         *                              6 = EvDo only
+53 −54
Original line number Diff line number Diff line
@@ -584,8 +584,7 @@ class DatabaseHelper extends SQLiteOpenHelper {
                + " VALUES(?,?);");

        Resources r = mContext.getResources();
        loadSetting(stmt, Settings.Secure.CURRENT_ACTIVE_PHONE,
                RILConstants.CDMA_PHONE);

        loadBooleanSetting(stmt, Settings.System.DIM_SCREEN,
                R.bool.def_dim_screen);
        loadSetting(stmt, Settings.System.STAY_ON_WHILE_PLUGGED_IN,
+8 −14
Original line number Diff line number Diff line
@@ -62,13 +62,10 @@ public abstract class CellLocation {
     * @hide
     */
    public static CellLocation newFromBundle(Bundle bundle) {
        // TODO: My need to be use: Settings.Secure.getInt(mContext, Settings.Secure.CURRENT_ACTIVE_PHONE, 0))
        //       instead of SystemProperties???

        // NOTE here TelephonyManager.getDefault().getPhoneType() cannot be used since at startup
        //      ITelephony have not been created
        if (RILConstants.CDMA_PHONE == SystemProperties.getInt(
                Settings.Secure.CURRENT_ACTIVE_PHONE, RILConstants.CDMA_PHONE)) {
        // TelephonyManager.getDefault().getPhoneType() handles the case when
        // ITelephony interface is not up yet.
        int type = TelephonyManager.getDefault().getPhoneType();
        if (type == RILConstants.CDMA_PHONE) {
            return new CdmaCellLocation(bundle);
        } else {
            return new GsmCellLocation(bundle);
@@ -85,13 +82,10 @@ public abstract class CellLocation {
     *
     */
    public static CellLocation getEmpty() {
        // TODO: My need to be use: Settings.Secure.getInt(mContext, Settings.Secure.CURRENT_ACTIVE_PHONE, 0))
        //       instead of SystemProperties???

        // NOTE here TelephonyManager.getDefault().getPhoneType() cannot be used since at startup
        //      ITelephony have not been created
        if (RILConstants.CDMA_PHONE == SystemProperties.getInt(
                Settings.Secure.CURRENT_ACTIVE_PHONE, RILConstants.CDMA_PHONE)) {
        // TelephonyManager.getDefault().getPhoneType() handles the case when
        // ITelephony interface is not up yet.
        int type = TelephonyManager.getDefault().getPhoneType();
        if (type == RILConstants.CDMA_PHONE) {
            return new CdmaCellLocation();
        } else {
            return new GsmCellLocation();
+47 −21
Original line number Diff line number Diff line
@@ -16,26 +16,24 @@

package android.telephony;

import com.android.internal.telephony.*;

import java.util.ArrayList;
import java.util.List;

import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.content.Context;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.telephony.CellLocation;

import com.android.internal.telephony.IPhoneSubInfo;
import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.ITelephonyRegistry;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.TelephonyProperties;

import java.util.List;

/**
 * Provides access to information about the telephony services on
 * the device. Applications can use the methods in this class to
@@ -256,19 +254,20 @@ public class TelephonyManager {

    /**
     * No phone module
     *
     */
    public static final int PHONE_TYPE_NONE = 0;

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

    /**
     * CDMA phone
     * @hide
     */
    public static final int PHONE_TYPE_CDMA = 2;
    public static final int PHONE_TYPE_CDMA = RILConstants.CDMA_PHONE;

    /**
     * Returns a constant indicating the device phone type.
@@ -279,16 +278,41 @@ public class TelephonyManager {
     */
    public int getPhoneType() {
        try{
            if(getITelephony().getActivePhoneType() == RILConstants.CDMA_PHONE) {
            ITelephony telephony = getITelephony();
            if (telephony != null) {
                if(telephony.getActivePhoneType() == RILConstants.CDMA_PHONE) {
                    return PHONE_TYPE_CDMA;
                } else {
                    return PHONE_TYPE_GSM;
                }
            } else {
                // This can happen when the ITelephony interface is not up yet.
                return getPhoneTypeFromProperty();
            }
        } catch(RemoteException ex){
            return PHONE_TYPE_NONE;
            // This shouldn't happen in the normal case, as a backup we
            // read from the system property.
            return getPhoneTypeFromProperty();
        }
    }


    private int getPhoneTypeFromProperty() {
        int type =
            SystemProperties.getInt(TelephonyProperties.CURRENT_ACTIVE_PHONE,
                    getPhoneTypeFromNetworkType());
        return type;
    }

    private int getPhoneTypeFromNetworkType() {
        // When the system property CURRENT_ACTIVE_PHONE, has not been set,
        // use the system property for default network type.
        // This is a fail safe, and can only happen at first boot.
        int mode = SystemProperties.getInt("ro.telephony.default_network", -1);
        if (mode == -1)
            return PHONE_TYPE_NONE;
        return PhoneFactory.getPhoneType(mode);
    }
    //
    //
    // Current Network
@@ -640,8 +664,10 @@ public class TelephonyManager {
    /** Data connection activity: Currently both sending and receiving
     *  IP PPP traffic. */
    public static final int DATA_ACTIVITY_INOUT = DATA_ACTIVITY_IN | DATA_ACTIVITY_OUT;
    /** Data connection is active, but physical link is down */
    /** @hide */
    /**
     * Data connection is active, but physical link is down
     * @hide
     */
    public static final int DATA_ACTIVITY_DORMANT = 0x00000004;

    /**
+37 −21
Original line number Diff line number Diff line
@@ -107,33 +107,49 @@ public class PhoneFactory {
                //reads the system properties and makes commandsinterface
                sCommandsInterface = new RIL(context, networkMode, cdmaSubscription);

                switch(networkMode) {
                    case RILConstants.NETWORK_MODE_WCDMA_PREF:
                    case RILConstants.NETWORK_MODE_GSM_ONLY:
                    case RILConstants.NETWORK_MODE_WCDMA_ONLY:
                    case RILConstants.NETWORK_MODE_GSM_UMTS:
                int phoneType = getPhoneType(networkMode);
                if (phoneType == RILConstants.GSM_PHONE) {
                    sProxyPhone = new PhoneProxy(new GSMPhone(context,
                            sCommandsInterface, sPhoneNotifier));
                    Log.i(LOG_TAG, "Creating GSMPhone");
                        break;
                    case RILConstants.NETWORK_MODE_CDMA:
                    case RILConstants.NETWORK_MODE_CDMA_NO_EVDO:
                    case RILConstants.NETWORK_MODE_EVDO_NO_CDMA:
                        sProxyPhone = new PhoneProxy(new CDMAPhone(context,
                                sCommandsInterface, sPhoneNotifier));
                        Log.i(LOG_TAG, "Creating CDMAPhone");
                        break;
                    case RILConstants.NETWORK_MODE_GLOBAL:
                    default:
                } else if (phoneType == RILConstants.CDMA_PHONE) {
                    sProxyPhone = new PhoneProxy(new CDMAPhone(context,
                            sCommandsInterface, sPhoneNotifier));
                    Log.i(LOG_TAG, "Creating CDMAPhone");
                }

                sMadeDefaults = true;
            }
        }
    }

    /*
     * This function returns the type of the phone, depending
     * on the network mode.
     *
     * @param network mode
     * @return Phone Type
     */
    public static int getPhoneType(int networkMode) {
        switch(networkMode) {
        case RILConstants.NETWORK_MODE_CDMA:
        case RILConstants.NETWORK_MODE_CDMA_NO_EVDO:
        case RILConstants.NETWORK_MODE_EVDO_NO_CDMA:
            return RILConstants.CDMA_PHONE;

        case RILConstants.NETWORK_MODE_WCDMA_PREF:
        case RILConstants.NETWORK_MODE_GSM_ONLY:
        case RILConstants.NETWORK_MODE_WCDMA_ONLY:
        case RILConstants.NETWORK_MODE_GSM_UMTS:
            return RILConstants.GSM_PHONE;

        case RILConstants.NETWORK_MODE_GLOBAL:
            return RILConstants.CDMA_PHONE;
        default:
            return RILConstants.GSM_PHONE;
        }
    }

    public static Phone getDefaultPhone() {
        if (sLooper != Looper.myLooper()) {
            throw new RuntimeException(
Loading