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

Commit 0bc5aaa3 authored by Hall Liu's avatar Hall Liu
Browse files

Rename getApnTypeString

Rename to getApnTypeStringInternal for compatibility since we don't want
the exposed API returning a string like "Unknown".

Also add a unit test for the method converting between APN bitmasks and
strings in TelephonyRegistry.

Bug: 173133122
Test: atest TelephonyRegistryTest
Change-Id: Id5a0aa8bc67b65c87e4e37ee8b070c9664f9e6d0
parent 1e2822c3
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -375,7 +375,7 @@ public class RetryManager {
                        if (splitStr.length == 2) {
                            String apnTypeStr = splitStr[0].trim();
                            // Check if this retry pattern is for the APN we want.
                            if (apnTypeStr.equals(ApnSetting.getApnTypeString(apnType))) {
                            if (apnTypeStr.equals(ApnSetting.getApnTypeStringInternal(apnType))) {
                                // Extract the config string. Note that an empty string is valid
                                // here, meaning no retry for the specified APN.
                                configString = splitStr[1];
@@ -697,7 +697,8 @@ public class RetryManager {

    public String toString() {
        if (mConfig == null) return "";
        return "RetryManager: apnType=" + ApnSetting.getApnTypeString(apnType) + " mRetryCount="
        return "RetryManager: apnType=" + ApnSetting.getApnTypeStringInternal(apnType)
                + " mRetryCount="
                + mRetryCount + " mMaxRetryCount=" + mMaxRetryCount + " mCurrentApnIndex="
                + mCurrentApnIndex + " mSameApnRtryCount=" + mSameApnRetryCount
                + " networkSuggestedDelay=" + getNetworkSuggestedRetryDelay() + " mRetryForever="
@@ -708,6 +709,6 @@ public class RetryManager {

    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    private void log(String s) {
        Rlog.d(LOG_TAG, "[" + ApnSetting.getApnTypeString(apnType) + "] " + s);
        Rlog.d(LOG_TAG, "[" + ApnSetting.getApnTypeStringInternal(apnType) + "] " + s);
    }
}
+3 −2
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ public class AccessNetworksManager extends Handler {
                accessNetworkStrings.add(AccessNetworkType.toString(network));
            }
            return "[QualifiedNetworks: apnType="
                    + ApnSetting.getApnTypeString(apnType)
                    + ApnSetting.getApnTypeStringInternal(apnType)
                    + ", networks="
                    + Arrays.stream(qualifiedNetworks)
                    .mapToObj(type -> AccessNetworkType.toString(type))
@@ -400,7 +400,8 @@ public class AccessNetworksManager extends Handler {
        pw.increaseIndent();

        for (int i = 0; i < mAvailableNetworks.size(); i++) {
            pw.println("APN type " + ApnSetting.getApnTypeString(mAvailableNetworks.keyAt(i))
            pw.println("APN type "
                    + ApnSetting.getApnTypeStringInternal(mAvailableNetworks.keyAt(i))
                    + ": [" + Arrays.stream(mAvailableNetworks.valueAt(i))
                    .mapToObj(type -> AccessNetworkType.toString(type))
                    .collect(Collectors.joining(",")) + "]");
+1 −1
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ public class ApnContext {
     * @param priority Priority of APN type
     */
    public ApnContext(Phone phone, int typeId, String logTag, DcTracker tracker, int priority) {
        this(phone, ApnSetting.getApnTypeString(typeId), logTag, tracker, priority);
        this(phone, ApnSetting.getApnTypeStringInternal(typeId), logTag, tracker, priority);
    }

    /**
+3 −3
Original line number Diff line number Diff line
@@ -162,8 +162,8 @@ public class ApnSettingUtils {
                    + Arrays.toString(meteredApnSet.toArray()));
        }

        if (meteredApnSet.contains(ApnSetting.getApnTypeString(apnType))) {
            if (DBG) Rlog.d(LOG_TAG, ApnSetting.getApnTypeString(apnType) + " is metered.");
        if (meteredApnSet.contains(ApnSetting.getApnTypeStringInternal(apnType))) {
            if (DBG) Rlog.d(LOG_TAG, ApnSetting.getApnTypeStringInternal(apnType) + " is metered.");
            return true;
        } else if (apnType == ApnSetting.TYPE_ALL) {
            // Assuming no configuration error, if at least one APN type is
@@ -174,7 +174,7 @@ public class ApnSettingUtils {
            }
        }

        if (DBG) Rlog.d(LOG_TAG, ApnSetting.getApnTypeString(apnType) + " is not metered.");
        if (DBG) Rlog.d(LOG_TAG, ApnSetting.getApnTypeStringInternal(apnType) + " is not metered.");
        return false;
    }

+1 −1
Original line number Diff line number Diff line
@@ -131,7 +131,7 @@ public class DataEnabledOverride {

        @Override
        public String toString() {
            return ApnSetting.getApnTypeString(mApnType) + "=" + mRequiredConditions;
            return ApnSetting.getApnTypeStringInternal(mApnType) + "=" + mRequiredConditions;
        }

        @Override
Loading