Add logging of package invoking TelecomManager#endCall() API. am: 587fc27faf
am: a68da876f6
Change-Id: I5b16a48c1ad46f03afef47ecf9f8b4bf2073b4d6
diff --git a/src/com/android/server/telecom/Call.java b/src/com/android/server/telecom/Call.java
index 5a54d93..f4c066b 100644
--- a/src/com/android/server/telecom/Call.java
+++ b/src/com/android/server/telecom/Call.java
@@ -1667,7 +1667,15 @@
*/
@VisibleForTesting
public void disconnect(long disconnectionTimeout) {
- Log.addEvent(this, LogUtils.Events.REQUEST_DISCONNECT);
+ disconnect(disconnectionTimeout, "internal" /** callingPackage */);
+ }
+
+ /**
+ * Attempts to disconnect the call through the connection service.
+ */
+ @VisibleForTesting
+ public void disconnect(long disconnectionTimeout, String callingPackage) {
+ Log.addEvent(this, LogUtils.Events.REQUEST_DISCONNECT, callingPackage);
// Track that the call is now locally disconnecting.
setLocallyDisconnecting(true);
@@ -1788,6 +1796,17 @@
*/
@VisibleForTesting
public void reject(boolean rejectWithMessage, String textMessage) {
+ reject(rejectWithMessage, textMessage, "internal" /** callingPackage */);
+ }
+
+ /**
+ * Rejects the call if it is ringing.
+ *
+ * @param rejectWithMessage Whether to send a text message as part of the call rejection.
+ * @param textMessage An optional text message to send as part of the rejection.
+ */
+ @VisibleForTesting
+ public void reject(boolean rejectWithMessage, String textMessage, String callingPackage) {
// Check to verify that the call is still in the ringing state. A call can change states
// between the time the user hits 'reject' and Telecomm receives the command.
if (isRinging("reject")) {
@@ -1800,8 +1819,7 @@
Log.e(this, new NullPointerException(),
"reject call failed due to null CS callId=%s", getId());
}
- Log.addEvent(this, LogUtils.Events.REQUEST_REJECT);
-
+ Log.addEvent(this, LogUtils.Events.REQUEST_REJECT, callingPackage);
}
}
diff --git a/src/com/android/server/telecom/TelecomServiceImpl.java b/src/com/android/server/telecom/TelecomServiceImpl.java
index b7ffbbe..e45cf30 100644
--- a/src/com/android/server/telecom/TelecomServiceImpl.java
+++ b/src/com/android/server/telecom/TelecomServiceImpl.java
@@ -766,7 +766,7 @@
* @see android.telecom.TelecomManager#endCall
*/
@Override
- public boolean endCall() {
+ public boolean endCall(String callingPackage) {
try {
Log.startSession("TSI.eC");
synchronized (mLock) {
@@ -774,7 +774,7 @@
long token = Binder.clearCallingIdentity();
try {
- return endCallInternal();
+ return endCallInternal(callingPackage);
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -1560,7 +1560,7 @@
}
}
- private boolean endCallInternal() {
+ private boolean endCallInternal(String callingPackage) {
// Always operate on the foreground call if one exists, otherwise get the first call in
// priority order by call-state.
Call call = mCallsManager.getForegroundCall();
@@ -1575,9 +1575,9 @@
if (call != null) {
if (call.getState() == CallState.RINGING) {
- call.reject(false /* rejectWithMessage */, null);
+ call.reject(false /* rejectWithMessage */, null, callingPackage);
} else {
- call.disconnect();
+ call.disconnect(0 /* disconnectionTimeout */, callingPackage);
}
return true;
}
diff --git a/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java b/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java
index b19e5d3..5963f8f 100644
--- a/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java
+++ b/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java
@@ -843,7 +843,7 @@
Call call = mock(Call.class);
when(call.getState()).thenReturn(CallState.RINGING);
when(mFakeCallsManager.getForegroundCall()).thenReturn(call);
- assertTrue(mTSIBinder.endCall());
+ assertTrue(mTSIBinder.endCall(null));
verify(call).reject(false, null);
}
@@ -853,7 +853,7 @@
Call call = mock(Call.class);
when(call.getState()).thenReturn(CallState.ACTIVE);
when(mFakeCallsManager.getForegroundCall()).thenReturn(call);
- assertTrue(mTSIBinder.endCall());
+ assertTrue(mTSIBinder.endCall(null));
verify(call).disconnect();
}
@@ -864,14 +864,14 @@
when(call.getState()).thenReturn(CallState.ACTIVE);
when(mFakeCallsManager.getFirstCallWithState(any()))
.thenReturn(call);
- assertTrue(mTSIBinder.endCall());
+ assertTrue(mTSIBinder.endCall(null));
verify(call).disconnect();
}
@SmallTest
@Test
public void testEndCallWithNoCalls() throws Exception {
- assertFalse(mTSIBinder.endCall());
+ assertFalse(mTSIBinder.endCall(null));
}
@SmallTest