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

Commit 9e9eea0d authored by SongFerng Wang's avatar SongFerng Wang Committed by Android (Google) Code Review
Browse files

Merge "Operator name modification by pattern add more condition" into qt-dev

parents c3da0e72 36695293
Loading
Loading
Loading
Loading
+30 −1
Original line number Diff line number Diff line
@@ -2087,7 +2087,8 @@ public class GsmCdmaPhone extends Phone {
    @Override
    public void getAvailableNetworks(Message response) {
        if (isPhoneTypeGsm() || isPhoneTypeCdmaLte()) {
            mCi.getAvailableNetworks(response);
            Message msg = obtainMessage(EVENT_GET_AVAILABLE_NETWORKS_DONE, response);
            mCi.getAvailableNetworks(msg);
        } else {
            loge("getAvailableNetworks: not possible in CDMA");
        }
@@ -2747,6 +2748,34 @@ public class GsmCdmaPhone extends Phone {
            case EVENT_DEVICE_PROVISIONING_DATA_SETTING_CHANGE:
                mDataEnabledSettings.updateProvisioningDataEnabled();
                break;
            case EVENT_GET_AVAILABLE_NETWORKS_DONE:
                ar = (AsyncResult) msg.obj;
                if (ar.exception == null && ar.result != null && mSST != null) {
                    List<OperatorInfo> operatorInfoList = (List<OperatorInfo>) ar.result;
                    List<OperatorInfo> filteredInfoList = new ArrayList<>();
                    for (OperatorInfo operatorInfo : operatorInfoList) {
                        if (OperatorInfo.State.CURRENT == operatorInfo.getState()) {
                            filteredInfoList.add(new OperatorInfo(
                                    mSST.filterOperatorNameByPattern(
                                            operatorInfo.getOperatorAlphaLong()),
                                    mSST.filterOperatorNameByPattern(
                                            operatorInfo.getOperatorAlphaShort()),
                                    operatorInfo.getOperatorNumeric(),
                                    operatorInfo.getState()
                            ));
                        } else {
                            filteredInfoList.add(operatorInfo);
                        }
                    }
                    ar.result = filteredInfoList;
                }

                onComplete = (Message) ar.userObj;
                if (onComplete != null) {
                    AsyncResult.forMessage(onComplete, ar.result, ar.exception);
                    onComplete.sendToTarget();
                }
                break;
            default:
                super.handleMessage(msg);
        }
+5 −0
Original line number Diff line number Diff line
@@ -437,6 +437,11 @@ public final class NetworkScanRequestTracker {
                        ? TelephonyScanManager.CALLBACK_SCAN_RESULTS
                        : TelephonyScanManager.CALLBACK_RESTRICTED_SCAN_RESULTS;
                if (nsr.scanError == NetworkScan.SUCCESS) {
                    if (nsri.mPhone.getServiceStateTracker() != null) {
                        nsri.mPhone.getServiceStateTracker().updateOperatorNameForCellInfo(
                                nsr.networkInfos);
                    }

                    notifyMessenger(nsri, notifyMsg,
                            rilErrorToScanError(nsr.scanError), nsr.networkInfos);
                    if (nsr.scanStatus == NetworkScanResult.SCAN_STATUS_COMPLETE) {
+2 −1
Original line number Diff line number Diff line
@@ -223,8 +223,9 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    protected static final int EVENT_SET_CARRIER_DATA_ENABLED       = 48;
    protected static final int EVENT_DEVICE_PROVISIONED_CHANGE      = 49;
    protected static final int EVENT_DEVICE_PROVISIONING_DATA_SETTING_CHANGE = 50;
    protected static final int EVENT_GET_AVAILABLE_NETWORKS_DONE    = 51;

    protected static final int EVENT_LAST = EVENT_DEVICE_PROVISIONING_DATA_SETTING_CHANGE;
    protected static final int EVENT_LAST = EVENT_GET_AVAILABLE_NETWORKS_DONE;

    // For shared prefs.
    private static final String GSM_ROAMING_LIST_OVERRIDE_PREFIX = "gsm_roaming_list_";
+29 −9
Original line number Diff line number Diff line
@@ -4589,11 +4589,7 @@ 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);
            }
            updateOperatorNamePattern(config);
        }

        // Sometimes the network registration information comes before carrier config is ready.
@@ -5319,6 +5315,17 @@ public class ServiceStateTracker extends Handler {
        return mEriManager.getCdmaEriText(roamInd, defRoamInd);
    }

    private void updateOperatorNamePattern(PersistableBundle config) {
        String operatorNamePattern = config.getString(
                CarrierConfigManager.KEY_OPERATOR_NAME_FILTER_PATTERN_STRING);
        if (!TextUtils.isEmpty(operatorNamePattern)) {
            mOperatorNameStringPattern = Pattern.compile(operatorNamePattern);
            if (DBG) {
                log("mOperatorNameStringPattern: " + mOperatorNameStringPattern.toString());
            }
        }
    }

    private void updateOperatorNameForServiceState(ServiceState servicestate) {
        if (servicestate == null) {
            return;
@@ -5350,16 +5357,29 @@ public class ServiceStateTracker extends Handler {
                filterOperatorNameByPattern((String) cellIdentity.getOperatorAlphaShort()));
    }

    private void updateOperatorNameForCellInfo(List<CellInfo> cellInfos) {
    /**
     * To modify the operator name of CellInfo by pattern.
     *
     * @param cellInfos List of CellInfo{@link CellInfo}.
     */
    public void updateOperatorNameForCellInfo(List<CellInfo> cellInfos) {
        if (cellInfos == null || cellInfos.isEmpty()) {
            return;
        }
        for (int i = 0; i < cellInfos.size(); i++) {
            updateOperatorNameForCellIdentity(cellInfos.get(i).getCellIdentity());
        for (CellInfo cellInfo : cellInfos) {
            if (cellInfo.isRegistered()) {
                updateOperatorNameForCellIdentity(cellInfo.getCellIdentity());
            }
        }
    }

    private String filterOperatorNameByPattern(String operatorName) {
    /**
     * To modify the operator name by pattern.
     *
     * @param operatorName Registered operator name
     * @return An operator name.
     */
    public String filterOperatorNameByPattern(String operatorName) {
        if (mOperatorNameStringPattern == null || TextUtils.isEmpty(operatorName)) {
            return operatorName;
        }