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

Commit 264ebb11 authored by Renaud Lepage's avatar Renaud Lepage
Browse files

Implementing Sunfire-related fixes

- Tegra2 World RIL (fine-tuning to be done)
- RIL Object creation modification
- Fixing a bug involving the switch from GSM to CDMA (and back) plaguing multiple world phones

Change-Id: Ic1aa7aae15b6e45a9968171bb1e8c216697791a8
parent ba3aebab
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -295,6 +295,27 @@ public final class CallManager {
     * @return true if register successfully
     */
    public boolean registerPhone(Phone phone) {
        return this.registerPhoneInternal(phone, false);
    }

    /**
     * Register phone to CallManager and force it as the default phone
     *
     * @param phone to be registered
     * @return true if register successfully
     */
    public boolean registerPhoneAsDefault(Phone phone) {
        return this.registerPhoneInternal(phone, true);
    }

    /**
     * Internal phone registration function used in two phone registering cases
     *
     * @param phone to be registered
     * @param overrideDefaultPhone is there a need to set this phone to be the default one
     * @return true if register successfully
     */
    private boolean registerPhoneInternal(Phone phone, boolean overrideDefaultPhone) {
        Phone basePhone = getPhoneBase(phone);

        if (basePhone != null && !mPhones.contains(basePhone)) {
@@ -304,7 +325,7 @@ public final class CallManager {
                        phone.getPhoneName() + " " + phone + ")");
            }

            if (mPhones.isEmpty()) {
            if (mPhones.isEmpty() || overrideDefaultPhone) {
                mDefaultPhone = basePhone;
            }
            mPhones.add(basePhone);
+49 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2011 The CyanogenMod Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.internal.telephony;

import android.content.Context;
import android.os.AsyncResult;
import android.os.Message;
import android.os.Parcel;
import android.util.Log;

import static com.android.internal.telephony.RILConstants.*;

import com.android.internal.telephony.gsm.NetworkInfo;

import java.util.ArrayList;

/**
 * Motorola Tegra2 World RIL class
 *
 * {@hide}
 */
public class MotoTegraWorldRIL extends MotoTegraRIL {

    public MotoTegraWorldRIL(Context context, int networkMode, int cdmaSubscription) {
        // for testing purposes, we're forcing Global. Will be reverted in due time.
        super(context, RILConstants.NETWORK_MODE_GLOBAL, cdmaSubscription);

        Log.i("TegraWorld", "Network mode is this at creation of object: "
              + networkMode + ", but has been forced to Global");

        // BUG: On CDMA Only, networkmode still is 0. That forces GSM_Phone,
        // since it's WCDMA-Preferred... by default.
    }

}
+3 −0
Original line number Diff line number Diff line
@@ -131,6 +131,9 @@ public class PhoneFactory {
                } else if ("mototegra".equals(sRILClassname)) {
                    Log.i(LOG_TAG, "Using Motorola Tegra2 RIL");
                    sCommandsInterface = new MotoTegraRIL(context, networkMode, cdmaSubscription);
                } else if ("mototegraworld".equals(sRILClassname)) {
                    Log.i(LOG_TAG, "Using Motorola Tegra2 World Edition RIL");
                    sCommandsInterface = new MotoTegraWorldRIL(context, networkMode, cdmaSubscription);
                } else if ("motow3g".equals(sRILClassname)) {
                    Log.i(LOG_TAG, "Using Motorola Wrigley 3G RIL");
                    sCommandsInterface = new MotoWrigley3GRIL(context, networkMode, cdmaSubscription);
+10 −0
Original line number Diff line number Diff line
@@ -89,6 +89,8 @@ public class PhoneProxy extends Handler implements Phone {
            if(mOutgoingPhone.equals("GSM")) {
                logd("Make a new CDMAPhone and destroy the old GSMPhone.");

                // Since we already know we're disposing of this
                CallManager.getInstance().unregisterPhone(mActivePhone);
                ((GSMPhone)mActivePhone).dispose();
                Phone oldPhone = mActivePhone;

@@ -100,10 +102,16 @@ public class PhoneProxy extends Handler implements Phone {

                mActivePhone = PhoneFactory.getCdmaPhone();
                ((GSMPhone)oldPhone).removeReferences();

                // out with the old...
                oldPhone = null;

                // ...and in with the new!
                CallManager.getInstance().registerPhoneAsDefault(mActivePhone);
            } else {
                logd("Make a new GSMPhone and destroy the old CDMAPhone.");

                CallManager.getInstance().unregisterPhone(mActivePhone);
                ((CDMAPhone)mActivePhone).dispose();
                //mActivePhone = null;
                Phone oldPhone = mActivePhone;
@@ -116,7 +124,9 @@ public class PhoneProxy extends Handler implements Phone {

                mActivePhone = PhoneFactory.getGsmPhone();
                ((CDMAPhone)oldPhone).removeReferences();

                oldPhone = null;
                CallManager.getInstance().registerPhoneAsDefault(mActivePhone);
            }

            if (mResetModemOnRadioTechnologyChange) {
+24 −3
Original line number Diff line number Diff line
@@ -666,6 +666,17 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
        curPlmn = plmn;
    }

    /**
     * Multi-mode radio indication facilitator
     */
    public boolean isMultiModeRadio() {
        // If the device you seek to make work here has a multi-mode radio, for example
        // a "world" CDMA/GSM/UMTS radio, this function is here to facilitate alternate
        // code paths in some events.
        return SystemProperties.get("ro.telephony.ril_class").equalsIgnoreCase("mototegraworld");
    }


    /**
     * Handle the result of one of the pollState()-related requests
     */
@@ -723,7 +734,12 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
                int defaultRoamingIndicator = 0;  //[12] Is default roaming indicator from PRL
                int reasonForDenial = 0;       //[13] Denial reason if registrationState = 3

                if (states.length == 14) {
                // in some rare cases, such as a CDMA/GSM/UMTS radio, the states array will
                // contain 15 arguments, differring from the usual 14 contained in CDMA
                // states packets.
                boolean multiModeRadio = isMultiModeRadio();

                if (states.length == 14 || (multiModeRadio && states.length == 15 )) {
                    try {
                        if (states[0] != null) {
                            registrationState = Integer.parseInt(states[0]);
@@ -777,13 +793,18 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
                        if (states[13] != null) {
                            reasonForDenial = Integer.parseInt(states[13]);
                        }
                        if((states.length == 15) && (states[14] != null) && multiModeRadio) {
                            Log.w(LOG_TAG, "Multi-Mode RIL detected - Extraneous value: "
                                  + states[14]);
                        }
                    } catch (NumberFormatException ex) {
                        Log.w(LOG_TAG, "error parsing RegistrationState: " + ex);
                    }
                } else {
                    throw new RuntimeException("Warning! Wrong number of parameters returned from "
                                         + "RIL_REQUEST_REGISTRATION_STATE: expected 14 got "
                                         + states.length);
                                         + "RIL_REQUEST_REGISTRATION_STATE: expected "
                                         + (multiModeRadio ? "15" : "14")
                                         + ", got " + states.length);
                }

                mRegistrationState = registrationState;