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

Commit 0944ca6b authored by fenglu's avatar fenglu Committed by Feng Lu
Browse files

LCE service implementation - tele service side

-redesigned based on ConnectivityService/NetworkCapabilities

Change-Id: I54074234e1117b41eb6ff761ead9241928585fc6
parent 833231d4
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ 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
@@ -881,4 +882,29 @@ public abstract class BaseCommands implements CommandsInterface {
    public void unregisterForRadioCapabilityChanged(Handler h) {
        mPhoneRadioCapabilityChangedRegistrants.remove(h);
    }

    @Override
    public void startLceService(int reportIntervalMs, boolean pullMode, Message result) {
    }

    @Override
    public void stopLceService(Message result) {
    }

    @Override
    public void pullLceData(Message result) {
    }

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

    @Override
    public void unregisterForLceInfo(Handler h) {
      if (mLceInfoRegistrant != null && mLceInfoRegistrant.getHandler() == h) {
          mLceInfoRegistrant.clear();
          mLceInfoRegistrant = null;
      }
    }
}
+44 −0
Original line number Diff line number Diff line
@@ -1971,4 +1971,48 @@ public interface CommandsInterface {
     * @param h Handler to be removed from the registrant list.
     */
    public void unregisterForRadioCapabilityChanged(Handler h);

    /**
     * Start LCE (Link Capacity Estimation) service with a desired reporting interval.
     *
     * @param reportIntervalMs
     *        LCE info reporting interval (ms).
     *
     * @param result Callback message contains the current LCE status.
     * {byte status, int actualIntervalMs}
     */
    public void startLceService(int reportIntervalMs, boolean pullMode, Message result);

    /**
     * Stop LCE service.
     *
     * @param result Callback message contains the current LCE status:
     * {byte status, int actualIntervalMs}
     *
     */
    public void stopLceService(Message result);

    /**
     * Pull LCE service for capacity data.
     *
     * @param result Callback message contains the capacity info:
     * {int capacityKbps, byte confidenceLevel, byte lceSuspendedTemporarily}
     */
    public void pullLceData(Message result);

    /**
     * Register a LCE info listener.
     *
     * @param h Handler for notification message.
     * @param what User-defined message code.
     * @param obj User object.
     */
    void registerForLceInfo(Handler h, int what, Object obj);

    /**
     * Unregister the LCE Info listener.
     *
     * @param h handle to be removed.
     */
    void unregisterForLceInfo(Handler h);
}
+26 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.telephony;

import static com.android.internal.telephony.RILConstants.*;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -167,7 +168,8 @@ public abstract class PhoneBase extends Handler implements Phone {
    protected static final int EVENT_UNSOL_OEM_HOOK_RAW             = 34;
    protected static final int EVENT_GET_RADIO_CAPABILITY           = 35;
    protected static final int EVENT_SS                             = 36;
    protected static final int EVENT_LAST                           = EVENT_SS;
    protected static final int EVENT_CONFIG_LCE                     = 37;
    protected static final int EVENT_LAST                           = EVENT_CONFIG_LCE;

    // For shared prefs.
    private static final String GSM_ROAMING_LIST_OVERRIDE_PREFIX = "gsm_roaming_list_";
@@ -231,6 +233,11 @@ public abstract class PhoneBase extends Handler implements Phone {

    protected int mRadioAccessFamily = RadioAccessFamily.RAF_UNKNOWN;

    protected static final int DEFAULT_REPORT_INTERVAL_MS = 200;
    protected static final boolean LCE_PULL_MODE = true;
    protected int mReportInterval = 0;  // ms
    protected int mLceStatus = RILConstants.LCE_NOT_AVAILABLE;

    @Override
    public String getPhoneName() {
        return mName;
@@ -438,6 +445,8 @@ public abstract class PhoneBase extends Handler implements Phone {

        mCi.registerForSrvccStateChanged(this, EVENT_SRVCC_STATE_CHANGED, null);
        mCi.setOnUnsolOemHookRaw(this, EVENT_UNSOL_OEM_HOOK_RAW, null);
        mCi.startLceService(DEFAULT_REPORT_INTERVAL_MS, LCE_PULL_MODE,
            obtainMessage(EVENT_CONFIG_LCE));
    }

    @Override
@@ -476,6 +485,7 @@ public abstract class PhoneBase extends Handler implements Phone {
            mUiccController.unregisterForIccChanged(this);
            mCi.unregisterForSrvccStateChanged(this);
            mCi.unSetOnUnsolOemHookRaw(this);
            mCi.stopLceService(obtainMessage(EVENT_CONFIG_LCE));

            if (mTelephonyTester != null) {
                mTelephonyTester.dispose();
@@ -610,6 +620,17 @@ public abstract class PhoneBase extends Handler implements Phone {
                        + "phone RAF : " + mRadioAccessFamily);
                break;

            case EVENT_CONFIG_LCE:
                ar = (AsyncResult) msg.obj;
                if (ar.exception != null) {
                    Rlog.d(LOG_TAG, "config LCE service failed: " + ar.exception);
                } else {
                    final ArrayList<Integer> statusInfo = (ArrayList<Integer>)ar.result;
                    mLceStatus = statusInfo.get(0);
                    mReportInterval = statusInfo.get(1);
                }
                break;

            default:
                throw new RuntimeException("unexpected event not handled");
        }
@@ -2278,6 +2299,10 @@ public abstract class PhoneBase extends Handler implements Phone {
        return false;
    }

    public int getLceStatus() {
        return mLceStatus;
    }

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("PhoneBase: subId=" + getSubId());
        pw.println(" mPhoneId=" + mPhoneId);
+78 −0
Original line number Diff line number Diff line
@@ -2554,6 +2554,9 @@ public final class RIL extends BaseCommands implements CommandsInterface {
            case RIL_REQUEST_SHUTDOWN: ret = responseVoid(p); break;
            case RIL_REQUEST_GET_RADIO_CAPABILITY: ret =  responseRadioCapability(p); break;
            case RIL_REQUEST_SET_RADIO_CAPABILITY: ret =  responseRadioCapability(p); break;
            case RIL_REQUEST_START_LCE: ret = responseLceStatus(p); break;
            case RIL_REQUEST_STOP_LCE: ret = responseLceStatus(p); break;
            case RIL_REQUEST_PULL_LCEDATA: ret = responseLceData(p); break;
            default:
                throw new RuntimeException("Unrecognized solicited response: " + rr.mRequest);
            //break;
@@ -2759,6 +2762,7 @@ public final class RIL extends BaseCommands implements CommandsInterface {
                    ret = responseRadioCapability(p); break;
            case RIL_UNSOL_ON_SS: ret =  responseSsData(p); break;
            case RIL_UNSOL_STK_CC_ALPHA_NOTIFY: ret =  responseString(p); break;
            case RIL_UNSOL_LCEDATA_RECV: ret = responseLceData(p); break;

            default:
                throw new RuntimeException("Unrecognized unsol response: " + response);
@@ -3184,6 +3188,13 @@ public final class RIL extends BaseCommands implements CommandsInterface {
                                        new AsyncResult (null, ret, null));
                }
                break;
            case RIL_UNSOL_LCEDATA_RECV:
                if (RILJ_LOGD) unsljLogRet(response, ret);

                if (mLceInfoRegistrant != null) {
                    mLceInfoRegistrant.notifyRegistrant(new AsyncResult(null, ret, null));
                }
                break;
        }
    }

@@ -3912,6 +3923,36 @@ public final class RIL extends BaseCommands implements CommandsInterface {
        return rc;
    }

    private Object responseLceData(Parcel p) {
        final ArrayList<Integer> capacityResponse = new ArrayList<Integer>();
        final int capacityDownBps = p.readInt();
        final int confidenceLevel = p.readByte();
        final int lceSuspended = p.readByte();

        riljLog("LCE capacity information received:" +
                " capacity=" + capacityDownBps +
                " confidence=" + confidenceLevel +
                " lceSuspended=" + lceSuspended);

        capacityResponse.add(capacityDownBps);
        capacityResponse.add(confidenceLevel);
        capacityResponse.add(lceSuspended);
        return capacityResponse;
    }

    private Object responseLceStatus(Parcel p) {
        final ArrayList<Integer> statusResponse = new ArrayList<Integer>();
        final int lceStatus = (int)p.readByte();
        final int actualInterval = p.readInt();

        riljLog("LCE status information received:" +
                " lceStatus=" + lceStatus +
                " actualInterval=" + actualInterval);
        statusResponse.add(lceStatus);
        statusResponse.add(actualInterval);
        return statusResponse;
    }

    static String
    requestToString(int request) {
/*
@@ -4051,6 +4092,9 @@ public final class RIL extends BaseCommands implements CommandsInterface {
                    return "RIL_REQUEST_SET_RADIO_CAPABILITY";
            case RIL_REQUEST_GET_RADIO_CAPABILITY:
                    return "RIL_REQUEST_GET_RADIO_CAPABILITY";
            case RIL_REQUEST_START_LCE: return "RIL_REQUEST_START_LCE";
            case RIL_REQUEST_STOP_LCE: return "RIL_REQUEST_STOP_LCE";
            case RIL_REQUEST_PULL_LCEDATA: return "RIL_REQUEST_PULL_LCEDATA";
            default: return "<unknown request>";
        }
    }
@@ -4112,6 +4156,7 @@ public final class RIL extends BaseCommands implements CommandsInterface {
                    return "RIL_UNSOL_RADIO_CAPABILITY";
            case RIL_UNSOL_ON_SS: return "UNSOL_ON_SS";
            case RIL_UNSOL_STK_CC_ALPHA_NOTIFY: return "UNSOL_STK_CC_ALPHA_NOTIFY";
            case RIL_UNSOL_LCEDATA_RECV: return "UNSOL_LCE_INFO_RECV";
            default: return "<unknown response>";
        }
    }
@@ -4656,4 +4701,37 @@ public final class RIL extends BaseCommands implements CommandsInterface {

        send(rr);
    }

    @Override
    public void startLceService(int reportIntervalMs, boolean pullMode, Message response) {
        RILRequest rr = RILRequest.obtain(RIL_REQUEST_START_LCE, response);
        /** solicited command argument: reportIntervalMs, pullMode. */
        rr.mParcel.writeInt(2);
        rr.mParcel.writeInt(reportIntervalMs);
        rr.mParcel.writeInt(pullMode ? 1: 0);  // PULL mode: 1; PUSH mode: 0;

        if (RILJ_LOGD) {
            riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
        }

        send(rr);
    }

    @Override
    public void stopLceService(Message response) {
        RILRequest rr = RILRequest.obtain(RIL_REQUEST_STOP_LCE, response);
        if (RILJ_LOGD) {
            riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
        }
        send(rr);
    }

    @Override
    public void pullLceData(Message response) {
        RILRequest rr = RILRequest.obtain(RIL_REQUEST_PULL_LCEDATA, response);
        if (RILJ_LOGD) {
            riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
        }
        send(rr);
    }
}
+0 −1
Original line number Diff line number Diff line
@@ -237,7 +237,6 @@ public abstract class ServiceStateTracker extends Handler {
    protected boolean mCurShowPlmn = false;
    protected boolean mCurShowSpn = false;


    private boolean mImsRegistered = false;

    protected SubscriptionManager mSubscriptionManager;
Loading