summaryrefslogtreecommitdiff
path: root/core/java/android/inputmethodservice/InputMethodService.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/inputmethodservice/InputMethodService.java')
-rw-r--r--core/java/android/inputmethodservice/InputMethodService.java22
1 files changed, 20 insertions, 2 deletions
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index da9cc8a47a39..49e1d5e4f213 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -38,6 +38,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;
@@ -451,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.
@@ -1230,6 +1234,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.
@@ -1239,12 +1248,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
@@ -3284,6 +3297,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.