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

Commit 72291c20 authored by Toshiki Kikuchi's avatar Toshiki Kikuchi
Browse files

Add config_quickSettingsShowMediaPlayer

This CL adds config_quickSettingsShowMediaPlayer as a device resource
value to control the media controls support.
Currently, the state is controlled by the settings provider which we can
change at run-time so it’s useful for debugging.
But disabling the support by default (e.g., for ARC++) can be
challenging because we need to change the setting at runtime before
notification pipeline uses it, which results in a race condition.
Therefore, we need a compile-time value for it.

Note: I believe we can deprecate the settings provider one with this new
way. But in order to fix the ARC tests issues asap and to cherry-pick CL
to downstream branches easily, I would like to keep the deprecation task
out of scope for this CL.

Flag: NONE
Bug: 314876656
Bug: 192412820
Bug: 314889864
Bug: 314889882
Bug: 314886766
Test: m
Test: v2/arc-eng/tast_critical
Change-Id: Ic87edfadfa49d8d287f6514c554b8c881f8018f3
parent 88fc7c7b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -6856,4 +6856,7 @@
    <!-- Whether the View-based scroll haptic feedback implementation is enabled for
         {@link InputDevice#SOURCE_ROTARY_ENCODER}s. -->
    <bool name="config_viewBasedRotaryEncoderHapticsEnabled">false</bool>

    <!-- Whether the media player is shown on the quick settings -->
    <bool name="config_quickSettingsShowMediaPlayer">true</bool>
</resources>
+2 −0
Original line number Diff line number Diff line
@@ -5298,4 +5298,6 @@
  <java-symbol type="array" name="config_tvExternalInputLoggingDeviceBrandNames" />
  <java-symbol type="bool" name="config_viewRotaryEncoderHapticScrollFedbackEnabled" />
  <java-symbol type="bool" name="config_viewBasedRotaryEncoderHapticsEnabled" />

  <java-symbol type="bool" name="config_quickSettingsShowMediaPlayer" />
</resources>
+6 −4
Original line number Diff line number Diff line
@@ -83,17 +83,19 @@ public class Utils {

    /**
     * Allow the media player to be shown in the QS area, controlled by 2 flags.
     * Off by default, but can be disabled by setting to 0
     * On by default, but can be disabled by setting either flag to 0/false.
     */
    public static boolean useQsMediaPlayer(Context context) {
        // TODO(b/192412820): Replace SHOW_MEDIA_ON_QUICK_SETTINGS with compile-time value
        // Settings.Global.SHOW_MEDIA_ON_QUICK_SETTINGS can't be toggled at runtime, so simply
        // cache the first result we fetch and use that going forward. Do this to avoid unnecessary
        // binder calls which may happen on the critical path.
        if (sUseQsMediaPlayer == null) {
            int flag = Settings.Global.getInt(context.getContentResolver(),
            // TODO(b/192412820): Consolidate SHOW_MEDIA_ON_QUICK_SETTINGS into compile-time value.
            final int settingsFlag = Settings.Global.getInt(context.getContentResolver(),
                    Settings.Global.SHOW_MEDIA_ON_QUICK_SETTINGS, 1);
            sUseQsMediaPlayer = flag > 0;
            final boolean configFlag = context.getResources()
                    .getBoolean(com.android.internal.R.bool.config_quickSettingsShowMediaPlayer);
            sUseQsMediaPlayer = settingsFlag > 0 && configFlag;
        }
        return sUseQsMediaPlayer;
    }
+7 −3
Original line number Diff line number Diff line
@@ -160,7 +160,6 @@ public class PreferencesHelper implements RankingConfig {
    static final boolean DEFAULT_BUBBLES_ENABLED = true;
    @VisibleForTesting
    static final int DEFAULT_BUBBLE_PREFERENCE = BUBBLE_PREFERENCE_NONE;
    static final boolean DEFAULT_MEDIA_NOTIFICATION_FILTERING = true;

    private static final int NOTIFICATION_UPDATE_LOG_SUBTYPE_FROM_APP = 0;
    private static final int NOTIFICATION_UPDATE_LOG_SUBTYPE_FROM_USER = 1;
@@ -199,7 +198,7 @@ public class PreferencesHelper implements RankingConfig {
    private SparseBooleanArray mBubblesEnabled;
    private SparseBooleanArray mLockScreenShowNotifications;
    private SparseBooleanArray mLockScreenPrivateNotifications;
    private boolean mIsMediaNotificationFilteringEnabled = DEFAULT_MEDIA_NOTIFICATION_FILTERING;
    private boolean mIsMediaNotificationFilteringEnabled;
    // When modes_api flag is enabled, this value only tracks whether the current user has any
    // channels marked as "priority channels", but not necessarily whether they are permitted
    // to bypass DND by current zen policy.
@@ -223,6 +222,8 @@ public class PreferencesHelper implements RankingConfig {
        mAppOps = appOpsManager;
        mUserProfiles = userProfiles;
        mShowReviewPermissionsNotification = showReviewPermissionsNotification;
        mIsMediaNotificationFilteringEnabled = context.getResources()
                .getBoolean(R.bool.config_quickSettingsShowMediaPlayer);

        XML_VERSION = 4;

@@ -2687,8 +2688,11 @@ public class PreferencesHelper implements RankingConfig {

    /** Requests check of the feature setting for showing media notifications in quick settings. */
    public void updateMediaNotificationFilteringEnabled() {
        // TODO(b/192412820): Consolidate SHOW_MEDIA_ON_QUICK_SETTINGS into compile-time value.
        final boolean newValue = Settings.Global.getInt(mContext.getContentResolver(),
                Settings.Global.SHOW_MEDIA_ON_QUICK_SETTINGS, 1) > 0;
                Settings.Global.SHOW_MEDIA_ON_QUICK_SETTINGS, 1) > 0
                        && mContext.getResources().getBoolean(
                                R.bool.config_quickSettingsShowMediaPlayer);
        if (newValue != mIsMediaNotificationFilteringEnabled) {
            mIsMediaNotificationFilteringEnabled = newValue;
            updateConfig();