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

Commit e2a2e2cd authored by Joseph Pirozzo's avatar Joseph Pirozzo
Browse files

Bluetooth in band ring

Prevent the telecom service from generating a ringer if there is already
a ringer generated by a phone connected over bluetooth headset client
service.

Bug: 65673832
Test: runtest bluetooth -c
com.android.bluetooth.hfpclient.HeadsetClientStateMachineTest

Change-Id: Ie4011598c2719897afb6185f928951289ab9c731
(cherry picked from commit 396dd51efd7e51b0f61647172b76f1cc4e9c85f7)
parent 86ddcab0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -784,7 +784,7 @@ public class HeadsetClientService extends ProfileService {
        BluetoothHeadsetClientCall call = new BluetoothHeadsetClientCall(device,
                HeadsetClientStateMachine.HF_ORIGINATED_CALL_ID,
                BluetoothHeadsetClientCall.CALL_STATE_DIALING, number, false  /* multiparty */,
                true  /* outgoing */);
                true  /* outgoing */, sm.getInBandRing());
        Message msg = sm.obtainMessage(HeadsetClientStateMachine.DIAL_NUMBER);
        msg.obj = call;
        sm.sendMessage(msg);
+21 −1
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ public class HeadsetClientStateMachine extends StateMachine {
    private static final boolean DBG = false;

    static final int NO_ACTION = 0;
    static final int IN_BAND_RING_ENABLED = 1;

    // external actions
    public static final int AT_OK = 0;
@@ -138,6 +139,7 @@ public class HeadsetClientStateMachine extends StateMachine {
    private int mIndicatorNetworkType;
    private int mIndicatorNetworkSignal;
    private int mIndicatorBatteryLevel;
    private boolean mInBandRing;

    private String mOperatorName;
    private String mSubscriberInfo;
@@ -170,6 +172,11 @@ public class HeadsetClientStateMachine extends StateMachine {
        return mDisconnected;
    }

    // Get if in band ring is currently enabled on device.
    public boolean getInBandRing() {
        return mInBandRing;
    }

    public void dump(StringBuilder sb) {
        ProfileService.println(sb, "mCurrentDevice: " + mCurrentDevice);
        ProfileService.println(sb, "mAudioState: " + mAudioState);
@@ -402,7 +409,7 @@ public class HeadsetClientStateMachine extends StateMachine {
        }
        mCallsUpdate.put(id,
                new BluetoothHeadsetClientCall(mCurrentDevice, id, state, number, multiParty,
                        outgoing));
                        outgoing, mInBandRing));
    }

    private void acceptCall(int flag) {
@@ -775,6 +782,7 @@ public class HeadsetClientStateMachine extends StateMachine {
            mIndicatorNetworkType = HeadsetClientHalConstants.SERVICE_TYPE_HOME;
            mIndicatorNetworkSignal = 0;
            mIndicatorBatteryLevel = 0;
            mInBandRing = false;

            mAudioWbs = false;

@@ -1400,6 +1408,18 @@ public class HeadsetClientStateMachine extends StateMachine {
                            intent.putExtra(BluetoothDevice.EXTRA_DEVICE, event.device);
                            mService.sendBroadcast(intent, ProfileService.BLUETOOTH_PERM);
                            break;
                        case StackEvent.EVENT_TYPE_IN_BAND_RINGTONE:
                            intent = new Intent(BluetoothHeadsetClient.ACTION_AG_EVENT);
                            mInBandRing = event.valueInt == IN_BAND_RING_ENABLED;
                            intent.putExtra(BluetoothHeadsetClient.EXTRA_IN_BAND_RING,
                                    event.valueInt);
                            intent.putExtra(BluetoothDevice.EXTRA_DEVICE, event.device);
                            mService.sendBroadcast(intent, ProfileService.BLUETOOTH_PERM);
                            if (DBG) {
                                Log.d(TAG,
                                        event.device.toString() + "onInBandRing" + event.valueInt);
                            }
                            break;
                        case StackEvent.EVENT_TYPE_RING_INDICATION:
                            // Ringing is not handled at this indication and rather should be
                            // implemented (by the client of this service). Use the
+13 −1
Original line number Diff line number Diff line
@@ -387,7 +387,19 @@ class NativeInterface {
    }

    private void onInBandRing(int inBand, byte[] address) {
        Log.w(TAG, "onInBandRing not supported");
        StackEvent event = new StackEvent(StackEvent.EVENT_TYPE_IN_BAND_RINGTONE);
        event.valueInt = inBand;
        event.device = getDevice(address);
        if (DBG) {
            Log.d(TAG, "onInBandRing: address " + address + " event " + event);
        }
        HeadsetClientService service = HeadsetClientService.getHeadsetClientService();
        if (service != null) {
            service.messageFromNative(event);
        } else {
            Log.w(TAG,
                    "onInBandRing: Ignoring message because service not available: " + event);
        }
    }

    private void onLastVoiceTagNumber(String number, byte[] address) {
+8 −7
Original line number Diff line number Diff line
@@ -38,13 +38,14 @@ public class StackEvent {
    public static final int EVENT_TYPE_CALL = 9;
    public static final int EVENT_TYPE_CALLSETUP = 10;
    public static final int EVENT_TYPE_CALLHELD = 11;
    public static final int EVENT_TYPE_CLIP = 12;
    public static final int EVENT_TYPE_CALL_WAITING = 13;
    public static final int EVENT_TYPE_CURRENT_CALLS = 14;
    public static final int EVENT_TYPE_VOLUME_CHANGED = 15;
    public static final int EVENT_TYPE_CMD_RESULT = 16;
    public static final int EVENT_TYPE_SUBSCRIBER_INFO = 17;
    public static final int EVENT_TYPE_RESP_AND_HOLD = 18;
    public static final int EVENT_TYPE_RESP_AND_HOLD = 12;
    public static final int EVENT_TYPE_CLIP = 13;
    public static final int EVENT_TYPE_CALL_WAITING = 14;
    public static final int EVENT_TYPE_CURRENT_CALLS = 15;
    public static final int EVENT_TYPE_VOLUME_CHANGED = 16;
    public static final int EVENT_TYPE_CMD_RESULT = 17;
    public static final int EVENT_TYPE_SUBSCRIBER_INFO = 18;
    public static final int EVENT_TYPE_IN_BAND_RINGTONE = 19;
    public static final int EVENT_TYPE_RING_INDICATION = 21;

    public int type = EVENT_TYPE_NONE;
+1 −0
Original line number Diff line number Diff line
@@ -184,6 +184,7 @@ public class HfpClientDeviceBlock {
                    || call.getState() == BluetoothHeadsetClientCall.CALL_STATE_WAITING) {
                // This is an incoming call.
                b.putParcelable(TelecomManager.EXTRA_INCOMING_CALL_EXTRAS, call);
                b.putBoolean(TelecomManager.EXTRA_CALL_EXTERNAL_RINGER, call.isInBandRing());
                mTelecomManager.addNewIncomingCall(mPhoneAccount.getAccountHandle(), b);
            }
        } else if (call.getState() == BluetoothHeadsetClientCall.CALL_STATE_TERMINATED) {
Loading