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: Francois Gaffie <francois.gaffie@renault.com>
Change-Id: I4d1b216b606c8f73c9b68353723284d9e178297d
This commit is contained in:
Francois Gaffie
2020-04-14 14:14:02 +02:00
committed by Eric Laurent
parent 094eafd471
commit 9704e1275a

View File

@@ -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);
}