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

Commit 72dd90b6 authored by Reema Bajwa's avatar Reema Bajwa
Browse files

Remove pending intent from framework provider APIs

Pending intents will be added to the Slice objects as
slice actions through the jetpack library. Earlier,
we needed this at the framework level as the framework was invoking
the pending intent. We have now changed the design to have the UI
app directly launch the pending intent.

Test: Built locally
Bug: 264717022

Change-Id: I2c62819bb4a60a55e9fbf7552ce2a7dc84dff3ee
parent 58e08406
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -39769,9 +39769,8 @@ package android.service.controls.templates {
package android.service.credentials {
  public class Action implements android.os.Parcelable {
    ctor public Action(@NonNull android.app.slice.Slice, @NonNull android.app.PendingIntent);
    ctor public Action(@NonNull android.app.slice.Slice);
    method public int describeContents();
    method @NonNull public android.app.PendingIntent getPendingIntent();
    method @NonNull public android.app.slice.Slice getSlice();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.service.credentials.Action> CREATOR;
@@ -39866,21 +39865,18 @@ package android.service.credentials {
  }
  public class CreateEntry implements android.os.Parcelable {
    ctor public CreateEntry(@NonNull android.app.slice.Slice, @NonNull android.app.PendingIntent);
    ctor public CreateEntry(@NonNull android.app.slice.Slice);
    method public int describeContents();
    method @NonNull public android.app.PendingIntent getPendingIntent();
    method @NonNull public android.app.slice.Slice getSlice();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.service.credentials.CreateEntry> CREATOR;
  }
  public class CredentialEntry implements android.os.Parcelable {
    ctor public CredentialEntry(@NonNull String, @NonNull android.app.slice.Slice, @NonNull android.app.PendingIntent, boolean);
    ctor public CredentialEntry(@NonNull String, @NonNull android.app.slice.Slice);
    method public int describeContents();
    method @NonNull public android.app.PendingIntent getPendingIntent();
    method @NonNull public android.app.slice.Slice getSlice();
    method @NonNull public String getType();
    method public boolean isAutoSelectAllowed();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.service.credentials.CredentialEntry> CREATOR;
  }
+2 −1
Original line number Diff line number Diff line
@@ -997,7 +997,8 @@ package android.credentials.ui {

  public final class Entry implements android.os.Parcelable {
    ctor public Entry(@NonNull String, @NonNull String, @NonNull android.app.slice.Slice);
    ctor public Entry(@NonNull String, @NonNull String, @NonNull android.app.slice.Slice, @NonNull android.app.PendingIntent, @Nullable android.content.Intent);
    ctor public Entry(@NonNull String, @NonNull String, @NonNull android.app.slice.Slice, @NonNull android.app.PendingIntent, @NonNull android.content.Intent);
    ctor public Entry(@NonNull String, @NonNull String, @NonNull android.app.slice.Slice, @NonNull android.content.Intent);
    method public int describeContents();
    method @Nullable public android.content.Intent getFrameworkExtrasIntent();
    method @NonNull public String getKey();
+10 −1
Original line number Diff line number Diff line
@@ -89,12 +89,21 @@ public final class Entry implements Parcelable {
     * when clicked.
     */
    public Entry(@NonNull String key, @NonNull String subkey, @NonNull Slice slice,
            @NonNull PendingIntent pendingIntent, @Nullable Intent intent) {
            @NonNull PendingIntent pendingIntent, @NonNull Intent intent) {
        this(key, subkey, slice);
        mPendingIntent = pendingIntent;
        mFrameworkExtrasIntent = intent;
    }

    /** Constructor to be used for an entry that requires a pending intent to be invoked
     * when clicked.
     */
    public Entry(@NonNull String key, @NonNull String subkey, @NonNull Slice slice,
            @NonNull Intent intent) {
        this(key, subkey, slice);
        mFrameworkExtrasIntent = intent;
    }

    /**
    * Returns the identifier of this entry that's unique within the context of the CredentialManager
    * request.
+10 −18
Original line number Diff line number Diff line
@@ -29,6 +29,9 @@ import java.util.Objects;
 * An action defined by the provider that intents into the provider's app for specific
 * user actions.
 *
 * <p>If user selects this action entry, the corresponding {@link PendingIntent} set on the
 * {@code slice} as a {@link androidx.slice.core.SliceAction} will get invoked.
 *
 * <p>Any class that derives this class must only add extra field values to the {@code slice}
 * object passed into the constructor. Any other field will not be parceled through. If the
 * derived class has custom parceling implementation, this class will not be able to unpack
@@ -37,9 +40,8 @@ import java.util.Objects;
@SuppressLint("ParcelNotFinal")
public class Action implements Parcelable {
    /** Slice object containing display content to be displayed with this action on the UI. */
    private final @NonNull Slice mSlice;
    /** The pending intent to be invoked when the user selects this action. */
    private final @NonNull PendingIntent mPendingIntent;
    @NonNull
    private final Slice mSlice;

    /**
     * Constructs an action to be displayed on the UI.
@@ -52,21 +54,18 @@ public class Action implements Parcelable {
     * {@link BeginCreateCredentialResponse} and {@link BeginGetCredentialResponse}.
     *
     * @param slice the display content to be displayed on the UI, along with this action
     * @param pendingIntent the intent to be invoked when the user selects this action
     */
    public Action(@NonNull Slice slice, @NonNull PendingIntent pendingIntent) {
    public Action(@NonNull Slice slice) {
        Objects.requireNonNull(slice, "slice must not be null");
        Objects.requireNonNull(pendingIntent, "pendingIntent must not be null");
        mSlice = slice;
        mPendingIntent = pendingIntent;
    }

    private Action(@NonNull Parcel in) {
        mSlice = in.readTypedObject(Slice.CREATOR);
        mPendingIntent = in.readTypedObject(PendingIntent.CREATOR);
    }

    public static final @NonNull Creator<Action> CREATOR = new Creator<Action>() {
    @NonNull
    public static final Creator<Action> CREATOR = new Creator<Action>() {
        @Override
        public Action createFromParcel(@NonNull Parcel in) {
            return new Action(in);
@@ -86,20 +85,13 @@ public class Action implements Parcelable {
    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeTypedObject(mSlice, flags);
        dest.writeTypedObject(mPendingIntent, flags);
    }

    /**
     * Returns a {@code Slice} object containing the display content to be displayed on the UI.
     */
    public @NonNull Slice getSlice() {
    @NonNull
    public Slice getSlice() {
        return mSlice;
    }

    /**
     * Returns the {@link PendingIntent} to be invoked when the action is selected.
     */
    public @NonNull PendingIntent getPendingIntent() {
        return mPendingIntent;
    }
}
+12 −16
Original line number Diff line number Diff line
@@ -27,6 +27,13 @@ import android.os.Parcelable;
 * An entry to be shown on the UI. This entry represents where the credential to be created will
 * be stored. Examples include user's account, family group etc.
 *
 * <p>If user selects this entry, the corresponding {@link PendingIntent} set on the
 * {@code slice} as a {@link androidx.slice.core.SliceAction} will get invoked.
 * Once the resulting activity fulfills the required user engagement,
 * the {@link android.app.Activity} result should be set to {@link android.app.Activity#RESULT_OK},
 * and the {@link CredentialProviderService#EXTRA_CREATE_CREDENTIAL_RESPONSE} must be set with a
 * {@link android.credentials.CreateCredentialResponse} object.
 *
 * <p>Any class that derives this class must only add extra field values to the {@code slice}
 * object passed into the constructor. Any other field will not be parceled through. If the
 * derived class has custom parceling implementation, this class will not be able to unpack
@@ -35,14 +42,13 @@ import android.os.Parcelable;
@SuppressLint("ParcelNotFinal")
public class CreateEntry implements Parcelable {
    private final @NonNull Slice mSlice;
    private final @NonNull PendingIntent mPendingIntent;

    private CreateEntry(@NonNull Parcel in) {
        mSlice = in.readTypedObject(Slice.CREATOR);
        mPendingIntent = in.readTypedObject(PendingIntent.CREATOR);
    }

    public static final @NonNull Creator<CreateEntry> CREATOR = new Creator<CreateEntry>() {
    @NonNull
    public static final Creator<CreateEntry> CREATOR = new Creator<CreateEntry>() {
        @Override
        public CreateEntry createFromParcel(@NonNull Parcel in) {
            return new CreateEntry(in);
@@ -62,33 +68,23 @@ public class CreateEntry implements Parcelable {
    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeTypedObject(mSlice, flags);
        dest.writeTypedObject(mPendingIntent, flags);
    }

    /**
     * Constructs a CreateEntry to be displayed on the UI.
     *
     * @param slice the display content to be displayed on the UI, along with this entry
     * @param pendingIntent the intent to be invoked when the user selects this entry
     */
    public CreateEntry(
            @NonNull Slice slice,
            @NonNull PendingIntent pendingIntent) {
            @NonNull Slice slice) {
        this.mSlice = slice;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mSlice);
        this.mPendingIntent = pendingIntent;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mPendingIntent);
    }

    /** Returns the content to be displayed with this create entry on the UI. */
    public @NonNull Slice getSlice() {
    @NonNull
    public Slice getSlice() {
        return mSlice;
    }

    /** Returns the pendingIntent to be invoked when this create entry on the UI is selectcd. */
    public @NonNull PendingIntent getPendingIntent() {
        return mPendingIntent;
    }
}
Loading