summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-06-24 05:31:34 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-06-24 05:31:34 +0000
commit6e3a4d76256f1cd0192bb5025f40d33b6a54c9da (patch)
tree0ce719583188faa1967db494d8defd7220b741df /core/java
parentcf084d5a4aedad8b7fee453d8d961ecf52ab01da (diff)
parent17ca1ee84e6740e003dbfbd0ebb21cc2d2579a7d (diff)
Merge "Release remove inline suggestion views when session destroyed" into rvc-dev
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/service/autofill/IInlineSuggestionRenderService.aidl8
-rw-r--r--core/java/android/service/autofill/InlineSuggestionRenderService.java49
2 files changed, 50 insertions, 7 deletions
diff --git a/core/java/android/service/autofill/IInlineSuggestionRenderService.aidl b/core/java/android/service/autofill/IInlineSuggestionRenderService.aidl
index bf0bb9e2a41f..7cd372fe97d8 100644
--- a/core/java/android/service/autofill/IInlineSuggestionRenderService.aidl
+++ b/core/java/android/service/autofill/IInlineSuggestionRenderService.aidl
@@ -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);
}
diff --git a/core/java/android/service/autofill/InlineSuggestionRenderService.java b/core/java/android/service/autofill/InlineSuggestionRenderService.java
index 8790fb2299f5..839caff5c3d4 100644
--- a/core/java/android/service/autofill/InlineSuggestionRenderService.java
+++ b/core/java/android/service/autofill/InlineSuggestionRenderService.java
@@ -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;
/**
@@ -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();
}
@@ -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();
@@ -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
@@ -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.
@@ -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;
}
/**
@@ -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) {
@@ -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
@@ -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();
}