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

Commit b2278d65 authored by John Spurlock's avatar John Spurlock
Browse files

An update on Downtime.

The update is that Downtime is obsolete.  Replaced by the
ability to define multiple named schedule calendars.

 - Make changes to ZenModeConfig to properly model manual
   and automatic rules.
 - Refactor the zen mode helper (and supporting classes) to
   properly handle / report multiple claims on zen mode.
   The "manual" rule (specified by the user in the UI) vs
   one or more automatic rules.
 - Automatic rules are still backed by condition providers,
   but the layering is now cleaner.  ConditionProviders is now
   completely generic, has no ties to zen mode.
 - Specifically, the new layering for zen mode (below noman) is:
   ZenModeHelper: Source of truth for zen state
     ZenModeFiltering: Subhelper dedicated to filtering rules.
     ZenModeConditions: Subhelper dedicated to managing automatic rules.
       ConditionProviders:  Underlying engine for reporting named boolean state.
 - Migration story for users with existing downtime config, migrated
   to a single new calendar named downtime.
 - For users with no existing downtime, two default calendars are created
   for weeknights + weekends (icu4j for all locales will be done in a followup).
 - Remove obsolete DowntimeConditionProvider/NextAlarmConditionProvider and tracking.
 - Clean up obsolete resources.
 - Add common zen summary description string computation.
 - Add proper noman wrappers for the new model.
 - Change the semantics of the global zen setting.  It is now read-only.  Setters
   must call noman, added a "reason" to all calls for better attribution.
 - Update zenmodepanel + volumedialog to the new model.
 - Display the one or more automatic rules in the new zen footer summary.
 - "Snooze" the automatic rules when the user explicitly turns zen off.

Bug: 20064962
Change-Id: Idd9deb865a6035ad0cfae660198dccb517e6d7cc
parent 64985063
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -76,12 +76,10 @@ interface INotificationManager
    boolean matchesCallFilter(in Bundle extras);
    boolean isSystemConditionProviderEnabled(String path);

    int getZenMode();
    ZenModeConfig getZenModeConfig();
    boolean setZenModeConfig(in ZenModeConfig config);
    oneway void setZenMode(int mode);
    boolean setZenModeConfig(in ZenModeConfig config, String reason);
    oneway void setZenMode(int mode, in Uri conditionId, String reason);
    oneway void notifyConditions(String pkg, in IConditionProvider provider, in Condition[] conditions);
    oneway void requestZenModeConditions(in IConditionListener callback, int relevance);
    oneway void setZenModeCondition(in Condition condition);
    oneway void setAutomaticZenModeConditions(in Uri[] conditionIds);
    Condition[] getAutomaticZenModeConditions();
}
+21 −10
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.SdkConstant;
import android.app.Notification.Builder;
import android.content.ComponentName;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
@@ -27,7 +28,7 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.StrictMode;
import android.os.UserHandle;
import android.service.notification.Condition;
import android.provider.Settings.Global;
import android.service.notification.IConditionListener;
import android.service.notification.ZenModeConfig;
import android.util.Log;
@@ -282,14 +283,26 @@ public class NotificationManager
    /**
     * @hide
     */
    public void setZenMode(int mode) {
    public void setZenMode(int mode, Uri conditionId, String reason) {
        INotificationManager service = getService();
        try {
            service.setZenMode(mode);
            service.setZenMode(mode, conditionId, reason);
        } catch (RemoteException e) {
        }
    }

    /**
     * @hide
     */
    public boolean setZenModeConfig(ZenModeConfig config, String reason) {
        INotificationManager service = getService();
        try {
            return service.setZenModeConfig(config, reason);
        } catch (RemoteException e) {
            return false;
        }
    }

    /**
     * @hide
     */
@@ -304,24 +317,22 @@ public class NotificationManager
    /**
     * @hide
     */
    public void setZenModeCondition(Condition exitCondition) {
    public int getZenMode() {
        INotificationManager service = getService();
        try {
            service.setZenModeCondition(exitCondition);
            return service.getZenMode();
        } catch (RemoteException e) {
        }
        return Global.ZEN_MODE_OFF;
    }

    /**
     * @hide
     */
    public Condition getZenModeCondition() {
    public ZenModeConfig getZenModeConfig() {
        INotificationManager service = getService();
        try {
            final ZenModeConfig config = service.getZenModeConfig();
            if (config != null) {
                return config.exitCondition;
            }
            return service.getZenModeConfig();
        } catch (RemoteException e) {
        }
        return null;
+21 −0
Original line number Diff line number Diff line
@@ -879,6 +879,15 @@ public final class Settings {
    public static final String ACTION_VOICE_CONTROL_DO_NOT_DISTURB_MODE =
            "android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE";

    /**
     * Activity Action: Show Zen Mode schedule rule configuration settings.
     *
     * @hide
     */
    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    public static final String ACTION_ZEN_MODE_SCHEDULE_RULE_SETTINGS
            = "android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS";

    /**
     * Activity Action: Show the regulatory information screen for the device.
     * <p>
@@ -7218,6 +7227,18 @@ public final class Settings {
            return "ZEN_MODE_OFF";
        }

        /** @hide */ public static boolean isValidZenMode(int value) {
            switch (value) {
                case Global.ZEN_MODE_OFF:
                case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
                case Global.ZEN_MODE_ALARMS:
                case Global.ZEN_MODE_NO_INTERRUPTIONS:
                    return true;
                default:
                    return false;
            }
        }

        /**
         * Opaque value, changes when persisted zen mode configuration changes.
         *
+468 −223

File changed.

Preview size limit exceeded, changes collapsed.

+3 −1
Original line number Diff line number Diff line
@@ -26,7 +26,9 @@ import android.os.Build;
 */
public class MetricsLogger implements MetricsConstants {
    // These constants are temporary, they should migrate to MetricsConstants.
    // next value is 144;
    // next value is 145;

    public static final int NOTIFICATION_ZEN_MODE_SCHEDULE_RULE = 144;

    public static void visible(Context context, int category) throws IllegalArgumentException {
        if (Build.IS_DEBUGGABLE && category == VIEW_UNKNOWN) {
Loading