Skip to content
Commit bab444a7 authored by Olivier Gaillard's avatar Olivier Gaillard
Browse files

Fix a bug with worksource propagation.

It is properly added to the parcel when Binder.setCallingWorkSource is
called manually, however it does not work when we call
Binder.setCallingWorkSource in Binder#ProxyTransactListener. The problem
is that we are adding the worksource to the parcel too early. It is
called before we add the work source to the thread local
(ThreadLocalWorkSource.setUid)...

What currently happens
- Client code calls an AIDL method
- AIDL generated code calls writeInterfaceToken which add the headers to the parcel (including the worksource)
- AIDL generated code calls Binder#transact
- Binder#transact calls ProxyTransactListener#onTransactStarted --> this code is calling Binder.setCallingWorkSource too late. After writeInterfaceToken is called which is where the code calls Binder.getCallingWorkSource and add it to the parcel.

To fix it, we udpate the parcel request headers if the work source has
been fixed when the listener is called.

Test: atest binderLibTest BinderWorkSourceTest BinderCallsStatsServiceTest android.os.ParcelTest BinderProxyTest
Bug: 123744028
Change-Id: Id1a4565c1f096d38bf1e423bea897da77ff84005
parent 79eed4bf
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