Fix the IllegalStateException problem.
RemoteCallbackList sychronizes on RemoteCallbackList.mInterfaces for the following methods: RemoteCallbackList.register RemoteCallbackList.unregister RemoteCallbackList.beginBroadcast (creates a copy-on-write of the list, also under mLock) RemoteCallbackList.finishBroadcast (clears copy-on-write of the list, also under mLock) The last two are done under mLock. The following method doesn't need to hold RemoteCallbackList.mInterfaces because it only accesses an immutable copy of the list, not the modifiable list. RemoteCallbackList.getBroadcastItem (reads copy-on-write array, without mLock) The only requirement to be thread-safe with RemoteCallbackList seems to be to beginBroadcast+getBroadcastItem+finishBroadcast all in the same handler thread, so we put the beginBroadcast+getBroadcastItem+finishBroadcast into the handler to excute. Bug: 443904984 Flag: EXEMPT bugfix (cherry picked from https://android-review.googlesource.com/q/commit:89cf756c65a74ef92a40b6b4fe5475de3e96c4da) Merged-In: Ifeb1fbe5bff21b0bbd7060c0ddfbbf6b5fdcb28e Change-Id: Ifeb1fbe5bff21b0bbd7060c0ddfbbf6b5fdcb28e ATTENTION: Conflicts occurred while applying the patch. Please resolve conflict markers. Change-Id: If0cda3eea9dd8657d7c51d7cb890f16669014335
Loading
Please register or sign in to comment