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

Commit d41ce92d authored by Adam He's avatar Adam He
Browse files

Add API to start pendingIntent for attribution from client App.

Bug: 150321630
Test: manual verification
Change-Id: I99f8529c94ef0cc8721d58af7f3c57ae43f4b6dd
parent 65b857a2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -9642,6 +9642,7 @@ package android.service.autofill {
    method @Nullable public final android.os.IBinder onBind(@NonNull android.content.Intent);
    method @Nullable public android.os.Bundle onGetInlineSuggestionsRendererInfo();
    method @Nullable public android.view.View onRenderSuggestion(@NonNull android.service.autofill.InlinePresentation, int, int);
    method public final void startIntentSender(@NonNull android.content.IntentSender);
    field public static final String SERVICE_INTERFACE = "android.service.autofill.InlineSuggestionRenderService";
  }
+1 −0
Original line number Diff line number Diff line
@@ -3169,6 +3169,7 @@ package android.service.autofill {
    method @Nullable public final android.os.IBinder onBind(@NonNull android.content.Intent);
    method @Nullable public android.os.Bundle onGetInlineSuggestionsRendererInfo();
    method @Nullable public android.view.View onRenderSuggestion(@NonNull android.service.autofill.InlinePresentation, int, int);
    method public final void startIntentSender(@NonNull android.content.IntentSender);
    field public static final String SERVICE_INTERFACE = "android.service.autofill.InlineSuggestionRenderService";
  }

+2 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.service.autofill;

import android.content.IntentSender;
import android.os.IBinder;
import android.view.SurfaceControlViewHost;

@@ -30,4 +31,5 @@ oneway interface IInlineSuggestionUiCallback {
    void onContent(in SurfaceControlViewHost.SurfacePackage surface);
    void onError();
    void onTransferTouchFocusToImeWindow(in IBinder sourceInputToken, int displayId);
    void onStartIntentSender(in IntentSender intentSender);
}
+18 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.annotation.TestApi;
import android.app.Service;
import android.app.slice.Slice;
import android.content.Intent;
import android.content.IntentSender;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.os.Handler;
@@ -60,6 +61,8 @@ public abstract class InlineSuggestionRenderService extends Service {

    private final Handler mHandler = new Handler(Looper.getMainLooper(), null, true);

    private IInlineSuggestionUiCallback mCallback;

    private void handleRenderSuggestion(IInlineSuggestionUiCallback callback,
            InlinePresentation presentation, int width, int height, IBinder hostInputToken,
            int displayId) {
@@ -84,6 +87,7 @@ public abstract class InlineSuggestionRenderService extends Service {
                }
                return;
            }
            mCallback = callback;

            final InlineSuggestionRoot suggestionRoot = new InlineSuggestionRoot(this, callback);
            suggestionRoot.addView(suggestionView);
@@ -154,6 +158,20 @@ public abstract class InlineSuggestionRenderService extends Service {
        return null;
    }

    /**
     * Starts the {@link IntentSender} from the client app.
     *
     * @param intentSender the {@link IntentSender} to start the attribution UI from the client app.
     */
    public final void startIntentSender(@NonNull IntentSender intentSender) {
        if (mCallback == null) return;
        try {
            mCallback.onStartIntentSender(intentSender);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
    }

    /**
     *  Returns the metadata about the renderer. Returns {@code null} if no metadata is provided.
     */
+23 −14
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.app.AppGlobals;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
import android.os.Bundle;
@@ -250,7 +251,9 @@ final class RemoteAugmentedAutofillService
        final InlineSuggestionsResponse inlineSuggestionsResponse =
                InlineSuggestionFactory.createAugmentedInlineSuggestionsResponse(
                        request, inlineSuggestionsData, focusedId,
                        dataset -> {
                        new InlineSuggestionFactory.InlineSuggestionUiCallback() {
                            @Override
                            public void autofill(Dataset dataset) {
                                mCallbacks.logAugmentedAutofillSelected(sessionId,
                                        dataset.getId());
                                try {
@@ -258,16 +261,22 @@ final class RemoteAugmentedAutofillService
                                    final int size = fieldIds.size();
                                    final boolean hideHighlight = size == 1
                                            && fieldIds.get(0).equals(focusedId);
                                if (dataset.getAuthentication() != null) {
                                    client.startIntentSender(dataset.getAuthentication(),
                                            new Intent());
                                } else {
                                    client.autofill(sessionId, fieldIds, dataset.getFieldValues(),
                                            hideHighlight);
                                }
                                } catch (RemoteException e) {
                                    Slog.w(TAG, "Encounter exception autofilling the values");
                                }
                            }

                            @Override
                            public void startIntentSender(IntentSender intentSender,
                                    Intent intent) {
                                try {
                                    client.startIntentSender(intentSender, intent);
                                } catch (RemoteException e) {
                                    Slog.w(TAG, "RemoteException starting intent sender");
                                }
                            }
                        }, onErrorCallback, remoteRenderService);

        if (inlineSuggestionsResponse == null) {
Loading