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

Commit 15e350db authored by Wink Saville's avatar Wink Saville Committed by android code review
Browse files

Merge "Telephony: Signal Strength cleanup"

parents 33f24931 5b81adc8
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -577,6 +577,11 @@ public abstract class PhoneBase extends Handler implements Phone {
        mNotifier.notifyServiceState(this);
    }

    /* package */void
    notifySignalStrength() {
        mNotifier.notifySignalStrength(this);
    }

    // Inherited documentation suffices.
    public SimulatedRadioControl getSimulatedRadioControl() {
        return mSimulatedRadioControl;
+3 −10
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import android.os.SystemProperties;
import android.os.PowerManager.WakeLock;
import android.telephony.NeighboringCellInfo;
import android.telephony.PhoneNumberUtils;
import android.telephony.SignalStrength;
import android.telephony.SmsManager;
import android.telephony.SmsMessage;
import android.text.TextUtils;
@@ -3347,16 +3348,8 @@ public final class RIL extends BaseCommands implements CommandsInterface {

    private Object
    responseSignalStrength(Parcel p) {
        int numInts = 12;
        int response[];

        /* TODO: Add SignalStrength class to match RIL_SignalStrength */
        response = new int[numInts];
        for (int i = 0 ; i < numInts ; i++) {
            response[i] = p.readInt();
        }

        return response;
        SignalStrength signalStrength = new SignalStrength(p);
        return signalStrength;
    }

    private ArrayList<CdmaInformationRecords>
+32 −0
Original line number Diff line number Diff line
@@ -467,6 +467,38 @@ public abstract class ServiceStateTracker extends Handler {
        }
    }

    /**
     * send signal-strength-changed notification if changed Called both for
     * solicited and unsolicited signal strength updates
     */
    protected void onSignalStrengthResult(AsyncResult ar, PhoneBase phone, boolean isGsm) {
        SignalStrength oldSignalStrength = mSignalStrength;

        // This signal is used for both voice and data radio signal so parse
        // all fields

        if ((ar.exception == null) && (ar.result != null)) {
            mSignalStrength = (SignalStrength) ar.result;
            mSignalStrength.validateInput();
            mSignalStrength.setGsm(isGsm);
        } else {
            log("onSignalStrengthResult() Exception from RIL : " + ar.exception);
            mSignalStrength = new SignalStrength(isGsm);
        }

        if (!mSignalStrength.equals(oldSignalStrength)) {
            try {
                // This takes care of delayed EVENT_POLL_SIGNAL_STRENGTH
                // (scheduled after POLL_PERIOD_MILLIS) during Radio Technology
                // Change)
                phone.notifySignalStrength();
            } catch (NullPointerException ex) {
                log("onSignalStrengthResult() Phone already destroyed: " + ex
                        + "SignalStrength not notified");
            }
        }
    }

    /**
     * Hang up all voice call and turn off radio. Implemented by derived class.
     */
+0 −5
Original line number Diff line number Diff line
@@ -352,11 +352,6 @@ public class CDMAPhone extends PhoneBase {
        return ret;
    }

    /*package*/ void
    notifySignalStrength() {
        mNotifier.notifySignalStrength(this);
    }

    public Connection
    dial (String dialString) throws CallStateException {
        // Need to make sure dialString gets parsed properly
+5 −53
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.telephony.cdma;

import com.android.internal.telephony.PhoneBase;
import com.android.internal.telephony.TelephonyProperties;
import com.android.internal.telephony.MccTable;
import com.android.internal.telephony.EventLogTags;
@@ -126,13 +127,6 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
        }
    }

    @Override
    protected void setSignalStrengthDefaultValues() {
        // TODO Make a constructor only has boolean gsm as parameter
        mSignalStrength = new SignalStrength(99, -1, -1, -1, -1, -1, -1,
                -1, -1, -1, SignalStrength.INVALID_SNR, -1, false);
    }

    @Override
    protected void pollState() {
        pollingContext = new int[1];
@@ -443,53 +437,11 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
    }

    @Override
    protected void onSignalStrengthResult(AsyncResult ar) {
        SignalStrength oldSignalStrength = mSignalStrength;

        if (ar.exception != null) {
            // Most likely radio is resetting/disconnected change to default
            // values.
            setSignalStrengthDefaultValues();
        } else {
            int[] ints = (int[])ar.result;

            int lteRssi = -1;
            int lteRsrp = -1;
            int lteRsrq = -1;
            int lteRssnr = SignalStrength.INVALID_SNR;
            int lteCqi = -1;

            int offset = 2;
            int cdmaDbm = (ints[offset] > 0) ? -ints[offset] : -120;
            int cdmaEcio = (ints[offset + 1] > 0) ? -ints[offset + 1] : -160;
            int evdoRssi = (ints[offset + 2] > 0) ? -ints[offset + 2] : -120;
            int evdoEcio = (ints[offset + 3] > 0) ? -ints[offset + 3] : -1;
            int evdoSnr = ((ints[offset + 4] > 0) && (ints[offset + 4] <= 8)) ? ints[offset + 4]
                    : -1;

    protected void onSignalStrengthResult(AsyncResult ar, PhoneBase phone, boolean isGsm) {
        if (mRilRadioTechnology == ServiceState.RIL_RADIO_TECHNOLOGY_LTE) {
                lteRssi = ints[offset+5];
                lteRsrp = ints[offset+6];
                lteRsrq = ints[offset+7];
                lteRssnr = ints[offset+8];
                lteCqi = ints[offset+9];
            }

            if (mRilRadioTechnology != ServiceState.RIL_RADIO_TECHNOLOGY_LTE) {
                mSignalStrength = new SignalStrength(99, -1, cdmaDbm, cdmaEcio, evdoRssi, evdoEcio,
                        evdoSnr, false);
            } else {
                mSignalStrength = new SignalStrength(99, -1, cdmaDbm, cdmaEcio, evdoRssi, evdoEcio,
                        evdoSnr, lteRssi, lteRsrp, lteRsrq, lteRssnr, lteCqi, true);
            }
        }

        try {
            phone.notifySignalStrength();
        } catch (NullPointerException ex) {
            loge("onSignalStrengthResult() Phone already destroyed: " + ex
                    + "SignalStrength not notified");
            isGsm = true;
        }
        super.onSignalStrengthResult(ar, phone, isGsm);
    }

    @Override
Loading