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

Commit 27effa7a authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6429305 from 7c379133 to rvc-release

Change-Id: I5862d5536817722298781bd6fb9074ada910ba39
parents 643d8f51 7c379133
Loading
Loading
Loading
Loading
+47 −1
Original line number Diff line number Diff line
@@ -55,15 +55,19 @@ import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.IntArray;
import android.util.LocalLog;

import com.android.internal.telephony.uicc.IccUtils;
import com.android.telephony.Rlog;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringJoiner;

/**
 * CarrierPrivilegesTracker will track the Carrier Privileges for a specific {@link Phone}.
@@ -126,6 +130,7 @@ public class CarrierPrivilegesTracker extends Handler {
    private final UserManager mUserManager;
    private final TelephonyManager mTelephonyManager;
    private final RegistrantList mRegistrantList;
    private final LocalLog mLocalLog;

    // Stores certificate hashes for Carrier Config-loaded certs. Certs must be UPPERCASE.
    private final Set<String> mCarrierConfigCerts;
@@ -140,7 +145,7 @@ public class CarrierPrivilegesTracker extends Handler {
    private final Map<String, Set<Integer>> mCachedUids;

    // Privileged UIDs must be kept in sorted order for update-checks.
    protected int[] mPrivilegedUids;
    private int[] mPrivilegedUids;

    private final BroadcastReceiver mIntentReceiver =
            new BroadcastReceiver() {
@@ -208,6 +213,7 @@ public class CarrierPrivilegesTracker extends Handler {
        mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
        mTelephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
        mPhone = phone;
        mLocalLog = new LocalLog(100);

        IntentFilter filter = new IntentFilter();
        filter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
@@ -291,6 +297,10 @@ public class CarrierPrivilegesTracker extends Handler {
            updatedCarrierConfigCerts = getCarrierConfigCerts(subId);
        }

        mLocalLog.log("CarrierConfigUpdated:"
                + " subId=" + subId
                + " slotIndex=" + slotIndex
                + " updated CarrierConfig certs=" + updatedCarrierConfigCerts);
        maybeUpdateCertsAndNotifyRegistrants(mCarrierConfigCerts, updatedCarrierConfigCerts);
    }

@@ -322,6 +332,10 @@ public class CarrierPrivilegesTracker extends Handler {
            updatedUiccCerts = getSimCerts();
        }

        mLocalLog.log("SIM State Changed:"
                + " slotId=" + slotId
                + " simState=" + simState
                + " updated SIM-loaded certs=" + updatedUiccCerts);
        maybeUpdateCertsAndNotifyRegistrants(mUiccCerts, updatedUiccCerts);
    }

@@ -352,6 +366,9 @@ public class CarrierPrivilegesTracker extends Handler {

        updateCertsForPackage(pkg);
        mCachedUids.put(pkg.packageName, getUidsForPackage(pkg.packageName));
        mLocalLog.log("Package added/replaced:"
                + " pkg=" + Rlog.pii(TAG, pkgName)
                + " cert hashes=" + mInstalledPackageCerts.get(pkgName));

        maybeUpdatePrivilegedUidsAndNotifyRegistrants();
    }
@@ -377,6 +394,8 @@ public class CarrierPrivilegesTracker extends Handler {
        }
        mCachedUids.remove(pkgName);

        mLocalLog.log("Package removed: pkg=" + Rlog.pii(TAG, pkgName));

        maybeUpdatePrivilegedUidsAndNotifyRegistrants();
    }

@@ -401,6 +420,19 @@ public class CarrierPrivilegesTracker extends Handler {

        // Okay because no registrants exist yet
        maybeUpdatePrivilegedUidsAndNotifyRegistrants();

        mLocalLog.log("Initializing state:"
                + " CarrierConfig certs=" + mCarrierConfigCerts
                + " SIM-loaded certs=" + mUiccCerts
                + " installed pkgs=" + getObfuscatedPackages());
    }

    private String getObfuscatedPackages() {
        StringJoiner obfuscatedPkgs = new StringJoiner(",", "{", "}");
        for (Map.Entry<String, Set<String>> pkg : mInstalledPackageCerts.entrySet()) {
            obfuscatedPkgs.add("pkg(" + Rlog.pii(TAG, pkg.getKey()) + ")=" + pkg.getValue());
        }
        return obfuscatedPkgs.toString();
    }

    private void maybeUpdateCertsAndNotifyRegistrants(
@@ -422,6 +454,8 @@ public class CarrierPrivilegesTracker extends Handler {

        mPrivilegedUids = currentPrivilegedUids;
        mRegistrantList.notifyResult(mPrivilegedUids);

        mLocalLog.log("Privileged UIDs changed. New UIDs=" + Arrays.toString(mPrivilegedUids));
    }

    private int[] getCurrentPrivilegedUidsForAllUsers() {
@@ -468,6 +502,18 @@ public class CarrierPrivilegesTracker extends Handler {
        return uids;
    }

    /**
     * Dump the local log buffer and other internal state of CarrierPrivilegesTracker.
     */
    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("Dump of CarrierPrivilegesTracker");
        pw.println("CarrierPrivilegesTracker - Log Begin ----");
        mLocalLog.dump(fd, pw, args);
        pw.println("CarrierPrivilegesTracker - Log End ----");
        pw.println("CarrierPrivilegesTracker - Privileged UIDs: "
                + Arrays.toString(mPrivilegedUids));
    }

    /**
     * Registers the given Registrant with this tracker.
     *
+6 −2
Original line number Diff line number Diff line
@@ -4313,8 +4313,6 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        pw.println(" isInEmergencySmsMode=" + isInEmergencySmsMode());
        pw.println(" isEcmCanceledForEmergency=" + isEcmCanceledForEmergency());
        pw.println(" service state=" + getServiceState());
        String privilegedUids = Arrays.toString(mCarrierPrivilegesTracker.mPrivilegedUids);
        pw.println(" administratorUids=" + privilegedUids);
        pw.flush();
        pw.println("++++++++++++++++++++++++++++++++");

@@ -4437,6 +4435,12 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
            pw.println("++++++++++++++++++++++++++++++++");
        }

        if (getCarrierPrivilegesTracker() != null) {
            pw.println("CarrierPrivilegesTracker:");
            getCarrierPrivilegesTracker().dump(fd, pw, args);
            pw.println("++++++++++++++++++++++++++++++++");
        }

        pw.println("Phone Local Log: ");
        if (mLocalLog != null) {
            try {
+23 −20
Original line number Diff line number Diff line
@@ -2419,28 +2419,28 @@ public class RIL extends BaseCommands implements CommandsInterface {
        android.hardware.radio.V1_1.RadioAccessSpecifier rasInHalFormat =
                new android.hardware.radio.V1_1.RadioAccessSpecifier();
        rasInHalFormat.radioAccessNetwork = ras.getRadioAccessNetwork();
        List<Integer> bands = null;
        ArrayList<Integer> bands = new ArrayList<>();
        if (ras.getBands() != null) {
            for (int band : ras.getBands()) {
                bands.add(band);
            }
        }
        switch (ras.getRadioAccessNetwork()) {
            case AccessNetworkType.GERAN:
                bands = rasInHalFormat.geranBands;
                rasInHalFormat.geranBands = bands;
                break;
            case AccessNetworkType.UTRAN:
                bands = rasInHalFormat.utranBands;
                rasInHalFormat.utranBands = bands;
                break;
            case AccessNetworkType.EUTRAN:
                bands = rasInHalFormat.eutranBands;
                rasInHalFormat.eutranBands = bands;
                break;
            default:
                Log.wtf(RILJ_LOG_TAG, "radioAccessNetwork " + ras.getRadioAccessNetwork()
                        + " not supported on IRadio 1.1!");
                        + " not supported on IRadio < 1.5!");
                return null;
        }

        if (ras.getBands() != null) {
            for (int band : ras.getBands()) {
                bands.add(band);
            }
        }
        if (ras.getChannels() != null) {
            for (int channel : ras.getChannels()) {
                rasInHalFormat.channels.add(channel);
@@ -2454,32 +2454,35 @@ public class RIL extends BaseCommands implements CommandsInterface {
            convertRadioAccessSpecifierToRadioHAL_1_5(RadioAccessSpecifier ras) {
        android.hardware.radio.V1_5.RadioAccessSpecifier rasInHalFormat =
                new android.hardware.radio.V1_5.RadioAccessSpecifier();
        android.hardware.radio.V1_5.RadioAccessSpecifier.Bands bandsInHalFormat =
                new android.hardware.radio.V1_5.RadioAccessSpecifier.Bands();
        rasInHalFormat.radioAccessNetwork = convertAntToRan(ras.getRadioAccessNetwork());
        List<Integer> bands;
        ArrayList<Integer> bands = new ArrayList<>();
        if (ras.getBands() != null) {
            for (int band : ras.getBands()) {
                bands.add(band);
            }
        }
        switch (ras.getRadioAccessNetwork()) {
            case AccessNetworkType.GERAN:
                bands = rasInHalFormat.bands.geranBands();
                bandsInHalFormat.geranBands(bands);
                break;
            case AccessNetworkType.UTRAN:
                bands = rasInHalFormat.bands.utranBands();
                bandsInHalFormat.utranBands(bands);
                break;
            case AccessNetworkType.EUTRAN:
                bands = rasInHalFormat.bands.eutranBands();
                bandsInHalFormat.eutranBands(bands);
                break;
            case AccessNetworkType.NGRAN:
                bands = rasInHalFormat.bands.ngranBands();
                bandsInHalFormat.ngranBands(bands);
                break;
            default:
                Log.wtf(RILJ_LOG_TAG, "radioAccessNetwork " + ras.getRadioAccessNetwork()
                        + " not supported on IRadio 1.5!");
                return null;
        }
        rasInHalFormat.bands = bandsInHalFormat;

        if (ras.getBands() != null) {
            for (int band : ras.getBands()) {
                bands.add(band);
            }
        }
        if (ras.getChannels() != null) {
            for (int channel : ras.getChannels()) {
                rasInHalFormat.channels.add(channel);
+50 −26
Original line number Diff line number Diff line
@@ -119,6 +119,8 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@@ -128,6 +130,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;

/**
 * {@hide}
@@ -448,7 +451,6 @@ public class ServiceStateTracker extends Handler {
    protected final GsmCdmaPhone mPhone;

    private CellIdentity mCellIdentity;
    private CellIdentity mNewCellIdentity;
    private static final int MS_PER_HOUR = 60 * 60 * 1000;
    private final NitzStateMachine mNitzState;

@@ -741,7 +743,6 @@ public class ServiceStateTracker extends Handler {
        mLastNitzData = null;
        mNitzState.handleNetworkUnavailable();
        mCellIdentity = null;
        mNewCellIdentity = null;
        mSignalStrengthUpdatedTime = System.currentTimeMillis();

        //cancel any pending pollstate request on voice tech switching
@@ -2181,8 +2182,6 @@ public class ServiceStateTracker extends Handler {
                    }
                }

                mNewCellIdentity = networkRegState.getCellIdentity();

                if (DBG) {
                    log("handlePollStateResultMessage: CS cellular. " + networkRegState);
                }
@@ -3083,7 +3082,6 @@ public class ServiceStateTracker extends Handler {
        switch (mCi.getRadioState()) {
            case TelephonyManager.RADIO_POWER_UNAVAILABLE:
                mNewSS.setStateOutOfService();
                mNewCellIdentity = null;
                setSignalStrengthDefaultValues();
                mLastNitzData = null;
                mNitzState.handleNetworkUnavailable();
@@ -3092,7 +3090,6 @@ public class ServiceStateTracker extends Handler {

            case TelephonyManager.RADIO_POWER_OFF:
                mNewSS.setStateOff();
                mNewCellIdentity = null;
                setSignalStrengthDefaultValues();
                mLastNitzData = null;
                mNitzState.handleNetworkUnavailable();
@@ -3139,6 +3136,35 @@ public class ServiceStateTracker extends Handler {
        }
    }

    /**
     * Get the highest-priority CellIdentity for a provided ServiceState.
     *
     * Choose a CellIdentity for ServiceState using the following rules:
     * 1) WWAN only (WLAN is excluded)
     * 2) Registered > Camped
     * 3) CS > PS
     *
     * @param ss a Non-Null ServiceState object
     *
     * @return a list of CellIdentity objects in *decreasing* order of preference.
     */
    @VisibleForTesting public static @NonNull List<CellIdentity> getPrioritizedCellIdentities(
            @NonNull final ServiceState ss) {
        final List<NetworkRegistrationInfo> regInfos = ss.getNetworkRegistrationInfoList();
        if (regInfos.isEmpty()) return Collections.emptyList();

        return regInfos.stream()
            .filter(nri -> nri.getCellIdentity() != null)
            .filter(nri -> nri.getTransportType() == AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
            .sorted(Comparator
                    .comparing(NetworkRegistrationInfo::isRegistered)
                    .thenComparing((nri) -> nri.getDomain() & NetworkRegistrationInfo.DOMAIN_CS)
                    .reversed())
            .map(nri -> nri.getCellIdentity())
            .distinct()
            .collect(Collectors.toList());
    }

    private void pollStateDone() {
        if (!mPhone.isPhoneTypeGsm()) {
            updateRoamingState();
@@ -3241,8 +3267,13 @@ public class ServiceStateTracker extends Handler {
                mNewSS.getNetworkRegistrationInfo(
                        NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkType.EUTRAN));

        boolean hasLocationChanged = (mCellIdentity == null ? mNewCellIdentity != null
                : !mCellIdentity.isSameCell(mNewCellIdentity));
        final List<CellIdentity> prioritizedCids = getPrioritizedCellIdentities(mNewSS);

        final CellIdentity primaryCellIdentity = prioritizedCids.isEmpty()
                ? null : prioritizedCids.get(0);

        boolean hasLocationChanged = mCellIdentity == null
                ? primaryCellIdentity != null : !mCellIdentity.isSameCell(primaryCellIdentity);

        // ratchet the new tech up through its rat family but don't drop back down
        // until cell change or device is OOS
@@ -3328,7 +3359,7 @@ public class ServiceStateTracker extends Handler {
            // TODO: we may add filtering to reduce the event logged,
            // i.e. check preferred network setting, only switch to 2G, etc
            if (hasRilVoiceRadioTechnologyChanged) {
                int cid = getCidFromCellIdentity(mNewCellIdentity);
                int cid = getCidFromCellIdentity(primaryCellIdentity);
                // NOTE: this code was previously located after mSS and mNewSS are swapped, so
                // existing logs were incorrectly using the new state for "network_from"
                // and STATE_OUT_OF_SERVICE for "network_to". To avoid confusion, use a new log tag
@@ -3364,10 +3395,7 @@ public class ServiceStateTracker extends Handler {
        // clean slate for next time
        mNewSS.setStateOutOfService();

        // swap mCellIdentity and mNewCellIdentity to put new state in mCellIdentity
        CellIdentity tempCellId = mCellIdentity;
        mCellIdentity = mNewCellIdentity;
        mNewCellIdentity = tempCellId;
        mCellIdentity = primaryCellIdentity;

        if (hasRilVoiceRadioTechnologyChanged) {
            updatePhoneObject();
@@ -3426,10 +3454,13 @@ public class ServiceStateTracker extends Handler {
            // incomplete.
            // CellIdentity can return a null MCC and MNC in CDMA
            String localeOperator = operatorNumeric;
            if (isInvalidOperatorNumeric(operatorNumeric) && (mCellIdentity != null)
                    && mCellIdentity.getMccString() != null
                    && mCellIdentity.getMncString() != null) {
                localeOperator = mCellIdentity.getMccString() + mCellIdentity.getMncString();
            if (isInvalidOperatorNumeric(operatorNumeric)) {
                for (CellIdentity cid : prioritizedCids) {
                    if (!TextUtils.isEmpty(cid.getPlmn())) {
                        localeOperator = cid.getPlmn();
                        break;
                    }
                }
            }

            if (isInvalidOperatorNumeric(localeOperator)) {
@@ -3438,16 +3469,10 @@ public class ServiceStateTracker extends Handler {
                // operator numeric in locale tracker is null. The async update will allow getting
                // cell info from the modem instead of using the cached one.
                mLocaleTracker.updateOperatorNumeric("");
            } else if (mSS.getRilDataRadioTechnology() != ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN) {
                // If the device is on IWLAN, modems manufacture a ServiceState with the MCC/MNC of
                // the SIM as if we were talking to towers. Telephony code then uses that with
                // mccTable to suggest a timezone. We shouldn't do that if the MCC/MNC is from IWLAN

                // Update IDD.
            } else {
                if (!mPhone.isPhoneTypeGsm()) {
                    setOperatorIdd(localeOperator);
                }

                mLocaleTracker.updateOperatorNumeric(localeOperator);
            }

@@ -3764,7 +3789,7 @@ public class ServiceStateTracker extends Handler {
        }

        // Retrieve the current country information
        // with the MCC got from opeatorNumeric.
        // with the MCC got from operatorNumeric.
        String idd = mHbpcdUtils.getIddByMcc(
                Integer.parseInt(operatorNumeric.substring(0,3)));
        if (idd != null && !idd.isEmpty()) {
@@ -5132,7 +5157,6 @@ public class ServiceStateTracker extends Handler {
        pw.println(" mPendingRadioPowerOffAfterDataOff=" + mPendingRadioPowerOffAfterDataOff);
        pw.println(" mPendingRadioPowerOffAfterDataOffTag=" + mPendingRadioPowerOffAfterDataOffTag);
        pw.println(" mCellIdentity=" + Rlog.pii(VDBG, mCellIdentity));
        pw.println(" mNewCellIdentity=" + Rlog.pii(VDBG, mNewCellIdentity));
        pw.println(" mLastCellInfoReqTime=" + mLastCellInfoReqTime);
        dumpCellInfoList(pw);
        pw.flush();
+170 −34

File changed.

Preview size limit exceeded, changes collapsed.

Loading