diff --git a/core/java/android/widget/AnalogClock.java b/core/java/android/widget/AnalogClock.java
index d5966269a753a..9c1285064afb6 100644
--- a/core/java/android/widget/AnalogClock.java
+++ b/core/java/android/widget/AnalogClock.java
@@ -111,7 +111,9 @@ public class AnalogClock extends View {
mSecondsHandFps = AppGlobals.getIntCoreSetting(
WidgetFlags.KEY_ANALOG_CLOCK_SECONDS_HAND_FPS,
- WidgetFlags.ANALOG_CLOCK_SECONDS_HAND_FPS_DEFAULT);
+ context.getResources()
+ .getInteger(com.android.internal.R.integer
+ .config_defaultAnalogClockSecondsHandFps));
final TypedArray a = context.obtainStyledAttributes(
attrs, com.android.internal.R.styleable.AnalogClock, defStyleAttr, defStyleRes);
@@ -720,7 +722,7 @@ public class AnalogClock extends View {
canvas.restore();
final Drawable secondHand = mSecondHand;
- if (secondHand != null) {
+ if (secondHand != null && mSecondsHandFps > 0) {
canvas.save();
canvas.rotate(mSeconds / 60.0f * 360.0f, x, y);
@@ -752,7 +754,10 @@ 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 * mSecondsHandFps) / (float) mSecondsHandFps;
+ mSeconds =
+ mSecondsHandFps <= 0
+ ? rawSeconds
+ : Math.round(rawSeconds * mSecondsHandFps) / (float) mSecondsHandFps;
mMinutes = localTime.getMinute() + mSeconds / 60.0f;
mHour = localTime.getHour() + mMinutes / 60.0f;
mChanged = true;
@@ -789,7 +794,7 @@ public class AnalogClock extends View {
LocalTime localTime = zonedDateTime.toLocalTime();
long millisUntilNextTick;
- if (mSecondHand == null) {
+ if (mSecondHand == null || mSecondsHandFps <= 0) {
// If there's no second hand, then tick at the start of the next minute.
//
// This must be done with ZonedDateTime as opposed to LocalDateTime to ensure proper
diff --git a/core/java/android/widget/WidgetFlags.java b/core/java/android/widget/WidgetFlags.java
index 097126807f711..fb40ee5ec8430 100644
--- a/core/java/android/widget/WidgetFlags.java
+++ b/core/java/android/widget/WidgetFlags.java
@@ -207,9 +207,6 @@ public final class WidgetFlags {
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() {
}
}
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 746bb506c5c4e..f604dc102eb58 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -5038,4 +5038,8 @@
- 0.05
+
+
+ 1
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index c05adfd4ba2e9..5d9fc0af5602b 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -490,6 +490,7 @@
+
diff --git a/services/core/java/com/android/server/am/CoreSettingsObserver.java b/services/core/java/com/android/server/am/CoreSettingsObserver.java
index b325ea3b21b34..5c9d38515e49f 100644
--- a/services/core/java/com/android/server/am/CoreSettingsObserver.java
+++ b/services/core/java/com/android/server/am/CoreSettingsObserver.java
@@ -27,6 +27,7 @@ import android.provider.DeviceConfig;
import android.provider.Settings;
import android.widget.WidgetFlags;
+import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import java.util.ArrayList;
@@ -159,12 +160,9 @@ 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...
}
+ private static volatile boolean sDeviceConfigContextEntriesLoaded = false;
private final Bundle mCoreSettings = new Bundle();
@@ -172,11 +170,29 @@ final class CoreSettingsObserver extends ContentObserver {
public CoreSettingsObserver(ActivityManagerService activityManagerService) {
super(activityManagerService.mHandler);
+
+ if (!sDeviceConfigContextEntriesLoaded) {
+ synchronized (sDeviceConfigEntries) {
+ if (!sDeviceConfigContextEntriesLoaded) {
+ loadDeviceConfigContextEntries(activityManagerService.mContext);
+ sDeviceConfigContextEntriesLoaded = true;
+ }
+ }
+ }
+
mActivityManagerService = activityManagerService;
beginObserveCoreSettings();
sendCoreSettings();
}
+ private static void loadDeviceConfigContextEntries(Context context) {
+ sDeviceConfigEntries.add(new DeviceConfigEntry<>(
+ DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.ANALOG_CLOCK_SECONDS_HAND_FPS,
+ WidgetFlags.KEY_ANALOG_CLOCK_SECONDS_HAND_FPS, int.class,
+ context.getResources()
+ .getInteger(R.integer.config_defaultAnalogClockSecondsHandFps)));
+ }
+
public Bundle getCoreSettingsLocked() {
return (Bundle) mCoreSettings.clone();
}