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

Commit c113b305 authored by Nikita Dubrovsky's avatar Nikita Dubrovsky Committed by Automerger Merge Worker
Browse files

Merge "Update some autofill var names for clarity" into sc-dev am: 1dad2faa

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13448137

Change-Id: Id18b6588251ee12ddbcc9573ff5a62f35e3b5ab3
parents 67680524 1dad2faa
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -1921,20 +1921,20 @@ public final class AutofillManager {
            if (client == null) return; // NOTE: getClient() already logged it..

            final SyncResultReceiver receiver = new SyncResultReceiver(SYNC_CALLS_TIMEOUT_MS);
            final ComponentName componentName = client.autofillClientGetComponentName();
            final ComponentName clientActivity = client.autofillClientGetComponentName();

            if (!mEnabledForAugmentedAutofillOnly && mOptions != null
                    && mOptions.isAutofillDisabledLocked(componentName)) {
                    && mOptions.isAutofillDisabledLocked(clientActivity)) {
                if (mOptions.isAugmentedAutofillEnabled(mContext)) {
                    if (sDebug) {
                        Log.d(TAG, "startSession(" + componentName + "): disabled by service but "
                                + "whitelisted for augmented autofill");
                        Log.d(TAG, "startSession(" + clientActivity + "): disabled by service but "
                                + "allowlisted for augmented autofill");
                        flags |= FLAG_ADD_CLIENT_ENABLED_FOR_AUGMENTED_AUTOFILL_ONLY;
                    }
                } else {
                    if (sDebug) {
                        Log.d(TAG, "startSession(" + componentName + "): ignored because "
                                + "disabled by service and not whitelisted for augmented autofill");
                        Log.d(TAG, "startSession(" + clientActivity + "): ignored because "
                                + "disabled by service and not allowlisted for augmented autofill");
                    }
                    setSessionFinished(AutofillManager.STATE_DISABLED_BY_SERVICE, null);
                    client.autofillClientResetableStateAvailable();
@@ -1951,7 +1951,7 @@ public final class AutofillManager {

            mService.startSession(client.autofillClientGetActivityToken(),
                    mServiceClient.asBinder(), id, bounds, value, mContext.getUserId(),
                    mCallback != null, flags, componentName,
                    mCallback != null, flags, clientActivity,
                    isCompatibilityModeEnabledLocked(), receiver);
            mSessionId = receiver.getIntResult();
            if (mSessionId != NO_SESSION) {
@@ -1959,7 +1959,7 @@ public final class AutofillManager {
            }
            final int extraFlags = receiver.getOptionalExtraIntResult(0);
            if ((extraFlags & RECEIVER_FLAG_SESSION_FOR_AUGMENTED_AUTOFILL_ONLY) != 0) {
                if (sDebug) Log.d(TAG, "startSession(" + componentName + "): for augmented only");
                if (sDebug) Log.d(TAG, "startSession(" + clientActivity + "): for augmented only");
                mForAugmentedAutofillOnly = true;
            }
            client.autofillClientResetableStateAvailable();
+12 −9
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ import static com.android.server.autofill.Helper.sDebug;
import static com.android.server.autofill.Helper.sFullScreenMode;
import static com.android.server.autofill.Helper.sVerbose;

import static java.util.Objects.requireNonNull;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
@@ -1370,15 +1372,16 @@ public final class AutofillManagerService
        }

        @Override
        public void startSession(IBinder activityToken, IBinder appCallback, AutofillId autofillId,
                Rect bounds, AutofillValue value, int userId, boolean hasCallback, int flags,
                ComponentName componentName, boolean compatMode, IResultReceiver receiver) {
        public void startSession(IBinder activityToken, IBinder clientCallback,
                AutofillId autofillId, Rect bounds, AutofillValue value, int userId,
                boolean hasCallback, int flags, ComponentName clientActivity,
                boolean compatMode, IResultReceiver receiver) {

            activityToken = Preconditions.checkNotNull(activityToken, "activityToken");
            appCallback = Preconditions.checkNotNull(appCallback, "appCallback");
            autofillId = Preconditions.checkNotNull(autofillId, "autoFillId");
            componentName = Preconditions.checkNotNull(componentName, "componentName");
            final String packageName = Preconditions.checkNotNull(componentName.getPackageName());
            requireNonNull(activityToken, "activityToken");
            requireNonNull(clientCallback, "clientCallback");
            requireNonNull(autofillId, "autofillId");
            requireNonNull(clientActivity, "clientActivity");
            final String packageName = requireNonNull(clientActivity.getPackageName());

            Preconditions.checkArgument(userId == UserHandle.getUserId(getCallingUid()), "userId");

@@ -1395,7 +1398,7 @@ public final class AutofillManagerService
            synchronized (mLock) {
                final AutofillManagerServiceImpl service = getServiceForUserLocked(userId);
                result = service.startSessionLocked(activityToken, taskId, getCallingUid(),
                        appCallback, autofillId, bounds, value, hasCallback, componentName,
                        clientCallback, autofillId, bounds, value, hasCallback, clientActivity,
                        compatMode, mAllowInstantService, flags);
            }
            final int sessionId = (int) result;
+18 −18
Original line number Diff line number Diff line
@@ -307,10 +307,10 @@ final class AutofillManagerServiceImpl
     * {@link AutofillManager#RECEIVER_FLAG_SESSION_FOR_AUGMENTED_AUTOFILL_ONLY}).
     */
    @GuardedBy("mLock")
    long startSessionLocked(@NonNull IBinder activityToken, int taskId, int uid,
            @NonNull IBinder appCallbackToken, @NonNull AutofillId autofillId,
    long startSessionLocked(@NonNull IBinder activityToken, int taskId, int clientUid,
            @NonNull IBinder clientCallback, @NonNull AutofillId autofillId,
            @NonNull Rect virtualBounds, @Nullable AutofillValue value, boolean hasCallback,
            @NonNull ComponentName componentName, boolean compatMode,
            @NonNull ComponentName clientActivity, boolean compatMode,
            boolean bindInstantServiceAllowed, int flags) {
        // FLAG_AUGMENTED_AUTOFILL_REQUEST is set in the flags when standard autofill is disabled
        // but the package is allowlisted for augmented autofill
@@ -320,29 +320,29 @@ final class AutofillManagerServiceImpl
            return 0;
        }

        if (!forAugmentedAutofillOnly && isAutofillDisabledLocked(componentName)) {
        if (!forAugmentedAutofillOnly && isAutofillDisabledLocked(clientActivity)) {
            // Standard autofill is enabled, but service disabled autofill for this activity; that
            // means no session, unless the activity is allowlisted for augmented autofill
            if (isWhitelistedForAugmentedAutofillLocked(componentName)) {
            if (isWhitelistedForAugmentedAutofillLocked(clientActivity)) {
                if (sDebug) {
                    Slog.d(TAG, "startSession(" + componentName + "): disabled by service but "
                    Slog.d(TAG, "startSession(" + clientActivity + "): disabled by service but "
                            + "whitelisted for augmented autofill");
                }
                forAugmentedAutofillOnly = true;

            } else {
                if (sDebug) {
                    Slog.d(TAG, "startSession(" + componentName + "): ignored because "
                    Slog.d(TAG, "startSession(" + clientActivity + "): ignored because "
                            + "disabled by service and not whitelisted for augmented autofill");
                }
                final IAutoFillManagerClient client = IAutoFillManagerClient.Stub
                        .asInterface(appCallbackToken);
                        .asInterface(clientCallback);
                try {
                    client.setSessionFinished(AutofillManager.STATE_DISABLED_BY_SERVICE,
                            /* autofillableIds= */ null);
                } catch (RemoteException e) {
                    Slog.w(TAG,
                            "Could not notify " + componentName + " that it's disabled: " + e);
                            "Could not notify " + clientActivity + " that it's disabled: " + e);
                }

                return NO_SESSION;
@@ -357,8 +357,8 @@ final class AutofillManagerServiceImpl
        // Occasionally clean up abandoned sessions
        pruneAbandonedSessionsLocked();

        final Session newSession = createSessionByTokenLocked(activityToken, taskId, uid,
                appCallbackToken, hasCallback, componentName, compatMode,
        final Session newSession = createSessionByTokenLocked(activityToken, taskId, clientUid,
                clientCallback, hasCallback, clientActivity, compatMode,
                bindInstantServiceAllowed, forAugmentedAutofillOnly, flags);
        if (newSession == null) {
            return NO_SESSION;
@@ -367,7 +367,7 @@ final class AutofillManagerServiceImpl
        // Service can be null when it's only for augmented autofill
        String servicePackageName = mInfo == null ? null : mInfo.getServiceInfo().packageName;
        final String historyItem =
                "id=" + newSession.id + " uid=" + uid + " a=" + componentName.toShortString()
                "id=" + newSession.id + " uid=" + clientUid + " a=" + clientActivity.toShortString()
                + " s=" + servicePackageName
                + " u=" + mUserId + " i=" + autofillId + " b=" + virtualBounds
                + " hc=" + hasCallback + " f=" + flags + " aa=" + forAugmentedAutofillOnly;
@@ -493,9 +493,9 @@ final class AutofillManagerServiceImpl
    }

    @GuardedBy("mLock")
    private Session createSessionByTokenLocked(@NonNull IBinder activityToken, int taskId, int uid,
            @NonNull IBinder appCallbackToken, boolean hasCallback,
            @NonNull ComponentName componentName, boolean compatMode,
    private Session createSessionByTokenLocked(@NonNull IBinder clientActivityToken, int taskId,
            int clientUid, @NonNull IBinder clientCallback, boolean hasCallback,
            @NonNull ComponentName clientActivity, boolean compatMode,
            boolean bindInstantServiceAllowed, boolean forAugmentedAutofillOnly, int flags) {
        // use random ids so that one app cannot know that another app creates sessions
        int sessionId;
@@ -511,15 +511,15 @@ final class AutofillManagerServiceImpl
        } while (sessionId == 0 || sessionId == NO_SESSION
                || mSessions.indexOfKey(sessionId) >= 0);

        assertCallerLocked(componentName, compatMode);
        assertCallerLocked(clientActivity, compatMode);

        // It's null when the session is just for augmented autofill
        final ComponentName serviceComponentName = mInfo == null ? null
                : mInfo.getServiceInfo().getComponentName();
        final Session newSession = new Session(this, mUi, getContext(), mHandler, mUserId, mLock,
                sessionId, taskId, uid, activityToken, appCallbackToken, hasCallback,
                sessionId, taskId, clientUid, clientActivityToken, clientCallback, hasCallback,
                mUiLatencyHistory, mWtfHistory, serviceComponentName,
                componentName, compatMode, bindInstantServiceAllowed, forAugmentedAutofillOnly,
                clientActivity, compatMode, bindInstantServiceAllowed, forAugmentedAutofillOnly,
                flags, mInputMethodManagerInternal);
        mSessions.put(newSession.id, newSession);

+2 −2
Original line number Diff line number Diff line
@@ -196,7 +196,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
    /** userId the session belongs to */
    public final int userId;

    /** uid the session is for */
    /** The uid of the app that's being autofilled */
    public final int uid;

    /** ID of the task associated with this session's activity */
@@ -208,7 +208,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
    @GuardedBy("mLock")
    @NonNull private IBinder mActivityToken;

    /** Component that's being auto-filled */
    /** The app activity that's being autofilled */
    @NonNull private final ComponentName mComponentName;

    /** Whether the app being autofilled is running in compat mode. */