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
Loading
Please register or sign in to comment