Loading media/java/android/media/MediaFocusControl.java +15 −9 Original line number Diff line number Diff line Loading @@ -1476,16 +1476,17 @@ public class MediaFocusControl implements OnFinished { * Set the new remote control receiver at the top of the RC focus stack. * Called synchronized on mAudioFocusLock, then mRCStack * precondition: mediaIntent != null * @return true if mRCStack was changed, false otherwise */ private void pushMediaButtonReceiver_syncAfRcs(PendingIntent mediaIntent, ComponentName target, IBinder token) { private boolean pushMediaButtonReceiver_syncAfRcs(PendingIntent mediaIntent, ComponentName target, IBinder token) { // already at top of stack? if (!mRCStack.empty() && mRCStack.peek().mMediaIntent.equals(mediaIntent)) { return; return false; } if (mAppOps.noteOp(AppOpsManager.OP_TAKE_MEDIA_BUTTONS, Binder.getCallingUid(), mediaIntent.getCreatorPackage()) != AppOpsManager.MODE_ALLOWED) { return; return false; } RemoteControlStackEntry rcse = null; boolean wasInsideStack = false; Loading Loading @@ -1513,6 +1514,9 @@ public class MediaFocusControl implements OnFinished { mEventHandler.sendMessage( mEventHandler.obtainMessage( MSG_PERSIST_MEDIABUTTONRECEIVER, 0, 0, target/*obj*/) ); } // RC stack was modified return true; } /** Loading Loading @@ -1856,12 +1860,13 @@ public class MediaFocusControl implements OnFinished { synchronized(mAudioFocusLock) { synchronized(mRCStack) { pushMediaButtonReceiver_syncAfRcs(mediaIntent, eventReceiver, token); if (pushMediaButtonReceiver_syncAfRcs(mediaIntent, eventReceiver, token)) { // new RC client, assume every type of information shall be queried checkUpdateRemoteControlDisplay_syncAfRcs(RC_INFO_ALL); } } } } /** * see AudioManager.unregisterMediaButtonIntent(PendingIntent mediaIntent) Loading Loading @@ -1925,6 +1930,7 @@ public class MediaFocusControl implements OnFinished { int rccId = RemoteControlClient.RCSE_ID_UNREGISTERED; synchronized(mAudioFocusLock) { synchronized(mRCStack) { boolean wasCurrentRcController = isCurrentRcController(mediaIntent); // store the new display information try { for (int index = mRCStack.size()-1; index >= 0; index--) { Loading Loading @@ -1971,9 +1977,9 @@ public class MediaFocusControl implements OnFinished { Log.e(TAG, "Wrong index accessing RC stack, lock error? ", e); } // if the eventReceiver is at the top of the stack // if the eventReceiver is now at the top of the stack but wasn't before // then check for potential refresh of the remote controls if (isCurrentRcController(mediaIntent)) { if (isCurrentRcController(mediaIntent) && !wasCurrentRcController) { checkUpdateRemoteControlDisplay_syncAfRcs(RC_INFO_ALL); } }//synchronized(mRCStack) Loading Loading
media/java/android/media/MediaFocusControl.java +15 −9 Original line number Diff line number Diff line Loading @@ -1476,16 +1476,17 @@ public class MediaFocusControl implements OnFinished { * Set the new remote control receiver at the top of the RC focus stack. * Called synchronized on mAudioFocusLock, then mRCStack * precondition: mediaIntent != null * @return true if mRCStack was changed, false otherwise */ private void pushMediaButtonReceiver_syncAfRcs(PendingIntent mediaIntent, ComponentName target, IBinder token) { private boolean pushMediaButtonReceiver_syncAfRcs(PendingIntent mediaIntent, ComponentName target, IBinder token) { // already at top of stack? if (!mRCStack.empty() && mRCStack.peek().mMediaIntent.equals(mediaIntent)) { return; return false; } if (mAppOps.noteOp(AppOpsManager.OP_TAKE_MEDIA_BUTTONS, Binder.getCallingUid(), mediaIntent.getCreatorPackage()) != AppOpsManager.MODE_ALLOWED) { return; return false; } RemoteControlStackEntry rcse = null; boolean wasInsideStack = false; Loading Loading @@ -1513,6 +1514,9 @@ public class MediaFocusControl implements OnFinished { mEventHandler.sendMessage( mEventHandler.obtainMessage( MSG_PERSIST_MEDIABUTTONRECEIVER, 0, 0, target/*obj*/) ); } // RC stack was modified return true; } /** Loading Loading @@ -1856,12 +1860,13 @@ public class MediaFocusControl implements OnFinished { synchronized(mAudioFocusLock) { synchronized(mRCStack) { pushMediaButtonReceiver_syncAfRcs(mediaIntent, eventReceiver, token); if (pushMediaButtonReceiver_syncAfRcs(mediaIntent, eventReceiver, token)) { // new RC client, assume every type of information shall be queried checkUpdateRemoteControlDisplay_syncAfRcs(RC_INFO_ALL); } } } } /** * see AudioManager.unregisterMediaButtonIntent(PendingIntent mediaIntent) Loading Loading @@ -1925,6 +1930,7 @@ public class MediaFocusControl implements OnFinished { int rccId = RemoteControlClient.RCSE_ID_UNREGISTERED; synchronized(mAudioFocusLock) { synchronized(mRCStack) { boolean wasCurrentRcController = isCurrentRcController(mediaIntent); // store the new display information try { for (int index = mRCStack.size()-1; index >= 0; index--) { Loading Loading @@ -1971,9 +1977,9 @@ public class MediaFocusControl implements OnFinished { Log.e(TAG, "Wrong index accessing RC stack, lock error? ", e); } // if the eventReceiver is at the top of the stack // if the eventReceiver is now at the top of the stack but wasn't before // then check for potential refresh of the remote controls if (isCurrentRcController(mediaIntent)) { if (isCurrentRcController(mediaIntent) && !wasCurrentRcController) { checkUpdateRemoteControlDisplay_syncAfRcs(RC_INFO_ALL); } }//synchronized(mRCStack) Loading