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

Commit 4482010d authored by Christopher Tate's avatar Christopher Tate
Browse files

stopForeground(boolean) deprecation & docs

Tidy up the reference docs and the deprecated API discussion

Bug: 196934059
Test: m offline-sdk-docs
Change-Id: Iea9461d6b07207e7e136d59c9b896e4e7343d76c
parent da5f6825
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6749,6 +6749,7 @@ package android.app {
    field public static final int START_STICKY = 1; // 0x1
    field public static final int START_STICKY_COMPATIBILITY = 0; // 0x0
    field public static final int STOP_FOREGROUND_DETACH = 2; // 0x2
    field @Deprecated public static final int STOP_FOREGROUND_LEGACY = 0; // 0x0
    field public static final int STOP_FOREGROUND_REMOVE = 1; // 0x1
  }
+16 −3
Original line number Diff line number Diff line
@@ -314,6 +314,16 @@ public abstract class Service extends ContextWrapper implements ComponentCallbac
        ContentCaptureManager.ContentCaptureClient {
    private static final String TAG = "Service";

    /**
     * Selector for {@link #stopForeground(int)}:  equivalent to passing {@code false}
     * to the legacy API {@link #stopForeground(boolean)}.
     *
     * @deprecated Use {@link #STOP_FOREGROUND_DETACH} instead.  The legacy
     * behavior was inconsistent, leading to bugs around unpredictable results.
     */
    @Deprecated
    public static final int STOP_FOREGROUND_LEGACY = 0;

    /**
     * Selector for {@link #stopForeground(int)}: if supplied, the notification previously
     * supplied to {@link #startForeground} will be cancelled and removed from display.
@@ -329,6 +339,7 @@ public abstract class Service extends ContextWrapper implements ComponentCallbac

    /** @hide */
    @IntDef(flag = false, prefix = { "STOP_FOREGROUND_" }, value = {
            STOP_FOREGROUND_LEGACY,
            STOP_FOREGROUND_REMOVE,
            STOP_FOREGROUND_DETACH
    })
@@ -795,15 +806,17 @@ public abstract class Service extends ContextWrapper implements ComponentCallbac
     * Legacy version of {@link #stopForeground(int)}.
     * @param removeNotification If true, the {@link #STOP_FOREGROUND_REMOVE}
     * selector will be passed to {@link #stopForeground(int)}; otherwise
     * {@code zero} will be passed.
     * {@link #STOP_FOREGROUND_LEGACY} will be passed.
     * @see #stopForeground(int)
     * @see #startForeground(int, Notification)
     *
     * @deprecated use {@link #stopForeground(int)} instead.
     * @deprecated call {@link #stopForeground(int)} and pass either
     * {@link #STOP_FOREGROUND_REMOVE} or {@link #STOP_FOREGROUND_DETACH}
     * explicitly instead.
     */
    @Deprecated
    public final void stopForeground(boolean removeNotification) {
        stopForeground(removeNotification ? STOP_FOREGROUND_REMOVE : 0);
        stopForeground(removeNotification ? STOP_FOREGROUND_REMOVE : STOP_FOREGROUND_LEGACY);
    }

    /**