From f6a9e5b6e0527ec1cd56b2f8e7f3d187e4e02d76 Mon Sep 17 00:00:00 2001 From: Sanket Padawe Date: Fri, 5 Jan 2018 14:26:16 -0800 Subject: [PATCH] Add permission check for old call handover apis. Bug: 65415068 Test: manual Change-Id: I4784debf1be255de24c341fe5474fc529bc1cebe --- telecomm/java/android/telecom/Call.java | 2 +- telecomm/java/android/telecom/InCallAdapter.java | 5 +++-- telecomm/java/android/telecom/TelecomManager.java | 8 ++++++++ .../java/com/android/internal/telecom/IInCallAdapter.aidl | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java index 20911012e6ba8..8c7d6b30ecdc2 100644 --- a/telecomm/java/android/telecom/Call.java +++ b/telecomm/java/android/telecom/Call.java @@ -1408,7 +1408,7 @@ public final class Call { * @param extras Bundle containing extra information associated with the event. */ public void sendCallEvent(String event, Bundle extras) { - mInCallAdapter.sendCallEvent(mTelecomCallId, event, extras); + mInCallAdapter.sendCallEvent(mTelecomCallId, event, mTargetSdkVersion, extras); } /** diff --git a/telecomm/java/android/telecom/InCallAdapter.java b/telecomm/java/android/telecom/InCallAdapter.java index 4bc2a9b149f24..658685fe29074 100644 --- a/telecomm/java/android/telecom/InCallAdapter.java +++ b/telecomm/java/android/telecom/InCallAdapter.java @@ -286,11 +286,12 @@ public final class InCallAdapter { * * @param callId The callId to send the event for. * @param event The event. + * @param targetSdkVer Target sdk version of the app calling this api * @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 { - mAdapter.sendCallEvent(callId, event, extras); + mAdapter.sendCallEvent(callId, event, targetSdkVer, extras); } catch (RemoteException ignored) { } } diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index a9bbd2421d888..7d85b2d64dc39 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -24,6 +24,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; @@ -1423,6 +1424,13 @@ public class TelecomManager { public void addNewIncomingCall(PhoneAccountHandle phoneAccount, Bundle extras) { try { 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( phoneAccount, extras == null ? new Bundle() : extras); } diff --git a/telecomm/java/com/android/internal/telecom/IInCallAdapter.aidl b/telecomm/java/com/android/internal/telecom/IInCallAdapter.aidl index 23ac940edfa88..87ccd3ed43694 100644 --- a/telecomm/java/com/android/internal/telecom/IInCallAdapter.aidl +++ b/telecomm/java/com/android/internal/telecom/IInCallAdapter.aidl @@ -64,7 +64,7 @@ oneway interface IInCallAdapter { 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);