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

Commit cbcf902a authored by John Spurlock's avatar John Spurlock Committed by Android (Google) Code Review
Browse files

Merge "Zen: Support external condition providers."

parents 4b825c07 39581cc1
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -888,6 +888,15 @@ public final class Settings {
    public static final String ACTION_ZEN_MODE_SCHEDULE_RULE_SETTINGS
            = "android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS";

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

    /**
     * Activity Action: Show the regulatory information screen for the device.
     * <p>
+7 −4
Original line number Diff line number Diff line
@@ -654,8 +654,7 @@ public class ZenModeConfig implements Parcelable {
        }
        String summary = "";
        for (ZenRule automaticRule : config.automaticRules.values()) {
            if (automaticRule.enabled && !automaticRule.snoozing
                    && automaticRule.isTrueOrUnknown()) {
            if (automaticRule.isAutomaticActive()) {
                if (summary.isEmpty()) {
                    summary = automaticRule.name;
                } else {
@@ -745,9 +744,13 @@ public class ZenModeConfig implements Parcelable {
                    component);
        }

        public boolean isAutomaticActive() {
            return enabled && !snoozing && component != null && isTrueOrUnknown();
        }

        public boolean isTrueOrUnknown() {
            return condition == null || condition.state == Condition.STATE_TRUE
                    || condition.state == Condition.STATE_UNKNOWN;
            return condition != null && (condition.state == Condition.STATE_TRUE
                    || condition.state == Condition.STATE_UNKNOWN);
        }

        public static final Parcelable.Creator<ZenRule> CREATOR
+2 −1
Original line number Diff line number Diff line
@@ -26,9 +26,10 @@ import android.os.Build;
 */
public class MetricsLogger implements MetricsConstants {
    // These constants are temporary, they should migrate to MetricsConstants.
    // next value is 145;
    // next value is 146;

    public static final int NOTIFICATION_ZEN_MODE_SCHEDULE_RULE = 144;
    public static final int NOTIFICATION_ZEN_MODE_EXTERNAL_RULE = 145;

    public static void visible(Context context, int category) throws IllegalArgumentException {
        if (Build.IS_DEBUGGABLE && category == VIEW_UNKNOWN) {
+14 −0
Original line number Diff line number Diff line
@@ -142,6 +142,9 @@ public class ConditionProviders extends ManagedServices {
        } catch (RemoteException e) {
            // we tried
        }
        if (mCallback != null) {
            mCallback.onServiceAdded(info.component);
        }
    }

    @Override
@@ -246,6 +249,16 @@ public class ConditionProviders extends ManagedServices {
        }
    }

    public IConditionProvider findConditionProvider(ComponentName component) {
        if (component == null) return null;
        for (ManagedServiceInfo service : mServices) {
            if (component.equals(service.component)) {
                return provider(service);
            }
        }
        return null;
    }

    public void ensureRecordExists(ComponentName component, Uri conditionId,
            IConditionProvider provider) {
        // constructed by convention, make sure the record exists...
@@ -378,6 +391,7 @@ public class ConditionProviders extends ManagedServices {

    public interface Callback {
        void onBootComplete();
        void onServiceAdded(ComponentName component);
        void onConditionChanged(Uri id, Condition condition);
        void onUserSwitched();
    }
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ import java.util.Date;

/** Built-in zen condition provider for simple time-based conditions */
public class CountdownConditionProvider extends SystemConditionProviderService {
    private static final String TAG = "CountdownConditions";
    private static final String TAG = "ConditionProviders";
    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);

    public static final ComponentName COMPONENT =
Loading