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

Commit cf89f6b3 authored by Powei Feng's avatar Powei Feng
Browse files

On STR_START, request audio focus for TV only

Bug: 79779046
Test: Manual
Change-Id: Ic44eb897ef755b25680122bdd505e38a5b072679
(cherry picked from commit 4745665d2d26c9d74752baf8ce1dc5414a07c7d0)
parent e26a3835
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -111,8 +111,14 @@ public class A2dpSinkStreamHandler extends Handler {
        }
        switch (message.what) {
            case SRC_STR_START:
                // Audio stream has started, stop it if we don't have focus.
                mStreamAvailable = true;
                // Always request audio focus if on TV.
                if (isTvDevice()) {
                    if (mAudioFocus == AudioManager.AUDIOFOCUS_NONE) {
                        requestAudioFocus();
                    }
                }
                // Audio stream has started, stop it if we don't have focus.
                if (mAudioFocus == AudioManager.AUDIOFOCUS_NONE) {
                    sendAvrcpPause();
                } else {
@@ -142,7 +148,7 @@ public class A2dpSinkStreamHandler extends Handler {
            case SRC_PLAY:
                // Remote play command.
                // If is an iot device gain focus and start avrcp updates.
                if (isIotDevice()) {
                if (isIotDevice() || isTvDevice()) {
                    if (mAudioFocus == AudioManager.AUDIOFOCUS_NONE) {
                        requestAudioFocus();
                    }
@@ -367,4 +373,9 @@ public class A2dpSinkStreamHandler extends Handler {
    private boolean isIotDevice() {
        return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_EMBEDDED);
    }

    private boolean isTvDevice() {
        return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK);
    }

}