summaryrefslogtreecommitdiff
path: root/core/java/android/inputmethodservice
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2020-07-15 17:55:04 -0700
committerXin Li <delphij@google.com>2020-07-15 17:55:04 -0700
commit8162b6e0d5fca625f2cdf0dcdc2ae8d07fb0ae53 (patch)
treea4c2dcff0c41117c83eda96c42403db0fb3465d8 /core/java/android/inputmethodservice
parent5f74d605ce2d2237a78d7e259e8adaa70e6683bf (diff)
parentf65210f9cad319d3e99320672e9eb36605c25851 (diff)
Merge ab/12162526 into stage-aosp-rvc-ts-dev
Bug: 148878042 Change-Id: I62d48fad449cae9233fb5c0d505593b17e9b6238
Diffstat (limited to 'core/java/android/inputmethodservice')
-rw-r--r--core/java/android/inputmethodservice/AbstractInputMethodService.java6
-rw-r--r--core/java/android/inputmethodservice/InlineSuggestionSession.java25
-rw-r--r--core/java/android/inputmethodservice/InlineSuggestionSessionController.java1
-rw-r--r--core/java/android/inputmethodservice/InputMethodService.java7
4 files changed, 36 insertions, 3 deletions
diff --git a/core/java/android/inputmethodservice/AbstractInputMethodService.java b/core/java/android/inputmethodservice/AbstractInputMethodService.java
index b0fca006d1e2..d7ca63a54987 100644
--- a/core/java/android/inputmethodservice/AbstractInputMethodService.java
+++ b/core/java/android/inputmethodservice/AbstractInputMethodService.java
@@ -260,4 +260,10 @@ public abstract class AbstractInputMethodService extends Service
*/
public void notifyUserActionIfNecessary() {
}
+
+ /** @hide */
+ @Override
+ public final boolean isUiContext() {
+ return true;
+ }
}
diff --git a/core/java/android/inputmethodservice/InlineSuggestionSession.java b/core/java/android/inputmethodservice/InlineSuggestionSession.java
index 26197883c32f..90d0ff0a5026 100644
--- a/core/java/android/inputmethodservice/InlineSuggestionSession.java
+++ b/core/java/android/inputmethodservice/InlineSuggestionSession.java
@@ -38,6 +38,7 @@ import com.android.internal.view.IInlineSuggestionsResponseCallback;
import com.android.internal.view.InlineSuggestionsRequestInfo;
import java.lang.ref.WeakReference;
+import java.util.Collections;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
@@ -58,6 +59,9 @@ import java.util.function.Supplier;
class InlineSuggestionSession {
private static final String TAG = "ImsInlineSuggestionSession";
+ static final InlineSuggestionsResponse EMPTY_RESPONSE = new InlineSuggestionsResponse(
+ Collections.emptyList());
+
@NonNull
private final Handler mMainThreadHandler;
@NonNull
@@ -72,6 +76,10 @@ class InlineSuggestionSession {
private final Supplier<IBinder> mHostInputTokenSupplier;
@NonNull
private final Consumer<InlineSuggestionsResponse> mResponseConsumer;
+ // Indicate whether the previous call to the mResponseConsumer is empty or not. If it hasn't
+ // been called yet, the value would be null.
+ @Nullable
+ private Boolean mPreviousResponseIsEmpty;
/**
@@ -141,7 +149,13 @@ class InlineSuggestionSession {
*/
@MainThread
void invalidate() {
+ try {
+ mCallback.onInlineSuggestionsSessionInvalidated();
+ } catch (RemoteException e) {
+ Log.w(TAG, "onInlineSuggestionsSessionInvalidated() remote exception:" + e);
+ }
if (mResponseCallback != null) {
+ consumeInlineSuggestionsResponse(EMPTY_RESPONSE);
mResponseCallback.invalidate();
mResponseCallback = null;
}
@@ -188,6 +202,17 @@ class InlineSuggestionSession {
if (DEBUG) {
Log.d(TAG, "IME receives response: " + response.getInlineSuggestions().size());
}
+ consumeInlineSuggestionsResponse(response);
+ }
+
+ @MainThread
+ void consumeInlineSuggestionsResponse(@NonNull InlineSuggestionsResponse response) {
+ boolean isResponseEmpty = response.getInlineSuggestions().isEmpty();
+ if (isResponseEmpty && Boolean.TRUE.equals(mPreviousResponseIsEmpty)) {
+ // No-op if both the previous response and current response are empty.
+ return;
+ }
+ mPreviousResponseIsEmpty = isResponseEmpty;
mResponseConsumer.accept(response);
}
diff --git a/core/java/android/inputmethodservice/InlineSuggestionSessionController.java b/core/java/android/inputmethodservice/InlineSuggestionSessionController.java
index c9f9059bed4f..071c096ee2f0 100644
--- a/core/java/android/inputmethodservice/InlineSuggestionSessionController.java
+++ b/core/java/android/inputmethodservice/InlineSuggestionSessionController.java
@@ -134,6 +134,7 @@ class InlineSuggestionSessionController {
mImeClientFieldId = imeFieldId;
if (mSession != null) {
+ mSession.consumeInlineSuggestionsResponse(InlineSuggestionSession.EMPTY_RESPONSE);
// Initiates the callback to Autofill if there is a pending matching session.
// Otherwise updates the session with the Ime status.
if (!mSession.isCallbackInvoked() && match(mSession.getRequestInfo())) {
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index d8b1f41c86d5..c5a11abe1136 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -471,6 +471,10 @@ public class InputMethodService extends AbstractInputMethodService {
final ViewTreeObserver.OnComputeInternalInsetsListener mInsetsComputer = info -> {
onComputeInsets(mTmpInsets);
+ if (!mViewsCreated) {
+ // The IME views are not ready, keep visible insets untouched.
+ mTmpInsets.visibleTopInsets = 0;
+ }
if (isExtractViewShown()) {
// In true fullscreen mode, we just say the window isn't covering
// any content so we don't impact whatever is behind.
@@ -601,9 +605,6 @@ public class InputMethodService extends AbstractInputMethodService {
if (DEBUG) Log.v(TAG, "unbindInput(): binding=" + mInputBinding
+ " ic=" + mInputConnection);
// Unbind input is per process per display.
- // TODO(b/150902448): free-up IME surface when target is changing.
- // e.g. DisplayContent#setInputMethodTarget()
- removeImeSurface();
onUnbindInput();
mInputBinding = null;
mInputConnection = null;