Question: I'm working with the android source, and want to add an additional method to the AUDIO\_SERVICE which is implemented in AudioManager.java. I have added the additional method to the AudioManager class, I now what to call that from and application.

I'm assuming that after adding the method I need to create/update and aidl file so the app knows about the interface

In the app I want to use it like:

```java
mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
mAudioManager.myNewFunction();

```

Any help would be greatly appreciated

Answer: 
You shouldn't update the android source code. I would do something like this: 

```
public class MyAudioManager {
    AudioManager myAudioManager;

    public MyAudioManager(Context context){
        this.myAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    }

    public void myAudioManagerMethod(){
        //Do your audio manager stuff here
    }

}

```

Then you can call your method like so: 

```
//Assuming you call this from an Activity
MyAudioManager mManager = new MyAudioManager(this); 
mManager.myAudioManagerMethod();

```

This allows you to get an instance of the `AudioManager` and allows you to interact with it as needed.
AudioManager as far as I know runs as part of the app process, not the system\_process. So you will need to modify [an AIDL file](http://androidxref.com/9.0.0_r3/xref/frameworks/base/media/java/android/media/IAudioService.aidl) if you want to add a method to AudioService and call it from AudioManager. But not if you are adding it only to AudioManager. 

Just add the method in AudioManager, and compile.
To have it "appear" when developing an app in Android Studio, you have to [generate the SDK from your ASOP env.](https://android.googlesource.com/platform/sdk/+/master/docs/howto_build_SDK.txt).  

Be sure to run "make update-api" in order to confirm a new public API method. 

Another option to SDK generation would be to use reflection in APP to access the new method. Not recommended

---