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

Commit 2d0f4860 authored by Ta-wei Yen's avatar Ta-wei Yen
Browse files

Add target package to VisualVoicemailFilterSettings.

When a VVM SMS is received, opt/telephony send a broadcast to
TelephonyService which will then bind to the remote package handling
VVM. The remote package might change when the broadcast is in flight
and caused the new package to receive SMS filtered by the old package.
This caused flakiness in CTS tests.

In this CL, the filter will also receive the package which set the
filter settings, and will instruct TelephonyService to bind to the
package that set the settings.

Change-Id: I05cf758903db71a919d2a45451eae160aea7acc3
Fixes: 70675403
Test: CtsTelephonyTestCases
parent cc1b3e0e
Loading
Loading
Loading
Loading
+19 −3
Original line number Diff line number Diff line
@@ -106,9 +106,12 @@ public class VoicemailContract {

    /**
     * Broadcast intent to inform a new visual voicemail SMS has been received. This intent will
     * only be delivered to the telephony service. {@link #EXTRA_VOICEMAIL_SMS} will be included.
     */
    /** @hide */
     * only be delivered to the telephony service.
     *
     * @see #EXTRA_VOICEMAIL_SMS
     * @see #EXTRA_TARGET_PACKAGE
     *
     * @hide */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_VOICEMAIL_SMS_RECEIVED =
            "com.android.internal.provider.action.VOICEMAIL_SMS_RECEIVED";
@@ -120,6 +123,19 @@ public class VoicemailContract {
     */
    public static final String EXTRA_VOICEMAIL_SMS = "android.provider.extra.VOICEMAIL_SMS";

    /**
     * Extra in {@link #ACTION_VOICEMAIL_SMS_RECEIVED} indicating the target package to bind {@link
     * android.telephony.VisualVoicemailService}.
     *
     * <p>This extra should be set to android.telephony.VisualVoicemailSmsFilterSettings#packageName
     * while performing filtering. Since the default dialer might change between the filter sending
     * it and telephony binding to the service, this ensures the service will not receive SMS
     * filtered by the previous app.
     *
     * @hide
     */
    public static final String EXTRA_TARGET_PACKAGE = "android.provider.extra.TARGET_PACAKGE";

    /**
     * Extra included in {@link Intent#ACTION_PROVIDER_CHANGED} broadcast intents to indicate if the
     * receiving package made this change.
+22 −5
Original line number Diff line number Diff line
@@ -15,12 +15,10 @@
 */
package android.telephony;

import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;

import android.telecom.PhoneAccountHandle;
import android.telephony.VisualVoicemailService.VisualVoicemailTask;

import java.util.Collections;
import java.util.List;

@@ -75,6 +73,7 @@ public final class VisualVoicemailSmsFilterSettings implements Parcelable {
        private String mClientPrefix = DEFAULT_CLIENT_PREFIX;
        private List<String> mOriginatingNumbers = DEFAULT_ORIGINATING_NUMBERS;
        private int mDestinationPort = DEFAULT_DESTINATION_PORT;
        private String mPackageName;

        public VisualVoicemailSmsFilterSettings build() {
            return new VisualVoicemailSmsFilterSettings(this);
@@ -116,6 +115,15 @@ public final class VisualVoicemailSmsFilterSettings implements Parcelable {
            return this;
        }

        /**
         * The package that registered this filter.
         *
         * @hide
         */
        public Builder setPackageName(String packageName) {
            mPackageName = packageName;
            return this;
        }
    }

    /**
@@ -137,6 +145,13 @@ public final class VisualVoicemailSmsFilterSettings implements Parcelable {
     */
    public final int destinationPort;

    /**
     * The package that registered this filter.
     *
     * @hide
     */
    public final String packageName;

    /**
     * Use {@link Builder} to construct
     */
@@ -144,6 +159,7 @@ public final class VisualVoicemailSmsFilterSettings implements Parcelable {
        clientPrefix = builder.mClientPrefix;
        originatingNumbers = builder.mOriginatingNumbers;
        destinationPort = builder.mDestinationPort;
        packageName = builder.mPackageName;
    }

    public static final Creator<VisualVoicemailSmsFilterSettings> CREATOR =
@@ -154,7 +170,7 @@ public final class VisualVoicemailSmsFilterSettings implements Parcelable {
                    builder.setClientPrefix(in.readString());
                    builder.setOriginatingNumbers(in.createStringArrayList());
                    builder.setDestinationPort(in.readInt());

                    builder.setPackageName(in.readString());
                    return builder.build();
                }

@@ -174,6 +190,7 @@ public final class VisualVoicemailSmsFilterSettings implements Parcelable {
        dest.writeString(clientPrefix);
        dest.writeStringList(originatingNumbers);
        dest.writeInt(destinationPort);
        dest.writeString(packageName);
    }

    @Override