Loading core/java/android/service/autofill/IInlineSuggestionRenderService.aidl +7 −1 Original line number Diff line number Diff line Loading @@ -29,6 +29,12 @@ import android.service.autofill.InlinePresentation; oneway interface IInlineSuggestionRenderService { void renderSuggestion(in IInlineSuggestionUiCallback callback, in InlinePresentation presentation, int width, int height, in IBinder hostInputToken, int displayId); in IBinder hostInputToken, int displayId, int userId, int sessionId); void getInlineSuggestionsRendererInfo(in RemoteCallback callback); /** * Releases the inline suggestion SurfaceControlViewHosts hosted in the service, for the * provided userId and sessionId. */ void destroySuggestionViews(int userId, int sessionId); } core/java/android/service/autofill/InlineSuggestionRenderService.java +43 −6 Original line number Diff line number Diff line Loading @@ -41,6 +41,8 @@ import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import java.io.FileDescriptor; import java.io.PrintWriter; import java.lang.ref.WeakReference; /** Loading Loading @@ -82,7 +84,7 @@ public abstract class InlineSuggestionRenderService extends Service { Boolean newValue) { if (evicted) { Log.w(TAG, "Hit max=100 entries in the cache. Releasing oldest one to make " "Hit max=30 entries in the cache. Releasing oldest one to make " + "space."); key.releaseSurfaceControlViewHost(); } Loading Loading @@ -130,7 +132,7 @@ public abstract class InlineSuggestionRenderService extends Service { private void handleRenderSuggestion(IInlineSuggestionUiCallback callback, InlinePresentation presentation, int width, int height, IBinder hostInputToken, int displayId) { int displayId, int userId, int sessionId) { if (hostInputToken == null) { try { callback.onError(); Loading Loading @@ -192,7 +194,8 @@ public abstract class InlineSuggestionRenderService extends Service { } return true; }); final InlineSuggestionUiImpl uiImpl = new InlineSuggestionUiImpl(host, mMainHandler); final InlineSuggestionUiImpl uiImpl = new InlineSuggestionUiImpl(host, mMainHandler, userId, sessionId); mActiveInlineSuggestions.put(uiImpl, true); // We post the callback invocation to the end of the main thread handler queue, to make Loading @@ -218,6 +221,18 @@ public abstract class InlineSuggestionRenderService extends Service { callback.sendResult(rendererInfo); } private void handleDestroySuggestionViews(int userId, int sessionId) { Log.v(TAG, "handleDestroySuggestionViews called for " + userId + ":" + sessionId); for (final InlineSuggestionUiImpl inlineSuggestionUi : mActiveInlineSuggestions.snapshot().keySet()) { if (inlineSuggestionUi.mUserId == userId && inlineSuggestionUi.mSessionId == sessionId) { Log.v(TAG, "Destroy " + inlineSuggestionUi); inlineSuggestionUi.releaseSurfaceControlViewHost(); } } } /** * A wrapper class around the {@link InlineSuggestionUiImpl} to ensure it's not strongly * reference by the remote system server process. Loading Loading @@ -260,10 +275,15 @@ public abstract class InlineSuggestionRenderService extends Service { private SurfaceControlViewHost mViewHost; @NonNull private final Handler mHandler; private final int mUserId; private final int mSessionId; InlineSuggestionUiImpl(SurfaceControlViewHost viewHost, Handler handler) { InlineSuggestionUiImpl(SurfaceControlViewHost viewHost, Handler handler, int userId, int sessionId) { this.mViewHost = viewHost; this.mHandler = handler; this.mUserId = userId; this.mSessionId = sessionId; } /** Loading Loading @@ -302,6 +322,16 @@ public abstract class InlineSuggestionRenderService extends Service { } } /** @hide */ @Override protected final void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) { pw.println("mActiveInlineSuggestions: " + mActiveInlineSuggestions.size()); for (InlineSuggestionUiImpl impl : mActiveInlineSuggestions.snapshot().keySet()) { pw.printf("ui: [%s] - [%d] [%d]\n", impl, impl.mUserId, impl.mSessionId); } } @Override @Nullable public final IBinder onBind(@NonNull Intent intent) { Loading @@ -311,11 +341,12 @@ public abstract class InlineSuggestionRenderService extends Service { @Override public void renderSuggestion(@NonNull IInlineSuggestionUiCallback callback, @NonNull InlinePresentation presentation, int width, int height, @Nullable IBinder hostInputToken, int displayId) { @Nullable IBinder hostInputToken, int displayId, int userId, int sessionId) { mMainHandler.sendMessage( obtainMessage(InlineSuggestionRenderService::handleRenderSuggestion, InlineSuggestionRenderService.this, callback, presentation, width, height, hostInputToken, displayId)); width, height, hostInputToken, displayId, userId, sessionId)); } @Override Loading @@ -324,6 +355,12 @@ public abstract class InlineSuggestionRenderService extends Service { InlineSuggestionRenderService::handleGetInlineSuggestionsRendererInfo, InlineSuggestionRenderService.this, callback)); } @Override public void destroySuggestionViews(int userId, int sessionId) { mMainHandler.sendMessage(obtainMessage( InlineSuggestionRenderService::handleDestroySuggestionViews, InlineSuggestionRenderService.this, userId, sessionId)); } }.asBinder(); } Loading services/autofill/java/com/android/server/autofill/RemoteAugmentedAutofillService.java +5 −4 Original line number Diff line number Diff line Loading @@ -149,7 +149,7 @@ final class RemoteAugmentedAutofillService @Nullable InlineSuggestionsRequest inlineSuggestionsRequest, @Nullable Function<InlineFillUi, Boolean> inlineSuggestionsCallback, @NonNull Runnable onErrorCallback, @Nullable RemoteInlineSuggestionRenderService remoteRenderService) { @Nullable RemoteInlineSuggestionRenderService remoteRenderService, int userId) { long requestTime = SystemClock.elapsedRealtime(); AtomicReference<ICancellationSignal> cancellationRef = new AtomicReference<>(); Loading @@ -173,7 +173,7 @@ final class RemoteAugmentedAutofillService inlineSuggestionsRequest, inlineSuggestionsData, clientState, focusedId, focusedValue, inlineSuggestionsCallback, client, onErrorCallback, remoteRenderService); client, onErrorCallback, remoteRenderService, userId); if (!showingFillWindow) { requestAutofill.complete(null); } Loading Loading @@ -243,7 +243,8 @@ final class RemoteAugmentedAutofillService @NonNull AutofillId focusedId, @Nullable AutofillValue focusedValue, @Nullable Function<InlineFillUi, Boolean> inlineSuggestionsCallback, @NonNull IAutoFillManagerClient client, @NonNull Runnable onErrorCallback, @Nullable RemoteInlineSuggestionRenderService remoteRenderService) { @Nullable RemoteInlineSuggestionRenderService remoteRenderService, int userId) { if (inlineSuggestionsData == null || inlineSuggestionsData.isEmpty() || inlineSuggestionsCallback == null || request == null || remoteRenderService == null) { Loading Loading @@ -312,7 +313,7 @@ final class RemoteAugmentedAutofillService Slog.w(TAG, "RemoteException starting intent sender"); } } }, onErrorCallback, remoteRenderService); }, onErrorCallback, remoteRenderService, userId, sessionId); if (inlineSuggestionsCallback.apply(inlineFillUi)) { mCallbacks.logAugmentedAutofillShown(sessionId, clientState); Loading services/autofill/java/com/android/server/autofill/RemoteInlineSuggestionRenderService.java +9 −2 Original line number Diff line number Diff line Loading @@ -88,9 +88,9 @@ public final class RemoteInlineSuggestionRenderService extends */ public void renderSuggestion(@NonNull IInlineSuggestionUiCallback callback, @NonNull InlinePresentation presentation, int width, int height, @Nullable IBinder hostInputToken, int displayId) { @Nullable IBinder hostInputToken, int displayId, int userId, int sessionId) { scheduleAsyncRequest((s) -> s.renderSuggestion(callback, presentation, width, height, hostInputToken, displayId)); hostInputToken, displayId, userId, sessionId)); } /** Loading @@ -100,6 +100,13 @@ public final class RemoteInlineSuggestionRenderService extends scheduleAsyncRequest((s) -> s.getInlineSuggestionsRendererInfo(callback)); } /** * Destroys the remote inline suggestion views associated with the given user id and session id. */ public void destroySuggestionViews(int userId, int sessionId) { scheduleAsyncRequest((s) -> s.destroySuggestionViews(userId, sessionId)); } @Nullable private static ServiceInfo getServiceInfo(Context context, int userId) { final String packageName = Loading services/autofill/java/com/android/server/autofill/Session.java +12 −2 Original line number Diff line number Diff line Loading @@ -155,6 +155,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState */ public final int id; /** userId the session belongs to */ public final int userId; /** uid the session is for */ public final int uid; Loading Loading @@ -823,6 +826,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } id = sessionId; mFlags = flags; this.userId = userId; this.taskId = taskId; this.uid = uid; mStartTime = SystemClock.elapsedRealtime(); Loading Loading @@ -2986,7 +2990,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState mInlineSessionController.setInlineFillUiLocked( InlineFillUi.emptyUi(focusedId)); } }, remoteRenderService); }, remoteRenderService, userId, id); return mInlineSessionController.setInlineFillUiLocked(inlineFillUi); } Loading Loading @@ -3296,7 +3300,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState mInlineSessionController.setInlineFillUiLocked( InlineFillUi.emptyUi(mCurrentViewId)); } }, mService.getRemoteInlineSuggestionRenderServiceLocked()); }, mService.getRemoteInlineSuggestionRenderServiceLocked(), userId); } }; Loading Loading @@ -3796,6 +3800,12 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState if (mCurrentViewId != null) { mInlineSessionController.destroyLocked(mCurrentViewId); } final RemoteInlineSuggestionRenderService remoteRenderService = mService.getRemoteInlineSuggestionRenderServiceLocked(); if (remoteRenderService != null) { remoteRenderService.destroySuggestionViews(userId, id); } mDestroyed = true; // Log metrics Loading Loading
core/java/android/service/autofill/IInlineSuggestionRenderService.aidl +7 −1 Original line number Diff line number Diff line Loading @@ -29,6 +29,12 @@ import android.service.autofill.InlinePresentation; oneway interface IInlineSuggestionRenderService { void renderSuggestion(in IInlineSuggestionUiCallback callback, in InlinePresentation presentation, int width, int height, in IBinder hostInputToken, int displayId); in IBinder hostInputToken, int displayId, int userId, int sessionId); void getInlineSuggestionsRendererInfo(in RemoteCallback callback); /** * Releases the inline suggestion SurfaceControlViewHosts hosted in the service, for the * provided userId and sessionId. */ void destroySuggestionViews(int userId, int sessionId); }
core/java/android/service/autofill/InlineSuggestionRenderService.java +43 −6 Original line number Diff line number Diff line Loading @@ -41,6 +41,8 @@ import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import java.io.FileDescriptor; import java.io.PrintWriter; import java.lang.ref.WeakReference; /** Loading Loading @@ -82,7 +84,7 @@ public abstract class InlineSuggestionRenderService extends Service { Boolean newValue) { if (evicted) { Log.w(TAG, "Hit max=100 entries in the cache. Releasing oldest one to make " "Hit max=30 entries in the cache. Releasing oldest one to make " + "space."); key.releaseSurfaceControlViewHost(); } Loading Loading @@ -130,7 +132,7 @@ public abstract class InlineSuggestionRenderService extends Service { private void handleRenderSuggestion(IInlineSuggestionUiCallback callback, InlinePresentation presentation, int width, int height, IBinder hostInputToken, int displayId) { int displayId, int userId, int sessionId) { if (hostInputToken == null) { try { callback.onError(); Loading Loading @@ -192,7 +194,8 @@ public abstract class InlineSuggestionRenderService extends Service { } return true; }); final InlineSuggestionUiImpl uiImpl = new InlineSuggestionUiImpl(host, mMainHandler); final InlineSuggestionUiImpl uiImpl = new InlineSuggestionUiImpl(host, mMainHandler, userId, sessionId); mActiveInlineSuggestions.put(uiImpl, true); // We post the callback invocation to the end of the main thread handler queue, to make Loading @@ -218,6 +221,18 @@ public abstract class InlineSuggestionRenderService extends Service { callback.sendResult(rendererInfo); } private void handleDestroySuggestionViews(int userId, int sessionId) { Log.v(TAG, "handleDestroySuggestionViews called for " + userId + ":" + sessionId); for (final InlineSuggestionUiImpl inlineSuggestionUi : mActiveInlineSuggestions.snapshot().keySet()) { if (inlineSuggestionUi.mUserId == userId && inlineSuggestionUi.mSessionId == sessionId) { Log.v(TAG, "Destroy " + inlineSuggestionUi); inlineSuggestionUi.releaseSurfaceControlViewHost(); } } } /** * A wrapper class around the {@link InlineSuggestionUiImpl} to ensure it's not strongly * reference by the remote system server process. Loading Loading @@ -260,10 +275,15 @@ public abstract class InlineSuggestionRenderService extends Service { private SurfaceControlViewHost mViewHost; @NonNull private final Handler mHandler; private final int mUserId; private final int mSessionId; InlineSuggestionUiImpl(SurfaceControlViewHost viewHost, Handler handler) { InlineSuggestionUiImpl(SurfaceControlViewHost viewHost, Handler handler, int userId, int sessionId) { this.mViewHost = viewHost; this.mHandler = handler; this.mUserId = userId; this.mSessionId = sessionId; } /** Loading Loading @@ -302,6 +322,16 @@ public abstract class InlineSuggestionRenderService extends Service { } } /** @hide */ @Override protected final void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) { pw.println("mActiveInlineSuggestions: " + mActiveInlineSuggestions.size()); for (InlineSuggestionUiImpl impl : mActiveInlineSuggestions.snapshot().keySet()) { pw.printf("ui: [%s] - [%d] [%d]\n", impl, impl.mUserId, impl.mSessionId); } } @Override @Nullable public final IBinder onBind(@NonNull Intent intent) { Loading @@ -311,11 +341,12 @@ public abstract class InlineSuggestionRenderService extends Service { @Override public void renderSuggestion(@NonNull IInlineSuggestionUiCallback callback, @NonNull InlinePresentation presentation, int width, int height, @Nullable IBinder hostInputToken, int displayId) { @Nullable IBinder hostInputToken, int displayId, int userId, int sessionId) { mMainHandler.sendMessage( obtainMessage(InlineSuggestionRenderService::handleRenderSuggestion, InlineSuggestionRenderService.this, callback, presentation, width, height, hostInputToken, displayId)); width, height, hostInputToken, displayId, userId, sessionId)); } @Override Loading @@ -324,6 +355,12 @@ public abstract class InlineSuggestionRenderService extends Service { InlineSuggestionRenderService::handleGetInlineSuggestionsRendererInfo, InlineSuggestionRenderService.this, callback)); } @Override public void destroySuggestionViews(int userId, int sessionId) { mMainHandler.sendMessage(obtainMessage( InlineSuggestionRenderService::handleDestroySuggestionViews, InlineSuggestionRenderService.this, userId, sessionId)); } }.asBinder(); } Loading
services/autofill/java/com/android/server/autofill/RemoteAugmentedAutofillService.java +5 −4 Original line number Diff line number Diff line Loading @@ -149,7 +149,7 @@ final class RemoteAugmentedAutofillService @Nullable InlineSuggestionsRequest inlineSuggestionsRequest, @Nullable Function<InlineFillUi, Boolean> inlineSuggestionsCallback, @NonNull Runnable onErrorCallback, @Nullable RemoteInlineSuggestionRenderService remoteRenderService) { @Nullable RemoteInlineSuggestionRenderService remoteRenderService, int userId) { long requestTime = SystemClock.elapsedRealtime(); AtomicReference<ICancellationSignal> cancellationRef = new AtomicReference<>(); Loading @@ -173,7 +173,7 @@ final class RemoteAugmentedAutofillService inlineSuggestionsRequest, inlineSuggestionsData, clientState, focusedId, focusedValue, inlineSuggestionsCallback, client, onErrorCallback, remoteRenderService); client, onErrorCallback, remoteRenderService, userId); if (!showingFillWindow) { requestAutofill.complete(null); } Loading Loading @@ -243,7 +243,8 @@ final class RemoteAugmentedAutofillService @NonNull AutofillId focusedId, @Nullable AutofillValue focusedValue, @Nullable Function<InlineFillUi, Boolean> inlineSuggestionsCallback, @NonNull IAutoFillManagerClient client, @NonNull Runnable onErrorCallback, @Nullable RemoteInlineSuggestionRenderService remoteRenderService) { @Nullable RemoteInlineSuggestionRenderService remoteRenderService, int userId) { if (inlineSuggestionsData == null || inlineSuggestionsData.isEmpty() || inlineSuggestionsCallback == null || request == null || remoteRenderService == null) { Loading Loading @@ -312,7 +313,7 @@ final class RemoteAugmentedAutofillService Slog.w(TAG, "RemoteException starting intent sender"); } } }, onErrorCallback, remoteRenderService); }, onErrorCallback, remoteRenderService, userId, sessionId); if (inlineSuggestionsCallback.apply(inlineFillUi)) { mCallbacks.logAugmentedAutofillShown(sessionId, clientState); Loading
services/autofill/java/com/android/server/autofill/RemoteInlineSuggestionRenderService.java +9 −2 Original line number Diff line number Diff line Loading @@ -88,9 +88,9 @@ public final class RemoteInlineSuggestionRenderService extends */ public void renderSuggestion(@NonNull IInlineSuggestionUiCallback callback, @NonNull InlinePresentation presentation, int width, int height, @Nullable IBinder hostInputToken, int displayId) { @Nullable IBinder hostInputToken, int displayId, int userId, int sessionId) { scheduleAsyncRequest((s) -> s.renderSuggestion(callback, presentation, width, height, hostInputToken, displayId)); hostInputToken, displayId, userId, sessionId)); } /** Loading @@ -100,6 +100,13 @@ public final class RemoteInlineSuggestionRenderService extends scheduleAsyncRequest((s) -> s.getInlineSuggestionsRendererInfo(callback)); } /** * Destroys the remote inline suggestion views associated with the given user id and session id. */ public void destroySuggestionViews(int userId, int sessionId) { scheduleAsyncRequest((s) -> s.destroySuggestionViews(userId, sessionId)); } @Nullable private static ServiceInfo getServiceInfo(Context context, int userId) { final String packageName = Loading
services/autofill/java/com/android/server/autofill/Session.java +12 −2 Original line number Diff line number Diff line Loading @@ -155,6 +155,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState */ public final int id; /** userId the session belongs to */ public final int userId; /** uid the session is for */ public final int uid; Loading Loading @@ -823,6 +826,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } id = sessionId; mFlags = flags; this.userId = userId; this.taskId = taskId; this.uid = uid; mStartTime = SystemClock.elapsedRealtime(); Loading Loading @@ -2986,7 +2990,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState mInlineSessionController.setInlineFillUiLocked( InlineFillUi.emptyUi(focusedId)); } }, remoteRenderService); }, remoteRenderService, userId, id); return mInlineSessionController.setInlineFillUiLocked(inlineFillUi); } Loading Loading @@ -3296,7 +3300,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState mInlineSessionController.setInlineFillUiLocked( InlineFillUi.emptyUi(mCurrentViewId)); } }, mService.getRemoteInlineSuggestionRenderServiceLocked()); }, mService.getRemoteInlineSuggestionRenderServiceLocked(), userId); } }; Loading Loading @@ -3796,6 +3800,12 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState if (mCurrentViewId != null) { mInlineSessionController.destroyLocked(mCurrentViewId); } final RemoteInlineSuggestionRenderService remoteRenderService = mService.getRemoteInlineSuggestionRenderServiceLocked(); if (remoteRenderService != null) { remoteRenderService.destroySuggestionViews(userId, id); } mDestroyed = true; // Log metrics Loading