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

Commit d7c77f27 authored by Sarah Chin's avatar Sarah Chin Committed by Gerrit Code Review
Browse files

Merge changes from topics "ccm_bw", "ccm_unmetered", "displayinfo"

* changes:
  Carrier config for 5G up/down bandwidth and LTE for NSA
  Support carrier config for sub6/mmwave unmetered
  Move override logic from SysUI to Telephony
parents 83cadde6 0d7320f4
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.telephony.Annotation.SrvccState;
import android.telephony.CallQuality;
import android.telephony.CellIdentity;
import android.telephony.CellInfo;
import android.telephony.DisplayInfo;
import android.telephony.PhoneCapability;
import android.telephony.PreciseCallState;
import android.telephony.PreciseDataConnectionState;
@@ -211,6 +212,12 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
            sender.getPhoneId(), rawData);
    }

    @Override
    public void notifyDisplayInfoChanged(Phone sender, DisplayInfo displayInfo) {
        mTelephonyRegistryMgr.notifyDisplayInfoChanged(
                sender.getSubId(), sender.getPhoneId(), displayInfo);
    }

    @Override
    public void notifyPhoneCapabilityChanged(PhoneCapability capability) {
        mTelephonyRegistryMgr.notifyPhoneCapabilityChanged(capability);
+6 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import android.telephony.CarrierRestrictionRules;
import android.telephony.CellIdentity;
import android.telephony.CellInfo;
import android.telephony.ClientRequestStats;
import android.telephony.DisplayInfo;
import android.telephony.ImsiEncryptionInfo;
import android.telephony.PhoneStateListener;
import android.telephony.PhysicalChannelConfig;
@@ -2393,6 +2394,11 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        mNotifier.notifyUserMobileDataStateChanged(this, state);
    }

    /** Send notification that display info has changed. */
    public void notifyDisplayInfoChanged(DisplayInfo displayInfo) {
        mNotifier.notifyDisplayInfoChanged(this, displayInfo);
    }

    public void notifySignalStrength() {
        mNotifier.notifySignalStrength(this);
    }
+4 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.telephony.Annotation.SrvccState;
import android.telephony.CallQuality;
import android.telephony.CellIdentity;
import android.telephony.CellInfo;
import android.telephony.DisplayInfo;
import android.telephony.PhoneCapability;
import android.telephony.PreciseDataConnectionState;
import android.telephony.emergency.EmergencyNumber;
@@ -88,6 +89,9 @@ public interface PhoneNotifier {
    /** Send a notification with an OEM hook payload */
    void notifyOemHookRawEventForSubscriber(Phone sender, byte[] rawData);

    /** Send a notification that the display info has changed */
    void notifyDisplayInfoChanged(Phone sender, DisplayInfo displayInfo);

    /** Send a notification that the phone capability has changed */
    void notifyPhoneCapabilityChanged(PhoneCapability capability);

+25 −2
Original line number Diff line number Diff line
@@ -222,6 +222,7 @@ public class ServiceStateTracker extends Handler {
    private RegistrantList mPsRestrictDisabledRegistrants = new RegistrantList();
    private RegistrantList mImsCapabilityChangedRegistrants = new RegistrantList();
    private RegistrantList mNrStateChangedRegistrants = new RegistrantList();
    private RegistrantList mNrFrequencyChangedRegistrants = new RegistrantList();

    /* Radio power off pending flag and tag counter */
    private boolean mPendingRadioPowerOffAfterDataOff = false;
@@ -1582,8 +1583,11 @@ public class ServiceStateTracker extends Handler {
                    }
                    mPhone.notifyPhysicalChannelConfiguration(list);
                    mLastPhysicalChannelConfigList = list;
                    boolean hasChanged =
                            updateNrFrequencyRangeFromPhysicalChannelConfigs(list, mSS);
                    boolean hasChanged = false;
                    if (updateNrFrequencyRangeFromPhysicalChannelConfigs(list, mSS)) {
                        mNrFrequencyChangedRegistrants.notifyRegistrants();
                        hasChanged = true;
                    }
                    if (updateNrStateFromPhysicalChannelConfigs(list, mSS)) {
                        mNrStateChangedRegistrants.notifyRegistrants();
                        hasChanged = true;
@@ -5642,6 +5646,25 @@ public class ServiceStateTracker extends Handler {
        mNrStateChangedRegistrants.remove(h);
    }

    /**
     * Registers for 5G NR frequency changed.
     * @param h handler to notify
     * @param what what code of message when delivered
     * @param obj placed in Message.obj
     */
    public void registerForNrFrequencyChanged(Handler h, int what, Object obj) {
        Registrant r = new Registrant(h, what, obj);
        mNrFrequencyChangedRegistrants.add(r);
    }

    /**
     * Unregisters for 5G NR frequency changed.
     * @param h handler to notify
     */
    public void unregisterForNrFrequencyChanged(Handler h) {
        mNrFrequencyChangedRegistrants.remove(h);
    }

    /**
     * Get the NR data connection context ids.
     *
+59 −41
Original line number Diff line number Diff line
@@ -321,8 +321,8 @@ public class DataConnection extends StateMachine {
    static final int EVENT_REEVALUATE_DATA_CONNECTION_PROPERTIES = BASE + 26;
    static final int EVENT_NR_STATE_CHANGED = BASE + 27;
    static final int EVENT_DATA_CONNECTION_METEREDNESS_CHANGED = BASE + 28;
    private static final int CMD_TO_STRING_COUNT =
            EVENT_DATA_CONNECTION_METEREDNESS_CHANGED - BASE + 1;
    static final int EVENT_NR_FREQUENCY_CHANGED = BASE + 29;
    private static final int CMD_TO_STRING_COUNT = EVENT_NR_FREQUENCY_CHANGED - BASE + 1;

    private static String[] sCmdToString = new String[CMD_TO_STRING_COUNT];
    static {
@@ -358,10 +358,10 @@ public class DataConnection extends StateMachine {
                "EVENT_REEVALUATE_RESTRICTED_STATE";
        sCmdToString[EVENT_REEVALUATE_DATA_CONNECTION_PROPERTIES - BASE] =
                "EVENT_REEVALUATE_DATA_CONNECTION_PROPERTIES";
        sCmdToString[EVENT_NR_STATE_CHANGED - BASE] =
                "EVENT_NR_STATE_CHANGED";
        sCmdToString[EVENT_NR_STATE_CHANGED - BASE] = "EVENT_NR_STATE_CHANGED";
        sCmdToString[EVENT_DATA_CONNECTION_METEREDNESS_CHANGED - BASE] =
                "EVENT_DATA_CONNECTION_METEREDNESS_CHANGED";
        sCmdToString[EVENT_NR_FREQUENCY_CHANGED - BASE] = "EVENT_NR_FREQUENCY_CHANGED";
    }
    // Convert cmd to string or null if unknown
    static String cmdToString(int cmd) {
@@ -748,8 +748,7 @@ public class DataConnection extends StateMachine {
     * @param isUnmetered whether this DC should be set to unmetered or not
     */
    public void onMeterednessChanged(boolean isUnmetered) {
        mUnmeteredOverride = isUnmetered;
        sendMessage(obtainMessage(EVENT_DATA_CONNECTION_METEREDNESS_CHANGED));
        sendMessage(obtainMessage(EVENT_DATA_CONNECTION_METEREDNESS_CHANGED, isUnmetered));
    }

    /**
@@ -1100,6 +1099,23 @@ public class DataConnection extends StateMachine {
        mLinkProperties.setTcpBufferSizes(sizes);
    }

    private void updateLinkBandwidths(NetworkCapabilities caps, int rilRat) {
        String ratName = ServiceState.rilRadioTechnologyToString(rilRat).toLowerCase(Locale.ROOT);
        if (ratName.equals("LTE") && isNRConnected()) {
            ratName = mPhone.getServiceState().getNrFrequencyRange()
                    == ServiceState.FREQUENCY_RANGE_MMWAVE ? "NR_NSA_MMWAVE" : "NR_NSA";
        }

        if (DBG) log("updateLinkBandwidths: " + ratName);

        Pair<Integer, Integer> values = mDct.getLinkBandwidths(ratName);
        if (values == null) {
            values = new Pair<>(14, 14);
        }
        caps.setLinkDownstreamBandwidthKbps(values.first);
        caps.setLinkUpstreamBandwidthKbps(values.second);
    }

    /**
     * Indicates if this data connection was established for unmetered use only. Note that this
     * flag should be populated when data becomes active. And if it is set to true, it can be set to
@@ -1312,29 +1328,7 @@ public class DataConnection extends StateMachine {
            result.removeCapability(NetworkCapabilities.NET_CAPABILITY_DUN);
        }

        int up = 14;
        int down = 14;
        switch (mRilRat) {
            case ServiceState.RIL_RADIO_TECHNOLOGY_GPRS: up = 80; down = 80; break;
            case ServiceState.RIL_RADIO_TECHNOLOGY_EDGE: up = 59; down = 236; break;
            case ServiceState.RIL_RADIO_TECHNOLOGY_UMTS: up = 384; down = 384; break;
            case ServiceState.RIL_RADIO_TECHNOLOGY_IS95A: // fall through
            case ServiceState.RIL_RADIO_TECHNOLOGY_IS95B: up = 14; down = 14; break;
            case ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_0: up = 153; down = 2457; break;
            case ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_A: up = 1843; down = 3174; break;
            case ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT: up = 100; down = 100; break;
            case ServiceState.RIL_RADIO_TECHNOLOGY_HSDPA: up = 2048; down = 14336; break;
            case ServiceState.RIL_RADIO_TECHNOLOGY_HSUPA: up = 5898; down = 14336; break;
            case ServiceState.RIL_RADIO_TECHNOLOGY_HSPA: up = 5898; down = 14336; break;
            case ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_B: up = 1843; down = 5017; break;
            case ServiceState.RIL_RADIO_TECHNOLOGY_LTE: up = 51200; down = 102400; break;
            case ServiceState.RIL_RADIO_TECHNOLOGY_LTE_CA: up = 51200; down = 102400; break;
            case ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD: up = 153; down = 2516; break;
            case ServiceState.RIL_RADIO_TECHNOLOGY_HSPAP: up = 11264; down = 43008; break;
            default:
        }
        result.setLinkUpstreamBandwidthKbps(up);
        result.setLinkDownstreamBandwidthKbps(down);
        updateLinkBandwidths(result, mRilRat);

        result.setNetworkSpecifier(new TelephonyNetworkSpecifier.Builder()
                .setSubscriptionId(mSubId).build());
@@ -1569,6 +1563,8 @@ public class DataConnection extends StateMachine {
                    DataConnection.EVENT_DATA_CONNECTION_ROAM_OFF, null, true);
            mPhone.getServiceStateTracker().registerForNrStateChanged(getHandler(),
                    DataConnection.EVENT_NR_STATE_CHANGED, null);
            mPhone.getServiceStateTracker().registerForNrFrequencyChanged(getHandler(),
                    DataConnection.EVENT_NR_FREQUENCY_CHANGED, null);

            // Add ourselves to the list of data connections
            mDcController.addDc(DataConnection.this);
@@ -1583,6 +1579,8 @@ public class DataConnection extends StateMachine {

            mPhone.getServiceStateTracker().unregisterForDataRoamingOn(getHandler());
            mPhone.getServiceStateTracker().unregisterForDataRoamingOff(getHandler());
            mPhone.getServiceStateTracker().unregisterForNrStateChanged(getHandler());
            mPhone.getServiceStateTracker().unregisterForNrFrequencyChanged(getHandler());

            // Remove ourselves from the DC lists
            mDcController.removeDc(DataConnection.this);
@@ -1664,9 +1662,16 @@ public class DataConnection extends StateMachine {
                        mNetworkAgent.sendLinkProperties(mLinkProperties, DataConnection.this);
                    }
                    break;
                case EVENT_DATA_CONNECTION_METEREDNESS_CHANGED:
                    boolean isUnmetered = (boolean) msg.obj;
                    if (isUnmetered == mUnmeteredOverride) {
                        break;
                    }
                    mUnmeteredOverride = isUnmetered;
                    // fallthrough
                case EVENT_NR_FREQUENCY_CHANGED:
                case EVENT_DATA_CONNECTION_ROAM_ON:
                case EVENT_DATA_CONNECTION_ROAM_OFF:
                case EVENT_DATA_CONNECTION_METEREDNESS_CHANGED:
                case EVENT_DATA_CONNECTION_OVERRIDE_CHANGED:
                    updateNetworkInfo();
                    if (mNetworkAgent != null) {
@@ -2289,15 +2294,23 @@ public class DataConnection extends StateMachine {
                    if (ar.exception != null) {
                        log("EVENT_BW_REFRESH_RESPONSE: error ignoring, e=" + ar.exception);
                    } else {
                        final LinkCapacityEstimate lce = (LinkCapacityEstimate) ar.result;
                        boolean useModem = DctConstants.BANDWIDTH_SOURCE_MODEM_KEY.equals(
                                mPhone.getContext().getResources().getString(com.android.internal.R
                                        .string.config_bandwidthEstimateSource));
                        NetworkCapabilities nc = getNetworkCapabilities();
                        if (mPhone.getLceStatus() == RILConstants.LCE_ACTIVE) {
                        LinkCapacityEstimate lce = (LinkCapacityEstimate) ar.result;
                        if (useModem && mPhone.getLceStatus() == RILConstants.LCE_ACTIVE) {
                            if (lce.downlinkCapacityKbps != LinkCapacityEstimate.INVALID) {
                                nc.setLinkDownstreamBandwidthKbps(lce.downlinkCapacityKbps);
                            }
                            if (lce.uplinkCapacityKbps != LinkCapacityEstimate.INVALID) {
                                nc.setLinkUpstreamBandwidthKbps(lce.uplinkCapacityKbps);
                            }
                        }
                        if (mNetworkAgent != null) {
                            mNetworkAgent.sendNetworkCapabilities(nc, DataConnection.this);
                        }
                    }
                    }
                    retVal = HANDLED;
                    break;
                }
@@ -2413,14 +2426,19 @@ public class DataConnection extends StateMachine {
                    if (ar.exception != null) {
                        loge("EVENT_LINK_CAPACITY_CHANGED e=" + ar.exception);
                    } else {
                        LinkCapacityEstimate lce = (LinkCapacityEstimate) ar.result;
                        boolean useModem = DctConstants.BANDWIDTH_SOURCE_MODEM_KEY.equals(
                                mPhone.getContext().getResources().getString(com.android.internal.R
                                        .string.config_bandwidthEstimateSource));
                        NetworkCapabilities nc = getNetworkCapabilities();
                        if (useModem) {
                            LinkCapacityEstimate lce = (LinkCapacityEstimate) ar.result;
                            if (lce.downlinkCapacityKbps != LinkCapacityEstimate.INVALID) {
                                nc.setLinkDownstreamBandwidthKbps(lce.downlinkCapacityKbps);
                            }
                            if (lce.uplinkCapacityKbps != LinkCapacityEstimate.INVALID) {
                                nc.setLinkUpstreamBandwidthKbps(lce.uplinkCapacityKbps);
                            }
                        }
                        if (mNetworkAgent != null) {
                            mNetworkAgent.sendNetworkCapabilities(nc, DataConnection.this);
                        }
Loading