Add TelecomManager.placeCall

Places a new outgoing call using the system telecom service
with the specified parameters.

Making emergency calls using this method requires that the
method-caller is either the user-selected default dialer app
or preloaded system dialer app.

Requires that the caller have the
{@link android.Manifest.permission#CALL_PHONE} permission.

Bug: 20348183
Change-Id: Ieedb5628e8c6be25137944e7c3639dc1d9bc61df
This commit is contained in:
Yorke Lee
2015-04-23 12:32:36 -07:00
parent 8d505ff025
commit 3e56ba14cc
4 changed files with 41 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ package android.telecom;
import android.annotation.SystemApi;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.RemoteException;
@@ -1057,6 +1058,39 @@ public class TelecomManager {
}
}
/**
* Places a new outgoing call to the provided address using the system telecom service with
* the specified extras.
*
* This method is equivalent to placing an outgoing call using {@link Intent#ACTION_CALL},
* except that the outgoing call will always be sent via the system telecom service. If
* method-caller is either the user selected default dialer app or preloaded system dialer
* app, then emergency calls will also be allowed.
*
* Requires permission: {@link android.Manifest.permission#CALL_PHONE}
*
* Usage example:
* <pre>
* Uri uri = Uri.fromParts("tel", "12345", null);
* Bundle extras = new Bundle();
* extras.putBoolean(TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, true);
* telecomManager.placeCall(uri, extras);
* </pre>
*
* @param address The address to make the call to.
* @param extras Bundle of extras to use with the call.
*/
public void placeCall(Uri address, Bundle extras) {
ITelecomService service = getTelecomService();
if (service != null) {
try {
service.placeCall(address, extras, mContext.getOpPackageName());
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelecomService#placeCall", e);
}
}
}
private ITelecomService getTelecomService() {
return ITelecomService.Stub.asInterface(ServiceManager.getService(Context.TELECOM_SERVICE));
}