Search in sources :

Example 1 with CDMALTEPhone

use of com.android.internal.telephony.cdma.CDMALTEPhone in project XobotOS by xamarin.

the class PhoneFactory method makeDefaultPhone.

/**
     * FIXME replace this with some other way of making these
     * instances
     */
public static void makeDefaultPhone(Context context) {
    synchronized (Phone.class) {
        if (!sMadeDefaults) {
            sLooper = Looper.myLooper();
            sContext = context;
            if (sLooper == null) {
                throw new RuntimeException("PhoneFactory.makeDefaultPhone must be called from Looper thread");
            }
            int retryCount = 0;
            for (; ; ) {
                boolean hasException = false;
                retryCount++;
                try {
                    // use UNIX domain socket to
                    // prevent subsequent initialization
                    new LocalServerSocket("com.android.internal.telephony");
                } catch (java.io.IOException ex) {
                    hasException = true;
                }
                if (!hasException) {
                    break;
                } else if (retryCount > SOCKET_OPEN_MAX_RETRY) {
                    throw new RuntimeException("PhoneFactory probably already running");
                } else {
                    try {
                        Thread.sleep(SOCKET_OPEN_RETRY_MILLIS);
                    } catch (InterruptedException er) {
                    }
                }
            }
            sPhoneNotifier = new DefaultPhoneNotifier();
            // Get preferred network mode
            int preferredNetworkMode = RILConstants.PREFERRED_NETWORK_MODE;
            if (BaseCommands.getLteOnCdmaModeStatic() == Phone.LTE_ON_CDMA_TRUE) {
                preferredNetworkMode = Phone.NT_MODE_GLOBAL;
            }
            int networkMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.PREFERRED_NETWORK_MODE, preferredNetworkMode);
            Log.i(LOG_TAG, "Network Mode set to " + Integer.toString(networkMode));
            // Get cdmaSubscription
            // TODO: Change when the ril will provides a way to know at runtime
            //       the configuration, bug 4202572. And the ril issues the
            //       RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED, bug 4295439.
            int cdmaSubscription;
            int lteOnCdma = BaseCommands.getLteOnCdmaModeStatic();
            switch(lteOnCdma) {
                case Phone.LTE_ON_CDMA_FALSE:
                    cdmaSubscription = RILConstants.SUBSCRIPTION_FROM_NV;
                    Log.i(LOG_TAG, "lteOnCdma is 0 use SUBSCRIPTION_FROM_NV");
                    break;
                case Phone.LTE_ON_CDMA_TRUE:
                    cdmaSubscription = RILConstants.SUBSCRIPTION_FROM_RUIM;
                    Log.i(LOG_TAG, "lteOnCdma is 1 use SUBSCRIPTION_FROM_RUIM");
                    break;
                case Phone.LTE_ON_CDMA_UNKNOWN:
                default:
                    //Get cdmaSubscription mode from Settings.System
                    cdmaSubscription = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.PREFERRED_CDMA_SUBSCRIPTION, preferredCdmaSubscription);
                    Log.i(LOG_TAG, "lteOnCdma not set, using PREFERRED_CDMA_SUBSCRIPTION");
                    break;
            }
            Log.i(LOG_TAG, "Cdma Subscription set to " + cdmaSubscription);
            //reads the system properties and makes commandsinterface
            sCommandsInterface = new RIL(context, networkMode, cdmaSubscription);
            int phoneType = getPhoneType(networkMode);
            if (phoneType == Phone.PHONE_TYPE_GSM) {
                Log.i(LOG_TAG, "Creating GSMPhone");
                sProxyPhone = new PhoneProxy(new GSMPhone(context, sCommandsInterface, sPhoneNotifier));
            } else if (phoneType == Phone.PHONE_TYPE_CDMA) {
                switch(BaseCommands.getLteOnCdmaModeStatic()) {
                    case Phone.LTE_ON_CDMA_TRUE:
                        Log.i(LOG_TAG, "Creating CDMALTEPhone");
                        sProxyPhone = new PhoneProxy(new CDMALTEPhone(context, sCommandsInterface, sPhoneNotifier));
                        break;
                    case Phone.LTE_ON_CDMA_FALSE:
                    default:
                        Log.i(LOG_TAG, "Creating CDMAPhone");
                        sProxyPhone = new PhoneProxy(new CDMAPhone(context, sCommandsInterface, sPhoneNotifier));
                        break;
                }
            }
            sMadeDefaults = true;
        }
    }
}
Also used : CDMAPhone(com.android.internal.telephony.cdma.CDMAPhone) LocalServerSocket(android.net.LocalServerSocket) CDMALTEPhone(com.android.internal.telephony.cdma.CDMALTEPhone) GSMPhone(com.android.internal.telephony.gsm.GSMPhone) CDMAPhone(com.android.internal.telephony.cdma.CDMAPhone) SipPhone(com.android.internal.telephony.sip.SipPhone) CDMALTEPhone(com.android.internal.telephony.cdma.CDMALTEPhone) GSMPhone(com.android.internal.telephony.gsm.GSMPhone)

Aggregations

LocalServerSocket (android.net.LocalServerSocket)1 CDMALTEPhone (com.android.internal.telephony.cdma.CDMALTEPhone)1 CDMAPhone (com.android.internal.telephony.cdma.CDMAPhone)1 GSMPhone (com.android.internal.telephony.gsm.GSMPhone)1 SipPhone (com.android.internal.telephony.sip.SipPhone)1