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

Unverified Commit 529393de authored by Arian's avatar Arian
Browse files

Revert "ThemePicker: Properly update clock face setting"

This reverts commit 875b3314.

Change-Id: I04553047ec3159771d6bbcc1dc05da38ddca353f
parent 0b2f7a31
Loading
Loading
Loading
Loading
+26 −2
Original line number Diff line number Diff line
@@ -17,9 +17,13 @@ package com.android.customization.model.clock;

import android.content.ContentResolver;
import android.provider.Settings.Secure;
import android.text.TextUtils;

import com.android.customization.module.ThemesUserEventLogger;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * {@link CustomizationManager} for clock faces that implements apply by writing to secure settings.
 */
@@ -27,6 +31,8 @@ public class ClockManager extends BaseClockManager {

    // TODO: use constant from Settings.Secure
    static final String CLOCK_FACE_SETTING = "lock_screen_custom_clock_face";
    private static final String CLOCK_FIELD = "clock";
    private static final String TIMESTAMP_FIELD = "_applied_timestamp";
    private final ContentResolver mContentResolver;
    private final ThemesUserEventLogger mEventLogger;

@@ -39,7 +45,16 @@ public class ClockManager extends BaseClockManager {

    @Override
    protected void handleApply(Clockface option, Callback callback) {
        if (Secure.putString(mContentResolver, CLOCK_FACE_SETTING, option.getId())) {
        boolean stored;
        try {
            final JSONObject json = new JSONObject();
            json.put(CLOCK_FIELD, option.getId());
            json.put(TIMESTAMP_FIELD, System.currentTimeMillis());
            stored = Secure.putString(mContentResolver, CLOCK_FACE_SETTING, json.toString());
        } catch (JSONException ex) {
            stored = false;
        }
        if (stored) {
            mEventLogger.logClockApplied(option);
            callback.onSuccess();
        } else {
@@ -49,6 +64,15 @@ public class ClockManager extends BaseClockManager {

    @Override
    protected String lookUpCurrentClock() {
        return Secure.getString(mContentResolver, CLOCK_FACE_SETTING);
        final String value = Secure.getString(mContentResolver, CLOCK_FACE_SETTING);
        if (TextUtils.isEmpty(value)) {
            return value;
        }
        try {
            final JSONObject json = new JSONObject(value);
            return json.getString(CLOCK_FIELD);
        } catch (JSONException ex) {
            return value;
        }
    }
}