package android.service.notification {
public class Condition implements android.os.Parcelable {
+ ctor public Condition(android.net.Uri, java.lang.String, java.lang.String, java.lang.String, int);
ctor public Condition(android.net.Uri, java.lang.String, java.lang.String, java.lang.String, int, int, int);
method public android.service.notification.Condition copy();
method public int describeContents();
method public final void notifyConditions(android.service.notification.Condition...);
method public android.os.IBinder onBind(android.content.Intent);
method public abstract void onConnected();
- method public abstract void onRequestConditions(int);
method public abstract void onSubscribe(android.net.Uri);
method public abstract void onUnsubscribe(android.net.Uri);
field public static final java.lang.String EXTRA_RULE_ID = "android.content.automatic.ruleId";
}
+package android.service.notification {
+
+ public abstract class ConditionProviderService extends android.app.Service {
+ method public void onRequestConditions(int);
+ }
+
+}
+
package android.test.mock {
public deprecated class MockPackageManager extends android.content.pm.PackageManager {
package android.service.notification {
public class Condition implements android.os.Parcelable {
+ ctor public Condition(android.net.Uri, java.lang.String, java.lang.String, java.lang.String, int);
ctor public Condition(android.net.Uri, java.lang.String, java.lang.String, java.lang.String, int, int, int);
method public android.service.notification.Condition copy();
method public int describeContents();
method public final void notifyConditions(android.service.notification.Condition...);
method public android.os.IBinder onBind(android.content.Intent);
method public abstract void onConnected();
- method public abstract void onRequestConditions(int);
+ method public void onRequestConditions(int);
method public abstract void onSubscribe(android.net.Uri);
method public abstract void onUnsubscribe(android.net.Uri);
field public static final java.lang.String EXTRA_RULE_ID = "android.content.automatic.ruleId";
package android.service.notification {
public class Condition implements android.os.Parcelable {
+ ctor public Condition(android.net.Uri, java.lang.String, java.lang.String, java.lang.String, int);
ctor public Condition(android.net.Uri, java.lang.String, java.lang.String, java.lang.String, int, int, int);
method public android.service.notification.Condition copy();
method public int describeContents();
method public final void notifyConditions(android.service.notification.Condition...);
method public android.os.IBinder onBind(android.content.Intent);
method public abstract void onConnected();
- method public abstract void onRequestConditions(int);
method public abstract void onSubscribe(android.net.Uri);
method public abstract void onUnsubscribe(android.net.Uri);
field public static final java.lang.String EXTRA_RULE_ID = "android.content.automatic.ruleId";
}
+package android.service.notification {
+
+ public abstract class ConditionProviderService extends android.app.Service {
+ method public void onRequestConditions(int);
+ }
+
+}
+
package android.test.mock {
public deprecated class MockPackageManager extends android.content.pm.PackageManager {
package android.service.notification;
+import android.annotation.SystemApi;
import android.content.Context;
import android.net.Uri;
import android.os.Parcel;
import java.util.Objects;
/**
- * Condition information from condition providers.
+ * Condition information from condition providers. Used to tell the system to enter Do Not Disturb
+ * mode and request that the system exit Do Not Disturb mode.
*/
public class Condition implements Parcelable {
public static final int FLAG_RELEVANT_NOW = 1 << 0;
public static final int FLAG_RELEVANT_ALWAYS = 1 << 1;
+ /**
+ * The URI representing the condition being updated.
+ * See {@link android.app.AutomaticZenRule#getConditionId()}.
+ */
public final Uri id;
+
+ /**
+ * A summary of what the rule encoded in {@link #id} means when it is enabled. User visible
+ * if the state of the condition is {@link #STATE_TRUE}.
+ */
public final String summary;
+
+ /**
+ * Additional information about what the rule encoded in {@link #id} means when it is enabled.
+ * User visible if the state of the condition is {@link #STATE_TRUE}.
+ */
public final String line1;
+
+ /**
+ * Additional information about what the rule encoded in {@link #id} means when it is enabled.
+ * User visible if the state of the condition is {@link #STATE_TRUE}.
+ */
public final String line2;
- public final int icon;
+
+ /**
+ * The state of this condition. {@link #STATE_TRUE} will enable Do Not Disturb mode. Any other
+ * state will turn Do Not Disturb off for this rule. Note that Do Not Disturb might still be
+ * enabled globally if other conditions are in a {@link #STATE_TRUE} state.
+ */
public final int state;
+
+ @SystemApi
public final int flags;
+ @SystemApi
+ public final int icon;
+
+ public Condition(Uri id, String summary, String line1, String line2, int state) {
+ this(id, summary, line1, line2, -1, state, FLAG_RELEVANT_ALWAYS);
+ }
+ @SystemApi
public Condition(Uri id, String summary, String line1, String line2, int icon,
int state, int flags) {
if (id == null) throw new IllegalArgumentException("id is required");
package android.service.notification;
import android.annotation.SdkConstant;
+import android.annotation.SystemApi;
import android.app.INotificationManager;
import android.app.Service;
import android.content.ComponentName;
abstract public void onConnected();
/**
- * Called when the system wants to know the state of Conditions managed by this provider.
- *
- * Implementations should evaluate the state of all subscribed conditions, and provide updates
- * by calling {@link #notifyCondition(Condition)} or {@link #notifyConditions(Condition...)}.
- * @param relevance
+ * @removed
*/
- abstract public void onRequestConditions(int relevance);
+ @SystemApi
+ public void onRequestConditions(int relevance) {}
/**
* Called by the system when there is a new {@link Condition} to be managed by this provider.
}
/**
- * Informs the notification manager that the state of a Condition has changed.
+ * Informs the notification manager that the state of a Condition has changed. Use this method
+ * to put the system into Do Not Disturb mode or request that it exits Do Not Disturb mode. This
+ * call will be ignored unless there is an enabled {@link android.app.AutomaticZenRule} owned by
+ * service that has an {@link android.app.AutomaticZenRule#getConditionId()} equal to this
+ * {@link Condition#id}.
* @param condition the condition that has changed.
*/
public final void notifyCondition(Condition condition) {
}
/**
- * Informs the notification manager that the state of one or more Conditions has changed.
+ * Informs the notification manager that the state of one or more Conditions has changed. See
+ * {@link #notifyCondition(Condition)} for restrictions.
* @param conditions the changed conditions.
*/
public final void notifyConditions(Condition... conditions) {
}
@Override
- public void onRequestConditions(int relevance) {
- // by convention
- }
-
- @Override
public void onSubscribe(Uri conditionId) {
if (DEBUG) Slog.d(TAG, "onSubscribe " + conditionId);
mTime = ZenModeConfig.tryParseCountdownConditionId(conditionId);
}
@Override
- public void onRequestConditions(int relevance) {
- if (DEBUG) Slog.d(TAG, "onRequestConditions relevance=" + relevance);
- // does not advertise conditions
- }
-
- @Override
public void onSubscribe(Uri conditionId) {
if (DEBUG) Slog.d(TAG, "onSubscribe " + conditionId);
if (!ZenModeConfig.isValidEventConditionId(conditionId)) {
}
@Override
- public void onRequestConditions(int relevance) {
- if (DEBUG) Slog.d(TAG, "onRequestConditions relevance=" + relevance);
- // does not advertise conditions
- }
-
- @Override
public void onSubscribe(Uri conditionId) {
if (DEBUG) Slog.d(TAG, "onSubscribe " + conditionId);
if (!ZenModeConfig.isValidScheduleConditionId(conditionId)) {