I\'m using aidl to answer call automagically, code as following:
ITelephony.Stub.asInterface(ServiceManager.getService(\"phone\"))
.answerRingingCall();
As said above these methods work only on System apps or framework apps from Android N on words. Still we can code for System app for ServiceManager usage as below using reflection of Android Code
@SuppressLint("PrivateApi")
public IMyAudioService getService(Context mContext) {
IMyAudioService mService = null;
Method method = null;
try {
method = Class.forName("android.os.ServiceManager").getMethod("getService", String.class);
IBinder binder = (IBinder) method.invoke(null, "YOUR_METHOD_NAME");
if (binder != null) {
mService = IMyAudioService .Stub.asInterface(binder);
}
} catch (NoSuchMethodException | ClassNotFoundException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
return mService;
}