Loading core/java/android/provider/Settings.java +10 −0 Original line number Diff line number Diff line Loading @@ -6100,6 +6100,15 @@ public final class Settings { @TestApi public static final String POINTER_SPEED = "pointer_speed"; /** * Pointer scale setting. * * <p>This float value represents the scale by which the size of the pointer increases. * @hide */ @Readable public static final String POINTER_SCALE = "pointer_scale"; /** * Touchpad pointer speed setting. * This is an integer value in a range between -7 and +7, so there are 15 possible values. Loading Loading @@ -6358,6 +6367,7 @@ public final class Settings { PRIVATE_SETTINGS.add(SIP_ASK_ME_EACH_TIME); PRIVATE_SETTINGS.add(POINTER_SPEED); PRIVATE_SETTINGS.add(POINTER_FILL_STYLE); PRIVATE_SETTINGS.add(POINTER_SCALE); PRIVATE_SETTINGS.add(LOCK_TO_APP_ENABLED); PRIVATE_SETTINGS.add(EGG_MODE); PRIVATE_SETTINGS.add(SHOW_BATTERY_PERCENT); Loading core/java/android/view/PointerIcon.java +29 −17 Original line number Diff line number Diff line Loading @@ -193,6 +193,9 @@ public final class PointerIcon implements Parcelable { /** @hide */ public static final int POINTER_ICON_VECTOR_STYLE_FILL_END = POINTER_ICON_VECTOR_STYLE_FILL_BLUE; /** @hide */ public static final float DEFAULT_POINTER_SCALE = 1f; /** @hide */ public static final float LARGE_POINTER_SCALE = 2.5f; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) private final int mType; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) Loading Loading @@ -253,7 +256,7 @@ public final class PointerIcon implements Parcelable { * @hide */ public static @NonNull PointerIcon getLoadedSystemIcon(@NonNull Context context, int type, boolean useLargeIcons) { boolean useLargeIcons, float pointerScale) { if (type == TYPE_NOT_SPECIFIED) { throw new IllegalStateException("Cannot load icon for type TYPE_NOT_SPECIFIED"); } Loading @@ -268,7 +271,11 @@ public final class PointerIcon implements Parcelable { } final int defStyle; // TODO(b/305193969): Use scaled vectors when large icons are requested. if (android.view.flags.Flags.enableVectorCursorA11ySettings()) { defStyle = com.android.internal.R.style.VectorPointer; } else { // TODO(b/346358375): Remove useLargeIcons and the legacy pointer styles when // enableVectorCursorA11ySetting is rolled out. if (useLargeIcons) { defStyle = com.android.internal.R.style.LargePointer; } else if (android.view.flags.Flags.enableVectorCursors()) { Loading @@ -276,6 +283,7 @@ public final class PointerIcon implements Parcelable { } else { defStyle = com.android.internal.R.style.Pointer; } } TypedArray a = context.obtainStyledAttributes(null, com.android.internal.R.styleable.Pointer, 0, defStyle); Loading @@ -286,11 +294,11 @@ public final class PointerIcon implements Parcelable { Log.w(TAG, "Missing theme resources for pointer icon type " + type); return type == TYPE_DEFAULT ? getSystemIcon(TYPE_NULL) : getLoadedSystemIcon(context, TYPE_DEFAULT, useLargeIcons); : getLoadedSystemIcon(context, TYPE_DEFAULT, useLargeIcons, pointerScale); } final PointerIcon icon = new PointerIcon(type); icon.loadResource(context.getResources(), resourceId, context.getTheme()); icon.loadResource(context.getResources(), resourceId, context.getTheme(), pointerScale); return icon; } Loading Loading @@ -353,7 +361,7 @@ public final class PointerIcon implements Parcelable { } PointerIcon icon = new PointerIcon(TYPE_CUSTOM); icon.loadResource(resources, resourceId, null); icon.loadResource(resources, resourceId, null, DEFAULT_POINTER_SCALE); return icon; } Loading Loading @@ -460,12 +468,13 @@ public final class PointerIcon implements Parcelable { } private BitmapDrawable getBitmapDrawableFromVectorDrawable(Resources resources, VectorDrawable vectorDrawable) { VectorDrawable vectorDrawable, float pointerScale) { // Ensure we pass the display metrics into the Bitmap constructor so that it is initialized // with the correct density. Bitmap bitmap = Bitmap.createBitmap(resources.getDisplayMetrics(), vectorDrawable.getIntrinsicWidth(), vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888, true /* hasAlpha */); (int) (vectorDrawable.getIntrinsicWidth() * pointerScale), (int) (vectorDrawable.getIntrinsicHeight() * pointerScale), Bitmap.Config.ARGB_8888, true /* hasAlpha */); Canvas canvas = new Canvas(bitmap); vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); vectorDrawable.draw(canvas); Loading @@ -473,7 +482,7 @@ public final class PointerIcon implements Parcelable { } private void loadResource(@NonNull Resources resources, @XmlRes int resourceId, @Nullable Resources.Theme theme) { @Nullable Resources.Theme theme, float pointerScale) { final XmlResourceParser parser = resources.getXml(resourceId); final int bitmapRes; final float hotSpotX; Loading @@ -484,8 +493,10 @@ public final class PointerIcon implements Parcelable { final TypedArray a = resources.obtainAttributes( parser, com.android.internal.R.styleable.PointerIcon); bitmapRes = a.getResourceId(com.android.internal.R.styleable.PointerIcon_bitmap, 0); hotSpotX = a.getDimension(com.android.internal.R.styleable.PointerIcon_hotSpotX, 0); hotSpotY = a.getDimension(com.android.internal.R.styleable.PointerIcon_hotSpotY, 0); hotSpotX = a.getDimension(com.android.internal.R.styleable.PointerIcon_hotSpotX, 0) * pointerScale; hotSpotY = a.getDimension(com.android.internal.R.styleable.PointerIcon_hotSpotY, 0) * pointerScale; a.recycle(); } catch (Exception ex) { throw new IllegalArgumentException("Exception parsing pointer icon resource.", ex); Loading Loading @@ -534,7 +545,7 @@ public final class PointerIcon implements Parcelable { } if (isVectorAnimation) { drawableFrame = getBitmapDrawableFromVectorDrawable(resources, (VectorDrawable) drawableFrame); (VectorDrawable) drawableFrame, pointerScale); } mBitmapFrames[i - 1] = getBitmapFromDrawable((BitmapDrawable) drawableFrame); } Loading @@ -542,7 +553,8 @@ public final class PointerIcon implements Parcelable { } if (drawable instanceof VectorDrawable) { mDrawNativeDropShadow = true; drawable = getBitmapDrawableFromVectorDrawable(resources, (VectorDrawable) drawable); drawable = getBitmapDrawableFromVectorDrawable(resources, (VectorDrawable) drawable, pointerScale); } if (!(drawable instanceof BitmapDrawable)) { throw new IllegalArgumentException("<pointer-icon> bitmap attribute must " Loading core/proto/android/providers/settings/system.proto +1 −0 Original line number Diff line number Diff line Loading @@ -126,6 +126,7 @@ message SystemSettingsProto { option (android.msg_privacy).dest = DEST_EXPLICIT; optional SettingProto pointer_fill_style = 1 [ (android.privacy).dest = DEST_AUTOMATIC ]; optional SettingProto pointer_scale = 3 [ (android.privacy).dest = DEST_AUTOMATIC ]; } optional Pointer pointer = 37; optional SettingProto pointer_speed = 18 [ (android.privacy).dest = DEST_AUTOMATIC ]; Loading packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java +1 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ public class SystemSettings { Settings.System.SIP_RECEIVE_CALLS, Settings.System.POINTER_SPEED, Settings.System.POINTER_FILL_STYLE, Settings.System.POINTER_SCALE, Settings.System.VIBRATE_ON, Settings.System.VIBRATE_WHEN_RINGING, Settings.System.RINGTONE, Loading packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java +4 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,8 @@ import static android.provider.settings.validators.SettingsValidators.NON_NEGATI import static android.provider.settings.validators.SettingsValidators.NON_NEGATIVE_INTEGER_VALIDATOR; import static android.provider.settings.validators.SettingsValidators.URI_VALIDATOR; import static android.provider.settings.validators.SettingsValidators.VIBRATION_INTENSITY_VALIDATOR; import static android.view.PointerIcon.DEFAULT_POINTER_SCALE; import static android.view.PointerIcon.LARGE_POINTER_SCALE; import static android.view.PointerIcon.POINTER_ICON_VECTOR_STYLE_FILL_BEGIN; import static android.view.PointerIcon.POINTER_ICON_VECTOR_STYLE_FILL_END; Loading Loading @@ -211,6 +213,8 @@ public class SystemSettingsValidators { VALIDATORS.put(System.POINTER_FILL_STYLE, new InclusiveIntegerRangeValidator(POINTER_ICON_VECTOR_STYLE_FILL_BEGIN, POINTER_ICON_VECTOR_STYLE_FILL_END)); VALIDATORS.put(System.POINTER_SCALE, new InclusiveFloatRangeValidator(DEFAULT_POINTER_SCALE, LARGE_POINTER_SCALE)); VALIDATORS.put(System.TOUCHPAD_POINTER_SPEED, new InclusiveIntegerRangeValidator(-7, 7)); VALIDATORS.put(System.TOUCHPAD_NATURAL_SCROLLING, BOOLEAN_VALIDATOR); VALIDATORS.put(System.TOUCHPAD_TAP_TO_CLICK, BOOLEAN_VALIDATOR); Loading Loading
core/java/android/provider/Settings.java +10 −0 Original line number Diff line number Diff line Loading @@ -6100,6 +6100,15 @@ public final class Settings { @TestApi public static final String POINTER_SPEED = "pointer_speed"; /** * Pointer scale setting. * * <p>This float value represents the scale by which the size of the pointer increases. * @hide */ @Readable public static final String POINTER_SCALE = "pointer_scale"; /** * Touchpad pointer speed setting. * This is an integer value in a range between -7 and +7, so there are 15 possible values. Loading Loading @@ -6358,6 +6367,7 @@ public final class Settings { PRIVATE_SETTINGS.add(SIP_ASK_ME_EACH_TIME); PRIVATE_SETTINGS.add(POINTER_SPEED); PRIVATE_SETTINGS.add(POINTER_FILL_STYLE); PRIVATE_SETTINGS.add(POINTER_SCALE); PRIVATE_SETTINGS.add(LOCK_TO_APP_ENABLED); PRIVATE_SETTINGS.add(EGG_MODE); PRIVATE_SETTINGS.add(SHOW_BATTERY_PERCENT); Loading
core/java/android/view/PointerIcon.java +29 −17 Original line number Diff line number Diff line Loading @@ -193,6 +193,9 @@ public final class PointerIcon implements Parcelable { /** @hide */ public static final int POINTER_ICON_VECTOR_STYLE_FILL_END = POINTER_ICON_VECTOR_STYLE_FILL_BLUE; /** @hide */ public static final float DEFAULT_POINTER_SCALE = 1f; /** @hide */ public static final float LARGE_POINTER_SCALE = 2.5f; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) private final int mType; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) Loading Loading @@ -253,7 +256,7 @@ public final class PointerIcon implements Parcelable { * @hide */ public static @NonNull PointerIcon getLoadedSystemIcon(@NonNull Context context, int type, boolean useLargeIcons) { boolean useLargeIcons, float pointerScale) { if (type == TYPE_NOT_SPECIFIED) { throw new IllegalStateException("Cannot load icon for type TYPE_NOT_SPECIFIED"); } Loading @@ -268,7 +271,11 @@ public final class PointerIcon implements Parcelable { } final int defStyle; // TODO(b/305193969): Use scaled vectors when large icons are requested. if (android.view.flags.Flags.enableVectorCursorA11ySettings()) { defStyle = com.android.internal.R.style.VectorPointer; } else { // TODO(b/346358375): Remove useLargeIcons and the legacy pointer styles when // enableVectorCursorA11ySetting is rolled out. if (useLargeIcons) { defStyle = com.android.internal.R.style.LargePointer; } else if (android.view.flags.Flags.enableVectorCursors()) { Loading @@ -276,6 +283,7 @@ public final class PointerIcon implements Parcelable { } else { defStyle = com.android.internal.R.style.Pointer; } } TypedArray a = context.obtainStyledAttributes(null, com.android.internal.R.styleable.Pointer, 0, defStyle); Loading @@ -286,11 +294,11 @@ public final class PointerIcon implements Parcelable { Log.w(TAG, "Missing theme resources for pointer icon type " + type); return type == TYPE_DEFAULT ? getSystemIcon(TYPE_NULL) : getLoadedSystemIcon(context, TYPE_DEFAULT, useLargeIcons); : getLoadedSystemIcon(context, TYPE_DEFAULT, useLargeIcons, pointerScale); } final PointerIcon icon = new PointerIcon(type); icon.loadResource(context.getResources(), resourceId, context.getTheme()); icon.loadResource(context.getResources(), resourceId, context.getTheme(), pointerScale); return icon; } Loading Loading @@ -353,7 +361,7 @@ public final class PointerIcon implements Parcelable { } PointerIcon icon = new PointerIcon(TYPE_CUSTOM); icon.loadResource(resources, resourceId, null); icon.loadResource(resources, resourceId, null, DEFAULT_POINTER_SCALE); return icon; } Loading Loading @@ -460,12 +468,13 @@ public final class PointerIcon implements Parcelable { } private BitmapDrawable getBitmapDrawableFromVectorDrawable(Resources resources, VectorDrawable vectorDrawable) { VectorDrawable vectorDrawable, float pointerScale) { // Ensure we pass the display metrics into the Bitmap constructor so that it is initialized // with the correct density. Bitmap bitmap = Bitmap.createBitmap(resources.getDisplayMetrics(), vectorDrawable.getIntrinsicWidth(), vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888, true /* hasAlpha */); (int) (vectorDrawable.getIntrinsicWidth() * pointerScale), (int) (vectorDrawable.getIntrinsicHeight() * pointerScale), Bitmap.Config.ARGB_8888, true /* hasAlpha */); Canvas canvas = new Canvas(bitmap); vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); vectorDrawable.draw(canvas); Loading @@ -473,7 +482,7 @@ public final class PointerIcon implements Parcelable { } private void loadResource(@NonNull Resources resources, @XmlRes int resourceId, @Nullable Resources.Theme theme) { @Nullable Resources.Theme theme, float pointerScale) { final XmlResourceParser parser = resources.getXml(resourceId); final int bitmapRes; final float hotSpotX; Loading @@ -484,8 +493,10 @@ public final class PointerIcon implements Parcelable { final TypedArray a = resources.obtainAttributes( parser, com.android.internal.R.styleable.PointerIcon); bitmapRes = a.getResourceId(com.android.internal.R.styleable.PointerIcon_bitmap, 0); hotSpotX = a.getDimension(com.android.internal.R.styleable.PointerIcon_hotSpotX, 0); hotSpotY = a.getDimension(com.android.internal.R.styleable.PointerIcon_hotSpotY, 0); hotSpotX = a.getDimension(com.android.internal.R.styleable.PointerIcon_hotSpotX, 0) * pointerScale; hotSpotY = a.getDimension(com.android.internal.R.styleable.PointerIcon_hotSpotY, 0) * pointerScale; a.recycle(); } catch (Exception ex) { throw new IllegalArgumentException("Exception parsing pointer icon resource.", ex); Loading Loading @@ -534,7 +545,7 @@ public final class PointerIcon implements Parcelable { } if (isVectorAnimation) { drawableFrame = getBitmapDrawableFromVectorDrawable(resources, (VectorDrawable) drawableFrame); (VectorDrawable) drawableFrame, pointerScale); } mBitmapFrames[i - 1] = getBitmapFromDrawable((BitmapDrawable) drawableFrame); } Loading @@ -542,7 +553,8 @@ public final class PointerIcon implements Parcelable { } if (drawable instanceof VectorDrawable) { mDrawNativeDropShadow = true; drawable = getBitmapDrawableFromVectorDrawable(resources, (VectorDrawable) drawable); drawable = getBitmapDrawableFromVectorDrawable(resources, (VectorDrawable) drawable, pointerScale); } if (!(drawable instanceof BitmapDrawable)) { throw new IllegalArgumentException("<pointer-icon> bitmap attribute must " Loading
core/proto/android/providers/settings/system.proto +1 −0 Original line number Diff line number Diff line Loading @@ -126,6 +126,7 @@ message SystemSettingsProto { option (android.msg_privacy).dest = DEST_EXPLICIT; optional SettingProto pointer_fill_style = 1 [ (android.privacy).dest = DEST_AUTOMATIC ]; optional SettingProto pointer_scale = 3 [ (android.privacy).dest = DEST_AUTOMATIC ]; } optional Pointer pointer = 37; optional SettingProto pointer_speed = 18 [ (android.privacy).dest = DEST_AUTOMATIC ]; Loading
packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java +1 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ public class SystemSettings { Settings.System.SIP_RECEIVE_CALLS, Settings.System.POINTER_SPEED, Settings.System.POINTER_FILL_STYLE, Settings.System.POINTER_SCALE, Settings.System.VIBRATE_ON, Settings.System.VIBRATE_WHEN_RINGING, Settings.System.RINGTONE, Loading
packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java +4 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,8 @@ import static android.provider.settings.validators.SettingsValidators.NON_NEGATI import static android.provider.settings.validators.SettingsValidators.NON_NEGATIVE_INTEGER_VALIDATOR; import static android.provider.settings.validators.SettingsValidators.URI_VALIDATOR; import static android.provider.settings.validators.SettingsValidators.VIBRATION_INTENSITY_VALIDATOR; import static android.view.PointerIcon.DEFAULT_POINTER_SCALE; import static android.view.PointerIcon.LARGE_POINTER_SCALE; import static android.view.PointerIcon.POINTER_ICON_VECTOR_STYLE_FILL_BEGIN; import static android.view.PointerIcon.POINTER_ICON_VECTOR_STYLE_FILL_END; Loading Loading @@ -211,6 +213,8 @@ public class SystemSettingsValidators { VALIDATORS.put(System.POINTER_FILL_STYLE, new InclusiveIntegerRangeValidator(POINTER_ICON_VECTOR_STYLE_FILL_BEGIN, POINTER_ICON_VECTOR_STYLE_FILL_END)); VALIDATORS.put(System.POINTER_SCALE, new InclusiveFloatRangeValidator(DEFAULT_POINTER_SCALE, LARGE_POINTER_SCALE)); VALIDATORS.put(System.TOUCHPAD_POINTER_SPEED, new InclusiveIntegerRangeValidator(-7, 7)); VALIDATORS.put(System.TOUCHPAD_NATURAL_SCROLLING, BOOLEAN_VALIDATOR); VALIDATORS.put(System.TOUCHPAD_TAP_TO_CLICK, BOOLEAN_VALIDATOR); Loading