Loading services/autofill/java/com/android/server/autofill/AutofillInlineSessionController.java +7 −2 Original line number Diff line number Diff line Loading @@ -45,6 +45,8 @@ final class AutofillInlineSessionController { private final Object mLock; @NonNull private final Handler mHandler; @NonNull private final InlineFillUi.InlineUiEventCallback mUiCallback; @Nullable @GuardedBy("mLock") Loading @@ -54,12 +56,14 @@ final class AutofillInlineSessionController { private InlineFillUi mInlineFillUi; AutofillInlineSessionController(InputMethodManagerInternal inputMethodManagerInternal, int userId, ComponentName componentName, Handler handler, Object lock) { int userId, ComponentName componentName, Handler handler, Object lock, InlineFillUi.InlineUiEventCallback callback) { mInputMethodManagerInternal = inputMethodManagerInternal; mUserId = userId; mComponentName = componentName; mHandler = handler; mLock = lock; mUiCallback = callback; } Loading @@ -82,7 +86,8 @@ final class AutofillInlineSessionController { // TODO(b/151123764): consider reusing the same AutofillInlineSession object for the // same field. mSession = new AutofillInlineSuggestionsRequestSession(mInputMethodManagerInternal, mUserId, mComponentName, mHandler, mLock, autofillId, requestConsumer, uiExtras); mComponentName, mHandler, mLock, autofillId, requestConsumer, uiExtras, mUiCallback); mSession.onCreateInlineSuggestionsRequestLocked(); } Loading services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java +42 −1 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.os.Handler; import android.os.RemoteException; import android.util.Slog; import android.view.autofill.AutofillId; import android.view.inputmethod.InlineSuggestion; import android.view.inputmethod.InlineSuggestionsRequest; import android.view.inputmethod.InlineSuggestionsResponse; Loading @@ -40,6 +41,7 @@ import com.android.server.autofill.ui.InlineFillUi; import com.android.server.inputmethod.InputMethodManagerInternal; import java.lang.ref.WeakReference; import java.util.List; import java.util.Optional; import java.util.function.Consumer; Loading @@ -65,6 +67,8 @@ final class AutofillInlineSuggestionsRequestSession { private final Handler mHandler; @NonNull private final Bundle mUiExtras; @NonNull private final InlineFillUi.InlineUiEventCallback mUiCallback; @GuardedBy("mLock") @NonNull Loading Loading @@ -97,18 +101,22 @@ final class AutofillInlineSuggestionsRequestSession { @GuardedBy("mLock") private boolean mDestroyed = false; @GuardedBy("mLock") private boolean mPreviousHasNonPinSuggestionShow; AutofillInlineSuggestionsRequestSession( @NonNull InputMethodManagerInternal inputMethodManagerInternal, int userId, @NonNull ComponentName componentName, @NonNull Handler handler, @NonNull Object lock, @NonNull AutofillId autofillId, @NonNull Consumer<InlineSuggestionsRequest> requestConsumer, @NonNull Bundle uiExtras) { @NonNull Consumer<InlineSuggestionsRequest> requestConsumer, @NonNull Bundle uiExtras, @NonNull InlineFillUi.InlineUiEventCallback callback) { mInputMethodManagerInternal = inputMethodManagerInternal; mUserId = userId; mComponentName = componentName; mHandler = handler; mLock = lock; mUiExtras = uiExtras; mUiCallback = callback; mAutofillId = autofillId; mImeRequestConsumer = requestConsumer; Loading Loading @@ -217,6 +225,7 @@ final class AutofillInlineSuggestionsRequestSession { // No-op if both the previous response and current response are empty. return; } maybeNotifyFillUiEventLocked(response.getInlineSuggestions()); updateResponseToImeUncheckLocked(response); mPreviousResponseIsNotEmpty = !isEmptyResponse; } Loading @@ -238,6 +247,38 @@ final class AutofillInlineSuggestionsRequestSession { } } @GuardedBy("mLock") private void maybeNotifyFillUiEventLocked(@NonNull List<InlineSuggestion> suggestions) { if (mDestroyed) { return; } boolean hasSuggestionToShow = false; for (int i = 0; i < suggestions.size(); i++) { InlineSuggestion suggestion = suggestions.get(i); // It is possible we don't have any match result but we still have pinned // suggestions. Only notify we have non-pinned suggestions to show if (!suggestion.getInfo().isPinned()) { hasSuggestionToShow = true; break; } } if (sDebug) { Slog.d(TAG, "maybeNotifyFillUiEventLoked(): hasSuggestionToShow=" + hasSuggestionToShow + ", mPreviousHasNonPinSuggestionShow=" + mPreviousHasNonPinSuggestionShow); } // Use mPreviousHasNonPinSuggestionShow to save previous status, if the display status // change, we can notify the event. if (hasSuggestionToShow && !mPreviousHasNonPinSuggestionShow) { // From no suggestion to has suggestions to show mUiCallback.notifyInlineUiShown(mAutofillId); } else if (!hasSuggestionToShow && mPreviousHasNonPinSuggestionShow) { // From has suggestions to no suggestions to show mUiCallback.notifyInlineUiHidden(mAutofillId); } // Update the latest status mPreviousHasNonPinSuggestionShow = hasSuggestionToShow; } /** * Handles the {@code request} and {@code callback} received from the IME. * Loading services/autofill/java/com/android/server/autofill/Session.java +32 −26 Original line number Diff line number Diff line Loading @@ -843,7 +843,18 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState setClientLocked(client); mInlineSessionController = new AutofillInlineSessionController(inputMethodManagerInternal, userId, componentName, handler, mLock); userId, componentName, handler, mLock, new InlineFillUi.InlineUiEventCallback() { @Override public void notifyInlineUiShown(AutofillId autofillId) { notifyFillUiShown(autofillId); } @Override public void notifyInlineUiHidden(AutofillId autofillId) { notifyFillUiHidden(autofillId); } }); mMetricsLogger.write(newLogMaker(MetricsEvent.AUTOFILL_SESSION_STARTED) .addTaggedData(MetricsEvent.FIELD_AUTOFILL_FLAGS, flags)); Loading Loading @@ -1329,6 +1340,26 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState this, intentSender, intent)); } private void notifyFillUiHidden(@NonNull AutofillId autofillId) { synchronized (mLock) { try { mClient.notifyFillUiHidden(this.id, autofillId); } catch (RemoteException e) { Slog.e(TAG, "Error sending fill UI hidden notification", e); } } } private void notifyFillUiShown(@NonNull AutofillId autofillId) { synchronized (mLock) { try { mClient.notifyFillUiShown(this.id, autofillId); } catch (RemoteException e) { Slog.e(TAG, "Error sending fill UI shown notification", e); } } } private void doStartIntentSender(IntentSender intentSender, Intent intent) { try { synchronized (mLock) { Loading Loading @@ -2769,11 +2800,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState // TODO(b/156099633): remove this once framework gets out of business of resending // inline suggestions when IME visibility changes. mInlineSessionController.hideInlineSuggestionsUiLocked(viewState.id); try { mClient.notifyFillUiHidden(this.id, viewState.id); } catch (RemoteException e) { Slog.e(TAG, "Error requesting to hide fill UI", e); } viewState.resetState(ViewState.STATE_CHANGED); return; } else if ((viewState.id.equals(this.mCurrentViewId)) Loading @@ -2800,11 +2826,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState // TODO: we should be able to replace this with controller#filterInlineFillUiLocked // to accomplish filtering for augmented autofill. mInlineSessionController.hideInlineSuggestionsUiLocked(mCurrentViewId); try { mClient.notifyFillUiHidden(this.id, mCurrentViewId); } catch (RemoteException e) { Slog.e(TAG, "Error sending fill UI hidden notification", e); } } } Loading Loading @@ -2890,11 +2911,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState if (requestShowInlineSuggestionsLocked(response, filterText)) { final ViewState currentView = mViewStates.get(mCurrentViewId); currentView.setState(ViewState.STATE_INLINE_SHOWN); try { mClient.notifyFillUiShown(this.id, mCurrentViewId); } catch (RemoteException e) { Slog.e(TAG, "Error sending fill UI shown notification", e); } //TODO(b/137800469): Fix it to log showed only when IME asks for inflation, // rather than here where framework sends back the response. mService.logDatasetShown(id, mClientState); Loading Loading @@ -2965,11 +2981,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState synchronized (mLock) { mInlineSessionController.hideInlineSuggestionsUiLocked( focusedId); try { mClient.notifyFillUiHidden(this.id, focusedId); } catch (RemoteException e) { Slog.e(TAG, "Error sending fill UI hidden notification", e); } } }, remoteRenderService); return mInlineSessionController.setInlineFillUiLocked(inlineFillUi); Loading Loading @@ -3484,11 +3495,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } if (mCurrentViewId != null) { mInlineSessionController.hideInlineSuggestionsUiLocked(mCurrentViewId); try { mClient.notifyFillUiHidden(this.id, mCurrentViewId); } catch (RemoteException e) { Slog.e(TAG, "Error sending fill UI hidden notification", e); } } autoFillApp(dataset); return; Loading services/autofill/java/com/android/server/autofill/ui/InlineFillUi.java +15 −0 Original line number Diff line number Diff line Loading @@ -297,4 +297,19 @@ public final class InlineFillUi { */ void startIntentSender(@NonNull IntentSender intentSender, @NonNull Intent intent); } /** * Callback for inline suggestion Ui related events. */ public interface InlineUiEventCallback { /** * Callback to notify inline ui is shown. */ void notifyInlineUiShown(@NonNull AutofillId autofillId); /** * Callback to notify inline ui is hidden. */ void notifyInlineUiHidden(@NonNull AutofillId autofillId); } } Loading
services/autofill/java/com/android/server/autofill/AutofillInlineSessionController.java +7 −2 Original line number Diff line number Diff line Loading @@ -45,6 +45,8 @@ final class AutofillInlineSessionController { private final Object mLock; @NonNull private final Handler mHandler; @NonNull private final InlineFillUi.InlineUiEventCallback mUiCallback; @Nullable @GuardedBy("mLock") Loading @@ -54,12 +56,14 @@ final class AutofillInlineSessionController { private InlineFillUi mInlineFillUi; AutofillInlineSessionController(InputMethodManagerInternal inputMethodManagerInternal, int userId, ComponentName componentName, Handler handler, Object lock) { int userId, ComponentName componentName, Handler handler, Object lock, InlineFillUi.InlineUiEventCallback callback) { mInputMethodManagerInternal = inputMethodManagerInternal; mUserId = userId; mComponentName = componentName; mHandler = handler; mLock = lock; mUiCallback = callback; } Loading @@ -82,7 +86,8 @@ final class AutofillInlineSessionController { // TODO(b/151123764): consider reusing the same AutofillInlineSession object for the // same field. mSession = new AutofillInlineSuggestionsRequestSession(mInputMethodManagerInternal, mUserId, mComponentName, mHandler, mLock, autofillId, requestConsumer, uiExtras); mComponentName, mHandler, mLock, autofillId, requestConsumer, uiExtras, mUiCallback); mSession.onCreateInlineSuggestionsRequestLocked(); } Loading
services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java +42 −1 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.os.Handler; import android.os.RemoteException; import android.util.Slog; import android.view.autofill.AutofillId; import android.view.inputmethod.InlineSuggestion; import android.view.inputmethod.InlineSuggestionsRequest; import android.view.inputmethod.InlineSuggestionsResponse; Loading @@ -40,6 +41,7 @@ import com.android.server.autofill.ui.InlineFillUi; import com.android.server.inputmethod.InputMethodManagerInternal; import java.lang.ref.WeakReference; import java.util.List; import java.util.Optional; import java.util.function.Consumer; Loading @@ -65,6 +67,8 @@ final class AutofillInlineSuggestionsRequestSession { private final Handler mHandler; @NonNull private final Bundle mUiExtras; @NonNull private final InlineFillUi.InlineUiEventCallback mUiCallback; @GuardedBy("mLock") @NonNull Loading Loading @@ -97,18 +101,22 @@ final class AutofillInlineSuggestionsRequestSession { @GuardedBy("mLock") private boolean mDestroyed = false; @GuardedBy("mLock") private boolean mPreviousHasNonPinSuggestionShow; AutofillInlineSuggestionsRequestSession( @NonNull InputMethodManagerInternal inputMethodManagerInternal, int userId, @NonNull ComponentName componentName, @NonNull Handler handler, @NonNull Object lock, @NonNull AutofillId autofillId, @NonNull Consumer<InlineSuggestionsRequest> requestConsumer, @NonNull Bundle uiExtras) { @NonNull Consumer<InlineSuggestionsRequest> requestConsumer, @NonNull Bundle uiExtras, @NonNull InlineFillUi.InlineUiEventCallback callback) { mInputMethodManagerInternal = inputMethodManagerInternal; mUserId = userId; mComponentName = componentName; mHandler = handler; mLock = lock; mUiExtras = uiExtras; mUiCallback = callback; mAutofillId = autofillId; mImeRequestConsumer = requestConsumer; Loading Loading @@ -217,6 +225,7 @@ final class AutofillInlineSuggestionsRequestSession { // No-op if both the previous response and current response are empty. return; } maybeNotifyFillUiEventLocked(response.getInlineSuggestions()); updateResponseToImeUncheckLocked(response); mPreviousResponseIsNotEmpty = !isEmptyResponse; } Loading @@ -238,6 +247,38 @@ final class AutofillInlineSuggestionsRequestSession { } } @GuardedBy("mLock") private void maybeNotifyFillUiEventLocked(@NonNull List<InlineSuggestion> suggestions) { if (mDestroyed) { return; } boolean hasSuggestionToShow = false; for (int i = 0; i < suggestions.size(); i++) { InlineSuggestion suggestion = suggestions.get(i); // It is possible we don't have any match result but we still have pinned // suggestions. Only notify we have non-pinned suggestions to show if (!suggestion.getInfo().isPinned()) { hasSuggestionToShow = true; break; } } if (sDebug) { Slog.d(TAG, "maybeNotifyFillUiEventLoked(): hasSuggestionToShow=" + hasSuggestionToShow + ", mPreviousHasNonPinSuggestionShow=" + mPreviousHasNonPinSuggestionShow); } // Use mPreviousHasNonPinSuggestionShow to save previous status, if the display status // change, we can notify the event. if (hasSuggestionToShow && !mPreviousHasNonPinSuggestionShow) { // From no suggestion to has suggestions to show mUiCallback.notifyInlineUiShown(mAutofillId); } else if (!hasSuggestionToShow && mPreviousHasNonPinSuggestionShow) { // From has suggestions to no suggestions to show mUiCallback.notifyInlineUiHidden(mAutofillId); } // Update the latest status mPreviousHasNonPinSuggestionShow = hasSuggestionToShow; } /** * Handles the {@code request} and {@code callback} received from the IME. * Loading
services/autofill/java/com/android/server/autofill/Session.java +32 −26 Original line number Diff line number Diff line Loading @@ -843,7 +843,18 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState setClientLocked(client); mInlineSessionController = new AutofillInlineSessionController(inputMethodManagerInternal, userId, componentName, handler, mLock); userId, componentName, handler, mLock, new InlineFillUi.InlineUiEventCallback() { @Override public void notifyInlineUiShown(AutofillId autofillId) { notifyFillUiShown(autofillId); } @Override public void notifyInlineUiHidden(AutofillId autofillId) { notifyFillUiHidden(autofillId); } }); mMetricsLogger.write(newLogMaker(MetricsEvent.AUTOFILL_SESSION_STARTED) .addTaggedData(MetricsEvent.FIELD_AUTOFILL_FLAGS, flags)); Loading Loading @@ -1329,6 +1340,26 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState this, intentSender, intent)); } private void notifyFillUiHidden(@NonNull AutofillId autofillId) { synchronized (mLock) { try { mClient.notifyFillUiHidden(this.id, autofillId); } catch (RemoteException e) { Slog.e(TAG, "Error sending fill UI hidden notification", e); } } } private void notifyFillUiShown(@NonNull AutofillId autofillId) { synchronized (mLock) { try { mClient.notifyFillUiShown(this.id, autofillId); } catch (RemoteException e) { Slog.e(TAG, "Error sending fill UI shown notification", e); } } } private void doStartIntentSender(IntentSender intentSender, Intent intent) { try { synchronized (mLock) { Loading Loading @@ -2769,11 +2800,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState // TODO(b/156099633): remove this once framework gets out of business of resending // inline suggestions when IME visibility changes. mInlineSessionController.hideInlineSuggestionsUiLocked(viewState.id); try { mClient.notifyFillUiHidden(this.id, viewState.id); } catch (RemoteException e) { Slog.e(TAG, "Error requesting to hide fill UI", e); } viewState.resetState(ViewState.STATE_CHANGED); return; } else if ((viewState.id.equals(this.mCurrentViewId)) Loading @@ -2800,11 +2826,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState // TODO: we should be able to replace this with controller#filterInlineFillUiLocked // to accomplish filtering for augmented autofill. mInlineSessionController.hideInlineSuggestionsUiLocked(mCurrentViewId); try { mClient.notifyFillUiHidden(this.id, mCurrentViewId); } catch (RemoteException e) { Slog.e(TAG, "Error sending fill UI hidden notification", e); } } } Loading Loading @@ -2890,11 +2911,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState if (requestShowInlineSuggestionsLocked(response, filterText)) { final ViewState currentView = mViewStates.get(mCurrentViewId); currentView.setState(ViewState.STATE_INLINE_SHOWN); try { mClient.notifyFillUiShown(this.id, mCurrentViewId); } catch (RemoteException e) { Slog.e(TAG, "Error sending fill UI shown notification", e); } //TODO(b/137800469): Fix it to log showed only when IME asks for inflation, // rather than here where framework sends back the response. mService.logDatasetShown(id, mClientState); Loading Loading @@ -2965,11 +2981,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState synchronized (mLock) { mInlineSessionController.hideInlineSuggestionsUiLocked( focusedId); try { mClient.notifyFillUiHidden(this.id, focusedId); } catch (RemoteException e) { Slog.e(TAG, "Error sending fill UI hidden notification", e); } } }, remoteRenderService); return mInlineSessionController.setInlineFillUiLocked(inlineFillUi); Loading Loading @@ -3484,11 +3495,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } if (mCurrentViewId != null) { mInlineSessionController.hideInlineSuggestionsUiLocked(mCurrentViewId); try { mClient.notifyFillUiHidden(this.id, mCurrentViewId); } catch (RemoteException e) { Slog.e(TAG, "Error sending fill UI hidden notification", e); } } autoFillApp(dataset); return; Loading
services/autofill/java/com/android/server/autofill/ui/InlineFillUi.java +15 −0 Original line number Diff line number Diff line Loading @@ -297,4 +297,19 @@ public final class InlineFillUi { */ void startIntentSender(@NonNull IntentSender intentSender, @NonNull Intent intent); } /** * Callback for inline suggestion Ui related events. */ public interface InlineUiEventCallback { /** * Callback to notify inline ui is shown. */ void notifyInlineUiShown(@NonNull AutofillId autofillId); /** * Callback to notify inline ui is hidden. */ void notifyInlineUiHidden(@NonNull AutofillId autofillId); } }