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

Commit 3daca8a2 authored by Joseph Pirozzo's avatar Joseph Pirozzo
Browse files

HFPClient call disconnect cause

When a phone call goes from Alerting to Terminated make sure that it
goes into the missed call log rather than the incomming call log.

Bug: 64936887
Test: Receive an incomming phonecall terminate it before answering from
any point, ensure that the record shows up in Missed call log.

Change-Id: Ia650da56e6753f72bbd8d2f344efe90104889d48
parent 3ffe98ed
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ public class HfpClientConnection extends Connection {
    private BluetoothHeadsetClient mHeadsetProfile;

    private BluetoothHeadsetClientCall mCurrentCall;
    private int mPreviousCallState = -1;
    private boolean mClosed;
    private boolean mClosing = false;
    private boolean mLocalDisconnect;
@@ -162,12 +163,19 @@ public class HfpClientConnection extends Connection {
                setRinging();
                break;
            case BluetoothHeadsetClientCall.CALL_STATE_TERMINATED:
                // TODO Use more specific causes
                close(mLocalDisconnect ? DisconnectCause.LOCAL : DisconnectCause.REMOTE);
                if (mPreviousCallState == BluetoothHeadsetClientCall.CALL_STATE_INCOMING
                        || mPreviousCallState == BluetoothHeadsetClientCall.CALL_STATE_WAITING) {
                    close(DisconnectCause.MISSED);
                } else if (mLocalDisconnect) {
                    close(DisconnectCause.LOCAL);
                } else {
                    close(DisconnectCause.REMOTE);
                }
                break;
            default:
                Log.wtf(TAG, "Unexpected phone state " + state);
        }
        mPreviousCallState = state;
    }

    public synchronized void close(int cause) {
+5 −5
Original line number Diff line number Diff line
@@ -192,15 +192,15 @@ public class HfpClientDeviceBlock {
            // (represented as unknown call in telecom since). Since BluetoothHeadsetClientCall is a
            // parcelable we simply pack the entire object in there.
            Bundle b = new Bundle();
            if (call.getState() == BluetoothHeadsetClientCall.CALL_STATE_DIALING ||
                call.getState() == BluetoothHeadsetClientCall.CALL_STATE_ALERTING ||
                call.getState() == BluetoothHeadsetClientCall.CALL_STATE_ACTIVE ||
                call.getState() == BluetoothHeadsetClientCall.CALL_STATE_WAITING) {
            if (call.getState() == BluetoothHeadsetClientCall.CALL_STATE_DIALING
                    || call.getState() == BluetoothHeadsetClientCall.CALL_STATE_ALERTING
                    || call.getState() == BluetoothHeadsetClientCall.CALL_STATE_ACTIVE) {
                // This is an outgoing call. Even if it is an active call we do not have a way of
                // putting that parcelable in a seaprate field.
                b.putParcelable(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, call);
                mTelecomManager.addNewUnknownCall(mPhoneAccount.getAccountHandle(), b);
            } else if (call.getState() == BluetoothHeadsetClientCall.CALL_STATE_INCOMING) {
            } else if (call.getState() == BluetoothHeadsetClientCall.CALL_STATE_INCOMING
                    || call.getState() == BluetoothHeadsetClientCall.CALL_STATE_WAITING) {
                // This is an incoming call.
                b.putParcelable(TelecomManager.EXTRA_INCOMING_CALL_EXTRAS, call);
                mTelecomManager.addNewIncomingCall(mPhoneAccount.getAccountHandle(), b);