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

Commit 7d8a9aea authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Use public APIs for modifying automatic zen rules.

Bug: 22977552
Change-Id: I544f1462ad77cdeb33ccff3c9de11ea37df5505d
parent 1556f3c3
Loading
Loading
Loading
Loading
+47 −68
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package com.android.settings.notification;

import android.app.AlertDialog;
import android.app.AutomaticZenRule;
import android.app.NotificationManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
@@ -32,10 +34,8 @@ import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.provider.Settings.Global;
import android.service.notification.ConditionProviderService;
import android.service.notification.ZenModeConfig;
import android.service.notification.ZenModeConfig.ZenRule;
import android.util.Log;
import android.view.View;

@@ -45,11 +45,10 @@ import com.android.settings.notification.ManagedServiceSettings.Config;
import com.android.settings.notification.ZenRuleNameDialog.RuleInfo;

import java.lang.ref.WeakReference;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;

public class ZenModeAutomationSettings extends ZenModeSettingsBase {

@@ -93,27 +92,20 @@ public class ZenModeAutomationSettings extends ZenModeSettingsBase {
    }

    private void showAddRuleDialog() {
        new ZenRuleNameDialog(mContext, mServiceListing, null, mConfig.getAutomaticRuleNames()) {
        new ZenRuleNameDialog(mContext, mServiceListing, null, mRules) {
            @Override
            public void onOk(String ruleName, RuleInfo ri) {
                MetricsLogger.action(mContext, MetricsLogger.ACTION_ZEN_ADD_RULE_OK);
                final ZenRule rule = new ZenRule();
                rule.name = ruleName;
                rule.enabled = true;
                rule.zenMode = Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
                rule.conditionId = ri.defaultConditionId;
                rule.component = ri.serviceComponent;
                final ZenModeConfig newConfig = mConfig.copy();
                final String ruleId = newConfig.newRuleId();
                newConfig.automaticRules.put(ruleId, rule);
                if (setZenModeConfig(newConfig)) {
                    showRule(ri.settingsAction, ri.configurationActivity, ruleId, rule.name);
                AutomaticZenRule rule = new AutomaticZenRule(ruleName, ri.serviceComponent, ri.defaultConditionId,
                        NotificationManager.INTERRUPTION_FILTER_PRIORITY, true);
                if (setZenRule(rule)) {
                    showRule(ri.settingsAction, ri.configurationActivity, rule.getName());
                }
            }
        }.show();
    }

    private void showDeleteRuleDialog(final String ruleName, final String ruleId) {
    private void showDeleteRuleDialog(final String ruleName) {
        new AlertDialog.Builder(mContext)
                .setMessage(getString(R.string.zen_mode_delete_rule_confirmation, ruleName))
                .setNegativeButton(R.string.cancel, null)
@@ -122,29 +114,22 @@ public class ZenModeAutomationSettings extends ZenModeSettingsBase {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        MetricsLogger.action(mContext, MetricsLogger.ACTION_ZEN_DELETE_RULE_OK);
                        mConfig.automaticRules.remove(ruleId);
                        setZenModeConfig(mConfig);
                        removeZenRule(ruleName);
                    }
                })
                .show();
    }

    private void showRule(String settingsAction, ComponentName configurationActivity,
            String ruleId, String ruleName) {
        if (DEBUG) Log.d(TAG, "showRule " + ruleId + " name=" + ruleName);
            String ruleName) {
        if (DEBUG) Log.d(TAG, "showRule name=" + ruleName);
        mContext.startActivity(new Intent(settingsAction)
                .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
                .putExtra(ZenModeRuleSettingsBase.EXTRA_RULE_ID, ruleId));
                .putExtra(ZenModeRuleSettingsBase.EXTRA_RULE_NAME, ruleName));
    }

    private ZenRuleInfo[] sortedRules() {
        final ZenRuleInfo[] rt = new ZenRuleInfo[mConfig.automaticRules.size()];
        for (int i = 0; i < rt.length; i++) {
            final ZenRuleInfo zri = new ZenRuleInfo();
            zri.id = mConfig.automaticRules.keyAt(i);
            zri.rule = mConfig.automaticRules.valueAt(i);
            rt[i] = zri;
        }
    private AutomaticZenRule[] sortedRules() {
        final AutomaticZenRule[] rt = mRules.toArray(new AutomaticZenRule[mRules.size()]);
        Arrays.sort(rt, RULE_COMPARATOR);
        return rt;
    }
@@ -152,12 +137,10 @@ public class ZenModeAutomationSettings extends ZenModeSettingsBase {
    private void updateControls() {
        final PreferenceScreen root = getPreferenceScreen();
        root.removeAll();
        if (mConfig == null) return;
        final ZenRuleInfo[] sortedRules = sortedRules();
        for (int i = 0; i < sortedRules.length; i++) {
            final String id = sortedRules[i].id;
            final ZenRule rule = sortedRules[i].rule;
            root.addPreference(new ZenRulePreference(mContext, rule, id));
        if (mRules.size() == 0) return;
        final AutomaticZenRule[] sortedRules = sortedRules();
        for (AutomaticZenRule sortedRule : sortedRules) {
            root.addPreference(new ZenRulePreference(mContext, sortedRule));
        }
        final Preference p = new Preference(mContext);
        p.setIcon(R.drawable.ic_add);
@@ -179,10 +162,10 @@ public class ZenModeAutomationSettings extends ZenModeSettingsBase {
        return MetricsLogger.NOTIFICATION_ZEN_MODE_AUTOMATION;
    }

    private String computeRuleSummary(ZenRule rule, boolean isSystemRule,
    private String computeRuleSummary(AutomaticZenRule rule, boolean isSystemRule,
            CharSequence providerLabel) {
        final String mode = computeZenModeCaption(getResources(), rule.zenMode);
        final String ruleState = (rule == null || !rule.enabled)
        final String mode = computeZenModeCaption(getResources(), rule.getInterruptionFilter());
        final String ruleState = (rule == null || !rule.isEnabled())
                ? getString(R.string.switch_off_text)
                : getString(R.string.zen_mode_rule_summary_enabled_combination, mode);

@@ -203,11 +186,11 @@ public class ZenModeAutomationSettings extends ZenModeSettingsBase {

    private static String computeZenModeCaption(Resources res, int zenMode) {
        switch (zenMode) {
            case Global.ZEN_MODE_ALARMS:
            case NotificationManager.INTERRUPTION_FILTER_ALARMS:
                return res.getString(R.string.zen_mode_option_alarms);
            case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
            case NotificationManager.INTERRUPTION_FILTER_PRIORITY:
                return res.getString(R.string.zen_mode_option_important_interruptions);
            case Global.ZEN_MODE_NO_INTERRUPTIONS:
            case NotificationManager.INTERRUPTION_FILTER_NONE:
                return res.getString(R.string.zen_mode_option_no_interruptions);
            default:
                return null;
@@ -220,7 +203,7 @@ public class ZenModeAutomationSettings extends ZenModeSettingsBase {
            for (ServiceInfo service : services) {
                final RuleInfo ri = ZenModeExternalRuleSettings.getRuleInfo(service);
                if (ri != null && ri.serviceComponent != null
                        && ri.settingsAction == ZenModeExternalRuleSettings.ACTION) {
                        && Objects.equals(ri.settingsAction, ZenModeExternalRuleSettings.ACTION)) {
                    if (!mServiceListing.isEnabled(ri.serviceComponent)) {
                        Log.i(TAG, "Enabling external condition provider: " + ri.serviceComponent);
                        mServiceListing.setEnabled(ri.serviceComponent, true);
@@ -231,43 +214,37 @@ public class ZenModeAutomationSettings extends ZenModeSettingsBase {
    };

    // TODO: Sort by creation date, once that data is available.
    private static final Comparator<ZenRuleInfo> RULE_COMPARATOR = new Comparator<ZenRuleInfo>() {
    private static final Comparator<AutomaticZenRule> RULE_COMPARATOR =
            new Comparator<AutomaticZenRule>() {
        @Override
        public int compare(ZenRuleInfo lhs, ZenRuleInfo rhs) {
        public int compare(AutomaticZenRule lhs, AutomaticZenRule rhs) {
            return key(lhs).compareTo(key(rhs));
        }

        private String key(ZenRuleInfo zri) {
            final ZenRule rule = zri.rule;
            final int type = ZenModeConfig.isValidScheduleConditionId(rule.conditionId) ? 1
                    : ZenModeConfig.isValidEventConditionId(rule.conditionId) ? 2
        private String key(AutomaticZenRule rule) {
            final int type = ZenModeConfig.isValidScheduleConditionId(rule.getConditionId()) ? 1
                    : ZenModeConfig.isValidEventConditionId(rule.getConditionId()) ? 2
                    : 3;
            return type + rule.name;
            return type + rule.getName();
        }
    };

    private static class ZenRuleInfo {
        String id;
        ZenRule rule;
    }

    private class ZenRulePreference extends Preference {
        final String mName;
        final String mId;

        public ZenRulePreference(Context context, final ZenRule rule, final String id) {
        public ZenRulePreference(Context context, final AutomaticZenRule rule) {
            super(context);

            mName = rule.name;
            this.mId = id;
            mName = rule.getName();

            final boolean isSchedule = ZenModeConfig.isValidScheduleConditionId(rule.conditionId);
            final boolean isEvent = ZenModeConfig.isValidEventConditionId(rule.conditionId);
            final boolean isSchedule = ZenModeConfig.isValidScheduleConditionId(
                    rule.getConditionId());
            final boolean isEvent = ZenModeConfig.isValidEventConditionId(rule.getConditionId());
            final boolean isSystemRule = isSchedule || isEvent;

            try {
                ApplicationInfo info = mPm.getApplicationInfo(
                        rule.component.getPackageName(), 0);
                        rule.getOwner().getPackageName(), 0);
                LoadIconTask task = new LoadIconTask(this);
                task.execute(info);
                setSummary(computeRuleSummary(rule, isSystemRule, info.loadLabel(mPm)));
@@ -275,7 +252,7 @@ public class ZenModeAutomationSettings extends ZenModeSettingsBase {
                setIcon(R.drawable.ic_label);
            }

            setTitle(rule.name);
            setTitle(rule.getName());
            setPersistent(false);
            setOnPreferenceClickListener(new OnPreferenceClickListener() {
                @Override
@@ -283,7 +260,7 @@ public class ZenModeAutomationSettings extends ZenModeSettingsBase {
                    final String action = isSchedule ? ZenModeScheduleRuleSettings.ACTION
                            : isEvent ? ZenModeEventRuleSettings.ACTION
                            : ZenModeExternalRuleSettings.ACTION;
                    showRule(action, null, id, rule.name);
                    showRule(action, null, rule.getName());
                    return true;
                }
            });
@@ -295,13 +272,15 @@ public class ZenModeAutomationSettings extends ZenModeSettingsBase {
            super.onBindView(view);

            View v = view.findViewById(R.id.delete_zen_rule);
            if (v != null) {
                v.setOnClickListener(mDeleteListener);
            }
        }

        private final View.OnClickListener mDeleteListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showDeleteRuleDialog(mName, mId);
                showDeleteRuleDialog(mName);
            }
        };
    }
@@ -310,7 +289,7 @@ public class ZenModeAutomationSettings extends ZenModeSettingsBase {
        private final WeakReference<Preference> prefReference;

        public LoadIconTask(Preference pref) {
            prefReference = new WeakReference<Preference>(pref);
            prefReference = new WeakReference<>(pref);
        }

        @Override
@@ -320,7 +299,7 @@ public class ZenModeAutomationSettings extends ZenModeSettingsBase {

        @Override
        protected void onPostExecute(Drawable icon) {
            if (prefReference != null && icon != null) {
            if (icon != null) {
                final Preference pref = prefReference.get();
                pref.setIcon(icon);
            }
+3 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.settings.notification;

import android.app.AutomaticZenRule;
import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
import android.database.Cursor;
@@ -28,7 +29,6 @@ import android.provider.CalendarContract.Calendars;
import android.provider.Settings;
import android.service.notification.ZenModeConfig;
import android.service.notification.ZenModeConfig.EventInfo;
import android.service.notification.ZenModeConfig.ZenRule;

import com.android.internal.logging.MetricsLogger;
import com.android.settings.DropDownPreference;
@@ -53,8 +53,8 @@ public class ZenModeEventRuleSettings extends ZenModeRuleSettingsBase {
    private boolean mCreate;

    @Override
    protected boolean setRule(ZenRule rule) {
        mEvent = rule != null ? ZenModeConfig.tryParseEventConditionId(rule.conditionId)
    protected boolean setRule(AutomaticZenRule rule) {
        mEvent = rule != null ? ZenModeConfig.tryParseEventConditionId(rule.getConditionId())
                : null;
        return mEvent != null;
    }
+7 −6
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.settings.notification;

import android.app.Activity;
import android.app.AutomaticZenRule;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.ServiceInfo;
@@ -26,7 +27,6 @@ import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.service.notification.ConditionProviderService;
import android.service.notification.ZenModeConfig.ZenRule;
import android.util.Log;

import com.android.internal.logging.MetricsLogger;
@@ -44,7 +44,7 @@ public class ZenModeExternalRuleSettings extends ZenModeRuleSettingsBase {
    private Preference mConfigure;

    @Override
    protected boolean setRule(ZenRule rule) {
    protected boolean setRule(AutomaticZenRule rule) {
        return rule != null;
    }

@@ -63,7 +63,7 @@ public class ZenModeExternalRuleSettings extends ZenModeRuleSettingsBase {
        addPreferencesFromResource(R.xml.zen_mode_external_rule_settings);
        final PreferenceScreen root = getPreferenceScreen();
        final ServiceInfo si = ServiceListing.findService(mContext,
                ZenModeAutomationSettings.CONFIG, mRule.component);
                ZenModeAutomationSettings.CONFIG, mRule.getOwner());
        if (DEBUG) Log.d(TAG, "ServiceInfo: " + si);
        final RuleInfo ri = getRuleInfo(si);
        if (DEBUG) Log.d(TAG, "RuleInfo: " + ri);
@@ -82,8 +82,9 @@ public class ZenModeExternalRuleSettings extends ZenModeRuleSettingsBase {
                @Override
                public boolean onPreferenceClick(Preference preference) {
                    Intent intent = new Intent().setComponent(ri.configurationActivity);
                    intent.putExtra(ConditionProviderService.EXTRA_RULE_NAME, mRule.name);
                    intent.putExtra(ConditionProviderService.EXTRA_CONDITION_ID, mRule.conditionId);
                    intent.putExtra(ConditionProviderService.EXTRA_RULE_NAME, mRule.getName());
                    intent.putExtra(ConditionProviderService.EXTRA_CONDITION_ID,
                            mRule.getConditionId());
                    startActivityForResult(intent, REQUEST_CODE_CONFIGURE);
                    return true;
                }
@@ -98,7 +99,7 @@ public class ZenModeExternalRuleSettings extends ZenModeRuleSettingsBase {
            if (resultCode == Activity.RESULT_OK && data != null) {
                final Uri conditionId =
                        data.getParcelableExtra(ConditionProviderService.EXTRA_CONDITION_ID);
                if (conditionId != null && !conditionId.equals(mRule.conditionId)) {
                if (conditionId != null && !conditionId.equals(mRule.getConditionId())) {
                    updateRule(conditionId);
                }
            }
+42 −37
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package com.android.settings.notification;

import android.app.AlertDialog;
import android.app.AutomaticZenRule;
import android.app.NotificationManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
@@ -27,9 +29,6 @@ import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceScreen;
import android.provider.Settings.Global;
import android.service.notification.ZenModeConfig;
import android.service.notification.ZenModeConfig.ZenRule;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
@@ -49,15 +48,15 @@ public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase
    protected static final String TAG = ZenModeSettingsBase.TAG;
    protected static final boolean DEBUG = ZenModeSettingsBase.DEBUG;

    public static final String EXTRA_RULE_ID = "rule_id";
    public static final String EXTRA_RULE_NAME = "rule_name";
    private static final String KEY_RULE_NAME = "rule_name";
    private static final String KEY_ZEN_MODE = "zen_mode";

    protected Context mContext;
    protected boolean mDisableListeners;
    protected ZenRule mRule;
    protected AutomaticZenRule mRule;
    protected String mName;

    private String mRuleId;
    private boolean mDeleting;
    private Preference mRuleName;
    private SwitchBar mSwitchBar;
@@ -65,7 +64,7 @@ public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase
    private Toast mEnabledToast;

    abstract protected void onCreateInternal();
    abstract protected boolean setRule(ZenRule rule);
    abstract protected boolean setRule(AutomaticZenRule rule);
    abstract protected String getZenModeDependency();
    abstract protected void updateControlsInternal();
    abstract protected int getEnabledToastText();
@@ -84,8 +83,8 @@ public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase
            return;
        }

        mRuleId = intent.getStringExtra(EXTRA_RULE_ID);
        if (DEBUG) Log.d(TAG, "mRuleId=" + mRuleId);
        mName = intent.getStringExtra(EXTRA_RULE_NAME);
        if (DEBUG) Log.d(TAG, "mName=" + mName);
        if (refreshRuleOrFinish()) {
            return;
        }
@@ -111,19 +110,19 @@ public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase
                getString(R.string.zen_mode_option_no_interruptions),
        });
        mZenMode.setEntryValues(new CharSequence[] {
                Integer.toString(Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS),
                Integer.toString(Global.ZEN_MODE_ALARMS),
                Integer.toString(Global.ZEN_MODE_NO_INTERRUPTIONS),
                Integer.toString(NotificationManager.INTERRUPTION_FILTER_PRIORITY),
                Integer.toString(NotificationManager.INTERRUPTION_FILTER_ALARMS),
                Integer.toString(NotificationManager.INTERRUPTION_FILTER_NONE),
        });
        mZenMode.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                if (mDisableListeners) return false;
                final int zenMode = Integer.parseInt((String) newValue);
                if (zenMode == mRule.zenMode) return false;
                if (zenMode == mRule.getInterruptionFilter()) return false;
                if (DEBUG) Log.d(TAG, "onPrefChange zenMode=" + zenMode);
                mRule.zenMode = zenMode;
                setZenModeConfig(mConfig);
                mRule.setInterruptionFilter(zenMode);
                setZenRule(mRule);
                return true;
            }
        });
@@ -159,12 +158,11 @@ public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase
        if (DEBUG) Log.d(TAG, "onSwitchChanged " + isChecked);
        if (mDisableListeners) return;
        final boolean enabled = isChecked;
        if (enabled == mRule.enabled) return;
        if (enabled == mRule.isEnabled()) return;
        MetricsLogger.action(mContext, MetricsLogger.ACTION_ZEN_ENABLE_RULE, enabled);
        if (DEBUG) Log.d(TAG, "onSwitchChanged enabled=" + enabled);
        mRule.enabled = enabled;
        mRule.snoozing = false;
        setZenModeConfig(mConfig);
        mRule.setEnabled(enabled);
        setZenRule(mRule);
        if (enabled) {
            final int toastText = getEnabledToastText();
            if (toastText != 0) {
@@ -179,10 +177,8 @@ public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase
    }

    protected void updateRule(Uri newConditionId) {
        mRule.conditionId = newConditionId;
        mRule.condition = null;
        mRule.snoozing = false;
        setZenModeConfig(mConfig);
        mRule.setConditionId(newConditionId);
        setZenRule(mRule);
    }

    @Override
@@ -215,20 +211,16 @@ public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase
    }

    private void showRuleNameDialog() {
        new ZenRuleNameDialog(mContext, null, mRule.name, mConfig.getAutomaticRuleNames()) {
        new ZenRuleNameDialog(mContext, null, mRule.getName(), mRules) {
            @Override
            public void onOk(String ruleName, RuleInfo type) {
                final ZenModeConfig newConfig = mConfig.copy();
                final ZenRule rule = newConfig.automaticRules.get(mRuleId);
                if (rule == null) return;
                rule.name = ruleName;
                setZenModeConfig(newConfig);
                renameZenRule(mRule.getName(), ruleName);
            }
        }.show();
    }

    private boolean refreshRuleOrFinish() {
        mRule = mConfig.automaticRules.get(mRuleId);
        mRule = getZenRule();
        if (DEBUG) Log.d(TAG, "mRule=" + mRule);
        if (!setRule(mRule)) {
            toastAndFinish();
@@ -239,15 +231,14 @@ public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase

    private void showDeleteRuleDialog() {
        final AlertDialog dialog = new AlertDialog.Builder(mContext)
                .setMessage(getString(R.string.zen_mode_delete_rule_confirmation, mRule.name))
                .setMessage(getString(R.string.zen_mode_delete_rule_confirmation, mRule.getName()))
                .setNegativeButton(R.string.cancel, null)
                .setPositiveButton(R.string.zen_mode_delete_rule_button, new OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        MetricsLogger.action(mContext, MetricsLogger.ACTION_ZEN_DELETE_RULE_OK);
                        mDeleting = true;
                        mConfig.automaticRules.remove(mRuleId);
                        setZenModeConfig(mConfig);
                        removeZenRule(mRule.getName());
                    }
                })
                .show();
@@ -266,17 +257,31 @@ public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase
    }

    private void updateRuleName() {
        getActivity().setTitle(mRule.name);
        mRuleName.setSummary(mRule.name);
        getActivity().setTitle(mRule.getName());
        mRuleName.setSummary(mRule.getName());
    }

    private AutomaticZenRule getZenRule() {
        return NotificationManager.from(mContext).getAutomaticZenRule(mName);
    }

    private boolean renameZenRule(String oldName, String newName) {
        final boolean success =
                NotificationManager.from(mContext).renameAutomaticZenRule(oldName, newName);
        if (success) {
            mName = newName;
        }
        maybeRefreshRules(success, true);
        return success;
    }

    private void updateControls() {
        mDisableListeners = true;
        updateRuleName();
        updateControlsInternal();
        mZenMode.setValue(Integer.toString(mRule.zenMode));
        mZenMode.setValue(Integer.toString(mRule.getInterruptionFilter()));
        if (mSwitchBar != null) {
            mSwitchBar.setChecked(mRule.enabled);
            mSwitchBar.setChecked(mRule.isEnabled());
        }
        mDisableListeners = false;
    }
+3 −3
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.settings.notification;
import static com.android.settings.notification.ZenModeScheduleDaysSelection.DAYS;

import android.app.AlertDialog;
import android.app.AutomaticZenRule;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.FragmentManager;
@@ -33,7 +34,6 @@ import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.service.notification.ZenModeConfig;
import android.service.notification.ZenModeConfig.ScheduleInfo;
import android.service.notification.ZenModeConfig.ZenRule;
import android.text.format.DateFormat;
import android.util.Log;
import android.widget.TimePicker;
@@ -62,8 +62,8 @@ public class ZenModeScheduleRuleSettings extends ZenModeRuleSettingsBase {
    private ScheduleInfo mSchedule;

    @Override
    protected boolean setRule(ZenRule rule) {
        mSchedule = rule != null ? ZenModeConfig.tryParseScheduleConditionId(rule.conditionId)
    protected boolean setRule(AutomaticZenRule rule) {
        mSchedule = rule != null ? ZenModeConfig.tryParseScheduleConditionId(rule.getConditionId())
                : null;
        return mSchedule != null;
    }
Loading