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

Commit 6501b0d3 authored by Meng Wang's avatar Meng Wang
Browse files

Add hidden API putPhoneIdAndMaybeSubIdExtra

Makes it easier to log subId besides phoneId, as the previous putPhoneIdAndSubIdExtra doesn't expose the subId.

Flag: NONE - adding a hidden API with minor refactor
Bug: 349680971
Change-Id: I5d31c7969c961216d45fd384f72b81589eacee79
parent 083bbcfe
Loading
Loading
Loading
Loading
+25 −8
Original line number Diff line number Diff line
@@ -2783,17 +2783,17 @@ public class SubscriptionManager {
        return phoneId >= 0 && phoneId < TelephonyManager.getDefault().getActiveModemCount();
    }

    /** @hide */
    /**
     * Puts phone ID and subscription ID into the {@code intent}.
     *
     * <p>If the subscription ID is not valid, only puts phone ID into the {@code intent}.
     *
     * @hide
     */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
    public static void putPhoneIdAndSubIdExtra(Intent intent, int phoneId) {
        int subId = SubscriptionManager.getSubscriptionId(phoneId);
        if (isValidSubscriptionId(subId)) {
            putPhoneIdAndSubIdExtra(intent, phoneId, subId);
        } else {
            logd("putPhoneIdAndSubIdExtra: no valid subs");
            intent.putExtra(PhoneConstants.PHONE_KEY, phoneId);
            intent.putExtra(EXTRA_SLOT_INDEX, phoneId);
        }
        putPhoneIdAndMaybeSubIdExtra(intent, phoneId, subId);
    }

    /** @hide */
@@ -2805,6 +2805,23 @@ public class SubscriptionManager {
        putSubscriptionIdExtra(intent, subId);
    }

    /**
     * Puts phone ID and subscription ID into the {@code intent}.
     *
     * <p>If the subscription ID is not valid, only puts phone ID into the {@code intent}.
     *
     * @hide
     */
    public static void putPhoneIdAndMaybeSubIdExtra(Intent intent, int phoneId, int subId) {
        if (isValidSubscriptionId(subId)) {
            putPhoneIdAndSubIdExtra(intent, phoneId, subId);
        } else {
            if (VDBG) logd("putPhoneIdAndMaybeSubIdExtra: invalid subId");
            intent.putExtra(PhoneConstants.PHONE_KEY, phoneId);
            intent.putExtra(EXTRA_SLOT_INDEX, phoneId);
        }
    }

    /**
     * Get visible subscription Id(s) of the currently active SIM(s).
     *