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

Commit 15fab378 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "On STR_START, request audio focus for TV only" into pi-dev

parents c1acf200 cf89f6b3
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);
    }

}