From 1ef714a28491962286a04f5ca45b9dd7ae580659 Mon Sep 17 00:00:00 2001 From: Johnson Hsieh Date: Mon, 1 Jun 2015 17:55:07 -0700 Subject: [PATCH] Updates AlarmClock intent API. Changes to the AlarmClock intent API based on feedback from Alarm team: 1. s/VOICE_CANCEL_ALARM/DISMISS_ALARM/g - "Cancel" is a bit unclear, so we're changing it to "dismiss". Also, remove "VOICE_" since we should also add support for this in multi-modal. 2. Removed DELETE_ALARM - we will likely not complete this for Android M. 3. Removed ALARM_SEARCH_MODE_NONE = "none". Instead, if EXTRA_ALARM_SEARCH_MODE is missing (and alarm data URI is not given), then: * If exactly one active alarm exists, it is dismissed. * If more than one active alarm exists, the user is prompted to choose the alarm to dismiss. 4. Add ALARM_SEARCH_MODE_LABEL, which allows searching for alarms by a (partially) matching label. 5. Add SNOOZE_ALARM for snoozing an alarm, with optional extra EXTRA_ALARM_SNOOZE_DURATION. Change-Id: I39502532e54d5f0fe51a8545a4c586615f5e5e89 --- api/current.txt | 15 +-- api/system-current.txt | 15 +-- core/java/android/provider/AlarmClock.java | 121 ++++++++++++--------- 3 files changed, 87 insertions(+), 64 deletions(-) diff --git a/api/current.txt b/api/current.txt index c9a8efb2360f7..9941326952305 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24479,13 +24479,14 @@ package android.provider { field public static final java.lang.String ACTION_SET_ALARM = "android.intent.action.SET_ALARM"; field public static final java.lang.String ACTION_SET_TIMER = "android.intent.action.SET_TIMER"; field public static final java.lang.String ACTION_SHOW_ALARMS = "android.intent.action.SHOW_ALARMS"; - field public static final java.lang.String ACTION_VOICE_CANCEL_ALARM = "android.intent.action.VOICE_CANCEL_ALARM"; - field public static final java.lang.String ACTION_VOICE_DELETE_ALARM = "android.intent.action.VOICE_DELETE_ALARM"; - field public static final java.lang.String ALARM_SEARCH_MODE_ALL = "all"; - field public static final java.lang.String ALARM_SEARCH_MODE_NEXT = "next"; - field public static final java.lang.String ALARM_SEARCH_MODE_NONE = "none"; - field public static final java.lang.String ALARM_SEARCH_MODE_TIME = "time"; - field public static final java.lang.String EXTRA_ALARM_SEARCH_MODE = "android.intent.extra.alarm.ALARM_SEARCH_MODE"; + field public static final java.lang.String ACTION_DISMISS_ALARM = "android.intent.action.DISMISS_ALARM"; + field public static final java.lang.String ACTION_SNOOZE_ALARM = "android.intent.action.SNOOZE_ALARM"; + field public static final java.lang.String ALARM_SEARCH_MODE_ALL = "android.all"; + field public static final java.lang.String ALARM_SEARCH_MODE_LABEL = "android.label"; + field public static final java.lang.String ALARM_SEARCH_MODE_NEXT = "android.next"; + field public static final java.lang.String ALARM_SEARCH_MODE_TIME = "android.time"; + field public static final java.lang.String EXTRA_ALARM_SEARCH_MODE = "android.intent.extra.alarm.SEARCH_MODE"; + field public static final java.lang.String EXTRA_ALARM_SNOOZE_DURATION = "android.intent.extra.alarm.SNOOZE_DURATION"; field public static final java.lang.String EXTRA_DAYS = "android.intent.extra.alarm.DAYS"; field public static final java.lang.String EXTRA_HOUR = "android.intent.extra.alarm.HOUR"; field public static final java.lang.String EXTRA_IS_PM = "android.intent.extra.alarm.IS_PM"; diff --git a/api/system-current.txt b/api/system-current.txt index 2f26891769dc4..6206c744fcae6 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -26409,13 +26409,14 @@ package android.provider { field public static final java.lang.String ACTION_SET_ALARM = "android.intent.action.SET_ALARM"; field public static final java.lang.String ACTION_SET_TIMER = "android.intent.action.SET_TIMER"; field public static final java.lang.String ACTION_SHOW_ALARMS = "android.intent.action.SHOW_ALARMS"; - field public static final java.lang.String ACTION_VOICE_CANCEL_ALARM = "android.intent.action.VOICE_CANCEL_ALARM"; - field public static final java.lang.String ACTION_VOICE_DELETE_ALARM = "android.intent.action.VOICE_DELETE_ALARM"; - field public static final java.lang.String ALARM_SEARCH_MODE_ALL = "all"; - field public static final java.lang.String ALARM_SEARCH_MODE_NEXT = "next"; - field public static final java.lang.String ALARM_SEARCH_MODE_NONE = "none"; - field public static final java.lang.String ALARM_SEARCH_MODE_TIME = "time"; - field public static final java.lang.String EXTRA_ALARM_SEARCH_MODE = "android.intent.extra.alarm.ALARM_SEARCH_MODE"; + field public static final java.lang.String ACTION_DISMISS_ALARM = "android.intent.action.DISMISS_ALARM"; + field public static final java.lang.String ACTION_SNOOZE_ALARM = "android.intent.action.SNOOZE_ALARM"; + field public static final java.lang.String ALARM_SEARCH_MODE_ALL = "android.all"; + field public static final java.lang.String ALARM_SEARCH_MODE_LABEL = "android.label"; + field public static final java.lang.String ALARM_SEARCH_MODE_NEXT = "android.next"; + field public static final java.lang.String ALARM_SEARCH_MODE_TIME = "android.time"; + field public static final java.lang.String EXTRA_ALARM_SEARCH_MODE = "android.intent.extra.alarm.SEARCH_MODE"; + field public static final java.lang.String EXTRA_ALARM_SNOOZE_DURATION = "android.intent.extra.alarm.SNOOZE_DURATION"; field public static final java.lang.String EXTRA_DAYS = "android.intent.extra.alarm.DAYS"; field public static final java.lang.String EXTRA_HOUR = "android.intent.extra.alarm.HOUR"; field public static final java.lang.String EXTRA_IS_PM = "android.intent.extra.alarm.IS_PM"; diff --git a/core/java/android/provider/AlarmClock.java b/core/java/android/provider/AlarmClock.java index 25a35e1358e7f..be372933a48ad 100644 --- a/core/java/android/provider/AlarmClock.java +++ b/core/java/android/provider/AlarmClock.java @@ -50,7 +50,7 @@ public final class AlarmClock { * {@link android.app.Activity#isVoiceInteraction}, and if true, the implementation should * report a deeplink of the created/enabled alarm using * {@link android.app.VoiceInteractor.CompleteVoiceRequest}. This allows follow-on voice actions - * such as {@link #ACTION_VOICE_CANCEL_ALARM} to cancel the alarm that was just enabled. + * such as {@link #ACTION_DISMISS_ALARM} to dismiss the alarm that was just enabled. *

*

Request parameters

* - * + *

* * @see #ALARM_SEARCH_MODE_TIME * @see #ALARM_SEARCH_MODE_NEXT * @see #ALARM_SEARCH_MODE_ALL - * @see #ALARM_SEARCH_MODE_NONE - * @see #ACTION_VOICE_CANCEL_ALARM - * @see #ACTION_VOICE_DELETE_ALARM + * @see #ALARM_SEARCH_MODE_LABEL + * @see #ACTION_DISMISS_ALARM */ public static final String EXTRA_ALARM_SEARCH_MODE = - "android.intent.extra.alarm.ALARM_SEARCH_MODE"; + "android.intent.extra.alarm.SEARCH_MODE"; /** * Search for the alarm that is most closely matched by the search parameters @@ -193,35 +204,33 @@ public final class AlarmClock { * * @see #EXTRA_ALARM_SEARCH_MODE */ - public static final String ALARM_SEARCH_MODE_TIME = "time"; + public static final String ALARM_SEARCH_MODE_TIME = "android.time"; /** * Selects the alarm that will ring next, or the alarm that is currently ringing, if any. * * @see #EXTRA_ALARM_SEARCH_MODE */ - public static final String ALARM_SEARCH_MODE_NEXT = "next"; + public static final String ALARM_SEARCH_MODE_NEXT = "android.next"; /** * Selects all alarms. * * @see #EXTRA_ALARM_SEARCH_MODE */ - public static final String ALARM_SEARCH_MODE_ALL = "all"; + public static final String ALARM_SEARCH_MODE_ALL = "android.all"; /** - * No search mode specified. The implementation should ask the user to select a search mode - * using {@link android.app.VoiceInteractor.PickOptionRequest} and proceed with a voice flow to - * identify the alarm. + * Search by alarm label. Should return alarms that contain the word or phrase in given label. * * @see #EXTRA_ALARM_SEARCH_MODE */ - public static final String ALARM_SEARCH_MODE_NONE = "none"; + public static final String ALARM_SEARCH_MODE_LABEL = "android.label"; /** * Bundle extra: The AM/PM of the alarm. *

- * Used by {@link #ACTION_VOICE_CANCEL_ALARM} and {@link #ACTION_VOICE_DELETE_ALARM}. + * Used by {@link #ACTION_DISMISS_ALARM}. *

* This extra is optional and only used when {@link #EXTRA_ALARM_SEARCH_MODE} is set to * {@link #ALARM_SEARCH_MODE_TIME}. In this search mode, the {@link #EXTRA_IS_PM} is @@ -233,13 +242,25 @@ public final class AlarmClock { * The value is a {@link Boolean}, where false=AM and true=PM. *

* - * @see #ACTION_VOICE_CANCEL_ALARM - * @see #ACTION_VOICE_DELETE_ALARM + * @see #ACTION_DISMISS_ALARM * @see #EXTRA_HOUR * @see #EXTRA_MINUTES */ public static final String EXTRA_IS_PM = "android.intent.extra.alarm.IS_PM"; + + /** + * Bundle extra: The snooze duration of the alarm in minutes. + *

+ * Used by {@link #ACTION_SNOOZE_ALARM}. This extra is optional and the value is an + * {@link Integer} that specifies the duration in minutes for which to snooze the alarm. + *

+ * + * @see #ACTION_SNOOZE_ALARM + */ + public static final String EXTRA_ALARM_SNOOZE_DURATION = + "android.intent.extra.alarm.SNOOZE_DURATION"; + /** * Bundle extra: Weekdays for repeating alarm. *