Loading core/java/android/widget/AnalogClock.java +9 −3 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.widget; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.AppGlobals; import android.compat.annotation.UnsupportedAppUsage; import android.content.BroadcastReceiver; import android.content.Context; Loading Loading @@ -61,8 +62,9 @@ import java.util.Locale; @Deprecated public class AnalogClock extends View { private static final String LOG_TAG = "AnalogClock"; /** How many times per second that the seconds hand advances. */ private static final long SECONDS_HAND_FPS = 30; private final int mSecondsHandFps; private Clock mClock; @Nullable Loading Loading @@ -106,6 +108,10 @@ public class AnalogClock extends View { public AnalogClock(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); mSecondsHandFps = AppGlobals.getIntCoreSetting( WidgetFlags.KEY_ANALOG_CLOCK_SECONDS_HAND_FPS, WidgetFlags.ANALOG_CLOCK_SECONDS_HAND_FPS_DEFAULT); final TypedArray a = context.obtainStyledAttributes( attrs, com.android.internal.R.styleable.AnalogClock, defStyleAttr, defStyleRes); saveAttributeDataForStyleable(context, com.android.internal.R.styleable.AnalogClock, Loading Loading @@ -743,7 +749,7 @@ public class AnalogClock extends View { // n positions between two given numbers, where n is the number of ticks per second. This // ensures the second hand advances by a consistent distance despite our handler callbacks // occurring at inconsistent frequencies. mSeconds = Math.round(rawSeconds * SECONDS_HAND_FPS) / (float) SECONDS_HAND_FPS; mSeconds = Math.round(rawSeconds * mSecondsHandFps) / (float) mSecondsHandFps; mMinutes = localTime.getMinute() + mSeconds / 60.0f; mHour = localTime.getHour() + mMinutes / 60.0f; mChanged = true; Loading Loading @@ -781,7 +787,7 @@ public class AnalogClock extends View { // How many milliseconds through the second we currently are. long millisOfSecond = Duration.ofNanos(localTime.getNano()).toMillis(); // How many milliseconds there are between tick positions for the seconds hand. double millisPerTick = 1000 / (double) SECONDS_HAND_FPS; double millisPerTick = 1000 / (double) mSecondsHandFps; // How many milliseconds we are past the last tick position. long millisPastLastTick = Math.round(millisOfSecond % millisPerTick); // How many milliseconds there are until the next tick position. Loading core/java/android/widget/WidgetFlags.java +11 −0 Original line number Diff line number Diff line Loading @@ -199,6 +199,17 @@ public final class WidgetFlags { */ public static final float MAGNIFIER_ASPECT_RATIO_DEFAULT = 5.5f; /** The flag of the fps of the analog clock seconds hand. */ public static final String ANALOG_CLOCK_SECONDS_HAND_FPS = "AnalogClockFeature__analog_clock_seconds_hand_fps"; /** The key name used in app core settings for {@link #ANALOG_CLOCK_SECONDS_HAND_FPS}. */ public static final String KEY_ANALOG_CLOCK_SECONDS_HAND_FPS = "widget__analog_clock_seconds_hand_fps"; /** Default value for the flag {@link #ANALOG_CLOCK_SECONDS_HAND_FPS}. */ public static final int ANALOG_CLOCK_SECONDS_HAND_FPS_DEFAULT = 1; private WidgetFlags() { } } services/core/java/com/android/server/am/CoreSettingsObserver.java +4 −0 Original line number Diff line number Diff line Loading @@ -159,6 +159,10 @@ final class CoreSettingsObserver extends ContentObserver { DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.MAGNIFIER_ASPECT_RATIO, WidgetFlags.KEY_MAGNIFIER_ASPECT_RATIO, float.class, WidgetFlags.MAGNIFIER_ASPECT_RATIO_DEFAULT)); sDeviceConfigEntries.add(new DeviceConfigEntry<>( DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.ANALOG_CLOCK_SECONDS_HAND_FPS, WidgetFlags.KEY_ANALOG_CLOCK_SECONDS_HAND_FPS, int.class, WidgetFlags.ANALOG_CLOCK_SECONDS_HAND_FPS_DEFAULT)); // add other device configs here... } Loading Loading
core/java/android/widget/AnalogClock.java +9 −3 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.widget; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.AppGlobals; import android.compat.annotation.UnsupportedAppUsage; import android.content.BroadcastReceiver; import android.content.Context; Loading Loading @@ -61,8 +62,9 @@ import java.util.Locale; @Deprecated public class AnalogClock extends View { private static final String LOG_TAG = "AnalogClock"; /** How many times per second that the seconds hand advances. */ private static final long SECONDS_HAND_FPS = 30; private final int mSecondsHandFps; private Clock mClock; @Nullable Loading Loading @@ -106,6 +108,10 @@ public class AnalogClock extends View { public AnalogClock(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); mSecondsHandFps = AppGlobals.getIntCoreSetting( WidgetFlags.KEY_ANALOG_CLOCK_SECONDS_HAND_FPS, WidgetFlags.ANALOG_CLOCK_SECONDS_HAND_FPS_DEFAULT); final TypedArray a = context.obtainStyledAttributes( attrs, com.android.internal.R.styleable.AnalogClock, defStyleAttr, defStyleRes); saveAttributeDataForStyleable(context, com.android.internal.R.styleable.AnalogClock, Loading Loading @@ -743,7 +749,7 @@ public class AnalogClock extends View { // n positions between two given numbers, where n is the number of ticks per second. This // ensures the second hand advances by a consistent distance despite our handler callbacks // occurring at inconsistent frequencies. mSeconds = Math.round(rawSeconds * SECONDS_HAND_FPS) / (float) SECONDS_HAND_FPS; mSeconds = Math.round(rawSeconds * mSecondsHandFps) / (float) mSecondsHandFps; mMinutes = localTime.getMinute() + mSeconds / 60.0f; mHour = localTime.getHour() + mMinutes / 60.0f; mChanged = true; Loading Loading @@ -781,7 +787,7 @@ public class AnalogClock extends View { // How many milliseconds through the second we currently are. long millisOfSecond = Duration.ofNanos(localTime.getNano()).toMillis(); // How many milliseconds there are between tick positions for the seconds hand. double millisPerTick = 1000 / (double) SECONDS_HAND_FPS; double millisPerTick = 1000 / (double) mSecondsHandFps; // How many milliseconds we are past the last tick position. long millisPastLastTick = Math.round(millisOfSecond % millisPerTick); // How many milliseconds there are until the next tick position. Loading
core/java/android/widget/WidgetFlags.java +11 −0 Original line number Diff line number Diff line Loading @@ -199,6 +199,17 @@ public final class WidgetFlags { */ public static final float MAGNIFIER_ASPECT_RATIO_DEFAULT = 5.5f; /** The flag of the fps of the analog clock seconds hand. */ public static final String ANALOG_CLOCK_SECONDS_HAND_FPS = "AnalogClockFeature__analog_clock_seconds_hand_fps"; /** The key name used in app core settings for {@link #ANALOG_CLOCK_SECONDS_HAND_FPS}. */ public static final String KEY_ANALOG_CLOCK_SECONDS_HAND_FPS = "widget__analog_clock_seconds_hand_fps"; /** Default value for the flag {@link #ANALOG_CLOCK_SECONDS_HAND_FPS}. */ public static final int ANALOG_CLOCK_SECONDS_HAND_FPS_DEFAULT = 1; private WidgetFlags() { } }
services/core/java/com/android/server/am/CoreSettingsObserver.java +4 −0 Original line number Diff line number Diff line Loading @@ -159,6 +159,10 @@ final class CoreSettingsObserver extends ContentObserver { DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.MAGNIFIER_ASPECT_RATIO, WidgetFlags.KEY_MAGNIFIER_ASPECT_RATIO, float.class, WidgetFlags.MAGNIFIER_ASPECT_RATIO_DEFAULT)); sDeviceConfigEntries.add(new DeviceConfigEntry<>( DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.ANALOG_CLOCK_SECONDS_HAND_FPS, WidgetFlags.KEY_ANALOG_CLOCK_SECONDS_HAND_FPS, int.class, WidgetFlags.ANALOG_CLOCK_SECONDS_HAND_FPS_DEFAULT)); // add other device configs here... } Loading