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

Commit 9a7b92c9 authored by SongFerngWang's avatar SongFerngWang Committed by SongFerng Wang
Browse files

Add 5G evolution icon

This add the 5GE icon to the system UI for specific carriers
LTE CA network.

Bug: 124768697
Test: build & manually test:
fake the operator name with pattern, and check the status bar data icon

Change-Id: I411bf44c98f1fe199592ea657127ad7c480fc2db
Merged-In: I411bf44c98f1fe199592ea657127ad7c480fc2db
(cherry picked from commit 3e0ea426)
parent d9288d55
Loading
Loading
Loading
Loading
+69 −0
Original line number Diff line number Diff line
@@ -113,6 +113,8 @@ import java.util.List;
import java.util.Objects;
import java.util.TimeZone;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

/**
@@ -322,6 +324,8 @@ public class ServiceStateTracker extends Handler {
    private final LocalLog mRadioPowerLog = new LocalLog(20);
    private final LocalLog mMdnLog = new LocalLog(20);

    private Pattern mOperatorNameStringPattern;

    private class SstSubscriptionsChangedListener extends OnSubscriptionsChangedListener {
        public final AtomicInteger mPreviousSubId =
                new AtomicInteger(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
@@ -1076,6 +1080,7 @@ public class ServiceStateTracker extends Handler {
                        loge("Invalid CellInfo result");
                    } else {
                        cellInfo = (List<CellInfo>) ar.result;
                        updateOperatorNameForCellInfo(cellInfo);
                        mLastCellInfoList = cellInfo;
                        mPhone.notifyCellInfo(cellInfo);
                        if (VDBG) {
@@ -1188,6 +1193,7 @@ public class ServiceStateTracker extends Handler {
                if (ar.exception == null) {
                    CellIdentity cellIdentity = ((NetworkRegistrationInfo) ar.result)
                            .getCellIdentity();
                    updateOperatorNameForCellIdentity(cellIdentity);
                    mCellIdentity = cellIdentity;
                    mPhone.notifyLocationChanged(getCellLocation());
                }
@@ -1776,6 +1782,7 @@ public class ServiceStateTracker extends Handler {
        if (mPollingContext[0] == 0) {
            mNewSS.setEmergencyOnly(mEmergencyOnly);
            combinePsRegistrationStates(mNewSS);
            updateOperatorNameForServiceState(mNewSS);
            if (mPhone.isPhoneTypeGsm()) {
                updateRoamingState();
            } else {
@@ -2158,6 +2165,8 @@ public class ServiceStateTracker extends Handler {
                    String opNames[] = (String[]) ar.result;

                    if (opNames != null && opNames.length >= 3) {
                        mNewSS.setOperatorAlphaLongRaw(opNames[0]);
                        mNewSS.setOperatorAlphaShortRaw(opNames[1]);
                        // FIXME: Giving brandOverride higher precedence, is this desired?
                        String brandOverride = mUiccController.getUiccCard(getPhoneId()) != null
                                ? mUiccController.getUiccCard(getPhoneId())
@@ -4481,6 +4490,11 @@ public class ServiceStateTracker extends Handler {
        if (config != null) {
            updateLteEarfcnLists(config);
            updateReportingCriteria(config);
            String operatorNamePattern = config.getString(
                    CarrierConfigManager.KEY_OPERATOR_NAME_FILTER_PATTERN_STRING);
            if (!TextUtils.isEmpty(operatorNamePattern)) {
                mOperatorNameStringPattern = Pattern.compile(operatorNamePattern);
            }
        }

        // Sometimes the network registration information comes before carrier config is ready.
@@ -5205,4 +5219,59 @@ public class ServiceStateTracker extends Handler {
    String getCdmaEriText(int roamInd, int defRoamInd) {
        return mEriManager.getCdmaEriText(roamInd, defRoamInd);
    }

    private void updateOperatorNameForServiceState(ServiceState servicestate) {
        if (servicestate == null) {
            return;
        }

        servicestate.setOperatorName(
                filterOperatorNameByPattern(servicestate.getOperatorAlphaLong()),
                filterOperatorNameByPattern(servicestate.getOperatorAlphaShort()),
                servicestate.getOperatorNumeric());

        List<NetworkRegistrationInfo> networkRegistrationInfos =
                servicestate.getNetworkRegistrationInfoList();

        for (int i = 0; i < networkRegistrationInfos.size(); i++) {
            if (networkRegistrationInfos.get(i) != null) {
                updateOperatorNameForCellIdentity(
                        networkRegistrationInfos.get(i).getCellIdentity());
            }
        }
    }

    private void updateOperatorNameForCellIdentity(CellIdentity cellIdentity) {
        if (cellIdentity == null) {
            return;
        }
        cellIdentity.setOperatorAlphaLong(
                filterOperatorNameByPattern((String) cellIdentity.getOperatorAlphaLong()));
        cellIdentity.setOperatorAlphaShort(
                filterOperatorNameByPattern((String) cellIdentity.getOperatorAlphaShort()));
    }

    private void updateOperatorNameForCellInfo(List<CellInfo> cellInfos) {
        if (cellInfos == null || cellInfos.isEmpty()) {
            return;
        }
        for (int i = 0; i < cellInfos.size(); i++) {
            updateOperatorNameForCellIdentity(cellInfos.get(i).getCellIdentity());
        }
    }

    private String filterOperatorNameByPattern(String operatorName) {
        if (mOperatorNameStringPattern == null || TextUtils.isEmpty(operatorName)) {
            return operatorName;
        }
        Matcher matcher = mOperatorNameStringPattern.matcher(operatorName);
        if (matcher.find()) {
            if (matcher.groupCount() > 0) {
                operatorName = matcher.group(1);
            } else {
                log("filterOperatorNameByPattern: pattern no group");
            }
        }
        return operatorName;
    }
}