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

Commit 30c2e843 authored by yongnamcha's avatar yongnamcha Committed by Yongnam Cha
Browse files

Add input validation for throttlingTimeSec in onDeregistered

The onDeregistered method accepts a throttlingTimeSec parameter, which is intended to be a non-negative value representing a time in seconds.
However, there was no explicit validation to prevent negative values from being passed.
Passing a negative value is invalid and could lead to undefined behavior.
This change introduces validation for the throttlingTimeSec parameter:
An IllegalArgumentException is now thrown if throttlingTimeSec is negative.
The @IntRange(from = 0) annotation has been added to enforce this constraint at the API level.
The Javadoc for the method has been updated to reflect this new validation and clarify the parameter's expected range.
This makes the API more robust by ensuring only valid inputs are processed.

Bug: 412452528
Test: atest ImsServiceTest
Flag: com.android.internal.telephony.flags.support_throttle_time_for_deregistration
Change-Id: I9646fc2ced6bf74c50447aeb13cabc4a0afeb4f5
parent eff6d198
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -18660,7 +18660,7 @@ package android.telephony.ims.stub {
    method public final void onDeregistered(android.telephony.ims.ImsReasonInfo);
    method public final void onDeregistered(@Nullable android.telephony.ims.ImsReasonInfo, int, int);
    method @FlaggedApi("com.android.internal.telephony.flags.emergency_registration_state") public final void onDeregistered(@Nullable android.telephony.ims.ImsReasonInfo, int, @NonNull android.telephony.ims.ImsRegistrationAttributes);
    method @FlaggedApi("com.android.internal.telephony.flags.support_throttle_time_for_deregistration") public final void onDeregistered(@Nullable android.telephony.ims.ImsReasonInfo, int, @NonNull android.telephony.ims.ImsRegistrationAttributes, int);
    method @FlaggedApi("com.android.internal.telephony.flags.support_throttle_time_for_deregistration") public final void onDeregistered(@Nullable android.telephony.ims.ImsReasonInfo, int, @NonNull android.telephony.ims.ImsRegistrationAttributes, @IntRange(from=0) int);
    method public final void onDeregistered(@Nullable android.telephony.ims.ImsReasonInfo, @NonNull android.telephony.ims.SipDetails);
    method public final void onDeregistered(@Nullable android.telephony.ims.ImsReasonInfo, int, int, @NonNull android.telephony.ims.SipDetails);
    method public final void onRegistered(int);
+10 −1
Original line number Diff line number Diff line
@@ -645,13 +645,22 @@ public class ImsRegistrationImplBase {
     * @param suggestedAction the expected behavior of radio protocol stack.
     * @param attributes The attributes associated with the IMS registration
     * @param throttlingTimeSec The registration throttling time in seconds.
     *                          This value must be 0 or greater. A value of 0 indicates that no
     *                          specific throttling time is being requested.
     * @throws IllegalArgumentException if throttlingTimeSec is a negative value.
     * @hide This API is not part of the Android public SDK API
     */
    @SystemApi
    @FlaggedApi(Flags.FLAG_SUPPORT_THROTTLE_TIME_FOR_DEREGISTRATION)
    public final void onDeregistered(@Nullable ImsReasonInfo info,
            @RegistrationManager.SuggestedAction int suggestedAction,
            @NonNull ImsRegistrationAttributes attributes, int throttlingTimeSec) {
            @NonNull ImsRegistrationAttributes attributes,
            @IntRange(from = 0) int throttlingTimeSec) {
        if (throttlingTimeSec < 0) {
            throw new IllegalArgumentException("throttlingTimeSec cannot be negative: "
                    + throttlingTimeSec);
        }

        boolean isEmergency = isEmergency(attributes);
        int imsRadioTech = attributes.getRegistrationTechnology();
        if (isEmergency) {