From 44fba3a53fc8d222934869db4884284317a75058 Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Wed, 9 Jun 2021 11:24:13 -0700 Subject: [PATCH] Update AlarmManager javadoc for S Beta 3 Sample partial output: https://screenshot.googleplex.com/4wey3a3y3jsoGcP Bug: 190625528 Test: build Test: m offline-sdk-docs && \ cd /android/sc-dev/out/target/common/docs/offline-sdk/ && \ python3 -m http.server 8000 && \ google-chrome http://localhost:8000/reference/android/app/AlarmManager.html#setExactAndAllowWhileIdle(int,%20long,%20android.app.PendingIntent) Change-Id: Ie106b03a1c20fa62b0023f82d2c3997b4e425d95 --- .../java/android/app/AlarmManager.java | 74 +++++++++++++++---- core/res/AndroidManifest.xml | 9 ++- 2 files changed, 67 insertions(+), 16 deletions(-) diff --git a/apex/jobscheduler/framework/java/android/app/AlarmManager.java b/apex/jobscheduler/framework/java/android/app/AlarmManager.java index 9fa7810ab155a..1efe5cb2f53e2 100644 --- a/apex/jobscheduler/framework/java/android/app/AlarmManager.java +++ b/apex/jobscheduler/framework/java/android/app/AlarmManager.java @@ -662,10 +662,19 @@ public class AlarmManager { * scheduled as exact. Applications are strongly discouraged from using exact * alarms unnecessarily as they reduce the OS's ability to minimize battery use. * - *

- * Starting with {@link Build.VERSION_CODES#S}, apps require the + *

Note: + * Starting with {@link Build.VERSION_CODES#S}, apps targeting SDK level 31 or higher + * need to request the * {@link Manifest.permission#SCHEDULE_EXACT_ALARM SCHEDULE_EXACT_ALARM} permission to use this - * API. + * API, unless the app is exempt from battery restrictions. + * The user and the system can revoke this permission via the special app access screen in + * Settings. + * + *

Note: + * Exact alarms should only be used for user-facing features. + * For more details, see + * Exact alarm permission. * * @param type type of alarm. * @param triggerAtMillis time in milliseconds that the alarm should go @@ -685,6 +694,7 @@ public class AlarmManager { * @see #ELAPSED_REALTIME_WAKEUP * @see #RTC * @see #RTC_WAKEUP + * @see Manifest.permission#SCHEDULE_EXACT_ALARM SCHEDULE_EXACT_ALARM */ @RequiresPermission(value = Manifest.permission.SCHEDULE_EXACT_ALARM, conditional = true) public void setExact(@AlarmType int type, long triggerAtMillis, PendingIntent operation) { @@ -701,10 +711,21 @@ public class AlarmManager { * invoked via the specified target Handler, or on the application's main looper * if {@code null} is passed as the {@code targetHandler} parameter. * - *

- * Starting with {@link Build.VERSION_CODES#S}, apps require the + *

Note: + * Starting with {@link Build.VERSION_CODES#S}, apps targeting SDK level 31 or higher + * need to request the * {@link Manifest.permission#SCHEDULE_EXACT_ALARM SCHEDULE_EXACT_ALARM} permission to use this - * API. + * API, unless the app is exempt from battery restrictions. + * The user and the system can revoke this permission via the special app access screen in + * Settings. + * + *

Note: + * Exact alarms should only be used for user-facing features. + * For more details, see + * Exact alarm permission. + * + * @see Manifest.permission#SCHEDULE_EXACT_ALARM SCHEDULE_EXACT_ALARM */ @RequiresPermission(value = Manifest.permission.SCHEDULE_EXACT_ALARM, conditional = true) public void setExact(@AlarmType int type, long triggerAtMillis, String tag, @@ -745,9 +766,21 @@ public class AlarmManager { * This method is like {@link #setExact(int, long, PendingIntent)}, but implies * {@link #RTC_WAKEUP}. * - *

- * Starting from API {@link Build.VERSION_CODES#S}, using this method requires the - * {@link Manifest.permission#SCHEDULE_EXACT_ALARM} permission. Alarms scheduled via this API + *

Note: + * Starting with {@link Build.VERSION_CODES#S}, apps targeting SDK level 31 or higher + * need to request the + * {@link Manifest.permission#SCHEDULE_EXACT_ALARM SCHEDULE_EXACT_ALARM} permission to use this + * API. + * The user and the system can revoke this permission via the special app access screen in + * Settings. + * + *

Note: + * Exact alarms should only be used for user-facing features. + * For more details, see + * Exact alarm permission. + * + *

Alarms scheduled via this API * will be allowed to start a foreground service even if the app is in the background. * * @param info @@ -764,6 +797,7 @@ public class AlarmManager { * @see android.content.Context#sendBroadcast * @see android.content.Context#registerReceiver * @see android.content.Intent#filterEquals + * @see Manifest.permission#SCHEDULE_EXACT_ALARM SCHEDULE_EXACT_ALARM */ @RequiresPermission(Manifest.permission.SCHEDULE_EXACT_ALARM) public void setAlarmClock(AlarmClockInfo info, PendingIntent operation) { @@ -1090,11 +1124,22 @@ public class AlarmManager { * device is idle it may take even more liberties with scheduling in order to optimize * for battery life.

* - *

- * Starting from API {@link Build.VERSION_CODES#S}, using this method requires the - * {@link Manifest.permission#SCHEDULE_EXACT_ALARM} permission, unless the app is exempt from - * battery restrictions. Alarms scheduled via this API will be allowed to start a foreground - * service even if the app is in the background. + *

Note: + * Starting with {@link Build.VERSION_CODES#S}, apps targeting SDK level 31 or higher + * need to request the + * {@link Manifest.permission#SCHEDULE_EXACT_ALARM SCHEDULE_EXACT_ALARM} permission to use this + * API, unless the app is exempt from battery restrictions. + * The user and the system can revoke this permission via the special app access screen in + * Settings. + * + *

Note: + * Exact alarms should only be used for user-facing features. + * For more details, see + * Exact alarm permission. + * + *

Alarms scheduled via this API + * will be allowed to start a foreground service even if the app is in the background. * * @param type type of alarm. * @param triggerAtMillis time in milliseconds that the alarm should go @@ -1114,6 +1159,7 @@ public class AlarmManager { * @see #ELAPSED_REALTIME_WAKEUP * @see #RTC * @see #RTC_WAKEUP + * @see Manifest.permission#SCHEDULE_EXACT_ALARM SCHEDULE_EXACT_ALARM */ @RequiresPermission(value = Manifest.permission.SCHEDULE_EXACT_ALARM, conditional = true) public void setExactAndAllowWhileIdle(@AlarmType int type, long triggerAtMillis, diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 50a242cab4812..27634df9c3430 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -4053,8 +4053,13 @@ -