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

Commit 6e4d0a23 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi Committed by android-build-merger
Browse files

Merge \\"Optimize audio playback restriction check\\" into nyc-mr1-dev am: 69c61666

am: 96a8ee3a

Change-Id: I0b78ebbfe10a56d2ce27af0b9317de93e29e4c13
parents 52396abf 96a8ee3a
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -181,10 +181,15 @@ public abstract class PlayerBase {
     * @return
     */
    boolean isRestricted_sync() {
        // check app ops
        if (mHasAppOpsPlayAudio) {
            return false;
        }
        // check bypass flag
        if ((mAttributes.getAllFlags() & AudioAttributes.FLAG_BYPASS_INTERRUPTION_POLICY) != 0) {
            return false;
        }
        return !mHasAppOpsPlayAudio;
        return true;
    }

    // Abstract methods a subclass needs to implement
+20 −16
Original line number Diff line number Diff line
@@ -505,27 +505,31 @@ public class SoundPool {
    }

    private boolean isRestricted() {
        IAudioService service = getService();
        // check app ops
        if (mHasAppOpsPlayAudio) {
            return false;
        }
        // check bypass flag
        if ((mAttributes.getAllFlags() & AudioAttributes.FLAG_BYPASS_INTERRUPTION_POLICY) != 0) {
            return false;
        }
        // check force audibility flag and camera restriction
        if ((mAttributes.getAllFlags() & AudioAttributes.FLAG_AUDIBILITY_ENFORCED) != 0) {
// FIXME: should also check usage when set properly by camera app
//          && (mAttributes.getUsage() == AudioAttributes.USAGE_ASSISTANCE_SONIFICATION)
            boolean cameraSoundForced = false;

            try {
            cameraSoundForced = service.isCameraSoundForced();
                cameraSoundForced = getService().isCameraSoundForced();
            } catch (RemoteException e) {
                Log.e(TAG, "Cannot access AudioService in isRestricted()");
            } catch (NullPointerException e) {
                Log.e(TAG, "Null AudioService in isRestricted()");
            }

        if (cameraSoundForced &&
                ((mAttributes.getAllFlags() & AudioAttributes.FLAG_AUDIBILITY_ENFORCED) != 0)
// FIXME: should also check usage when set properly by camera app
//                && (mAttributes.getUsage() == AudioAttributes.USAGE_ASSISTANCE_SONIFICATION)
                ) {
            if (cameraSoundForced) {
                return false;
            }

        if ((mAttributes.getAllFlags() & AudioAttributes.FLAG_BYPASS_INTERRUPTION_POLICY) != 0) {
            return false;
        }
        return !mHasAppOpsPlayAudio;
        return true;
    }

    private void updateAppOpsPlayAudio() {