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

Commit bb90d617 authored by Pierre Barbier de Reuille's avatar Pierre Barbier de Reuille Committed by Automerger Merge Worker
Browse files

Merge "Add a config value for the default of the analog clock flag" into sc-dev am: 8ea2a96c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15001970

Change-Id: Ib3741e272583a0985ce186299d89074381bb43a1
parents 4b23dbb4 8ea2a96c
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -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
+0 −3
Original line number Diff line number Diff line
@@ -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() {
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -5038,4 +5038,8 @@
    <!-- The amount of dimming to apply to wallpapers with mid range luminance. 0 displays
         the wallpaper at full brightness. 1 displays the wallpaper as fully black. -->
    <item name="config_wallpaperDimAmount" format="float" type="dimen">0.05</item>

    <!-- The default number of times per second that the seconds hand on AnalogClock ticks. If set
         to 0, the seconds hand will be disabled. -->
    <integer name="config_defaultAnalogClockSecondsHandFps">1</integer>
</resources>
+1 −0
Original line number Diff line number Diff line
@@ -490,6 +490,7 @@
  <java-symbol type="integer" name="config_smartSelectionInitializedTimeoutMillis" />
  <java-symbol type="integer" name="config_smartSelectionInitializingTimeoutMillis" />
  <java-symbol type="bool" name="config_hibernationDeletesOatArtifactsEnabled"/>
  <java-symbol type="integer" name="config_defaultAnalogClockSecondsHandFps"/>

  <java-symbol type="color" name="tab_indicator_text_v4" />

+20 −4
Original line number Diff line number Diff line
@@ -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();
    }