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

Commit 19bb0085 authored by Jesse Melhuish's avatar Jesse Melhuish Committed by Android (Google) Code Review
Browse files

Merge "TelephonyRegistry: Add notifyCarrierNetworkChangeForPhone" into main

parents 8aed22cb b9b82737
Loading
Loading
Loading
Loading
+28 −1
Original line number Diff line number Diff line
@@ -354,6 +354,31 @@ public class TelephonyRegistryManager {
        }
    }

    /**
     * Informs the system of an intentional upcoming carrier network change by a carrier app. At
     * this time, there are no phone-based listeners to notify, so this method is only intended for
     * cleaning up system state.
     *
     * <p>This will apply to the SIM slot provided, and subsequent listener registrations for
     * subscriptions belonging to this slot will receive the updated value.
     *
     * Requires Permission: calling app has carrier privileges.
     *
     * @param phoneId that should be notified.
     * @param subId the subscription of the carrier network.
     * @param active Whether the carrier network change is or shortly will be active.
     * @see TelephonyManager#hasCarrierPrivileges
     * @hide
     */
    public void notifyCarrierNetworkChange(int phoneId, int subId, boolean active) {
        try {
            sRegistry.notifyCarrierNetworkChangeForPhoneAndSubId(phoneId, subId, active);
        } catch (RemoteException ex) {
            // system server crash
            throw ex.rethrowFromSystemServer();
        }
    }

    /**
     * Informs the system of an intentional upcoming carrier network change by a carrier app on the
     * given {@code subscriptionId}. This call only used to allow the system to provide alternative
@@ -370,11 +395,13 @@ public class TelephonyRegistryManager {
     * @param active whether the carrier network change is or shortly will be active. Set this value
     *              to true to begin showing alternative UI and false to stop.
     * @see TelephonyManager#hasCarrierPrivileges
     * TODO(b/418794900): Remove when all call sites are migrated.
     * @hide
     */
    public void notifyCarrierNetworkChange(int subscriptionId, boolean active) {
        try {
            sRegistry.notifyCarrierNetworkChangeWithSubId(subscriptionId, active);
            sRegistry.notifyCarrierNetworkChangeForPhoneAndSubId(
                    SubscriptionManager.INVALID_SIM_SLOT_INDEX, subscriptionId, active);
        } catch (RemoteException ex) {
            // system server crash
            throw ex.rethrowFromSystemServer();
+1 −1
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ interface ITelephonyRegistry {
    void notifySubscriptionInfoChanged();
    void notifyOpportunisticSubscriptionInfoChanged();
    void notifyCarrierNetworkChange(in boolean active);
    void notifyCarrierNetworkChangeWithSubId(in int subId, in boolean active);
    void notifyCarrierNetworkChangeForPhoneAndSubId(in int phoneId, in int subId, in boolean active);
    void notifyUserMobileDataStateChangedForPhoneId(in int phoneId, in int subId, in boolean state);
    void notifyDisplayInfoChanged(int slotIndex, int subId, in TelephonyDisplayInfo telephonyDisplayInfo);
    void notifyPhoneCapabilityChanged(in PhoneCapability capability);
+9 −7
Original line number Diff line number Diff line
@@ -1984,22 +1984,24 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
        }

        for (int subId : subIds) {
            notifyCarrierNetworkChangeWithPermission(subId, active);
            notifyCarrierNetworkChangeWithPermission(getPhoneIdFromSubId(subId), subId, active);
        }
    }

    @Override
    public void notifyCarrierNetworkChangeWithSubId(int subId, boolean active) {
        if (!TelephonyPermissions.checkCarrierPrivilegeForSubId(mContext, subId)) {
    public void notifyCarrierNetworkChangeForPhoneAndSubId(int phoneId, int subId, boolean active) {
        // We only need to check carrier privileges for the subId if we don't have
        // MODIFY_PHONE_STATE.
        if (!checkNotifyPermission("notifyCarrierNetworkChangeForPhoneAndSubId()")
                && !TelephonyPermissions.checkCarrierPrivilegeForSubId(mContext, subId)) {
            throw new SecurityException(
                     "notifyCarrierNetworkChange without carrier privilege on subId " + subId);
        }

        notifyCarrierNetworkChangeWithPermission(subId, active);
        notifyCarrierNetworkChangeWithPermission(phoneId, subId, active);
    }

    private void notifyCarrierNetworkChangeWithPermission(int subId, boolean active) {
        int phoneId = getPhoneIdFromSubId(subId);
    private void notifyCarrierNetworkChangeWithPermission(int phoneId, int subId, boolean active) {
        synchronized (mRecords) {
            mCarrierNetworkChangeState[phoneId] = active;