Loading core/java/android/app/StatusBarManager.java +39 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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"; Loading data/etc/com.android.systemui.xml +3 −0 Original line number Diff line number Diff line Loading @@ -76,5 +76,8 @@ <permission name="android.permission.FORCE_STOP_PACKAGES" /> <permission name="android.permission.ACCESS_FPS_COUNTER" /> <permission name="android.permission.CHANGE_CONFIGURATION" /> <permission name="android.permission.LOG_COMPAT_CHANGE" /> <permission name="android.permission.READ_COMPAT_CHANGE_CONFIG" /> <permission name="android.permission.READ_DEVICE_CONFIG" /> </privapp-permissions> </permissions> packages/SystemUI/AndroidManifest.xml +5 −0 Original line number Diff line number Diff line Loading @@ -314,6 +314,11 @@ <!-- To change system captions state --> <uses-permission android:name="android.permission.SET_SYSTEM_AUDIO_CAPTION" /> <!-- Compat framework --> <uses-permission android:name="android.permission.LOG_COMPAT_CHANGE" /> <uses-permission android:name="android.permission.READ_COMPAT_CHANGE_CONFIG" /> <uses-permission android:name="android.permission.READ_DEVICE_CONFIG" /> <protected-broadcast android:name="com.android.settingslib.action.REGISTER_SLICE_RECEIVER" /> <protected-broadcast android:name="com.android.settingslib.action.UNREGISTER_SLICE_RECEIVER" /> <protected-broadcast android:name="com.android.settings.flashlight.action.FLASHLIGHT_CHANGED" /> Loading packages/SystemUI/src/com/android/systemui/flags/Flags.java +1 −1 Original line number Diff line number Diff line Loading @@ -145,7 +145,7 @@ public class Flags { /***************************************/ // 900 - media public static final BooleanFlag MEDIA_TAP_TO_TRANSFER = new BooleanFlag(900, true); public static final BooleanFlag MEDIA_SESSION_ACTIONS = new BooleanFlag(901, true); public static final BooleanFlag MEDIA_SESSION_ACTIONS = new BooleanFlag(901, false); public static final BooleanFlag MEDIA_SESSION_LAYOUT = new BooleanFlag(902, true); public static final BooleanFlag MEDIA_NEARBY_DEVICES = new BooleanFlag(903, true); public static final BooleanFlag MEDIA_MUTE_AWAIT = new BooleanFlag(904, true); Loading packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java +3 −6 Original line number Diff line number Diff line Loading @@ -137,7 +137,6 @@ public class MediaControlPanel { private MediaCarouselController mMediaCarouselController; private final MediaOutputDialogFactory mMediaOutputDialogFactory; private final FalsingManager mFalsingManager; private final MediaFlags mMediaFlags; // Used for swipe-to-dismiss logging. protected boolean mIsImpressed = false; Loading @@ -156,7 +155,7 @@ public class MediaControlPanel { Lazy<MediaDataManager> lazyMediaDataManager, MediaOutputDialogFactory mediaOutputDialogFactory, MediaCarouselController mediaCarouselController, FalsingManager falsingManager, MediaFlags mediaFlags, SystemClock systemClock) { FalsingManager falsingManager, SystemClock systemClock) { mContext = context; mBackgroundExecutor = backgroundExecutor; mActivityStarter = activityStarter; Loading @@ -167,7 +166,6 @@ public class MediaControlPanel { mMediaOutputDialogFactory = mediaOutputDialogFactory; mMediaCarouselController = mediaCarouselController; mFalsingManager = falsingManager; mMediaFlags = mediaFlags; mSystemClock = systemClock; loadDimens(); Loading Loading @@ -506,9 +504,8 @@ public class MediaControlPanel { List<MediaAction> actionIcons = data.getActions(); List<Integer> actionsWhenCollapsed = data.getActionsToShowInCompact(); // If the session actions flag is enabled, but we're still using the regular layout, use // the session actions anyways if (mMediaFlags.areMediaSessionActionsEnabled() && data.getSemanticActions() != null) { // If we got session actions, use those instead if (data.getSemanticActions() != null) { MediaButton semanticActions = data.getSemanticActions(); actionIcons = new ArrayList<MediaAction>(); Loading Loading
core/java/android/app/StatusBarManager.java +39 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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"; Loading
data/etc/com.android.systemui.xml +3 −0 Original line number Diff line number Diff line Loading @@ -76,5 +76,8 @@ <permission name="android.permission.FORCE_STOP_PACKAGES" /> <permission name="android.permission.ACCESS_FPS_COUNTER" /> <permission name="android.permission.CHANGE_CONFIGURATION" /> <permission name="android.permission.LOG_COMPAT_CHANGE" /> <permission name="android.permission.READ_COMPAT_CHANGE_CONFIG" /> <permission name="android.permission.READ_DEVICE_CONFIG" /> </privapp-permissions> </permissions>
packages/SystemUI/AndroidManifest.xml +5 −0 Original line number Diff line number Diff line Loading @@ -314,6 +314,11 @@ <!-- To change system captions state --> <uses-permission android:name="android.permission.SET_SYSTEM_AUDIO_CAPTION" /> <!-- Compat framework --> <uses-permission android:name="android.permission.LOG_COMPAT_CHANGE" /> <uses-permission android:name="android.permission.READ_COMPAT_CHANGE_CONFIG" /> <uses-permission android:name="android.permission.READ_DEVICE_CONFIG" /> <protected-broadcast android:name="com.android.settingslib.action.REGISTER_SLICE_RECEIVER" /> <protected-broadcast android:name="com.android.settingslib.action.UNREGISTER_SLICE_RECEIVER" /> <protected-broadcast android:name="com.android.settings.flashlight.action.FLASHLIGHT_CHANGED" /> Loading
packages/SystemUI/src/com/android/systemui/flags/Flags.java +1 −1 Original line number Diff line number Diff line Loading @@ -145,7 +145,7 @@ public class Flags { /***************************************/ // 900 - media public static final BooleanFlag MEDIA_TAP_TO_TRANSFER = new BooleanFlag(900, true); public static final BooleanFlag MEDIA_SESSION_ACTIONS = new BooleanFlag(901, true); public static final BooleanFlag MEDIA_SESSION_ACTIONS = new BooleanFlag(901, false); public static final BooleanFlag MEDIA_SESSION_LAYOUT = new BooleanFlag(902, true); public static final BooleanFlag MEDIA_NEARBY_DEVICES = new BooleanFlag(903, true); public static final BooleanFlag MEDIA_MUTE_AWAIT = new BooleanFlag(904, true); Loading
packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java +3 −6 Original line number Diff line number Diff line Loading @@ -137,7 +137,6 @@ public class MediaControlPanel { private MediaCarouselController mMediaCarouselController; private final MediaOutputDialogFactory mMediaOutputDialogFactory; private final FalsingManager mFalsingManager; private final MediaFlags mMediaFlags; // Used for swipe-to-dismiss logging. protected boolean mIsImpressed = false; Loading @@ -156,7 +155,7 @@ public class MediaControlPanel { Lazy<MediaDataManager> lazyMediaDataManager, MediaOutputDialogFactory mediaOutputDialogFactory, MediaCarouselController mediaCarouselController, FalsingManager falsingManager, MediaFlags mediaFlags, SystemClock systemClock) { FalsingManager falsingManager, SystemClock systemClock) { mContext = context; mBackgroundExecutor = backgroundExecutor; mActivityStarter = activityStarter; Loading @@ -167,7 +166,6 @@ public class MediaControlPanel { mMediaOutputDialogFactory = mediaOutputDialogFactory; mMediaCarouselController = mediaCarouselController; mFalsingManager = falsingManager; mMediaFlags = mediaFlags; mSystemClock = systemClock; loadDimens(); Loading Loading @@ -506,9 +504,8 @@ public class MediaControlPanel { List<MediaAction> actionIcons = data.getActions(); List<Integer> actionsWhenCollapsed = data.getActionsToShowInCompact(); // If the session actions flag is enabled, but we're still using the regular layout, use // the session actions anyways if (mMediaFlags.areMediaSessionActionsEnabled() && data.getSemanticActions() != null) { // If we got session actions, use those instead if (data.getSemanticActions() != null) { MediaButton semanticActions = data.getSemanticActions(); actionIcons = new ArrayList<MediaAction>(); Loading