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

Commit 88872971 authored by Feng Cao's avatar Feng Cao
Browse files

Create InlineAction class to wrap the IntentSender and the presentation

* Before this change, we were putting the action intent in the Slice,
  but we realize that's not the best place as slice is only meant for
  data representation, and intent does not fall into that
* This patch includes the code to actually fire the pending intent when
  action suggestion is clicked. However, it'll only work if the fill
  service have the SYSTEM_ALERT_WINDOW permission for the intent to
  be fired when it is in the background. We will move it to be fired
  from the client foreground app in a separate patch

Test: manual verification
Test: atest android.autofillservice.cts.inline
Bug: 150499490

Change-Id: I411a7ee05e783f7de94a54064c44a6126afe0b12
parent 3a68e2d0
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -43108,7 +43108,7 @@ package android.service.autofill {
  public static final class FillResponse.Builder {
    ctor public FillResponse.Builder();
    method @NonNull public android.service.autofill.FillResponse.Builder addDataset(@Nullable android.service.autofill.Dataset);
    method @NonNull public android.service.autofill.FillResponse.Builder addInlineAction(@NonNull android.service.autofill.InlinePresentation);
    method @NonNull public android.service.autofill.FillResponse.Builder addInlineAction(@NonNull android.service.autofill.InlineAction);
    method @NonNull public android.service.autofill.FillResponse build();
    method @NonNull public android.service.autofill.FillResponse.Builder disableAutofill(long);
    method @NonNull public android.service.autofill.FillResponse.Builder setAuthentication(@NonNull android.view.autofill.AutofillId[], @Nullable android.content.IntentSender, @Nullable android.widget.RemoteViews);
@@ -43138,6 +43138,15 @@ package android.service.autofill {
    method public android.service.autofill.ImageTransformation build();
  }
  public final class InlineAction implements android.os.Parcelable {
    ctor public InlineAction(@NonNull android.service.autofill.InlinePresentation, @NonNull android.content.IntentSender);
    method public int describeContents();
    method @NonNull public android.content.IntentSender getAction();
    method @NonNull public android.service.autofill.InlinePresentation getInlinePresentation();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.service.autofill.InlineAction> CREATOR;
  }
  public final class InlinePresentation implements android.os.Parcelable {
    ctor public InlinePresentation(@NonNull android.app.slice.Slice, @NonNull android.view.inline.InlinePresentationSpec, boolean);
    method public int describeContents();
+1 −1
Original line number Diff line number Diff line
@@ -9868,7 +9868,7 @@ package android.service.autofill.augmented {
    method @NonNull public android.service.autofill.augmented.FillResponse build();
    method @NonNull public android.service.autofill.augmented.FillResponse.Builder setClientState(@NonNull android.os.Bundle);
    method @NonNull public android.service.autofill.augmented.FillResponse.Builder setFillWindow(@NonNull android.service.autofill.augmented.FillWindow);
    method @NonNull public android.service.autofill.augmented.FillResponse.Builder setInlineActions(@NonNull java.util.List<android.service.autofill.InlinePresentation>);
    method @NonNull public android.service.autofill.augmented.FillResponse.Builder setInlineActions(@NonNull java.util.List<android.service.autofill.InlineAction>);
    method @NonNull public android.service.autofill.augmented.FillResponse.Builder setInlineSuggestions(@NonNull java.util.List<android.service.autofill.Dataset>);
  }
+1 −1
Original line number Diff line number Diff line
@@ -3229,7 +3229,7 @@ package android.service.autofill.augmented {
    method @NonNull public android.service.autofill.augmented.FillResponse build();
    method @NonNull public android.service.autofill.augmented.FillResponse.Builder setClientState(@NonNull android.os.Bundle);
    method @NonNull public android.service.autofill.augmented.FillResponse.Builder setFillWindow(@NonNull android.service.autofill.augmented.FillWindow);
    method @NonNull public android.service.autofill.augmented.FillResponse.Builder setInlineActions(@NonNull java.util.List<android.service.autofill.InlinePresentation>);
    method @NonNull public android.service.autofill.augmented.FillResponse.Builder setInlineActions(@NonNull java.util.List<android.service.autofill.InlineAction>);
    method @NonNull public android.service.autofill.augmented.FillResponse.Builder setInlineSuggestions(@NonNull java.util.List<android.service.autofill.Dataset>);
  }

+8 −11
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ public final class FillResponse implements Parcelable {
    private final @Nullable int[] mCancelIds;
    private final boolean mSupportsInlineSuggestions;
    // TODO(b/149240554): revert back to use ParceledListSlice after the bug is resolved.
    private final @Nullable ArrayList<InlinePresentation> mInlineActions;
    private final @Nullable ArrayList<InlineAction> mInlineActions;

    private FillResponse(@NonNull Builder builder) {
        mDatasets = (builder.mDatasets != null) ? new ParceledListSlice<>(builder.mDatasets) : null;
@@ -213,7 +213,7 @@ public final class FillResponse implements Parcelable {
    }

    /** @hide */
    public @Nullable List<InlinePresentation> getInlineActions() {
    public @Nullable List<InlineAction> getInlineActions() {
        return mInlineActions;
    }

@@ -239,7 +239,7 @@ public final class FillResponse implements Parcelable {
        private UserData mUserData;
        private int[] mCancelIds;
        private boolean mSupportsInlineSuggestions;
        private ArrayList<InlinePresentation> mInlineActions;
        private ArrayList<InlineAction> mInlineActions;

        /**
         * Triggers a custom UI before before autofilling the screen with any data set in this
@@ -656,15 +656,12 @@ public final class FillResponse implements Parcelable {
        }

        /**
         * Adds a new {@link InlinePresentation} to this response representing an action UI.
         *
         * <p> For example, the UI can be associated with an intent which can open an activity for
         * the user to manage the Autofill provider settings.
         * Adds a new {@link InlineAction} to this response representing an action UI.
         *
         * @return This builder.
         */
        @NonNull
        public Builder addInlineAction(@NonNull InlinePresentation inlineAction) {
        public Builder addInlineAction(@NonNull InlineAction inlineAction) {
            throwIfDestroyed();
            throwIfAuthenticationCalled();
            if (mInlineActions == null) {
@@ -881,10 +878,10 @@ public final class FillResponse implements Parcelable {
            final int[] cancelIds = parcel.createIntArray();
            builder.setPresentationCancelIds(cancelIds);

            final List<InlinePresentation> inlineActions = parcel.createTypedArrayList(
                    InlinePresentation.CREATOR);
            final List<InlineAction> inlineActions = parcel.createTypedArrayList(
                    InlineAction.CREATOR);
            if (inlineActions != null) {
                for (InlinePresentation inlineAction : inlineActions) {
                for (InlineAction inlineAction : inlineActions) {
                    builder.addInlineAction(inlineAction);
                }
            }
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.service.autofill;

parcelable InlineAction;
Loading