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

Commit c3bbed68 authored by Simranjit Kohli's avatar Simranjit Kohli
Browse files

[Fill Dialog Improvements] Using Ime animation updats

Route animation updates from AutofillManagerService to Session.
The rest of the logic is already implemented.

Bug: 390528373
Flag: android.service.autofill.improve_fill_dialog_aconfig
Test: atest CtsAutoFillServiceTestCases
Change-Id: I3c17d476af5bd89817e85b95fafbcaaaa06ce7cb
parent 183c8252
Loading
Loading
Loading
Loading
+53 −10
Original line number Diff line number Diff line
@@ -246,6 +246,8 @@ public final class AutofillManagerService

    private static final boolean DEFAULT_PCC_USE_FALLBACK = true;

    private static final boolean DBG = false;

    public AutofillManagerService(Context context) {
        super(context,
                new SecureSettingsServiceNameResolver(context, Settings.Secure.AUTOFILL_SERVICE),
@@ -313,21 +315,59 @@ public final class AutofillManagerService
                    new WindowManagerInternal.ImeInsetsAnimationChangeListener() {
                        @Override
                        public void onAnimationStart(
                                @InsetsController.AnimationType int animationType,
                                int userId) {
                            // TODO: Add logic
                            if (sVerbose) {
                                Slog.e(TAG, "onAnimationStart()");
                                @InsetsController.AnimationType int animationType, int userId) {
                            if (DBG) {
                                Slog.e(TAG,
                                        "onAnimationStart() notifyImeAnimationStart() "
                                                + "animationType:"
                                                + String.valueOf(animationType));
                            }
                            synchronized (mLock) {

                                // We are mostly interested in animations that show up the IME
                                if (animationType == InsetsController.ANIMATION_TYPE_HIDE) {
                                    // IME is going away
                                    mIsImeShowing = false;
                                }
                                if (animationType != InsetsController.ANIMATION_TYPE_SHOW) {
                                    return;
                                }
                                mIsImeShowing = true;
                                mImeAnimatingWhileShowingUp = true;
                                final AutofillManagerServiceImpl service =
                                        peekServiceForUserWithLocalBinderIdentityLocked(userId);
                                if (service != null) {
                                    service.notifyImeAnimationStart();
                                } else if (sVerbose) {
                                    Slog.v(TAG,
                                            "notifyImeAnimationStart(): no service for " + userId);
                                }
                            }
                        }

                        @Override
                        public void onAnimationEnd(
                                @InsetsController.AnimationType int animationType,
                                int userId) {
                            // TODO: Add logic
                            if (sVerbose) {
                                Slog.e(TAG, "onAnimationEnd()");
                                @InsetsController.AnimationType int animationType, int userId) {
                            if (DBG) {
                                Slog.e(TAG,
                                        "onAnimationEnd() notifyImeAnimationEnd() "
                                                + "animationType:"
                                                + String.valueOf(animationType));
                            }
                            // We are only interested in animations that show up the IME
                            if (animationType != InsetsController.ANIMATION_TYPE_SHOW) {
                                return;
                            }
                            mImeAnimatingWhileShowingUp = false;
                            synchronized (mLock) {
                                final AutofillManagerServiceImpl service =
                                        peekServiceForUserWithLocalBinderIdentityLocked(userId);
                                if (service != null) {
                                    service.notifyImeAnimationEnd();
                                } else if (sVerbose) {
                                    Slog.v(TAG, "notifyImeAnimationEnd(): no service for "
                                            + userId);
                                }
                            }
                        }
                    };
@@ -336,6 +376,9 @@ public final class AutofillManagerService
        }
    }

    public boolean mImeAnimatingWhileShowingUp = false;
    public boolean mIsImeShowing = false;

    @Override // from AbstractMasterSystemService
    protected String getServiceSettingsProperty() {
        return Settings.Secure.AUTOFILL_SERVICE;
+44 −1
Original line number Diff line number Diff line
@@ -208,6 +208,11 @@ final class AutofillManagerServiceImpl

    private final DisabledInfoCache mDisabledInfoCache;

    // Tracks active session id. There is no guarantee that such a session exists. For eg, if the
    // session is destroyed, the id may no longer be valid. We don't update the state in all the
    // cases.
    private int mActiveSessionId = NO_SESSION;

    AutofillManagerServiceImpl(AutofillManagerService master, Object lock,
            LocalLog uiLatencyHistory, LocalLog wtfHistory, int userId, AutoFillUI ui,
            AutofillCompatState autofillCompatState,
@@ -386,6 +391,7 @@ final class AutofillManagerServiceImpl
            @NonNull Rect virtualBounds, @Nullable AutofillValue value, boolean hasCallback,
            @NonNull ComponentName clientActivity, boolean compatMode,
            boolean bindInstantServiceAllowed, int flags) {
        mActiveSessionId = NO_SESSION;
        // FLAG_AUGMENTED_AUTOFILL_REQUEST is set in the flags when standard autofill is disabled
        // but the package is allowlisted for augmented autofill
        boolean forAugmentedAutofillOnly = (flags
@@ -444,6 +450,7 @@ final class AutofillManagerServiceImpl
        if (newSession == null) {
            return NO_SESSION;
        }
        mActiveSessionId = newSession.id;

        // Service can be null when it's only for augmented autofill
        String servicePackageName = mInfo == null ? null : mInfo.getServiceInfo().packageName;
@@ -747,6 +754,7 @@ final class AutofillManagerServiceImpl
                    Slog.d(TAG, "restarting session " + sessionId + " due to manual request on "
                            + autofillId);
                }
                mActiveSessionId = sessionId;
                return true;
            }
            if (sVerbose) {
@@ -756,6 +764,8 @@ final class AutofillManagerServiceImpl
            return false;
        }


        mActiveSessionId = sessionId;
        session.updateLocked(autofillId, virtualBounds, value, action, flags);
        return false;
    }
@@ -873,6 +883,20 @@ final class AutofillManagerServiceImpl
        session.notifyImeAnimationStart(startTimeMs);
    }

    @GuardedBy("mLock")
    public void notifyImeAnimationStart() {
        if (!isEnabledLocked()) {
            Slog.wtf(TAG, "Service not enabled");
            return;
        }
        final Session session = mSessions.get(mActiveSessionId);
        if (session == null) {
            Slog.v(TAG, "notifyImeAnimationEnd(): no session for " + mActiveSessionId);
            return;
        }
        session.notifyImeAnimationStart(SystemClock.elapsedRealtime());
    }

    @GuardedBy("mLock")
    public void notifyImeAnimationEnd(int sessionId, long endTimeMs, int uid) {
        if (!isEnabledLocked()) {
@@ -880,14 +904,33 @@ final class AutofillManagerServiceImpl
            return;
        }
        final Session session = mSessions.get(sessionId);
        if (session == null || uid != session.uid) {
        if (session == null) {
            Slog.v(TAG, "notifyImeAnimationEnd(): no session for "
                    + sessionId + "(" + uid + ")");
            return;
        }
        if (uid != session.uid) {
            Slog.v(TAG, "notifyImeAnimationEnd(): Mismatched session id's "
                    + sessionId + "(" + uid + ")");
            return;
        }
        session.notifyImeAnimationEnd(endTimeMs);
    }

    @GuardedBy("mLock")
    public void notifyImeAnimationEnd() {
        if (!isEnabledLocked()) {
            Slog.wtf(TAG, "Service not enabled");
            return;
        }
        final Session session = mSessions.get(mActiveSessionId);
        if (session == null) {
            Slog.v(TAG, "notifyImeAnimationEnd(): no session for " + mActiveSessionId);
            return;
        }
        session.notifyImeAnimationEnd(SystemClock.elapsedRealtime());
    }

    @GuardedBy("mLock")
    @Override // from PerUserSystemService
    protected void handlePackageUpdateLocked(@NonNull String packageName) {