AudioManager.java -> AudioService.java (Java Binder)
AudioManager provides an interface in SDK for Audio service.
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
AudioManager(.java) calls functions of AudioService(.java) through Java Binder. AudioService itself is a hidden class in framework, its interface is not exposed in SDK directly.
AudioService.java -> AudioSystem.java + android_media_AudioSystem.cpp (JNI)
AudioService call functions of AudioSystem which is actually a container of JNI calls. The JNI calls are implemented in android_media_AudioSystem.cpp
android_media_AudioSystem.cpp
- Located under ../frameworks/base/core/jni. It is named according to its counterpart's full name, android.media.AudioSystem.
- Android.mk builds it as a part of module libandroid_runtime.so, which is loaded somewhere ( probably LoadClass.java ) - System.loadLibrary( "android_runtime" );
android_media_AudioSystem.cpp -> AudioSystem.cpp
The main purpose of android_media_AudioSystem.cpp is to conform with JNI. It delegates most of its jobs to av/media/libmedia/AudioSystem.cpp
AudioSystem.cpp -> AudioFlinger.cpp (C++ Binder )
AudioSystem.cpp acts as a low-level facade talking to other processes which provide the final implementation of audio service. The main one is AudioFlinger.
binder = sm->getService(String16("media.audio_flinger"));
gAudioFlinger = interface_cast<IAudioFlinger>(binder);