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

Commit 88f9d793 authored by Suprabh Shukla's avatar Suprabh Shukla
Browse files

Deprecate unsupported AlarmManager#set System API

This .set system API has many undesirable traits:
1. It accepts an interval, when providing any interval except 0 will
   result in an Exception.
2. It doesn't allow the caller to pass a tag to help identify the
   listener that may be involved in an issue.
3. The window length parameter is redundant as there are already better
   named APIs to use for windowed or exact alarms.
Using WINDOW_HEURISTIC as window length is an internal implementation
detail and its usage is not supported.

Test: atest CtsAlarmManagerTestCases:BasicApiTests

Bug: 141785404
Change-Id: Iaa0e4e914db6cd957885b431b8a1c1175afba13e
parent de1bae62
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -667,7 +667,7 @@ public class AlarmManager {
     * than supplying a PendingIntent to be sent when the alarm time is reached, this variant
     * supplies an {@link OnAlarmListener} instance that will be invoked at that time.
     * <p>
     * The OnAlarmListener {@link OnAlarmListener#onAlarm() onAlarm()} method will be
     * The OnAlarmListener's {@link OnAlarmListener#onAlarm() onAlarm()} method will be
     * invoked via the specified target Executor.
     *
     * <p>
@@ -919,8 +919,19 @@ 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.
     *
     * <p>The behavior of this API when {@code windowMillis < 0} is undefined.
     *
     * @deprecated Better alternative APIs exist for setting an alarm with this method:
     * <ul>
     *     <li>For alarms with {@code windowMillis > 0}, use
     *     {@link #setWindow(int, long, long, String, Executor, WorkSource, OnAlarmListener)}</li>
     *     <li>For alarms with {@code windowMillis = 0}, use
     *     {@link #setExact(int, long, String, Executor, WorkSource, OnAlarmListener)}</li>
     * </ul>
     *
     * @hide
     */
    @Deprecated
    @SystemApi
    @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
    public void set(@AlarmType int type, long triggerAtMillis, long windowMillis,
+1 −1
Original line number Diff line number Diff line
@@ -545,7 +545,7 @@ package android.app {
  public class AlarmManager {
    method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void set(int, long, long, long, @NonNull android.app.PendingIntent, @Nullable android.os.WorkSource);
    method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void set(int, long, long, long, @NonNull android.app.AlarmManager.OnAlarmListener, @Nullable android.os.Handler, @Nullable android.os.WorkSource);
    method @Deprecated @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void set(int, long, long, long, @NonNull android.app.AlarmManager.OnAlarmListener, @Nullable android.os.Handler, @Nullable android.os.WorkSource);
    method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void setExact(int, long, @Nullable String, @NonNull java.util.concurrent.Executor, @NonNull android.os.WorkSource, @NonNull android.app.AlarmManager.OnAlarmListener);
    method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void setExactAndAllowWhileIdle(int, long, @Nullable String, @NonNull java.util.concurrent.Executor, @Nullable android.os.WorkSource, @NonNull android.app.AlarmManager.OnAlarmListener);
    method @RequiresPermission(android.Manifest.permission.SCHEDULE_PRIORITIZED_ALARM) public void setPrioritized(int, long, long, @Nullable String, @NonNull java.util.concurrent.Executor, @NonNull android.app.AlarmManager.OnAlarmListener);