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

Commit 22ed7392 authored by Daniel Kim's avatar Daniel Kim Committed by Android (Google) Code Review
Browse files

Merge "Enable credential suggestions without autofill provider" into main

parents 0cb8c7fc 1db5e5d1
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -1592,7 +1592,8 @@ public final class AutofillManager {
                // request comes in but PCC Detection hasn't been triggered. There is no benefit to
                // trigger PCC Detection separately in those cases.
                if (!isActiveLocked()) {
                    final boolean clientAdded = tryAddServiceClientIfNeededLocked();
                    final boolean clientAdded =
                            tryAddServiceClientIfNeededLocked(isCredmanRequested);
                    if (clientAdded) {
                        startSessionLocked(/* id= */ AutofillId.NO_AUTOFILL_ID, /* bounds= */ null,
                            /* value= */ null, /* flags= */ FLAG_PCC_DETECTION);
@@ -1850,7 +1851,8 @@ public final class AutofillManager {
            Rect bounds, AutofillValue value, int flags) {
        if (shouldIgnoreViewEnteredLocked(id, flags)) return null;

        final boolean clientAdded = tryAddServiceClientIfNeededLocked();
        boolean credmanRequested = isCredmanRequested(view);
        final boolean clientAdded = tryAddServiceClientIfNeededLocked(credmanRequested);
        if (!clientAdded) {
            if (sVerbose) Log.v(TAG, "ignoring notifyViewEntered(" + id + "): no service client");
            return null;
@@ -2645,6 +2647,11 @@ public final class AutofillManager {
     */
    @GuardedBy("mLock")
    private boolean tryAddServiceClientIfNeededLocked() {
        return tryAddServiceClientIfNeededLocked(/*credmanRequested=*/ false);
    }

    @GuardedBy("mLock")
    private boolean tryAddServiceClientIfNeededLocked(boolean credmanRequested) {
        final AutofillClient client = getClient();
        if (client == null) {
            return false;
@@ -2659,7 +2666,7 @@ public final class AutofillManager {
                final int userId = mContext.getUserId();
                final SyncResultReceiver receiver = new SyncResultReceiver(SYNC_CALLS_TIMEOUT_MS);
                mService.addClient(mServiceClient, client.autofillClientGetComponentName(),
                        userId, receiver);
                        userId, receiver, credmanRequested);
                int flags = 0;
                try {
                    flags = receiver.getIntResult();
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ import com.android.internal.os.IResultReceiver;
oneway interface IAutoFillManager {
    // Returns flags: FLAG_ADD_CLIENT_ENABLED | FLAG_ADD_CLIENT_DEBUG | FLAG_ADD_CLIENT_VERBOSE
    void addClient(in IAutoFillManagerClient client, in ComponentName componentName, int userId,
        in IResultReceiver result);
        in IResultReceiver result, boolean credmanRequested);
    void removeClient(in IAutoFillManagerClient client, int userId);
    void startSession(IBinder activityToken, in IBinder appCallback, in AutofillId autoFillId,
        in Rect bounds, in AutofillValue value, int userId, boolean hasCallback, int flags,
+1 −1
Original line number Diff line number Diff line
@@ -5,6 +5,6 @@
   Note: This file is ignored for devices older that API 31
   See https://developer.android.com/about/versions/12/backup-restore
-->
<autofill-service-configuration
<autofill-service
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:supportsInlineSuggestions="true"/>
 No newline at end of file
+3 −3
Original line number Diff line number Diff line
@@ -1625,13 +1625,13 @@ public final class AutofillManagerService
    final class AutoFillManagerServiceStub extends IAutoFillManager.Stub {
        @Override
        public void addClient(IAutoFillManagerClient client, ComponentName componentName,
                int userId, IResultReceiver receiver) {
                int userId, IResultReceiver receiver, boolean credmanRequested) {
            int flags = 0;
            try {
                synchronized (mLock) {
                    final int enabledFlags =
                            getServiceForUserWithLocalBinderIdentityLocked(userId)
                            .addClientLocked(client, componentName);
                            .addClientLocked(client, componentName, credmanRequested);
                    if (enabledFlags != 0) {
                        flags |= enabledFlags;
                    }
@@ -1644,7 +1644,7 @@ public final class AutofillManagerService
                }
            } catch (Exception ex) {
                // Don't do anything, send back default flags
                Log.wtf(TAG, "addClient(): failed " + ex.toString());
                Log.wtf(TAG, "addClient(): failed " + ex.toString(), ex);
            } finally {
                send(receiver, flags);
            }
+41 −11
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManagerInternal;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
@@ -96,6 +97,7 @@ import com.android.server.wm.ActivityTaskManagerInternal;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Random;
/**
 * Bridge between the {@code system_server}'s {@link AutofillManagerService} and the
@@ -293,8 +295,19 @@ final class AutofillManagerServiceImpl
     * @return {@code 0} if disabled, {@code FLAG_ADD_CLIENT_ENABLED} if enabled (it might be
     * OR'ed with {@code FLAG_AUGMENTED_AUTOFILL_REQUEST}).
     */
    @GuardedBy("mLock")
    int addClientLocked(IAutoFillManagerClient client, ComponentName componentName) {
    int addClientLocked(IAutoFillManagerClient client, ComponentName componentName,
            boolean credmanRequested) {
        synchronized (mLock) {
            ComponentName credComponentName = getCredentialAutofillService(getContext());

            if (!credmanRequested
                    && Objects.equals(credComponentName,
                    mInfo == null ? null : mInfo.getServiceInfo().getComponentName())) {
                // If the service component name corresponds to cred component name, then it means
                // no autofill provider is selected by the user. Cred Autofill Service should only
                // be active if there is a credman request.
                return 0;
            }
            if (mClients == null) {
                mClients = new RemoteCallbackList<>();
            }
@@ -307,6 +320,7 @@ final class AutofillManagerServiceImpl
                    && isWhitelistedForAugmentedAutofillLocked(componentName)) {
                return FLAG_ADD_CLIENT_ENABLED_FOR_AUGMENTED_AUTOFILL_ONLY;
            }
        }

        // No flags / disabled
        return 0;
@@ -1486,6 +1500,22 @@ final class AutofillManagerServiceImpl
        return true;
    }

    @Nullable
    private ComponentName getCredentialAutofillService(Context context) {
        ComponentName componentName = null;
        String credentialManagerAutofillCompName = context.getResources().getString(
                R.string.config_defaultCredentialManagerAutofillService);
        if (credentialManagerAutofillCompName != null
                && !credentialManagerAutofillCompName.isEmpty()) {
            componentName = ComponentName.unflattenFromString(
                    credentialManagerAutofillCompName);
        }
        if (componentName == null) {
            Slog.w(TAG, "Invalid CredentialAutofillService");
        }
        return componentName;
    }

    @GuardedBy("mLock")
    private int getAugmentedAutofillServiceUidLocked() {
        if (mRemoteAugmentedAutofillServiceInfo == null) {
Loading