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

Commit 96111249 authored by Jack Yu's avatar Jack Yu Committed by Android (Google) Code Review
Browse files

Merge "Revert "Fixed the set/getAllowedNetworkTypes debug messages""

parents 3b4e30d2 3fc8c2f5
Loading
Loading
Loading
Loading
+48 −17
Original line number Diff line number Diff line
@@ -472,6 +472,10 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    protected SimulatedRadioControl mSimulatedRadioControl;

    private Map<Integer, Long> mAllowedNetworkTypesForReasons = new HashMap<>();
    private static final String ALLOWED_NETWORK_TYPES_TEXT_USER = "user";
    private static final String ALLOWED_NETWORK_TYPES_TEXT_POWER = "power";
    private static final String ALLOWED_NETWORK_TYPES_TEXT_CARRIER = "carrier";
    private static final String ALLOWED_NETWORK_TYPES_TEXT_ENABLE_2G = "enable_2g";
    private static final int INVALID_ALLOWED_NETWORK_TYPES = -1;
    protected boolean mIsCarrierNrSupported = false;
    protected boolean mIsAllowedNetworkTypesLoadedFromDb = false;
@@ -2326,9 +2330,8 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
     */
    public void notifyAllowedNetworkTypesChanged(
            @TelephonyManager.AllowedNetworkTypesReason int reason) {
        logd("notifyAllowedNetworkTypesChanged: subId=" + getSubId() + ", reason="
                + TelephonyManager.allowedNetworkTypesReasonToString(reason)
                + " network types=" + TelephonyManager.convertNetworkTypeBitmaskToString(
        logd("SubId" + getSubId() + ",notifyAllowedNetworkTypesChanged: reason: " + reason
                + " value:" + TelephonyManager.convertNetworkTypeBitmaskToString(
                getAllowedNetworkTypes(reason)));
        mNotifier.notifyAllowedNetworkTypesChanged(this, reason, getAllowedNetworkTypes(reason));
    }
@@ -2381,9 +2384,9 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
                && reason == TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_CARRIER) {
            allowedNetworkTypes = updateAllowedNetworkTypeForCarrierWithCarrierConfig();
        }
        logd("getAllowedNetworkTypes: subId=" + getSubId() + ", reason="
                + TelephonyManager.allowedNetworkTypesReasonToString(reason)
                + ", network types=" + TelephonyManager.convertNetworkTypeBitmaskToString(
        logd("SubId" + getSubId() + ",get allowed network types "
                + convertAllowedNetworkTypeMapIndexToDbName(reason)
                + ": value = " + TelephonyManager.convertNetworkTypeBitmaskToString(
                allowedNetworkTypes));
        return allowedNetworkTypes;
    }
@@ -2418,8 +2421,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
            return;
        }

        logd("loadAllowedNetworksFromSubscriptionDatabase: subId=" + getSubId() + ", "
                + SubscriptionInfoInternal.getPrintableAllowedNetworkTypesForReasons(result));
        logd("SubId" + getSubId() + ",load allowed network types : value = " + result);
        Map<Integer, Long> oldAllowedNetworkTypes = new HashMap<>(mAllowedNetworkTypesForReasons);
        mAllowedNetworkTypesForReasons.clear();
        try {
@@ -2430,10 +2432,10 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
                    Rlog.e(LOG_TAG, "Invalid ALLOWED_NETWORK_TYPES from DB, value = " + pair);
                    continue;
                }
                int key = TelephonyManager.allowedNetworkTypesReasonFromString(
                        networkTypesValues[0]);
                int key = convertAllowedNetworkTypeDbNameToMapIndex(networkTypesValues[0]);
                long value = Long.parseLong(networkTypesValues[1]);
                if (value != INVALID_ALLOWED_NETWORK_TYPES) {
                if (key != INVALID_ALLOWED_NETWORK_TYPES
                        && value != INVALID_ALLOWED_NETWORK_TYPES) {
                    synchronized (mAllowedNetworkTypesForReasons) {
                        mAllowedNetworkTypesForReasons.put(key, value);
                    }
@@ -2455,6 +2457,36 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        }
    }

    private int convertAllowedNetworkTypeDbNameToMapIndex(String name) {
        switch (name) {
            case ALLOWED_NETWORK_TYPES_TEXT_USER:
                return TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER;
            case ALLOWED_NETWORK_TYPES_TEXT_POWER:
                return TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_POWER;
            case ALLOWED_NETWORK_TYPES_TEXT_CARRIER:
                return TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_CARRIER;
            case ALLOWED_NETWORK_TYPES_TEXT_ENABLE_2G:
                return TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G;
            default:
                return INVALID_ALLOWED_NETWORK_TYPES;
        }
    }

    private String convertAllowedNetworkTypeMapIndexToDbName(int reason) {
        switch (reason) {
            case TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER:
                return ALLOWED_NETWORK_TYPES_TEXT_USER;
            case TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_POWER:
                return ALLOWED_NETWORK_TYPES_TEXT_POWER;
            case TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_CARRIER:
                return ALLOWED_NETWORK_TYPES_TEXT_CARRIER;
            case TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G:
                return ALLOWED_NETWORK_TYPES_TEXT_ENABLE_2G;
            default:
                return Integer.toString(INVALID_ALLOWED_NETWORK_TYPES);
        }
    }

    private @TelephonyManager.NetworkTypeBitMask long
            updateAllowedNetworkTypeForCarrierWithCarrierConfig() {
        long defaultAllowedNetworkTypes = RadioAccessFamily.getRafFromNetworkType(
@@ -2496,8 +2528,8 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        }
        if (!SubscriptionManager.isUsableSubscriptionId(subId)
                || !mIsAllowedNetworkTypesLoadedFromDb) {
            loge("setAllowedNetworkTypes: no sim or network type is not loaded. subId="
                    + subId + ", isNetworkTypeLoaded=" + mIsAllowedNetworkTypesLoadedFromDb);
            loge("setAllowedNetworkTypes: no sim or network type is not loaded. SubscriptionId: "
                    + subId + ", isNetworkTypeLoaded" + mIsAllowedNetworkTypesLoadedFromDb);
            if (response != null) {
                AsyncResult.forMessage(response, null,
                        new CommandException(CommandException.Error.MISSING_RESOURCE));
@@ -2509,15 +2541,14 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        synchronized (mAllowedNetworkTypesForReasons) {
            mAllowedNetworkTypesForReasons.put(reason, networkTypes);
            mapAsString = mAllowedNetworkTypesForReasons.keySet().stream()
                    .map(key -> TelephonyManager.allowedNetworkTypesReasonToString(key) + "="
                    .map(key -> convertAllowedNetworkTypeMapIndexToDbName(key) + "="
                            + mAllowedNetworkTypesForReasons.get(key))
                    .collect(Collectors.joining(","));
        }
        SubscriptionManager.setSubscriptionProperty(subId,
                SubscriptionManager.ALLOWED_NETWORK_TYPES,
                mapAsString);
        logd("setAllowedNetworkTypes: subId=" + subId + ", "
                + SubscriptionInfoInternal.getPrintableAllowedNetworkTypesForReasons(mapAsString));
        logd("setAllowedNetworkTypes: SubId" + subId + ",setAllowedNetworkTypes " + mapAsString);

        updateAllowedNetworkTypes(response);
        notifyAllowedNetworkTypesChanged(reason);
+3 −3
Original line number Diff line number Diff line
@@ -141,9 +141,9 @@ public class LinkBandwidthEstimator extends Handler {
    private static final int MAX_ERROR_PERCENT = 100 * 100;
    private static final String[] AVG_BW_PER_RAT = {
            "GPRS:24,24", "EDGE:70,18", "UMTS:115,115", "CDMA:14,14",
            "1xRTT:30,30", "EVDO-0:750,48", "EVDO-A:950,550",
            "HSDPA:4300,620", "HSUPA:4300,1800", "HSPA:4300,1800", "EVDO-B:1500,550",
            "eHRPD:750,48", "HSPA+:13000,3400", "TD-SCDMA:115,115",
            "CDMA - 1xRTT:30,30", "CDMA - EvDo rev. 0:750,48", "CDMA - EvDo rev. A:950,550",
            "HSDPA:4300,620", "HSUPA:4300,1800", "HSPA:4300,1800", "CDMA - EvDo rev. B:1500,550",
            "CDMA - eHRPD:750,48", "HSPA+:13000,3400", "TD_SCDMA:115,115",
            "LTE:30000,15000", "NR_NSA:47000,18000",
            "NR_NSA_MMWAVE:145000,60000", "NR:145000,60000", "NR_MMWAVE:145000,60000"};
    private static final Map<String, Pair<Integer, Integer>> AVG_BW_PER_RAT_MAP = new ArrayMap<>();
+5 −26
Original line number Diff line number Diff line
@@ -55,8 +55,6 @@ import com.android.telephony.Rlog;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * The class represents a single row of {@link SimInfo} table. All columns (excepts unused columns)
@@ -1053,7 +1051,7 @@ public class SubscriptionInfoInternal {
     *
     * @return The stripped string.
     */
    public static String getPrintableId(String id) {
    public static String givePrintableId(String id) {
        String idToPrint = null;
        if (id != null) {
            int len = id.length();
@@ -1066,28 +1064,10 @@ public class SubscriptionInfoInternal {
        return idToPrint;
    }

    /**
     * Convert the allowed network types for reasons to readable format.
     *
     * @param allowedNetworkTypesForReasons The raw value of allowed network types for reasons
     * stored in the database.
     *
     * @return The converted string.
     */
    public static String getPrintableAllowedNetworkTypesForReasons(
            @NonNull String allowedNetworkTypesForReasons) {
        if (TextUtils.isEmpty(allowedNetworkTypesForReasons)) return "";
        return Stream.of(allowedNetworkTypesForReasons.split(","))
                .map(s -> s.substring(0, s.indexOf("=") + 1)
                        + TelephonyManager.convertNetworkTypeBitmaskToString(
                                Long.parseLong(s.substring(s.indexOf("=") + 1))))
                .collect(Collectors.joining(", "));
    }

    @Override
    public String toString() {
        return "[SubscriptionInfoInternal: id=" + mId
                + " iccId=" + getPrintableId(mIccId)
                + " iccId=" + givePrintableId(mIccId)
                + " simSlotIndex=" + mSimSlotIndex
                + " portIndex=" + mPortIndex
                + " isEmbedded=" + mIsEmbedded
@@ -1107,7 +1087,7 @@ public class SubscriptionInfoInternal {
                + " mnc=" + mMnc
                + " ehplmns=" + mEhplmns
                + " hplmns=" + mHplmns
                + " cardString=" + getPrintableId(mCardString)
                + " cardString=" + givePrintableId(mCardString)
                + " cardId=" + mCardId
                + " nativeAccessRules=" + IccUtils.bytesToHexString(mNativeAccessRules)
                + " carrierConfigAccessRules=" + IccUtils.bytesToHexString(
@@ -1125,12 +1105,11 @@ public class SubscriptionInfoInternal {
                + " wifiCallingModeForRoaming="
                + ImsMmTelManager.wifiCallingModeToString(mWifiCallingModeForRoaming)
                + " enabledMobileDataPolicies=" + mEnabledMobileDataPolicies
                + " imsi=" + getPrintableId(mImsi)
                + " imsi=" + givePrintableId(mImsi)
                + " rcsUceEnabled=" + mIsRcsUceEnabled
                + " crossSimCallingEnabled=" + mIsCrossSimCallingEnabled
                + " rcsConfig=" + IccUtils.bytesToHexString(mRcsConfig)
                + " allowedNetworkTypesForReasons="
                + getPrintableAllowedNetworkTypesForReasons(mAllowedNetworkTypesForReasons)
                + " allowedNetworkTypesForReasons=" + mAllowedNetworkTypesForReasons
                + " deviceToDeviceStatusSharingPreference=" + mDeviceToDeviceStatusSharingPreference
                + " isVoImsOptInEnabled=" + mIsVoImsOptInEnabled
                + " deviceToDeviceStatusSharingContacts=" + mDeviceToDeviceStatusSharingContacts