Search in sources :

Example 1 with CDMAPhone

use of com.android.internal.telephony.cdma.CDMAPhone 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)

Example 2 with CDMAPhone

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

the class PhoneProxy method handleMessage.

@Override
public void handleMessage(Message msg) {
    switch(msg.what) {
        case EVENT_RADIO_TECHNOLOGY_CHANGED:
            //switch Phone from CDMA to GSM or vice versa
            mOutgoingPhone = mActivePhone.getPhoneName();
            logd("Switching phone from " + mOutgoingPhone + "Phone to " + (mOutgoingPhone.equals("GSM") ? "CDMAPhone" : "GSMPhone"));
            // old power state to off
            boolean oldPowerState = false;
            if (mResetModemOnRadioTechnologyChange) {
                if (mCommandsInterface.getRadioState().isOn()) {
                    oldPowerState = true;
                    logd("Setting Radio Power to Off");
                    mCommandsInterface.setRadioPower(false, null);
                }
            }
            if (mOutgoingPhone.equals("GSM")) {
                logd("Make a new CDMAPhone and destroy the old GSMPhone.");
                ((GSMPhone) mActivePhone).dispose();
                Phone oldPhone = mActivePhone;
                //Give the garbage collector a hint to start the garbage collection asap
                // NOTE this has been disabled since radio technology change could happen during
                //   e.g. a multimedia playing and could slow the system. Tests needs to be done
                //   to see the effects of the GC call here when system is busy.
                //System.gc();
                mActivePhone = PhoneFactory.getCdmaPhone();
                ((GSMPhone) oldPhone).removeReferences();
                oldPhone = null;
            } else {
                logd("Make a new GSMPhone and destroy the old CDMAPhone.");
                ((CDMAPhone) mActivePhone).dispose();
                //mActivePhone = null;
                Phone oldPhone = mActivePhone;
                // Give the GC a hint to start the garbage collection asap
                // NOTE this has been disabled since radio technology change could happen during
                //   e.g. a multimedia playing and could slow the system. Tests needs to be done
                //   to see the effects of the GC call here when system is busy.
                //System.gc();
                mActivePhone = PhoneFactory.getGsmPhone();
                ((CDMAPhone) oldPhone).removeReferences();
                oldPhone = null;
            }
            if (mResetModemOnRadioTechnologyChange) {
                logd("Resetting Radio");
                mCommandsInterface.setRadioPower(oldPowerState, null);
            }
            //Set the new interfaces in the proxy's
            mIccSmsInterfaceManagerProxy.setmIccSmsInterfaceManager(mActivePhone.getIccSmsInterfaceManager());
            mIccPhoneBookInterfaceManagerProxy.setmIccPhoneBookInterfaceManager(mActivePhone.getIccPhoneBookInterfaceManager());
            mPhoneSubInfoProxy.setmPhoneSubInfo(this.mActivePhone.getPhoneSubInfo());
            mCommandsInterface = ((PhoneBase) mActivePhone).mCM;
            //Send an Intent to the PhoneApp that we had a radio technology change
            Intent intent = new Intent(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
            intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
            intent.putExtra(Phone.PHONE_NAME_KEY, mActivePhone.getPhoneName());
            ActivityManagerNative.broadcastStickyIntent(intent, null);
            break;
        default:
            Log.e(LOG_TAG, "Error! This handler was not registered for this message type. Message: " + msg.what);
            break;
    }
    super.handleMessage(msg);
}
Also used : CDMAPhone(com.android.internal.telephony.cdma.CDMAPhone) GSMPhone(com.android.internal.telephony.gsm.GSMPhone) CDMAPhone(com.android.internal.telephony.cdma.CDMAPhone) Intent(android.content.Intent) GSMPhone(com.android.internal.telephony.gsm.GSMPhone)

Aggregations

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