Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ede3a97e authored by Taran Singh's avatar Taran Singh
Browse files

Introduce Stylus handwriting developer option

Introduce stylus handwriting settings and check if its enabled before
calling IMM#startStylusHandwriting()

Bug: 219777744
Test: atest StylusHandwritingTest

Change-Id: Id58b2eb66a0a1178743d08921918f3d9d717546c
parent 3e4365b8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2157,6 +2157,7 @@ package android.provider {
    field @Deprecated public static final String NOTIFICATION_BUBBLES = "notification_bubbles";
    field public static final String OVERLAY_DISPLAY_DEVICES = "overlay_display_devices";
    field public static final String SHOW_FIRST_CRASH_DIALOG = "show_first_crash_dialog";
    field public static final String STYLUS_HANDWRITING_ENABLED = "stylus_handwriting_enabled";
    field public static final String USER_DISABLED_HDR_FORMATS = "user_disabled_hdr_formats";
    field public static final String USER_PREFERRED_REFRESH_RATE = "user_preferred_refresh_rate";
    field public static final String USER_PREFERRED_RESOLUTION_HEIGHT = "user_preferred_resolution_height";
+13 −0
Original line number Diff line number Diff line
@@ -86,8 +86,10 @@ import android.util.ArraySet;
import android.util.Log;
import android.util.MemoryIntArray;
import android.view.Display;
import android.view.MotionEvent;
import android.view.Window;
import android.view.WindowManager.LayoutParams;
import android.widget.Editor;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.Preconditions;
@@ -15482,6 +15484,17 @@ public final class Settings {
        @Readable
        public static final String AUTOFILL_MAX_VISIBLE_DATASETS = "autofill_max_visible_datasets";
        /**
         * Toggle for enabling stylus handwriting. When enabled, current Input method receives
         * stylus {@link MotionEvent}s if an {@link Editor} is focused.
         *
         * @hide
         */
        @TestApi
        @Readable
        @SuppressLint("NoSettingsProvider")
        public static final String STYLUS_HANDWRITING_ENABLED = "stylus_handwriting_enabled";
        /**
         * Exemptions to the hidden API blacklist.
         *
+8 −1
Original line number Diff line number Diff line
@@ -1895,10 +1895,17 @@ public final class InputMethodManager {
        if (fallbackImm != null) {
            fallbackImm.startStylusHandwriting(view);
        }
        Objects.requireNonNull(view);

        if (Settings.Global.getInt(view.getContext().getContentResolver(),
                Settings.Global.STYLUS_HANDWRITING_ENABLED, 0) == 0) {
            Log.d(TAG, "Ignoring startStylusHandwriting(view) as stylus handwriting is disabled");
            return;
        }

        checkFocus();
        synchronized (mH) {
            if (view == null || !hasServedByInputMethodLocked(view)) {
            if (!hasServedByInputMethodLocked(view)) {
                Log.w(TAG,
                        "Ignoring startStylusHandwriting() as view=" + view + " is not served.");
                return;
+1 −0
Original line number Diff line number Diff line
@@ -271,6 +271,7 @@ public class SettingsBackupTest {
                    Settings.Global.DYNAMIC_POWER_SAVINGS_DISABLE_THRESHOLD,
                    Settings.Global.SMART_REPLIES_IN_NOTIFICATIONS_FLAGS,
                    Settings.Global.SMART_SUGGESTIONS_IN_NOTIFICATIONS_FLAGS,
                    Settings.Global.STYLUS_HANDWRITING_ENABLED,
                    Settings.Global.ENABLE_ADB_INCREMENTAL_INSTALL_DEFAULT,
                    Settings.Global.ENABLE_MULTI_SLOT_TIMEOUT_MILLIS,
                    Settings.Global.ENHANCED_4G_MODE_ENABLED,