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

Commit 5f01fe89 authored by Adam He's avatar Adam He Committed by Android (Google) Code Review
Browse files

Merge "Move mAugmentedAutofillResolver to AutofillManagerService instead."

parents f870dc12 61969af0
Loading
Loading
Loading
Loading
+17 −22
Original line number Original line Diff line number Diff line
@@ -80,6 +80,7 @@ import com.android.server.FgThread;
import com.android.server.LocalServices;
import com.android.server.LocalServices;
import com.android.server.autofill.ui.AutoFillUI;
import com.android.server.autofill.ui.AutoFillUI;
import com.android.server.infra.AbstractMasterSystemService;
import com.android.server.infra.AbstractMasterSystemService;
import com.android.server.infra.FrameworkResourcesServiceNameResolver;
import com.android.server.infra.SecureSettingsServiceNameResolver;
import com.android.server.infra.SecureSettingsServiceNameResolver;


import java.io.FileDescriptor;
import java.io.FileDescriptor;
@@ -132,6 +133,12 @@ public final class AutofillManagerService
    @GuardedBy("sLock")
    @GuardedBy("sLock")
    private static int sVisibleDatasetsMaxCount = 0;
    private static int sVisibleDatasetsMaxCount = 0;


    /**
     * Object used to set the name of the augmented autofill service.
     */
    @NonNull
    final FrameworkResourcesServiceNameResolver mAugmentedAutofillResolver;

    private final AutoFillUI mUi;
    private final AutoFillUI mUi;


    private final LocalLog mRequestsHistory = new LocalLog(20);
    private final LocalLog mRequestsHistory = new LocalLog(20);
@@ -200,6 +207,11 @@ public final class AutofillManagerService
                getServiceForUserLocked(userId);
                getServiceForUserLocked(userId);
            }
            }
        }
        }

        mAugmentedAutofillResolver = new FrameworkResourcesServiceNameResolver(getContext(),
                com.android.internal.R.string.config_defaultAugmentedAutofillService);
        mAugmentedAutofillResolver.setOnTemporaryServiceNameChangedCallback(
                (u, s) -> getServiceForUserLocked(u).updateRemoteAugmentedAutofillService());
    }
    }


    @Override // from AbstractMasterSystemService
    @Override // from AbstractMasterSystemService
@@ -549,37 +561,19 @@ public final class AutofillManagerService
                    + MAX_TEMP_AUGMENTED_SERVICE_DURATION_MS + " (called with " + durationMs + ")");
                    + MAX_TEMP_AUGMENTED_SERVICE_DURATION_MS + " (called with " + durationMs + ")");
        }
        }


        synchronized (mLock) {
        mAugmentedAutofillResolver.setTemporaryService(userId, serviceName, durationMs);
            final AutofillManagerServiceImpl service = getServiceForUserLocked(userId);
            if (service != null) {
                service.mAugmentedAutofillResolver.setTemporaryService(userId, serviceName,
                        durationMs);
            }
        }
    }
    }


    // Called by Shell command
    // Called by Shell command
    void resetTemporaryAugmentedAutofillService(@UserIdInt int userId) {
    void resetTemporaryAugmentedAutofillService(@UserIdInt int userId) {
        enforceCallingPermissionForManagement();
        enforceCallingPermissionForManagement();
        synchronized (mLock) {
        mAugmentedAutofillResolver.resetTemporaryService(userId);
            final AutofillManagerServiceImpl service = getServiceForUserLocked(userId);
            if (service != null) {
                service.mAugmentedAutofillResolver.resetTemporaryService(userId);
            }
        }
    }
    }


    // Called by Shell command
    // Called by Shell command
    boolean isDefaultAugmentedServiceEnabled(@UserIdInt int userId) {
    boolean isDefaultAugmentedServiceEnabled(@UserIdInt int userId) {
        enforceCallingPermissionForManagement();
        enforceCallingPermissionForManagement();

        return mAugmentedAutofillResolver.isDefaultServiceEnabled(userId);
        synchronized (mLock) {
            final AutofillManagerServiceImpl service = getServiceForUserLocked(userId);
            if (service != null) {
                return service.mAugmentedAutofillResolver.isDefaultServiceEnabled(userId);
            }
        }
        return false;
    }
    }


    // Called by Shell command
    // Called by Shell command
@@ -590,7 +584,7 @@ public final class AutofillManagerService
        synchronized (mLock) {
        synchronized (mLock) {
            final AutofillManagerServiceImpl service = getServiceForUserLocked(userId);
            final AutofillManagerServiceImpl service = getServiceForUserLocked(userId);
            if (service != null) {
            if (service != null) {
                final boolean changed = service.mAugmentedAutofillResolver
                final boolean changed = mAugmentedAutofillResolver
                        .setDefaultServiceEnabled(userId, enabled);
                        .setDefaultServiceEnabled(userId, enabled);
                if (changed) {
                if (changed) {
                    service.updateRemoteAugmentedAutofillService();
                    service.updateRemoteAugmentedAutofillService();
@@ -1348,6 +1342,7 @@ public final class AutofillManagerService
                    pw.print(" sVerbose: "); pw.println(realVerbose);
                    pw.print(" sVerbose: "); pw.println(realVerbose);
                    // Dump per-user services
                    // Dump per-user services
                    dumpLocked("", pw);
                    dumpLocked("", pw);
                    mAugmentedAutofillResolver.dumpShort(pw); pw.println();
                    pw.print("Max partitions per session: "); pw.println(sPartitionMaxCount);
                    pw.print("Max partitions per session: "); pw.println(sPartitionMaxCount);
                    pw.print("Max visible datasets: "); pw.println(sVisibleDatasetsMaxCount);
                    pw.print("Max visible datasets: "); pw.println(sVisibleDatasetsMaxCount);
                    if (sFullScreenMode != null) {
                    if (sFullScreenMode != null) {
+6 −19
Original line number Original line Diff line number Diff line
@@ -83,7 +83,6 @@ import com.android.server.autofill.AutofillManagerService.AutofillCompatState;
import com.android.server.autofill.RemoteAugmentedAutofillService.RemoteAugmentedAutofillServiceCallbacks;
import com.android.server.autofill.RemoteAugmentedAutofillService.RemoteAugmentedAutofillServiceCallbacks;
import com.android.server.autofill.ui.AutoFillUI;
import com.android.server.autofill.ui.AutoFillUI;
import com.android.server.infra.AbstractPerUserSystemService;
import com.android.server.infra.AbstractPerUserSystemService;
import com.android.server.infra.FrameworkResourcesServiceNameResolver;


import java.io.PrintWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.ArrayList;
@@ -159,13 +158,6 @@ final class AutofillManagerServiceImpl
    /** When was {@link PruneTask} last executed? */
    /** When was {@link PruneTask} last executed? */
    private long mLastPrune = 0;
    private long mLastPrune = 0;


    // TODO(b/128911469): move to AutofillManagerService
    /**
     * Object used to set the name of the augmented autofill service.
     */
    @NonNull
    final FrameworkResourcesServiceNameResolver mAugmentedAutofillResolver;

    /**
    /**
     * Reference to the {@link RemoteAugmentedAutofillService}, is set on demand.
     * Reference to the {@link RemoteAugmentedAutofillService}, is set on demand.
     */
     */
@@ -195,11 +187,6 @@ final class AutofillManagerServiceImpl
        mFieldClassificationStrategy = new FieldClassificationStrategy(getContext(), userId);
        mFieldClassificationStrategy = new FieldClassificationStrategy(getContext(), userId);
        mAutofillCompatState = autofillCompatState;
        mAutofillCompatState = autofillCompatState;


        mAugmentedAutofillResolver = new FrameworkResourcesServiceNameResolver(master.getContext(),
                com.android.internal.R.string.config_defaultAugmentedAutofillService);
        mAugmentedAutofillResolver.setOnTemporaryServiceNameChangedCallback(
                (u, s) -> updateRemoteAugmentedAutofillService());

        updateLocked(disabled);
        updateLocked(disabled);
    }
    }


@@ -951,8 +938,7 @@ final class AutofillManagerServiceImpl
                .getString(R.string.config_defaultAutofillService));
                .getString(R.string.config_defaultAutofillService));


        pw.print(prefix); pw.println("mAugmentedAutofillNamer: ");
        pw.print(prefix); pw.println("mAugmentedAutofillNamer: ");
        pw.print(prefix2); mAugmentedAutofillResolver.dumpShort(pw); pw.println();
        pw.print(prefix2); mMaster.mAugmentedAutofillResolver.dumpShort(pw, mUserId); pw.println();
        pw.print(prefix2); mAugmentedAutofillResolver.dumpShort(pw, mUserId); pw.println();


        if (mRemoteAugmentedAutofillService != null) {
        if (mRemoteAugmentedAutofillService != null) {
            pw.print(prefix); pw.println("RemoteAugmentedAutofillService: ");
            pw.print(prefix); pw.println("RemoteAugmentedAutofillService: ");
@@ -1109,7 +1095,7 @@ final class AutofillManagerServiceImpl
    @GuardedBy("mLock")
    @GuardedBy("mLock")
    @Nullable RemoteAugmentedAutofillService getRemoteAugmentedAutofillServiceLocked() {
    @Nullable RemoteAugmentedAutofillService getRemoteAugmentedAutofillServiceLocked() {
        if (mRemoteAugmentedAutofillService == null) {
        if (mRemoteAugmentedAutofillService == null) {
            final String serviceName = mAugmentedAutofillResolver.getServiceName(mUserId);
            final String serviceName = mMaster.mAugmentedAutofillResolver.getServiceName(mUserId);
            if (serviceName == null) {
            if (serviceName == null) {
                if (mMaster.verbose) {
                if (mMaster.verbose) {
                    Slog.v(TAG, "getRemoteAugmentedAutofillServiceLocked(): not set");
                    Slog.v(TAG, "getRemoteAugmentedAutofillServiceLocked(): not set");
@@ -1117,8 +1103,8 @@ final class AutofillManagerServiceImpl
                return null;
                return null;
            }
            }
            final Pair<ServiceInfo, ComponentName> pair = RemoteAugmentedAutofillService
            final Pair<ServiceInfo, ComponentName> pair = RemoteAugmentedAutofillService
                    .getComponentName(
                    .getComponentName(serviceName, mUserId,
                            serviceName, mUserId, mAugmentedAutofillResolver.isTemporary(mUserId));
                            mMaster.mAugmentedAutofillResolver.isTemporary(mUserId));
            if (pair == null) return null;
            if (pair == null) return null;


            mRemoteAugmentedAutofillServiceInfo = pair.first;
            mRemoteAugmentedAutofillServiceInfo = pair.first;
@@ -1148,7 +1134,8 @@ final class AutofillManagerServiceImpl
    }
    }


    /**
    /**
     * Called when the {@link #mAugmentedAutofillResolver} changed (among other places).
     * Called when the {@link AutofillManagerService#mAugmentedAutofillResolver}
     * changed (among other places).
     */
     */
    void updateRemoteAugmentedAutofillService() {
    void updateRemoteAugmentedAutofillService() {
        synchronized (mLock) {
        synchronized (mLock) {