summaryrefslogtreecommitdiff
path: root/core/java/android/inputmethodservice/InputMethodService.java
diff options
context:
space:
mode:
authorJianYang Liu <jianyliu@google.com>2020-01-23 17:09:26 -0800
committerJianYang Liu <jianyliu@google.com>2020-01-28 14:42:00 -0800
commit7eec316f54e22237f92a2808a3a2f9356229335d (patch)
tree1c50c3f644548fc8716bb3c4517f7d527aef04f7 /core/java/android/inputmethodservice/InputMethodService.java
parentc8e17b66f313fd2777876b20a09f61f0c7fa0f79 (diff)
Updated InputMethodService to not inset by navigation bar if requested
by automotive. Bug: 147155538 Test: Manual Change-Id: I4faf82bdd7536bd2d049ded04034a9635d8ca0d3
Diffstat (limited to 'core/java/android/inputmethodservice/InputMethodService.java')
-rw-r--r--core/java/android/inputmethodservice/InputMethodService.java23
1 files changed, 20 insertions, 3 deletions
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index 92047dcad09e..cc6a0de64cb3 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -39,6 +39,7 @@ import android.app.Dialog;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -52,7 +53,6 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
-import android.os.Process;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.SystemClock;
@@ -452,6 +452,9 @@ public class InputMethodService extends AbstractInputMethodService {
@Nullable
private InlineSuggestionsRequestInfo mInlineSuggestionsRequestInfo = null;
+ private boolean mAutomotiveHideNavBarForKeyboard;
+ private boolean mIsAutomotive;
+
/**
* An opaque {@link Binder} token of window requesting {@link InputMethodImpl#showSoftInput}
* The original app window token is passed from client app window.
@@ -1233,6 +1236,11 @@ public class InputMethodService extends AbstractInputMethodService {
super.onCreate();
mImm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
mSettingsObserver = SettingsObserver.createAndRegister(this);
+
+ mIsAutomotive = isAutomotive();
+ mAutomotiveHideNavBarForKeyboard = getApplicationContext().getResources().getBoolean(
+ com.android.internal.R.bool.config_automotiveHideNavBarForKeyboard);
+
// TODO(b/111364446) Need to address context lifecycle issue if need to re-create
// for update resources & configuration correctly when show soft input
// in non-default display.
@@ -1242,12 +1250,16 @@ public class InputMethodService extends AbstractInputMethodService {
WindowManager.LayoutParams.TYPE_INPUT_METHOD, Gravity.BOTTOM, false);
mWindow.getWindow().getAttributes().setFitInsetsTypes(WindowInsets.Type.statusBars());
- // IME layout should always be inset by navigation bar, no matter it's current visibility.
+ // IME layout should always be inset by navigation bar, no matter its current visibility,
+ // unless automotive requests it, since automotive may hide the navigation bar.
mWindow.getWindow().getDecorView().setOnApplyWindowInsetsListener(
(v, insets) -> v.onApplyWindowInsets(
new WindowInsets.Builder(insets).setInsets(
navigationBars(),
- insets.getInsetsIgnoringVisibility(navigationBars()))
+ mIsAutomotive && mAutomotiveHideNavBarForKeyboard
+ ? android.graphics.Insets.NONE
+ : insets.getInsetsIgnoringVisibility(navigationBars())
+ )
.build()));
// For ColorView in DecorView to work, FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS needs to be set
@@ -3286,6 +3298,11 @@ public class InputMethodService extends AbstractInputMethodService {
: IME_VISIBLE) : 0);
}
+ private boolean isAutomotive() {
+ return getApplicationContext().getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_AUTOMOTIVE);
+ }
+
/**
* Performs a dump of the InputMethodService's internal state. Override
* to add your own information to the dump.