Loading media/java/android/media/AudioService.java +69 −53 Original line number Diff line number Diff line Loading @@ -5324,9 +5324,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished { synchronized(mAudioFocusLock) { synchronized(mRCStack) { // store the new display information Iterator<RemoteControlStackEntry> stackIterator = mRCStack.iterator(); while(stackIterator.hasNext()) { RemoteControlStackEntry rcse = stackIterator.next(); try { for (int index = mRCStack.size()-1; index >= 0; index--) { final RemoteControlStackEntry rcse = mRCStack.elementAt(index); if(rcse.mMediaIntent.equals(mediaIntent)) { // already had a remote control client? if (rcse.mRcClientDeathHandler != null) { Loading @@ -5350,8 +5350,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished { try { rcse.mRcClient.plugRemoteControlDisplay(mRcDisplay); } catch (RemoteException e) { Log.e(TAG, "Error connecting remote control display to client: "+e); e.printStackTrace(); Log.e(TAG, "Error connecting RCD to RCC in RCC registration",e); } } // 2/ monitor the new client's death Loading @@ -5368,14 +5367,19 @@ public class AudioService extends IAudioService.Stub implements OnFinished { rcse.mRcClientDeathHandler = rcdh; break; } }//for } catch (ArrayIndexOutOfBoundsException e) { // not expected to happen, indicates improper concurrent modification Log.e(TAG, "Wrong index accessing RC stack, lock error? ", e); } // if the eventReceiver is at the top of the stack // then check for potential refresh of the remote controls if (isCurrentRcController(mediaIntent)) { checkUpdateRemoteControlDisplay_syncAfRcs(RC_INFO_ALL); } } } }//synchronized(mRCStack) }//synchronized(mAudioFocusLock) return rccId; } Loading @@ -5387,9 +5391,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished { IRemoteControlClient rcClient) { synchronized(mAudioFocusLock) { synchronized(mRCStack) { Iterator<RemoteControlStackEntry> stackIterator = mRCStack.iterator(); while(stackIterator.hasNext()) { RemoteControlStackEntry rcse = stackIterator.next(); boolean topRccChange = false; try { for (int index = mRCStack.size()-1; index >= 0; index--) { final RemoteControlStackEntry rcse = mRCStack.elementAt(index); if ((rcse.mMediaIntent.equals(mediaIntent)) && rcClient.equals(rcse.mRcClient)) { // we found the IRemoteControlClient to unregister Loading @@ -5398,7 +5403,18 @@ public class AudioService extends IAudioService.Stub implements OnFinished { // reset the client-related fields rcse.mRcClient = null; rcse.mCallingPackageName = null; topRccChange = (index == mRCStack.size()-1); // there can only be one matching RCC in the RC stack, we're done break; } } } catch (ArrayIndexOutOfBoundsException e) { // not expected to happen, indicates improper concurrent modification Log.e(TAG, "Wrong index accessing RC stack, lock error? ", e); } if (topRccChange) { // no more RCC for the RCD, check for potential refresh of the remote controls checkUpdateRemoteControlDisplay_syncAfRcs(RC_INFO_ALL); } } } Loading Loading
media/java/android/media/AudioService.java +69 −53 Original line number Diff line number Diff line Loading @@ -5324,9 +5324,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished { synchronized(mAudioFocusLock) { synchronized(mRCStack) { // store the new display information Iterator<RemoteControlStackEntry> stackIterator = mRCStack.iterator(); while(stackIterator.hasNext()) { RemoteControlStackEntry rcse = stackIterator.next(); try { for (int index = mRCStack.size()-1; index >= 0; index--) { final RemoteControlStackEntry rcse = mRCStack.elementAt(index); if(rcse.mMediaIntent.equals(mediaIntent)) { // already had a remote control client? if (rcse.mRcClientDeathHandler != null) { Loading @@ -5350,8 +5350,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished { try { rcse.mRcClient.plugRemoteControlDisplay(mRcDisplay); } catch (RemoteException e) { Log.e(TAG, "Error connecting remote control display to client: "+e); e.printStackTrace(); Log.e(TAG, "Error connecting RCD to RCC in RCC registration",e); } } // 2/ monitor the new client's death Loading @@ -5368,14 +5367,19 @@ public class AudioService extends IAudioService.Stub implements OnFinished { rcse.mRcClientDeathHandler = rcdh; break; } }//for } catch (ArrayIndexOutOfBoundsException e) { // not expected to happen, indicates improper concurrent modification Log.e(TAG, "Wrong index accessing RC stack, lock error? ", e); } // if the eventReceiver is at the top of the stack // then check for potential refresh of the remote controls if (isCurrentRcController(mediaIntent)) { checkUpdateRemoteControlDisplay_syncAfRcs(RC_INFO_ALL); } } } }//synchronized(mRCStack) }//synchronized(mAudioFocusLock) return rccId; } Loading @@ -5387,9 +5391,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished { IRemoteControlClient rcClient) { synchronized(mAudioFocusLock) { synchronized(mRCStack) { Iterator<RemoteControlStackEntry> stackIterator = mRCStack.iterator(); while(stackIterator.hasNext()) { RemoteControlStackEntry rcse = stackIterator.next(); boolean topRccChange = false; try { for (int index = mRCStack.size()-1; index >= 0; index--) { final RemoteControlStackEntry rcse = mRCStack.elementAt(index); if ((rcse.mMediaIntent.equals(mediaIntent)) && rcClient.equals(rcse.mRcClient)) { // we found the IRemoteControlClient to unregister Loading @@ -5398,7 +5403,18 @@ public class AudioService extends IAudioService.Stub implements OnFinished { // reset the client-related fields rcse.mRcClient = null; rcse.mCallingPackageName = null; topRccChange = (index == mRCStack.size()-1); // there can only be one matching RCC in the RC stack, we're done break; } } } catch (ArrayIndexOutOfBoundsException e) { // not expected to happen, indicates improper concurrent modification Log.e(TAG, "Wrong index accessing RC stack, lock error? ", e); } if (topRccChange) { // no more RCC for the RCD, check for potential refresh of the remote controls checkUpdateRemoteControlDisplay_syncAfRcs(RC_INFO_ALL); } } } Loading