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

Commit 467a6559 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use Settings.Secure values, not Global values"

parents 919334c0 b00cef30
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ abstract public class AbstractZenModePreferenceController extends
    }

    protected int getZenDuration() {
        return Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.ZEN_DURATION,
        return Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.ZEN_DURATION,
                0);
    }

@@ -125,8 +125,8 @@ abstract public class AbstractZenModePreferenceController extends
        private final Uri ZEN_MODE_URI = Settings.Global.getUriFor(Settings.Global.ZEN_MODE);
        private final Uri ZEN_MODE_CONFIG_ETAG_URI = Settings.Global.getUriFor(
                Settings.Global.ZEN_MODE_CONFIG_ETAG);
        private final Uri ZEN_MODE_DURATION_URI = Settings.Global.getUriFor(
                Settings.Global.ZEN_DURATION);
        private final Uri ZEN_MODE_DURATION_URI = Settings.Secure.getUriFor(
                Settings.Secure.ZEN_DURATION);

        private final Preference mPreference;

+3 −3
Original line number Diff line number Diff line
@@ -16,10 +16,10 @@

package com.android.settings.notification;

import static com.android.settings.notification.SettingPref.TYPE_GLOBAL;
import static com.android.settings.notification.SettingPref.TYPE_SECURE;

import android.content.Context;
import android.provider.Settings.Global;
import android.provider.Settings.Secure;

import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
@@ -33,7 +33,7 @@ public class ChargingSoundPreferenceController extends SettingPrefController {
            Lifecycle lifecycle) {
        super(context, parent, lifecycle);
        mPreference = new SettingPref(
            TYPE_GLOBAL, KEY_CHARGING_SOUNDS, Global.CHARGING_SOUNDS_ENABLED, DEFAULT_ON);
            TYPE_SECURE, KEY_CHARGING_SOUNDS, Secure.CHARGING_SOUNDS_ENABLED, DEFAULT_ON);
    }

    @Override
+8 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.Context;
import android.content.res.Resources;
import android.net.Uri;
import android.provider.Settings.Global;
import android.provider.Settings.Secure;
import android.provider.Settings.System;

import com.android.settings.SettingsPreferenceFragment;
@@ -34,6 +35,7 @@ import androidx.preference.TwoStatePreference;
public class SettingPref {
    public static final int TYPE_GLOBAL = 1;
    public static final int TYPE_SYSTEM = 2;
    public static final int TYPE_SECURE = 3;

    protected final int mType;
    private final String mKey;
@@ -132,6 +134,8 @@ public class SettingPref {
                return Global.getUriFor(setting);
            case TYPE_SYSTEM:
                return System.getUriFor(setting);
            case TYPE_SECURE:
                return Secure.getUriFor(setting);
        }
        throw new IllegalArgumentException();
    }
@@ -142,6 +146,8 @@ public class SettingPref {
                return Global.putInt(cr, setting, value);
            case TYPE_SYSTEM:
                return System.putInt(cr, setting, value);
            case TYPE_SECURE:
                return Secure.putInt(cr, setting, value);
        }
        throw new IllegalArgumentException();
    }
@@ -152,6 +158,8 @@ public class SettingPref {
                return Global.getInt(cr, setting, def);
            case TYPE_SYSTEM:
                return System.getInt(cr, setting, def);
            case TYPE_SECURE:
                return Secure.getInt(cr, setting, def);
        }
        throw new IllegalArgumentException();
    }
+2 −2
Original line number Diff line number Diff line
@@ -136,8 +136,8 @@ public class ZenModeBackend {
    }

    protected void saveVisualEffectsPolicy(int category, boolean suppress) {
        Settings.Global.putInt(mContext.getContentResolver(),
                Settings.Global.ZEN_SETTINGS_UPDATED, 1);
        Settings.Secure.putInt(mContext.getContentResolver(),
                Settings.Secure.ZEN_SETTINGS_UPDATED, 1);

        int suppressedEffects = getNewSuppressedEffects(suppress, category);
        savePolicy(mPolicy.priorityCategories, mPolicy.priorityCallSenders,
+2 −2
Original line number Diff line number Diff line
@@ -97,14 +97,14 @@ public class ZenModeButtonPreferenceController extends AbstractZenModePreference
    private void updateZenButtonOnClickListener() {
        int zenDuration = getZenDuration();
        switch (zenDuration) {
            case Settings.Global.ZEN_DURATION_PROMPT:
            case Settings.Secure.ZEN_DURATION_PROMPT:
                mZenButtonOn.setOnClickListener(v -> {
                    mMetricsFeatureProvider.action(mContext,
                            MetricsProto.MetricsEvent.ACTION_ZEN_TOGGLE_DND_BUTTON, false);
                    new SettingsEnableZenModeDialog().show(mFragment, TAG);
                });
                break;
            case Settings.Global.ZEN_DURATION_FOREVER:
            case Settings.Secure.ZEN_DURATION_FOREVER:
                mZenButtonOn.setOnClickListener(v -> {
                    mMetricsFeatureProvider.action(mContext,
                            MetricsProto.MetricsEvent.ACTION_ZEN_TOGGLE_DND_BUTTON, false);
Loading