Add permission checks for old call handover apis.
Bug: 65415068
Test: manual unit tests.
Change-Id: I1ae241059f5d4a3d2d16ea96faf7f86fcf0a89cd
diff --git a/src/com/android/server/telecom/Call.java b/src/com/android/server/telecom/Call.java
index c301aac..d42de3e 100644
--- a/src/com/android/server/telecom/Call.java
+++ b/src/com/android/server/telecom/Call.java
@@ -21,6 +21,7 @@
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
+import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@@ -2027,16 +2028,34 @@
}
/**
- * Sends a call event to the {@link ConnectionService} for this call.
- *
- * See {@link Call#sendCallEvent(String, Bundle)}.
+ * Sends a call event to the {@link ConnectionService} for this call. This function is
+ * called for event other than {@link Call#EVENT_REQUEST_HANDOVER}
*
* @param event The call event.
* @param extras Associated extras.
*/
public void sendCallEvent(String event, Bundle extras) {
+ sendCallEvent(event, 0/*For Event != EVENT_REQUEST_HANDOVER*/, extras);
+ }
+
+ /**
+ * Sends a call event to the {@link ConnectionService} for this call.
+ *
+ * See {@link Call#sendCallEvent(String, Bundle)}.
+ *
+ * @param event The call event.
+ * @param targetSdkVer SDK version of the app calling this api
+ * @param extras Associated extras.
+ */
+ public void sendCallEvent(String event, int targetSdkVer, Bundle extras) {
if (mConnectionService != null) {
if (android.telecom.Call.EVENT_REQUEST_HANDOVER.equals(event)) {
+ if (targetSdkVer > Build.VERSION_CODES.O_MR1) {
+ Log.e(this, new Exception(), "sendCallEvent failed. Use public api handoverTo" +
+ " for API > 27(O-MR1)");
+ // TODO: Add "return" after DUO team adds new API support for handover
+ }
+
// Handover requests are targeted at Telecom, not the ConnectionService.
if (extras == null) {
Log.w(this, "sendCallEvent: %s event received with null extras.",
diff --git a/src/com/android/server/telecom/InCallAdapter.java b/src/com/android/server/telecom/InCallAdapter.java
index f544158..7801140 100644
--- a/src/com/android/server/telecom/InCallAdapter.java
+++ b/src/com/android/server/telecom/InCallAdapter.java
@@ -396,7 +396,7 @@
}
@Override
- public void sendCallEvent(String callId, String event, Bundle extras) {
+ public void sendCallEvent(String callId, String event, int targetSdkVer, Bundle extras) {
try {
Log.startSession("ICA.sCE", mOwnerComponentName);
long token = Binder.clearCallingIdentity();
@@ -404,7 +404,7 @@
synchronized (mLock) {
Call call = mCallIdMapper.getCall(callId);
if (call != null) {
- call.sendCallEvent(event, extras);
+ call.sendCallEvent(event, targetSdkVer, extras);
} else {
Log.w(this, "sendCallEvent, unknown call id: %s", callId);
}
diff --git a/tests/src/com/android/server/telecom/tests/BasicCallTests.java b/tests/src/com/android/server/telecom/tests/BasicCallTests.java
index 9db70fd..bdb9157 100644
--- a/tests/src/com/android/server/telecom/tests/BasicCallTests.java
+++ b/tests/src/com/android/server/telecom/tests/BasicCallTests.java
@@ -736,7 +736,7 @@
mPhoneAccountA0.getAccountHandle(), mConnectionServiceFixtureA);
assertEquals(Call.STATE_ACTIVE, mInCallServiceFixtureX.getCall(ids.mCallId).getState());
- mInCallServiceFixtureX.mInCallAdapter.sendCallEvent(ids.mCallId, TEST_EVENT, null);
+ mInCallServiceFixtureX.mInCallAdapter.sendCallEvent(ids.mCallId, TEST_EVENT, 26, null);
verify(mConnectionServiceFixtureA.getTestDouble(), timeout(TEST_TIMEOUT))
.sendCallEvent(eq(ids.mConnectionId), eq(TEST_EVENT), isNull(Bundle.class), any());
}
@@ -757,7 +757,7 @@
testBundle.putString(TEST_BUNDLE_KEY, "TEST");
ArgumentCaptor<Bundle> bundleArgumentCaptor = ArgumentCaptor.forClass(Bundle.class);
- mInCallServiceFixtureX.mInCallAdapter.sendCallEvent(ids.mCallId, TEST_EVENT,
+ mInCallServiceFixtureX.mInCallAdapter.sendCallEvent(ids.mCallId, TEST_EVENT, 26,
testBundle);
verify(mConnectionServiceFixtureA.getTestDouble(), timeout(TEST_TIMEOUT))
.sendCallEvent(eq(ids.mConnectionId), eq(TEST_EVENT),