ITelephony code를 이용하니 answer call code는 시스템 permission이 필요하더라구요
구글링으로 찾아 본 소스 중 keycode를 control 해서 쓰는 코드 (하단)
try {
Log.d(TAG, "execute input keycode headset hook");
Runtime.getRuntime().exec("input keyevent " +
Integer.toString(KeyEvent.KEYCODE_HEADSETHOOK));
} catch (IOException e) {
// Runtime.exec(String) had an I/O problem, try to fall back
Log.d(TAG, "send keycode headset hook intents");
String enforcedPerm = "android.permission.CALL_PRIVILEGED";
Intent btnDown = new Intent(Intent.ACTION_MEDIA_BUTTON).putExtra(
Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_HEADSETHOOK));
Intent btnUp = new Intent(Intent.ACTION_MEDIA_BUTTON).putExtra(
Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP,
KeyEvent.KEYCODE_HEADSETHOOK));
sendOrderedBroadcast(btnDown, enforcedPerm);
sendOrderedBroadcast(btnUp, enforcedPerm);
는 5.0 이하에서만 동작하는 것 같았습니다.
혹시 다른 방식을 아시는 분이 계실까요?ㅠㅠ
end call도 ITelephony로 동작 확인 하긴 했는데 다른 방식이 있으면 추천 부탁드립니다!