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

Commit 5d5c0ac6 authored by Alexandr Shabalin's avatar Alexandr Shabalin Committed by Android (Google) Code Review
Browse files

Merge "Check user volume adjustment restrictions only once." into main

parents 198f1343 8988888f
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import static android.media.RouteListingPreference.ACTION_TRANSFER_MEDIA;
import static android.media.RouteListingPreference.EXTRA_ROUTE_ID;
import static android.provider.Settings.ACTION_BLUETOOTH_SETTINGS;

import static com.android.media.flags.Flags.avoidBinderCallsDuringRender;

import android.annotation.CallbackExecutor;
import android.app.AlertDialog;
import android.app.KeyguardManager;
@@ -173,6 +175,7 @@ public class MediaSwitchingController
    @NonNull private MediaOutputColorScheme mMediaOutputColorScheme;
    @NonNull private MediaOutputColorSchemeLegacy mMediaOutputColorSchemeLegacy;
    private boolean mIsGroupListCollapsed = true;
    private boolean mHasAdjustVolumeUserRestriction = false;

    public enum BroadcastNotifyDialog {
        ACTION_FIRST_LAUNCH,
@@ -276,6 +279,9 @@ public class MediaSwitchingController
        if (enableInputRouting()) {
            mInputRouteManager.registerCallback(mInputDeviceCallback);
        }
        if (avoidBinderCallsDuringRender()) {
            mHasAdjustVolumeUserRestriction = checkIfAdjustVolumeRestrictionEnforced();
        }
    }

    public boolean isRefreshing() {
@@ -1010,6 +1016,13 @@ public class MediaSwitchingController
    }

    boolean hasAdjustVolumeUserRestriction() {
        if (avoidBinderCallsDuringRender()) {
            return mHasAdjustVolumeUserRestriction;
        }
        return checkIfAdjustVolumeRestrictionEnforced();
    }

    private boolean checkIfAdjustVolumeRestrictionEnforced() {
        if (RestrictedLockUtilsInternal.checkIfRestrictionEnforced(
                mContext, UserManager.DISALLOW_ADJUST_VOLUME, UserHandle.myUserId()) != null) {
            return true;