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

Commit 48b2bbde authored by Winson Chung's avatar Winson Chung
Browse files

Request autofill data instead of assist data when swiping up.

Bug: 118476918
Test: Swipe up, ensure autofill data exists
Change-Id: I61a94ab488913a5fe2b879f37e8a6f1384b67d03
parent fbbb158d
Loading
Loading
Loading
Loading
+39 −6
Original line number Diff line number Diff line
@@ -134,11 +134,40 @@ public class AssistDataRequester extends IAssistDataReceiver.Stub {
        mRequestScreenshotAppOps = requestScreenshotAppOps;
    }

    /**
     * Request that autofill data be loaded asynchronously. The resulting data will be provided
     * through the {@link AssistDataRequesterCallbacks}.
     *
     * See {@link #requestData(List, boolean, boolean, boolean, boolean, boolean, int, String)}.
     */
    public void requestAutofillData(List<IBinder> activityTokens, int callingUid,
            String callingPackage) {
        requestData(activityTokens, true /* requestAutofillData */,
                true /* fetchData */, false /* fetchScreenshot */,
                true /* allowFetchData */, false /* allowFetchScreenshot */,
                callingUid, callingPackage);
    }

    /**
     * Request that assist data be loaded asynchronously. The resulting data will be provided
     * through the {@link AssistDataRequesterCallbacks}.
     *
     * See {@link #requestData(List, boolean, boolean, boolean, boolean, boolean, int, String)}.
     */
    public void requestAssistData(List<IBinder> activityTokens, final boolean fetchData,
            final boolean fetchScreenshot, boolean allowFetchData, boolean allowFetchScreenshot,
            int callingUid, String callingPackage) {
        requestData(activityTokens, false /* requestAutofillData */, fetchData, fetchScreenshot,
                allowFetchData, allowFetchScreenshot, callingUid, callingPackage);
    }

    /**
     * Request that assist data be loaded asynchronously. The resulting data will be provided
     * through the {@link AssistDataRequesterCallbacks}.
     *
     * @param activityTokens the list of visible activities
     * @param requestAutofillData if true, will fetch the autofill data, otherwise, will fetch the
     *     assist context data
     * @param fetchData whether or not to fetch the assist data, only applies if the caller is
     *     allowed to fetch the assist data, and the current activity allows assist data to be
     *     fetched from it
@@ -150,9 +179,9 @@ public class AssistDataRequester extends IAssistDataReceiver.Stub {
     * @param allowFetchScreenshot to be joined with other checks, determines whether or not the
     *     requester is allowed to fetch the assist screenshot
     */
    public void requestAssistData(List<IBinder> activityTokens, final boolean fetchData,
            final boolean fetchScreenshot, boolean allowFetchData, boolean allowFetchScreenshot,
            int callingUid, String callingPackage) {
    private void requestData(List<IBinder> activityTokens, final boolean requestAutofillData,
            final boolean fetchData, final boolean fetchScreenshot, boolean allowFetchData,
            boolean allowFetchScreenshot, int callingUid, String callingPackage) {
        // TODO(b/34090158): Known issue, if the assist data is not allowed on the current activity,
        //                   then no assist data is requested for any of the other activities

@@ -192,9 +221,13 @@ public class AssistDataRequester extends IAssistDataReceiver.Stub {
                        Bundle receiverExtras = new Bundle();
                        receiverExtras.putInt(KEY_RECEIVER_EXTRA_INDEX, i);
                        receiverExtras.putInt(KEY_RECEIVER_EXTRA_COUNT, numActivities);
                        if (ActivityTaskManager.getService().requestAssistContextExtras(
                        boolean result = requestAutofillData
                                ? ActivityTaskManager.getService().requestAssistContextExtras(
                                        ASSIST_CONTEXT_FULL, this, receiverExtras, topActivity,
                                /* focused= */ i == 0, /* newSessionId= */ i == 0)) {
                                                /* focused= */ i == 0, /* newSessionId= */ i == 0)
                                : ActivityTaskManager.getService().requestAutofillData(this,
                                        receiverExtras, topActivity, 0 /* flags */);
                        if (result) {
                            mPendingDataCount++;
                        } else if (i == 0) {
                            // Wasn't allowed... given that, let's not do the screenshot either.
+1 −3
Original line number Diff line number Diff line
@@ -259,9 +259,7 @@ class RecentsAnimation implements RecentsAnimationCallbacks,
        }
        mAssistDataRequester = new AssistDataRequester(mService.mContext, mWindowManager,
                appOpsManager, assistDataCallbacks, this, OP_ASSIST_STRUCTURE, OP_NONE);
        mAssistDataRequester.requestAssistData(topActivities,
                true /* fetchData */, false /* fetchScreenshots */,
                true /* allowFetchData */, false /* allowFetchScreenshots */,
        mAssistDataRequester.requestAutofillData(topActivities,
                recentsUid, recentsComponent.getPackageName());
    }