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

Commit bc1bfd5b authored by Prabir Pradhan's avatar Prabir Pradhan Committed by Android (Google) Code Review
Browse files

Merge "Move stylus hover icon setting to core settings" into main

parents 558a4186 2b03716a
Loading
Loading
Loading
Loading
+26 −6
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.annotation.SuppressLint;
import android.annotation.TestApi;
import android.app.AppGlobals;
import android.content.Context;
import android.os.UserHandle;
import android.provider.Settings;
@@ -393,16 +394,35 @@ public class InputSettings {
     *
     * @hide
     */
    public static boolean isStylusPointerIconEnabled(@NonNull Context context) {
    public static boolean isStylusPointerIconEnabled(@NonNull Context context,
            boolean forceReloadSetting) {
        if (InputProperties.force_enable_stylus_pointer_icon().orElse(false)) {
            // Sysprop override is set
            return true;
        }
        return context.getResources()
                        .getBoolean(com.android.internal.R.bool.config_enableStylusPointerIcon)
                && Settings.Secure.getIntForUser(context.getContentResolver(),
        if (!context.getResources().getBoolean(
                com.android.internal.R.bool.config_enableStylusPointerIcon)) {
            // Stylus pointer icons are disabled for the build
            return false;
        }
        if (forceReloadSetting) {
            return Settings.Secure.getIntForUser(context.getContentResolver(),
                    Settings.Secure.STYLUS_POINTER_ICON_ENABLED,
                    DEFAULT_STYLUS_POINTER_ICON_ENABLED, UserHandle.USER_CURRENT_OR_SELF) != 0;
        }
        return AppGlobals.getIntCoreSetting(Settings.Secure.STYLUS_POINTER_ICON_ENABLED,
                DEFAULT_STYLUS_POINTER_ICON_ENABLED) != 0;
    }

    /**
     * Whether a pointer icon will be shown over the location of a stylus pointer.
     *
     * @hide
     * @see #isStylusPointerIconEnabled(Context, boolean)
     */
    public static boolean isStylusPointerIconEnabled(@NonNull Context context) {
        return isStylusPointerIconEnabled(context, false /* forceReloadSetting */);
    }

    /**
     * Whether Accessibility bounce keys feature is enabled.
+1 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ final class CoreSettingsObserver extends ContentObserver {
        sSecureSettingToTypeMap.put(Settings.Secure.MULTI_PRESS_TIMEOUT, int.class);
        sSecureSettingToTypeMap.put(Settings.Secure.KEY_REPEAT_TIMEOUT_MS, int.class);
        sSecureSettingToTypeMap.put(Settings.Secure.KEY_REPEAT_DELAY_MS, int.class);
        sSecureSettingToTypeMap.put(Settings.Secure.STYLUS_POINTER_ICON_ENABLED, int.class);
        // add other secure settings here...

        sSystemSettingToTypeMap.put(Settings.System.TIME_12_24, String.class);
+2 −1
Original line number Diff line number Diff line
@@ -258,6 +258,7 @@ class InputSettingsObserver extends ContentObserver {
    }

    private void updateStylusPointerIconEnabled() {
        mNative.setStylusPointerIconEnabled(InputSettings.isStylusPointerIconEnabled(mContext));
        mNative.setStylusPointerIconEnabled(
                InputSettings.isStylusPointerIconEnabled(mContext, true /* forceReloadSetting */));
    }
}