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

Commit 64ad5586 authored by Jaikumar Ganesh's avatar Jaikumar Ganesh Committed by Android (Google) Code Review
Browse files

Merge "Update BT code for voice capability cases."

parents d1479e7d 58b93c36
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -520,6 +520,21 @@ public final class BluetoothAdapter {
        return null;
    }

    /**
     * Get the UUIDs supported by the local Bluetooth adapter.
     *
     * <p>Requires {@link android.Manifest.permission#BLUETOOTH}
     *
     * @return the UUIDs supported by the local Bluetooth Adapter.
     * @hide
     */
    public ParcelUuid[] getUuids() {
        try {
            return mService.getUuids();
        } catch (RemoteException e) {Log.e(TAG, "", e);}
        return null;
    }

    /**
     * Set the friendly Bluetooth name of the local Bluetooth adapter.
     * <p>This name is visible to remote Bluetooth devices.
+4 −4
Original line number Diff line number Diff line
@@ -301,10 +301,9 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
                    if (isPhoneDocked(mDevice)) {
                        // Don't auto connect to docks.
                        break;
                    } else if (mHeadsetService == null) {
                        deferMessage(message);
                    } else {
                        if (mHeadsetService.getPriority(mDevice) ==
                        if (mHeadsetService != null && 
                              mHeadsetService.getPriority(mDevice) ==
                              BluetoothHeadset.PRIORITY_AUTO_CONNECT &&
                              mHeadsetService.getDevicesMatchingConnectionStates(
                                  new int[] {BluetoothProfile.STATE_CONNECTED,
@@ -1027,7 +1026,8 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
                // This is again against spec. HFP incoming connections should be made
                // before A2DP, so we should not hit this case. But many devices
                // don't follow this.
                if (mHeadsetService.getPriority(mDevice) == BluetoothProfile.PRIORITY_ON) {
                if (mHeadsetService != null && 
                      mHeadsetService.getPriority(mDevice) == BluetoothProfile.PRIORITY_ON) {
                    Message msg = new Message();
                    msg.what = CONNECT_OTHER_PROFILES;
                    msg.arg1 = CONNECT_HFP_OUTGOING;
+1 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ interface IBluetooth
    String getAddress();
    String getName();
    boolean setName(in String name);
    ParcelUuid[] getUuids();

    int getScanMode();
    boolean setScanMode(int mode, int duration);
+32 −6
Original line number Diff line number Diff line
@@ -541,14 +541,15 @@ public class BluetoothService extends IBluetooth.Stub {
                            mHandler.obtainMessage(MESSAGE_REGISTER_SDP_RECORDS, 3, -1), 500);
                    break;
                case 3:
                    Log.d(TAG, "Registering opush record");
                    SystemService.start("opush");
                    Log.d(TAG, "Registering pbap record");
                    SystemService.start("pbap");
                    mHandler.sendMessageDelayed(
                        mHandler.obtainMessage(MESSAGE_REGISTER_SDP_RECORDS, 4, -1), 500);

                    break;
                case 4:
                    Log.d(TAG, "Registering pbap record");
                    SystemService.start("pbap");
                    Log.d(TAG, "Registering opush record");
                    SystemService.start("opush");
                    break;
                }
                break;
@@ -630,8 +631,15 @@ public class BluetoothService extends IBluetooth.Stub {
                initProfileState();

                //Register SDP records.
                if (mContext.getResources().
                        getBoolean(com.android.internal.R.bool.config_voice_capable)) {
                    mHandler.sendMessageDelayed(
                        mHandler.obtainMessage(MESSAGE_REGISTER_SDP_RECORDS, 1, -1), 3000);
                } else {
                    // Register only OPP.
                    mHandler.sendMessageDelayed(
                        mHandler.obtainMessage(MESSAGE_REGISTER_SDP_RECORDS, 4, -1), 3000);
                }
                setBluetoothTetheringNative(true, BluetoothPan.NAP_ROLE, BluetoothPan.NAP_BRIDGE);


@@ -1196,6 +1204,24 @@ public class BluetoothService extends IBluetooth.Stub {
        return getProperty("Name");
    }

    public synchronized ParcelUuid[] getUuids() {
        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        String value =  getProperty("UUIDs");
        if (value == null) return null;

        String[] uuidStrings = null;
        // The UUIDs are stored as a "," separated string.
        uuidStrings = value.split(",");
        ParcelUuid[] uuids = new ParcelUuid[uuidStrings.length];

        for (int i = 0; i < uuidStrings.length; i++) {
            uuids[i] = ParcelUuid.fromString(uuidStrings[i]);
        }
        return uuids;

    }


    /**
     * Returns the user-friendly name of a remote device.  This value is
     * returned from our local cache, which is updated when onPropertyChange