Snap for 4598635 from 13694901709887289a0ad98337a2c7faaa3cd196 to pi-release
Change-Id: Iad26c77db8bc68ac431e7143f20f99881a4c8bba
diff --git a/src/com/android/server/telecom/Call.java b/src/com/android/server/telecom/Call.java
index e7d490d..89575da 100644
--- a/src/com/android/server/telecom/Call.java
+++ b/src/com/android/server/telecom/Call.java
@@ -48,6 +48,7 @@
import android.telecom.VideoProfile;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
+import android.util.StatsLog;
import android.os.UserHandle;
import com.android.internal.annotations.VisibleForTesting;
@@ -924,6 +925,10 @@
}
Log.addEvent(this, event, stringData);
}
+ int statsdDisconnectCause = (newState == CallState.DISCONNECTED) ?
+ getDisconnectCause().getCode() : DisconnectCause.UNKNOWN;
+ StatsLog.write(StatsLog.CALL_STATE_CHANGED, newState, statsdDisconnectCause,
+ isSelfManaged(), isExternalCall());
}
}
@@ -1720,7 +1725,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);
@@ -1841,6 +1854,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")) {
@@ -1853,8 +1877,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/CallState.java b/src/com/android/server/telecom/CallState.java
index 0aa928f..05ac38e 100644
--- a/src/com/android/server/telecom/CallState.java
+++ b/src/com/android/server/telecom/CallState.java
@@ -16,6 +16,8 @@
package com.android.server.telecom;
+import android.telecom.TelecomProtoEnums;
+
/**
* Defines call-state constants of the different states in which a call can exist. Although states
* have the notion of normal transitions, due to the volatile nature of telephony systems, code
@@ -32,20 +34,20 @@
* not expected to ever interact with NEW calls, but {@link android.telecom.InCallService}s will
* see calls in this state.
*/
- public static final int NEW = 0;
+ public static final int NEW = TelecomProtoEnums.NEW; // = 0
/**
* The initial state of an outgoing {@code Call}.
* Common transitions are to {@link #DIALING} state for a successful call or
* {@link #DISCONNECTED} if it failed.
*/
- public static final int CONNECTING = 1;
+ public static final int CONNECTING = TelecomProtoEnums.CONNECTING; // = 1
/**
* The state of an outgoing {@code Call} when waiting on user to select a
* {@link android.telecom.PhoneAccount} through which to place the call.
*/
- public static final int SELECT_PHONE_ACCOUNT = 2;
+ public static final int SELECT_PHONE_ACCOUNT = TelecomProtoEnums.SELECT_PHONE_ACCOUNT; // = 2
/**
* Indicates that a call is outgoing and in the dialing state. A call transitions to this state
@@ -53,7 +55,7 @@
* state usually transition to {@link #ACTIVE} if the call was answered or {@link #DISCONNECTED}
* if the call was disconnected somehow (e.g., failure or cancellation of the call by the user).
*/
- public static final int DIALING = 3;
+ public static final int DIALING = TelecomProtoEnums.DIALING; // = 3
/**
* Indicates that a call is incoming and the user still has the option of answering, rejecting,
@@ -61,14 +63,14 @@
* ringtone. Normal transitions are to {@link #ACTIVE} if answered or {@link #DISCONNECTED}
* otherwise.
*/
- public static final int RINGING = 4;
+ public static final int RINGING = TelecomProtoEnums.RINGING; // = 4
/**
* Indicates that a call is currently connected to another party and a communication channel is
* open between them. The normal transition to this state is by the user answering a
* {@link #DIALING} call or a {@link #RINGING} call being answered by the other party.
*/
- public static final int ACTIVE = 5;
+ public static final int ACTIVE = TelecomProtoEnums.ACTIVE; // = 5
/**
* Indicates that the call is currently on hold. In this state, the call is not terminated
@@ -76,7 +78,7 @@
* to this state is by the user putting an {@link #ACTIVE} call on hold by explicitly performing
* an action, such as clicking the hold button.
*/
- public static final int ON_HOLD = 6;
+ public static final int ON_HOLD = TelecomProtoEnums.ON_HOLD; // = 6
/**
* Indicates that a call is currently disconnected. All states can transition to this state
@@ -85,13 +87,13 @@
* the disconnection or communication was lost to the call service currently responsible for
* this call (e.g., call service crashes).
*/
- public static final int DISCONNECTED = 7;
+ public static final int DISCONNECTED = TelecomProtoEnums.DISCONNECTED; // = 7
/**
* Indicates that the call was attempted (mostly in the context of outgoing, at least at the
* time of writing) but cancelled before it was successfully connected.
*/
- public static final int ABORTED = 8;
+ public static final int ABORTED = TelecomProtoEnums.ABORTED; // = 8
/**
* Indicates that the call is in the process of being disconnected and will transition next
@@ -101,7 +103,7 @@
* to the InCall UI for calls where disconnection has been initiated by the user but the
* ConnectionService has confirmed the call as disconnected.
*/
- public static final int DISCONNECTING = 9;
+ public static final int DISCONNECTING = TelecomProtoEnums.DISCONNECTING; // = 9
/**
* Indicates that the call is in the process of being pulled to the local device.
@@ -110,7 +112,7 @@
* {@link android.telecom.Connection#PROPERTY_IS_EXTERNAL_CALL} and
* {@link android.telecom.Connection#CAPABILITY_CAN_PULL_CALL}.
*/
- public static final int PULLING = 10;
+ public static final int PULLING = TelecomProtoEnums.PULLING; // = 10
public static String toString(int callState) {
switch (callState) {
diff --git a/src/com/android/server/telecom/TelecomServiceImpl.java b/src/com/android/server/telecom/TelecomServiceImpl.java
index dbb19fb..a72e5b6 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);
}
@@ -1554,7 +1554,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();
@@ -1569,9 +1569,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