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

Commit 0555c815 authored by nharold's avatar nharold Committed by Gerrit Code Review
Browse files

Merge "Pipe Radio 1.2 LCE to DataConnection"

parents aa3b7d02 7afdb394
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ public abstract class BaseCommands implements CommandsInterface {
    protected RegistrantList mModemResetRegistrants = new RegistrantList();
    protected RegistrantList mNattKeepaliveStatusRegistrants = new RegistrantList();
    protected RegistrantList mPhysicalChannelConfigurationRegistrants = new RegistrantList();
    protected RegistrantList mLceInfoRegistrants = new RegistrantList();

    protected Registrant mGsmSmsRegistrant;
    protected Registrant mCdmaSmsRegistrant;
@@ -96,7 +97,6 @@ public abstract class BaseCommands implements CommandsInterface {
    protected Registrant mGsmBroadcastSmsRegistrant;
    protected Registrant mCatCcAlphaRegistrant;
    protected Registrant mSsRegistrant;
    protected Registrant mLceInfoRegistrant;

    // Preferred network type received from PhoneFactory.
    // This is used when establishing a connection to the
@@ -911,14 +911,17 @@ public abstract class BaseCommands implements CommandsInterface {

    @Override
    public void registerForLceInfo(Handler h, int what, Object obj) {
      mLceInfoRegistrant = new Registrant(h, what, obj);
        Registrant r = new Registrant(h, what, obj);

        synchronized (mStateMonitor) {
            mLceInfoRegistrants.add(r);
        }
    }

    @Override
    public void unregisterForLceInfo(Handler h) {
      if (mLceInfoRegistrant != null && mLceInfoRegistrant.getHandler() == h) {
          mLceInfoRegistrant.clear();
          mLceInfoRegistrant = null;
        synchronized (mStateMonitor) {
            mLceInfoRegistrants.remove(h);
        }
    }

+73 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source 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;

/**
 * Link Bandwidth Information from the Radio
 */
public class LinkCapacityEstimate {
    /** Any field that is not reported shall be set to INVALID */
    public static final int INVALID = -1;

    /** LCE is active; Deprecated in HAL 1.2 */
    public static final int STATUS_ACTIVE = 0;

    /** LCE is suspended; Deprecated in HAL 1.2 */
    public static final int STATUS_SUSPENDED = 1;

    /** Downlink radio link capacity in kbps */
    public final int downlinkCapacityKbps;

    /** Uplink radio link capacity; added in HAL 1.2 */
    public final int uplinkCapacityKbps;

    /** Confidence of the downlink estimate as a percentage [1, 100]; deprecated in HAL 1.2 */
    public final int confidence;

    /** Status of the LCE; deprecated in HAL 1.2 */
    public final int status; // either STATUS_ACTIVE, STATUS_SUSPENDED, or INVALID

    /** Constructor matching the estimate in Radio HAL v1.0 */
    public LinkCapacityEstimate(int downlinkCapacityKbps, int confidence, int status) {
        this.downlinkCapacityKbps = downlinkCapacityKbps;
        this.confidence = confidence;
        this.status = status;
        this.uplinkCapacityKbps = INVALID;
    }

    /** Constructor matching the estimate in Radio HAL v1.2 */
    public LinkCapacityEstimate(int downlinkCapacityKbps, int uplinkCapacityKbps) {
        this.downlinkCapacityKbps = downlinkCapacityKbps;
        this.uplinkCapacityKbps = uplinkCapacityKbps;
        this.confidence = INVALID;
        this.status = INVALID;
    }

    @Override
    public String toString() {
        return new StringBuilder()
                .append("{downlinkCapacityKbps=")
                .append(downlinkCapacityKbps)
                .append(", uplinkCapacityKbps=")
                .append(uplinkCapacityKbps)
                .append(", confidence=")
                .append(confidence)
                .append(", status=")
                .append(status)
                .toString();
    }
}
+43 −13
Original line number Diff line number Diff line
@@ -3382,6 +3382,14 @@ public class RIL extends BaseCommands implements CommandsInterface {
    @Override
    public void startLceService(int reportIntervalMs, boolean pullMode, Message result) {
        IRadio radioProxy = getRadioProxy(result);
        android.hardware.radio.V1_2.IRadio radioProxy12 =
                android.hardware.radio.V1_2.IRadio.castFrom(radioProxy);
        if (radioProxy12 != null) {
            // We have a 1.2 or later radio, so the LCE 1.0 LCE service control path is unused.
            // Instead the LCE functionality is always-on and provides unsolicited indications.
            return;
        }

        if (radioProxy != null) {
            RILRequest rr = obtainRequest(RIL_REQUEST_START_LCE, result,
                    mRILDefaultWorkSource);
@@ -3402,6 +3410,14 @@ public class RIL extends BaseCommands implements CommandsInterface {
    @Override
    public void stopLceService(Message result) {
        IRadio radioProxy = getRadioProxy(result);
        android.hardware.radio.V1_2.IRadio radioProxy12 =
                android.hardware.radio.V1_2.IRadio.castFrom(radioProxy);
        if (radioProxy12 != null) {
            // We have a 1.2 or later radio, so the LCE 1.0 LCE service control is unused.
            // Instead the LCE functionality is always-on and provides unsolicited indications.
            return;
        }

        if (radioProxy != null) {
            RILRequest rr = obtainRequest(RIL_REQUEST_STOP_LCE, result,
                    mRILDefaultWorkSource);
@@ -3418,6 +3434,17 @@ public class RIL extends BaseCommands implements CommandsInterface {
        }
    }

    /**
     * This will only be called if the LCE service is started in PULL mode, which is
     * only enabled when using Radio HAL versions 1.1 and earlier.
     *
     * It is still possible for vendors to override this behavior and use the 1.1 version
     * of LCE; however, this is strongly discouraged and this functionality will be removed
     * when HAL 1.x support is dropped.
     *
     * @deprecated HAL 1.2 and later use an always-on LCE that relies on indications.
     */
    @Deprecated
    @Override
    public void pullLceData(Message response) {
        IRadio radioProxy = getRadioProxy(response);
@@ -4955,21 +4982,24 @@ public class RIL extends BaseCommands implements CommandsInterface {
        return rc;
    }

    static ArrayList<Integer> convertHalLceData(LceDataInfo lce, RIL ril) {
        final ArrayList<Integer> capacityResponse = new ArrayList<Integer>();
        final int capacityDownKbps = lce.lastHopCapacityKbps;
        final int confidenceLevel = Byte.toUnsignedInt(lce.confidenceLevel);
        final int lceSuspended = lce.lceSuspended ? 1 : 0;
    static LinkCapacityEstimate convertHalLceData(LceDataInfo halData, RIL ril) {
        final LinkCapacityEstimate lce = new LinkCapacityEstimate(
                halData.lastHopCapacityKbps,
                Byte.toUnsignedInt(halData.confidenceLevel),
                halData.lceSuspended ? LinkCapacityEstimate.STATUS_SUSPENDED
                        : LinkCapacityEstimate.STATUS_ACTIVE);

        ril.riljLog("LCE capacity information received:" +
                " capacity=" + capacityDownKbps +
                " confidence=" + confidenceLevel +
                " lceSuspended=" + lceSuspended);
        ril.riljLog("LCE capacity information received:" + lce);
        return lce;
    }

        capacityResponse.add(capacityDownKbps);
        capacityResponse.add(confidenceLevel);
        capacityResponse.add(lceSuspended);
        return capacityResponse;
    static LinkCapacityEstimate convertHalLceData(
            android.hardware.radio.V1_2.LinkCapacityEstimate halData, RIL ril) {
        final LinkCapacityEstimate lce = new LinkCapacityEstimate(
                halData.downlinkCapacityKbps,
                halData.uplinkCapacityKbps);
        ril.riljLog("LCE capacity information received:" + lce);
        return lce;
    }

    private static void writeToParcelForGsm(
+12 −4
Original line number Diff line number Diff line
@@ -241,7 +241,15 @@ public class RadioIndication extends IRadioIndication.Stub {
     */
    public void currentLinkCapacityEstimate(int indicationType,
                                            android.hardware.radio.V1_2.LinkCapacityEstimate lce) {
      // TODO(b/70638175) Implement method.
        mRil.processIndication(indicationType);

        LinkCapacityEstimate response = RIL.convertHalLceData(lce, mRil);

        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_LCEDATA_RECV, response);

        if (mRil.mLceInfoRegistrants != null) {
            mRil.mLceInfoRegistrants.notifyRegistrants(new AsyncResult(null, response, null));
        }
    }

    /**
@@ -831,12 +839,12 @@ public class RadioIndication extends IRadioIndication.Stub {
    public void lceData(int indicationType, LceDataInfo lce) {
        mRil.processIndication(indicationType);

        ArrayList<Integer> response = RIL.convertHalLceData(lce, mRil);
        LinkCapacityEstimate response = RIL.convertHalLceData(lce, mRil);

        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_LCEDATA_RECV, response);

        if (mRil.mLceInfoRegistrant != null) {
            mRil.mLceInfoRegistrant.notifyRegistrant(new AsyncResult(null, response, null));
        if (mRil.mLceInfoRegistrants != null) {
            mRil.mLceInfoRegistrants.notifyRegistrants(new AsyncResult(null, response, null));
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -2009,7 +2009,7 @@ public class RadioResponse extends IRadioResponse.Stub {
        RILRequest rr = mRil.processResponse(responseInfo);

        if (rr != null) {
            ArrayList<Integer> ret = RIL.convertHalLceData(lceInfo, mRil);
            LinkCapacityEstimate ret = RIL.convertHalLceData(lceInfo, mRil);
            if (responseInfo.error == RadioError.NONE) {
                sendMessageResponse(rr.mResult, ret);
            }
Loading