From 0099726f09368b56b1a39283547cb23499613b6a Mon Sep 17 00:00:00 2001 From: Taran Singh Date: Tue, 21 Jun 2022 16:09:28 -0700 Subject: [PATCH] isStylusHwAvailable considers Scribe preference Take the user preference into consideration as well to return if stylus handwriting is available. Bug: 228514000 Test: atest StylusHandwritingTest Change-Id: Iaa2e758ebf8fa30978c43de067ed40a8ad08d9b5 --- .../android/view/inputmethod/InputMethodManager.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 50f3e0cfbcf3d..80903c55eb037 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -1421,12 +1421,21 @@ public final class InputMethodManager { } /** - * Returns {@code true} if currently selected IME supports Stylus handwriting. + * Returns {@code true} if currently selected IME supports Stylus handwriting & is enabled. * If the method returns {@code false}, {@link #startStylusHandwriting(View)} shouldn't be * called and Stylus touch should continue as normal touch input. * @see #startStylusHandwriting(View) */ public boolean isStylusHandwritingAvailable() { + final Context fallbackContext = ActivityThread.currentApplication(); + if (fallbackContext == null) { + return false; + } + if (Settings.Global.getInt(fallbackContext.getContentResolver(), + Settings.Global.STYLUS_HANDWRITING_ENABLED, 0) == 0) { + Log.d(TAG, "Stylus handwriting is not enabled in settings."); + return false; + } try { return mService.isStylusHandwritingAvailable(); } catch (RemoteException e) {