Loading apex/media/service/java/com/android/server/media/MediaCommunicationService.java +16 −15 Original line number Diff line number Diff line Loading @@ -79,7 +79,7 @@ public class MediaCommunicationService extends SystemService { final Executor mRecordExecutor = Executors.newSingleThreadExecutor(); @GuardedBy("mLock") final List<CallbackRecord> mCallbackRecords = new ArrayList<>(); final ArrayList<CallbackRecord> mCallbackRecords = new ArrayList<>(); final NotificationManager mNotificationManager; MediaSessionManager mSessionManager; Loading Loading @@ -150,8 +150,8 @@ public class MediaCommunicationService extends SystemService { return null; } List<Session2Token> getSession2TokensLocked(int userId) { List<Session2Token> list = new ArrayList<>(); ArrayList<Session2Token> getSession2TokensLocked(int userId) { ArrayList<Session2Token> list = new ArrayList<>(); if (userId == ALL.getIdentifier()) { int size = mUserRecords.size(); for (int i = 0; i < size; i++) { Loading Loading @@ -237,28 +237,29 @@ public class MediaCommunicationService extends SystemService { } void dispatchSession2Changed(int userId) { MediaParceledListSlice<Session2Token> allSession2Tokens; MediaParceledListSlice<Session2Token> userSession2Tokens; ArrayList<Session2Token> allSession2Tokens; ArrayList<Session2Token> userSession2Tokens; synchronized (mLock) { allSession2Tokens = new MediaParceledListSlice<>(getSession2TokensLocked(ALL.getIdentifier())); userSession2Tokens = new MediaParceledListSlice<>(getSession2TokensLocked(userId)); } allSession2Tokens.setInlineCountLimit(1); userSession2Tokens.setInlineCountLimit(1); allSession2Tokens = getSession2TokensLocked(ALL.getIdentifier()); userSession2Tokens = getSession2TokensLocked(userId); synchronized (mLock) { for (CallbackRecord record : mCallbackRecords) { if (record.mUserId == ALL.getIdentifier()) { try { record.mCallback.onSession2Changed(allSession2Tokens); MediaParceledListSlice<Session2Token> toSend = new MediaParceledListSlice<>(allSession2Tokens); toSend.setInlineCountLimit(0); record.mCallback.onSession2Changed(toSend); } catch (RemoteException e) { Log.w(TAG, "Failed to notify session2 tokens changed " + record); } } else if (record.mUserId == userId) { try { record.mCallback.onSession2Changed(userSession2Tokens); MediaParceledListSlice<Session2Token> toSend = new MediaParceledListSlice<>(userSession2Tokens); toSend.setInlineCountLimit(0); record.mCallback.onSession2Changed(toSend); } catch (RemoteException e) { Log.w(TAG, "Failed to notify session2 tokens changed " + record); } Loading Loading @@ -382,7 +383,7 @@ public class MediaCommunicationService extends SystemService { try { // Check that they can make calls on behalf of the user and get the final user id int resolvedUserId = handleIncomingUser(pid, uid, userId, null); List<Session2Token> result; ArrayList<Session2Token> result; synchronized (mLock) { result = getSession2TokensLocked(resolvedUserId); } Loading services/core/java/com/android/server/media/MediaSessionRecord.java +10 −9 Original line number Diff line number Diff line Loading @@ -52,7 +52,6 @@ import android.os.Process; import android.os.RemoteException; import android.os.ResultReceiver; import android.os.SystemClock; import android.text.TextUtils; import android.util.Log; import android.view.KeyEvent; Loading Loading @@ -643,22 +642,24 @@ public class MediaSessionRecord implements IBinder.DeathRecipient, MediaSessionR } private void pushQueueUpdate() { ParceledListSlice<QueueItem> parcelableQueue; ArrayList<QueueItem> toSend; synchronized (mLock) { if (mDestroyed) { return; } if (mQueue == null) { parcelableQueue = null; } else { parcelableQueue = new ParceledListSlice<>(mQueue); // Limit the size of initial Parcel to prevent binder buffer overflow // as onQueueChanged is an async binder call. parcelableQueue.setInlineCountLimit(1); toSend = new ArrayList<>(); if (mQueue != null) { toSend.ensureCapacity(mQueue.size()); toSend.addAll(mQueue); } } Collection<ISessionControllerCallbackHolder> deadCallbackHolders = null; for (ISessionControllerCallbackHolder holder : mControllerCallbackHolders) { ParceledListSlice<QueueItem> parcelableQueue = new ParceledListSlice<>(toSend); // Limit the size of initial Parcel to prevent binder buffer overflow // as onQueueChanged is an async binder call. parcelableQueue.setInlineCountLimit(1); try { holder.mCallback.onQueueChanged(parcelableQueue); } catch (DeadObjectException e) { Loading Loading
apex/media/service/java/com/android/server/media/MediaCommunicationService.java +16 −15 Original line number Diff line number Diff line Loading @@ -79,7 +79,7 @@ public class MediaCommunicationService extends SystemService { final Executor mRecordExecutor = Executors.newSingleThreadExecutor(); @GuardedBy("mLock") final List<CallbackRecord> mCallbackRecords = new ArrayList<>(); final ArrayList<CallbackRecord> mCallbackRecords = new ArrayList<>(); final NotificationManager mNotificationManager; MediaSessionManager mSessionManager; Loading Loading @@ -150,8 +150,8 @@ public class MediaCommunicationService extends SystemService { return null; } List<Session2Token> getSession2TokensLocked(int userId) { List<Session2Token> list = new ArrayList<>(); ArrayList<Session2Token> getSession2TokensLocked(int userId) { ArrayList<Session2Token> list = new ArrayList<>(); if (userId == ALL.getIdentifier()) { int size = mUserRecords.size(); for (int i = 0; i < size; i++) { Loading Loading @@ -237,28 +237,29 @@ public class MediaCommunicationService extends SystemService { } void dispatchSession2Changed(int userId) { MediaParceledListSlice<Session2Token> allSession2Tokens; MediaParceledListSlice<Session2Token> userSession2Tokens; ArrayList<Session2Token> allSession2Tokens; ArrayList<Session2Token> userSession2Tokens; synchronized (mLock) { allSession2Tokens = new MediaParceledListSlice<>(getSession2TokensLocked(ALL.getIdentifier())); userSession2Tokens = new MediaParceledListSlice<>(getSession2TokensLocked(userId)); } allSession2Tokens.setInlineCountLimit(1); userSession2Tokens.setInlineCountLimit(1); allSession2Tokens = getSession2TokensLocked(ALL.getIdentifier()); userSession2Tokens = getSession2TokensLocked(userId); synchronized (mLock) { for (CallbackRecord record : mCallbackRecords) { if (record.mUserId == ALL.getIdentifier()) { try { record.mCallback.onSession2Changed(allSession2Tokens); MediaParceledListSlice<Session2Token> toSend = new MediaParceledListSlice<>(allSession2Tokens); toSend.setInlineCountLimit(0); record.mCallback.onSession2Changed(toSend); } catch (RemoteException e) { Log.w(TAG, "Failed to notify session2 tokens changed " + record); } } else if (record.mUserId == userId) { try { record.mCallback.onSession2Changed(userSession2Tokens); MediaParceledListSlice<Session2Token> toSend = new MediaParceledListSlice<>(userSession2Tokens); toSend.setInlineCountLimit(0); record.mCallback.onSession2Changed(toSend); } catch (RemoteException e) { Log.w(TAG, "Failed to notify session2 tokens changed " + record); } Loading Loading @@ -382,7 +383,7 @@ public class MediaCommunicationService extends SystemService { try { // Check that they can make calls on behalf of the user and get the final user id int resolvedUserId = handleIncomingUser(pid, uid, userId, null); List<Session2Token> result; ArrayList<Session2Token> result; synchronized (mLock) { result = getSession2TokensLocked(resolvedUserId); } Loading
services/core/java/com/android/server/media/MediaSessionRecord.java +10 −9 Original line number Diff line number Diff line Loading @@ -52,7 +52,6 @@ import android.os.Process; import android.os.RemoteException; import android.os.ResultReceiver; import android.os.SystemClock; import android.text.TextUtils; import android.util.Log; import android.view.KeyEvent; Loading Loading @@ -643,22 +642,24 @@ public class MediaSessionRecord implements IBinder.DeathRecipient, MediaSessionR } private void pushQueueUpdate() { ParceledListSlice<QueueItem> parcelableQueue; ArrayList<QueueItem> toSend; synchronized (mLock) { if (mDestroyed) { return; } if (mQueue == null) { parcelableQueue = null; } else { parcelableQueue = new ParceledListSlice<>(mQueue); // Limit the size of initial Parcel to prevent binder buffer overflow // as onQueueChanged is an async binder call. parcelableQueue.setInlineCountLimit(1); toSend = new ArrayList<>(); if (mQueue != null) { toSend.ensureCapacity(mQueue.size()); toSend.addAll(mQueue); } } Collection<ISessionControllerCallbackHolder> deadCallbackHolders = null; for (ISessionControllerCallbackHolder holder : mControllerCallbackHolders) { ParceledListSlice<QueueItem> parcelableQueue = new ParceledListSlice<>(toSend); // Limit the size of initial Parcel to prevent binder buffer overflow // as onQueueChanged is an async binder call. parcelableQueue.setInlineCountLimit(1); try { holder.mCallback.onQueueChanged(parcelableQueue); } catch (DeadObjectException e) { Loading