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

Commit eaa2a701 authored by Rambo Wang's avatar Rambo Wang Committed by Gerrit Code Review
Browse files

Merge "Support CarrierService#notifyCarrierNetworkChange with subscription"

parents d1b31d48 241b1fa9
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -38281,7 +38281,8 @@ package android.service.carrier {
  public abstract class CarrierService extends android.app.Service {
  public abstract class CarrierService extends android.app.Service {
    ctor public CarrierService();
    ctor public CarrierService();
    method public final void notifyCarrierNetworkChange(boolean);
    method @Deprecated public final void notifyCarrierNetworkChange(boolean);
    method public final void notifyCarrierNetworkChange(int, boolean);
    method @CallSuper public android.os.IBinder onBind(android.content.Intent);
    method @CallSuper public android.os.IBinder onBind(android.content.Intent);
    method public abstract android.os.PersistableBundle onLoadConfig(android.service.carrier.CarrierIdentifier);
    method public abstract android.os.PersistableBundle onLoadConfig(android.service.carrier.CarrierIdentifier);
    field public static final String CARRIER_SERVICE_INTERFACE = "android.service.carrier.CarrierService";
    field public static final String CARRIER_SERVICE_INTERFACE = "android.service.carrier.CarrierService";
+27 −0
Original line number Original line Diff line number Diff line
@@ -285,6 +285,8 @@ public class TelephonyRegistryManager {
     * UI. There is no timeout associated with showing this UX, so a carrier app must be sure to
     * UI. There is no timeout associated with showing this UX, so a carrier app must be sure to
     * call with active set to false sometime after calling with it set to {@code true}.
     * call with active set to false sometime after calling with it set to {@code true}.
     * <p>
     * <p>
     * This will apply to all subscriptions the carrier app has carrier privileges on.
     * <p>
     * Requires Permission: calling app has carrier privileges.
     * Requires Permission: calling app has carrier privileges.
     *
     *
     * @param active Whether the carrier network change is or shortly will be
     * @param active Whether the carrier network change is or shortly will be
@@ -299,6 +301,31 @@ public class TelephonyRegistryManager {
        }
        }
    }
    }


    /**
     * 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
     * UI while telephony is performing an action that may result in intentional, temporary network
     * lack of connectivity.
     * <p>
     * Based on the active parameter passed in, this method will either show or hide the
     * alternative UI. There is no timeout associated with showing this UX, so a carrier app must be
     * sure to call with active set to false sometime after calling with it set to {@code true}.
     * <p>
     * Requires Permission: calling app has carrier privileges.
     *
     * @param subscriptionId the subscription of the carrier network.
     * @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
     */
    public void notifyCarrierNetworkChange(int subscriptionId, boolean active) {
        try {
            sRegistry.notifyCarrierNetworkChangeWithSubId(subscriptionId, active);
        } catch (RemoteException ex) {
            // system server crash
        }
    }

    /**
    /**
     * Notify call state changed on certain subscription.
     * Notify call state changed on certain subscription.
     *
     *
+1 −0
Original line number Original line Diff line number Diff line
@@ -77,6 +77,7 @@ interface ITelephonyRegistry {
    void notifySubscriptionInfoChanged();
    void notifySubscriptionInfoChanged();
    void notifyOpportunisticSubscriptionInfoChanged();
    void notifyOpportunisticSubscriptionInfoChanged();
    void notifyCarrierNetworkChange(in boolean active);
    void notifyCarrierNetworkChange(in boolean active);
    void notifyCarrierNetworkChangeWithSubId(in int subId, in boolean active);
    void notifyUserMobileDataStateChangedForPhoneId(in int phoneId, in int subId, in boolean state);
    void notifyUserMobileDataStateChangedForPhoneId(in int phoneId, in int subId, in boolean state);
    void notifyDisplayInfoChanged(int slotIndex, int subId, in TelephonyDisplayInfo telephonyDisplayInfo);
    void notifyDisplayInfoChanged(int slotIndex, int subId, in TelephonyDisplayInfo telephonyDisplayInfo);
    void notifyPhoneCapabilityChanged(in PhoneCapability capability);
    void notifyPhoneCapabilityChanged(in PhoneCapability capability);
+37 −18
Original line number Original line Diff line number Diff line
@@ -366,7 +366,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {


    private List<BarringInfo> mBarringInfo = null;
    private List<BarringInfo> mBarringInfo = null;


    private boolean mCarrierNetworkChangeState = false;
    private boolean[] mCarrierNetworkChangeState = null;


    private PhoneCapability mPhoneCapability = null;
    private PhoneCapability mPhoneCapability = null;


@@ -675,6 +675,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
        mOutgoingCallEmergencyNumber = copyOf(mOutgoingCallEmergencyNumber, mNumPhones);
        mOutgoingCallEmergencyNumber = copyOf(mOutgoingCallEmergencyNumber, mNumPhones);
        mOutgoingSmsEmergencyNumber = copyOf(mOutgoingSmsEmergencyNumber, mNumPhones);
        mOutgoingSmsEmergencyNumber = copyOf(mOutgoingSmsEmergencyNumber, mNumPhones);
        mTelephonyDisplayInfos = copyOf(mTelephonyDisplayInfos, mNumPhones);
        mTelephonyDisplayInfos = copyOf(mTelephonyDisplayInfos, mNumPhones);
        mCarrierNetworkChangeState = copyOf(mCarrierNetworkChangeState, mNumPhones);
        mIsDataEnabled= copyOf(mIsDataEnabled, mNumPhones);
        mIsDataEnabled= copyOf(mIsDataEnabled, mNumPhones);
        mDataEnabledReason = copyOf(mDataEnabledReason, mNumPhones);
        mDataEnabledReason = copyOf(mDataEnabledReason, mNumPhones);
        mAllowedNetworkTypeReason = copyOf(mAllowedNetworkTypeReason, mNumPhones);
        mAllowedNetworkTypeReason = copyOf(mAllowedNetworkTypeReason, mNumPhones);
@@ -720,6 +721,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
            mBackgroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
            mBackgroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
            mPreciseDataConnectionStates.add(new ArrayMap<>());
            mPreciseDataConnectionStates.add(new ArrayMap<>());
            mBarringInfo.add(i, new BarringInfo());
            mBarringInfo.add(i, new BarringInfo());
            mCarrierNetworkChangeState[i] = false;
            mTelephonyDisplayInfos[i] = null;
            mTelephonyDisplayInfos[i] = null;
            mIsDataEnabled[i] = false;
            mIsDataEnabled[i] = false;
            mDataEnabledReason[i] = TelephonyManager.DATA_ENABLED_REASON_USER;
            mDataEnabledReason[i] = TelephonyManager.DATA_ENABLED_REASON_USER;
@@ -784,6 +786,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
        mOutgoingCallEmergencyNumber = new EmergencyNumber[numPhones];
        mOutgoingCallEmergencyNumber = new EmergencyNumber[numPhones];
        mOutgoingSmsEmergencyNumber = new EmergencyNumber[numPhones];
        mOutgoingSmsEmergencyNumber = new EmergencyNumber[numPhones];
        mBarringInfo = new ArrayList<>();
        mBarringInfo = new ArrayList<>();
        mCarrierNetworkChangeState = new boolean[numPhones];
        mTelephonyDisplayInfos = new TelephonyDisplayInfo[numPhones];
        mTelephonyDisplayInfos = new TelephonyDisplayInfo[numPhones];
        mPhysicalChannelConfigs = new ArrayList<>();
        mPhysicalChannelConfigs = new ArrayList<>();
        mAllowedNetworkTypeReason = new int[numPhones];
        mAllowedNetworkTypeReason = new int[numPhones];
@@ -820,6 +823,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
            mBackgroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
            mBackgroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
            mPreciseDataConnectionStates.add(new ArrayMap<>());
            mPreciseDataConnectionStates.add(new ArrayMap<>());
            mBarringInfo.add(i, new BarringInfo());
            mBarringInfo.add(i, new BarringInfo());
            mCarrierNetworkChangeState[i] = false;
            mTelephonyDisplayInfos[i] = null;
            mTelephonyDisplayInfos[i] = null;
            mIsDataEnabled[i] = false;
            mIsDataEnabled[i] = false;
            mDataEnabledReason[i] = TelephonyManager.DATA_ENABLED_REASON_USER;
            mDataEnabledReason[i] = TelephonyManager.DATA_ENABLED_REASON_USER;
@@ -1230,7 +1234,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
                }
                }
                if (events.contains(TelephonyCallback.EVENT_CARRIER_NETWORK_CHANGED)) {
                if (events.contains(TelephonyCallback.EVENT_CARRIER_NETWORK_CHANGED)) {
                    try {
                    try {
                        r.callback.onCarrierNetworkChange(mCarrierNetworkChangeState);
                        r.callback.onCarrierNetworkChange(mCarrierNetworkChangeState[r.phoneId]);
                    } catch (RemoteException ex) {
                    } catch (RemoteException ex) {
                        remove(r.binder);
                        remove(r.binder);
                    }
                    }
@@ -1724,10 +1728,25 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
            throw new SecurityException("notifyCarrierNetworkChange without carrier privilege");
            throw new SecurityException("notifyCarrierNetworkChange without carrier privilege");
        }
        }


        synchronized (mRecords) {
            mCarrierNetworkChangeState = active;
        for (int subId : subIds) {
        for (int subId : subIds) {
            notifyCarrierNetworkChangeWithPermission(subId, active);
        }
    }

    @Override
    public void notifyCarrierNetworkChangeWithSubId(int subId, boolean active) {
        if (!TelephonyPermissions.checkCarrierPrivilegeForSubId(mContext, subId)) {
            throw new SecurityException(
                    "notifyCarrierNetworkChange without carrier privilege on subId " + subId);
        }

        notifyCarrierNetworkChangeWithPermission(subId, active);
    }

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


            if (VDBG) {
            if (VDBG) {
                log("notifyCarrierNetworkChange: active=" + active + "subId: " + subId);
                log("notifyCarrierNetworkChange: active=" + active + "subId: " + subId);
@@ -1743,7 +1762,6 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
                    }
                    }
                }
                }
            }
            }
            }
            handleRemoveListLocked();
            handleRemoveListLocked();
        }
        }
    }
    }
@@ -2788,6 +2806,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
                pw.println("mOutgoingCallEmergencyNumber=" + mOutgoingCallEmergencyNumber[i]);
                pw.println("mOutgoingCallEmergencyNumber=" + mOutgoingCallEmergencyNumber[i]);
                pw.println("mOutgoingSmsEmergencyNumber=" + mOutgoingSmsEmergencyNumber[i]);
                pw.println("mOutgoingSmsEmergencyNumber=" + mOutgoingSmsEmergencyNumber[i]);
                pw.println("mBarringInfo=" + mBarringInfo.get(i));
                pw.println("mBarringInfo=" + mBarringInfo.get(i));
                pw.println("mCarrierNetworkChangeState=" + mCarrierNetworkChangeState[i]);
                pw.println("mTelephonyDisplayInfo=" + mTelephonyDisplayInfos[i]);
                pw.println("mTelephonyDisplayInfo=" + mTelephonyDisplayInfos[i]);
                pw.println("mIsDataEnabled=" + mIsDataEnabled);
                pw.println("mIsDataEnabled=" + mIsDataEnabled);
                pw.println("mDataEnabledReason=" + mDataEnabledReason);
                pw.println("mDataEnabledReason=" + mDataEnabledReason);
@@ -2797,7 +2816,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
                pw.println("mLinkCapacityEstimateList=" + mLinkCapacityEstimateLists.get(i));
                pw.println("mLinkCapacityEstimateList=" + mLinkCapacityEstimateLists.get(i));
                pw.decreaseIndent();
                pw.decreaseIndent();
            }
            }
            pw.println("mCarrierNetworkChangeState=" + mCarrierNetworkChangeState);

            pw.println("mPhoneCapability=" + mPhoneCapability);
            pw.println("mPhoneCapability=" + mPhoneCapability);
            pw.println("mActiveDataSubId=" + mActiveDataSubId);
            pw.println("mActiveDataSubId=" + mActiveDataSubId);
            pw.println("mRadioPowerState=" + mRadioPowerState);
            pw.println("mRadioPowerState=" + mRadioPowerState);
+30 −0
Original line number Original line Diff line number Diff line
@@ -115,7 +115,12 @@ public abstract class CarrierService extends Service {
     *               active. Set this value to true to begin showing
     *               active. Set this value to true to begin showing
     *               alternative UI and false to stop.
     *               alternative UI and false to stop.
     * @see android.telephony.TelephonyManager#hasCarrierPrivileges
     * @see android.telephony.TelephonyManager#hasCarrierPrivileges
     * @deprecated use {@link #notifyCarrierNetworkChange(int, boolean)} instead.
     *             With no parameter to specify the subscription, this API will
     *             apply to all subscriptions that the carrier app has carrier
     *             privileges on.
     */
     */
    @Deprecated
    public final void notifyCarrierNetworkChange(boolean active) {
    public final void notifyCarrierNetworkChange(boolean active) {
        TelephonyRegistryManager telephonyRegistryMgr =
        TelephonyRegistryManager telephonyRegistryMgr =
            (TelephonyRegistryManager) this.getSystemService(
            (TelephonyRegistryManager) this.getSystemService(
@@ -125,6 +130,31 @@ public abstract class CarrierService extends Service {
        }
        }
    }
    }


    /**
     * Informs the system of an intentional upcoming carrier network change by a carrier app on the
     * given {@code subscriptionId}. This call is optional and is only used to allow the system to
     * provide alternative UI while telephony is performing an action that may result in
     * intentional, temporary network lack of connectivity.
     *
     * <p>Based on the active parameter passed in, this method will either show or hide the
     * alternative UI. There is no timeout associated with showing this UX, so a carrier app must
     * be sure to call with active set to false sometime after calling with it set to true.
     *
     * <p>Requires Permission: calling app has carrier privileges.
     *
     * @param subscriptionId the subscription of the carrier network that trigger the change.
     * @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 android.telephony.TelephonyManager#hasCarrierPrivileges
     */
    public final void notifyCarrierNetworkChange(int subscriptionId, boolean active) {
        TelephonyRegistryManager telephonyRegistryMgr = this.getSystemService(
                TelephonyRegistryManager.class);
        if (telephonyRegistryMgr != null) {
            telephonyRegistryMgr.notifyCarrierNetworkChange(subscriptionId, active);
        }
    }

    /**
    /**
     * If overriding this method, call through to the super method for any unknown actions.
     * If overriding this method, call through to the super method for any unknown actions.
     * {@inheritDoc}
     * {@inheritDoc}