Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit ccd79ce9 authored by Rambo Wang's avatar Rambo Wang
Browse files

CellularDataService: mCallbackMap is not thread safe

The HashMap object mCallbackMap in CellularDataService is a shared
resource between DataService's handler thread and CellularDataService's
handler thread. The update operations (put and remove) has
synchronization issue.

This CL fixes the issue by letting CellularDataService shares the
looper/handler thread of DataService (but keeping its own handler). And
thus all the operations of mCallbackMap are handled serializally in
DataService's handler thread.

One alternative solution is to  move all operations of the mCallbackMap into
CellularDataService's handler thread to make it thread-safe. But it's
difficult for close() method which need to clear mCallbackMap and
shutdown the handler thread.

The other alternative solution is to replace HashMap with ConcurrentHashMap
for mCallbackMap. This do make mCallbackMap thread-safe but do not
change the fact that it is still a shared resource between two threads.

Bug: 151103522
Test: atest FrameworksTelephonyTests
Change-Id: Id0f830b27b0b64e83a937b76575bd9497e56cd03
parent 3e5e1a76
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment