Merge "Add permission check for old call handover apis."

This commit is contained in:
Sanket Padawe
2018-01-12 23:50:40 +00:00
committed by Gerrit Code Review
4 changed files with 13 additions and 4 deletions

View File

@@ -1408,7 +1408,7 @@ public final class Call {
* @param extras Bundle containing extra information associated with the event. * @param extras Bundle containing extra information associated with the event.
*/ */
public void sendCallEvent(String event, Bundle extras) { public void sendCallEvent(String event, Bundle extras) {
mInCallAdapter.sendCallEvent(mTelecomCallId, event, extras); mInCallAdapter.sendCallEvent(mTelecomCallId, event, mTargetSdkVersion, extras);
} }
/** /**

View File

@@ -286,11 +286,12 @@ public final class InCallAdapter {
* *
* @param callId The callId to send the event for. * @param callId The callId to send the event for.
* @param event The event. * @param event The event.
* @param targetSdkVer Target sdk version of the app calling this api
* @param extras Extras associated with the event. * @param extras Extras associated with the event.
*/ */
public void sendCallEvent(String callId, String event, Bundle extras) { public void sendCallEvent(String callId, String event, int targetSdkVer, Bundle extras) {
try { try {
mAdapter.sendCallEvent(callId, event, extras); mAdapter.sendCallEvent(callId, event, targetSdkVer, extras);
} catch (RemoteException ignored) { } catch (RemoteException ignored) {
} }
} }

View File

@@ -24,6 +24,7 @@ import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.ServiceManager; import android.os.ServiceManager;
@@ -1432,6 +1433,13 @@ public class TelecomManager {
public void addNewIncomingCall(PhoneAccountHandle phoneAccount, Bundle extras) { public void addNewIncomingCall(PhoneAccountHandle phoneAccount, Bundle extras) {
try { try {
if (isServiceConnected()) { if (isServiceConnected()) {
if (extras != null && extras.getBoolean(EXTRA_IS_HANDOVER) &&
mContext.getApplicationContext().getApplicationInfo().targetSdkVersion >
Build.VERSION_CODES.O_MR1) {
Log.e("TAG", "addNewIncomingCall failed. Use public api " +
"acceptHandover for API > O-MR1");
// TODO add "return" after DUO team adds support for new handover API
}
getTelecomService().addNewIncomingCall( getTelecomService().addNewIncomingCall(
phoneAccount, extras == null ? new Bundle() : extras); phoneAccount, extras == null ? new Bundle() : extras);
} }

View File

@@ -64,7 +64,7 @@ oneway interface IInCallAdapter {
void pullExternalCall(String callId); void pullExternalCall(String callId);
void sendCallEvent(String callId, String event, in Bundle extras); void sendCallEvent(String callId, String event, int targetSdkVer, in Bundle extras);
void putExtras(String callId, in Bundle extras); void putExtras(String callId, in Bundle extras);