diff options
| author | TreeHugger Robot <treehugger-gerrit@google.com> | 2022-03-15 17:03:06 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2022-03-15 17:03:06 +0000 |
| commit | 96a7b9ee75f67cd717df20fb0c9769137f3a047d (patch) | |
| tree | c1127dd689e829cbc759fb775097673762f3f3b5 /core/java | |
| parent | e76e08874f05cf609066578bce87752ab35d5881 (diff) | |
| parent | 85dddfc3c6d77105eec3e34099ee52928db7cb4a (diff) | |
Merge "Use compat framework to gate session actions" into tm-dev
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/StatusBarManager.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/core/java/android/app/StatusBarManager.java b/core/java/android/app/StatusBarManager.java index 89854bbab3e8..150888ccb2d8 100644 --- a/core/java/android/app/StatusBarManager.java +++ b/core/java/android/app/StatusBarManager.java @@ -24,6 +24,9 @@ import android.annotation.RequiresPermission; import android.annotation.SystemApi; import android.annotation.SystemService; import android.annotation.TestApi; +import android.app.compat.CompatChanges; +import android.compat.annotation.ChangeId; +import android.compat.annotation.EnabledSince; import android.compat.annotation.UnsupportedAppUsage; import android.content.ComponentName; import android.content.Context; @@ -39,6 +42,7 @@ import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; import android.os.ServiceManager; +import android.os.UserHandle; import android.util.Pair; import android.util.Slog; import android.view.View; @@ -520,6 +524,27 @@ public class StatusBarManager { private final Map<NearbyMediaDevicesProvider, NearbyMediaDevicesProviderWrapper> nearbyMediaDevicesProviderMap = new HashMap<>(); + /** + * Media controls based on {@link android.app.Notification.MediaStyle} notifications will have + * actions based on the media session's {@link android.media.session.PlaybackState}, rather than + * the notification's actions. + * + * These actions will be: + * - Play/Pause (depending on whether the current state is a playing state) + * - Previous (if declared), or a custom action if the slot is not reserved with + * {@code SESSION_EXTRAS_KEY_SLOT_RESERVATION_SKIP_TO_PREV} + * - Next (if declared), or a custom action if the slot is not reserved with + * {@code SESSION_EXTRAS_KEY_SLOT_RESERVATION_SKIP_TO_NEXT} + * - Custom action + * - Custom action + * + * @see androidx.media.utils.MediaConstants#SESSION_EXTRAS_KEY_SLOT_RESERVATION_SKIP_TO_PREV + * @see androidx.media.utils.MediaConstants#SESSION_EXTRAS_KEY_SLOT_RESERVATION_SKIP_TO_NEXT + */ + @ChangeId + @EnabledSince(targetSdkVersion = Build.VERSION_CODES.TIRAMISU) + private static final long MEDIA_CONTROL_SESSION_ACTIONS = 203800354L; + @UnsupportedAppUsage private Context mContext; private IStatusBarService mService; @@ -1127,6 +1152,20 @@ public class StatusBarManager { } } + /** + * Checks whether the given package should use session-based actions for its media controls. + * + * @param packageName App posting media controls + * @param userId Current user ID + * @return true if the app supports session actions + * + * @hide + */ + public static boolean useMediaSessionActionsForApp(String packageName, int userId) { + UserHandle handle = UserHandle.getUserHandleForUid(userId); + return CompatChanges.isChangeEnabled(MEDIA_CONTROL_SESSION_ACTIONS, packageName, handle); + } + /** @hide */ public static String windowStateToString(int state) { if (state == WINDOW_STATE_HIDING) return "WINDOW_STATE_HIDING"; |
