AudioService: updates to death of focus requester
On the death of a focus requester that is in the focus stack: - keep track of event in AudioService event log - notify focus follower policies of the focus loss Bug: 155098568 Test: "adb shell dumpsys audio | grep died" after killing a focus client Test: atest com.google.android.gts.audio.AudioHostTest#testFocusChangeMediaToGuidance Change-Id: I455ca4c5292c609421b5ed37176ff94e756dd00b
This commit is contained in:
@@ -140,6 +140,10 @@ public class FocusRequester {
|
||||
return (mFocusDispatcher != null) && mFocusDispatcher.equals(fd);
|
||||
}
|
||||
|
||||
@NonNull String getPackageName() {
|
||||
return mPackageName;
|
||||
}
|
||||
|
||||
boolean hasSamePackage(@NonNull String pack) {
|
||||
return mPackageName.compareTo(pack) == 0;
|
||||
}
|
||||
|
||||
@@ -353,6 +353,13 @@ public class MediaFocusControl implements PlayerFocusEnforcer {
|
||||
FocusRequester fr = stackIterator.next();
|
||||
if(fr.hasSameBinder(cb)) {
|
||||
Log.i(TAG, "AudioFocus removeFocusStackEntryOnDeath(): removing entry for " + cb);
|
||||
mEventLogger.log(new AudioEventLogger.StringEvent(
|
||||
"focus requester:" + fr.getClientId()
|
||||
+ " in uid:" + fr.getClientUid()
|
||||
+ " pack:" + fr.getPackageName()
|
||||
+ " died"));
|
||||
notifyExtPolicyFocusLoss_syncAf(fr.toAudioFocusInfo(), false);
|
||||
|
||||
stackIterator.remove();
|
||||
// stack entry not used anymore, clear references
|
||||
fr.release();
|
||||
@@ -371,7 +378,7 @@ public class MediaFocusControl implements PlayerFocusEnforcer {
|
||||
* it has died.
|
||||
*/
|
||||
@GuardedBy("mAudioFocusLock")
|
||||
private void removeFocusEntryForExtPolicy(IBinder cb) {
|
||||
private void removeFocusEntryForExtPolicyOnDeath(IBinder cb) {
|
||||
if (mFocusOwnersForFocusPolicy.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -383,6 +390,11 @@ public class MediaFocusControl implements PlayerFocusEnforcer {
|
||||
final FocusRequester fr = owner.getValue();
|
||||
if (fr.hasSameBinder(cb)) {
|
||||
ownerIterator.remove();
|
||||
mEventLogger.log(new AudioEventLogger.StringEvent(
|
||||
"focus requester:" + fr.getClientId()
|
||||
+ " in uid:" + fr.getClientUid()
|
||||
+ " pack:" + fr.getPackageName()
|
||||
+ " died"));
|
||||
fr.release();
|
||||
notifyExtFocusPolicyFocusAbandon_syncAf(fr.toAudioFocusInfo());
|
||||
break;
|
||||
@@ -456,7 +468,7 @@ public class MediaFocusControl implements PlayerFocusEnforcer {
|
||||
public void binderDied() {
|
||||
synchronized(mAudioFocusLock) {
|
||||
if (mFocusPolicy != null) {
|
||||
removeFocusEntryForExtPolicy(mCb);
|
||||
removeFocusEntryForExtPolicyOnDeath(mCb);
|
||||
} else {
|
||||
removeFocusStackEntryOnDeath(mCb);
|
||||
if (mMultiAudioFocusEnabled && !mMultiAudioFocusList.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user