Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 587fc27f authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Add logging of package invoking TelecomManager#endCall() API.

For debugging purposes it is useful to see in the Telecom dumpsys the
package name of the package which has invoked the endCall() API.

Bug: 73006395
Test: Manual testing to confirm logging works as expected.
Change-Id: Ic1ef69cca43c256ff36ca3e23b1607db9a33f3ab
parent ad4ebc02
Loading
Loading
Loading
Loading
+21 −3
Original line number Diff line number Diff line
@@ -1667,7 +1667,15 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
     */
    @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 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
     */
    @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 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
                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);
        }
    }

+5 −5
Original line number Diff line number Diff line
@@ -766,7 +766,7 @@ public class TelecomServiceImpl {
         * @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 @@ public class TelecomServiceImpl {

                    long token = Binder.clearCallingIdentity();
                    try {
                        return endCallInternal();
                        return endCallInternal(callingPackage);
                    } finally {
                        Binder.restoreCallingIdentity(token);
                    }
@@ -1560,7 +1560,7 @@ public class TelecomServiceImpl {
        }
    }

    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 @@ public class TelecomServiceImpl {

        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;
        }
+4 −4
Original line number Diff line number Diff line
@@ -843,7 +843,7 @@ public class TelecomServiceImplTest extends TelecomTestCase {
        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 @@ public class TelecomServiceImplTest extends TelecomTestCase {
        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 @@ public class TelecomServiceImplTest extends TelecomTestCase {
        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