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

Commit 9704e127 authored by Francois Gaffie's avatar Francois Gaffie Committed by Eric Laurent
Browse files

AudioService: Focus: cleanup FocusOwner upon requestAudioFocus failure



When the focus is owned by an external audio policy, and when
a client's request fails, the FocusRequester dedicated Map is not
cleared.
As the client app may not call AudioManager#abandonAudioFocus (since
the requestAudioFocus failed), it leads to not only dumpsys side effects but
also it triggers upon client's focus binder died event, the call
of notifyExtFocusPolicyFocusAbandon_syncAf.

This CL fixes this issue by removing the FocusRequester when the request
fails, the same way it is already done on permanent loss of focus.

Test: build & boot

Signed-off-by: default avatarFrancois Gaffie <francois.gaffie@renault.com>
Change-Id: I4d1b216b606c8f73c9b68353723284d9e178297d
parent 094eafd4
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -625,7 +625,12 @@ public class MediaFocusControl implements PlayerFocusEnforcer {
                return;
            }
        }
        final FocusRequester fr = mFocusOwnersForFocusPolicy.get(afi.getClientId());
        final FocusRequester fr;
        if (requestResult == AudioManager.AUDIOFOCUS_REQUEST_FAILED) {
            fr = mFocusOwnersForFocusPolicy.remove(afi.getClientId());
        } else {
            fr = mFocusOwnersForFocusPolicy.get(afi.getClientId());
        }
        if (fr != null) {
            fr.dispatchFocusResultFromExtPolicy(requestResult);
        }