status_t Audiosystem::setstreamvolumeindex (audio_stream_type_t stream, int index, audio_devices_t device) {
Const sp<iaudiopolicyservice>& APS = Audiosystem::get_audio_policy_service ();//
if (APs = = 0) return permission_denied;
Return Aps->setstreamvolumeindex (stream, index, device); (1)
}
Virtual status_t Setstreamvolumeindex (audio_stream_type_t stream, int index, audio_devices_t device) {
Parcel data, reply;
Data.writeinterfacetoken (Iaudiopolicyservice::getinterfacedescriptor ());
Data.writeint32 (static_cast <uint32_t> (stream));
Data.writeint32 (index);
Data.writeint32 (static_cast <uint32_t> (device));
Remote ()->transact (Set_stream_volume, data, &reply);//(2)
return static_cast <status_t> (Reply.readint32 ());
}
I was tracking the volume setting problem is, from (1) to chase (2), do not know how to trace,
Grep-r Setstreamvolumeindex. Search Audiopolicyservice, there are also setstreamvolumeindex this function, it seems to be called here.
Print Log Discovery sure will come here, but how did the code get here? This requires us to understand the binder principle.
Such as: is the diagram between IBinder bprefbase iinterface INTERFACE.
With this figure, although it is not possible to see how the binder is implemented, we can approximate how the binder is used.
Analyze the flow of data with Setstreamvolumeindex.
Such as:
There is a key point, is Audiopolicyservice, is how to pass to the APS inside of the mremote inside, is through rewriting Interface_cast pass.
Android Framework Review (3) Binder utilization and IBinder bprefbase iinterface INTERFACE Relationship