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

Commit a1333c3a authored by Vasu Nori's avatar Vasu Nori Committed by vnori
Browse files

Add new hidden API to return SDP record's MapSupportedFeatures field.

That field is documented in Bluetooth MAP 1.4 spec, page 114.

Bug: 111614861
Test: tested manually and with kitchensink app
Change-Id: I49511ca4a17941d9267706a6d5327c841d321e5d
parent b8e7d3e2
Loading
Loading
Loading
Loading
+29 −0
Original line number Original line Diff line number Diff line
@@ -346,6 +346,20 @@ public class MapClientService extends ProfileService {
        return mapStateMachine.getUnreadMessages();
        return mapStateMachine.getUnreadMessages();
    }
    }


    /**
     * Returns the SDP record's MapSupportedFeatures field (see Bluetooth MAP 1.4 spec, page 114).
     * @param device The Bluetooth device to get this value for.
     * @return the SDP record's MapSupportedFeatures field.
     */
    public synchronized int getSupportedFeatures(BluetoothDevice device) {
        MceStateMachine mapStateMachine = mMapInstanceMap.get(device);
        if (mapStateMachine == null) {
            if (DBG) Log.d(TAG, "in getSupportedFeatures, returning 0");
            return 0;
        }
        return mapStateMachine.getSupportedFeatures();
    }

    @Override
    @Override
    public void dump(StringBuilder sb) {
    public void dump(StringBuilder sb) {
        super.dump(sb);
        super.dump(sb);
@@ -503,6 +517,21 @@ public class MapClientService extends ProfileService {
                    "Need READ_SMS permission");
                    "Need READ_SMS permission");
            return service.getUnreadMessages(device);
            return service.getUnreadMessages(device);
        }
        }

        @Override
        public int getSupportedFeatures(BluetoothDevice device) {
            MapClientService service = getService();
            if (service == null) {
                if (DBG) {
                    Log.d(TAG,
                            "in MapClientService getSupportedFeatures stub, returning 0");
                }
                return 0;
            }
            mService.enforceCallingOrSelfPermission(Manifest.permission.BLUETOOTH,
                    "Need BLUETOOTH permission");
            return service.getSupportedFeatures(device);
        }
    }
    }


    private class MapBroadcastReceiver extends BroadcastReceiver {
    private class MapBroadcastReceiver extends BroadcastReceiver {
+4 −0
Original line number Original line Diff line number Diff line
@@ -190,6 +190,10 @@ public class MasClient {
        NATIVE, UTF_8;
        NATIVE, UTF_8;
    }
    }


    SdpMasRecord getSdpMasRecord() {
        return mSdpMasRecord;
    }

    private static class MasClientHandler extends Handler {
    private static class MasClientHandler extends Handler {
        WeakReference<MasClient> mInst;
        WeakReference<MasClient> mInst;


+17 −3
Original line number Original line Diff line number Diff line
@@ -280,6 +280,15 @@ final class MceStateMachine extends StateMachine {
        return false;
        return false;
    }
    }


    synchronized int getSupportedFeatures() {
        if (this.getCurrentState() == mConnected && mMasClient != null) {
            if (DBG) Log.d(TAG, "returning getSupportedFeatures from SDP record");
            return mMasClient.getSdpMasRecord().getSupportedFeatures();
        }
        if (DBG) Log.d(TAG, "in getSupportedFeatures, returning 0");
        return 0;
    }

    private String getContactURIFromPhone(String number) {
    private String getContactURIFromPhone(String number) {
        return PhoneAccount.SCHEME_TEL + ":" + number;
        return PhoneAccount.SCHEME_TEL + ":" + number;
    }
    }
@@ -349,9 +358,14 @@ final class MceStateMachine extends StateMachine {
                        Log.d(TAG, "SDP Complete");
                        Log.d(TAG, "SDP Complete");
                    }
                    }
                    if (mMasClient == null) {
                    if (mMasClient == null) {
                        mMasClient = new MasClient(mDevice, MceStateMachine.this,
                        SdpMasRecord record = (SdpMasRecord) message.obj;
                                (SdpMasRecord) message.obj);
                        if (record == null) {
                        setDefaultMessageType((SdpMasRecord) message.obj);
                            Log.e(TAG, "Unexpected: SDP record is null for device "
                                    + mDevice.getName());
                            return NOT_HANDLED;
                        }
                        mMasClient = new MasClient(mDevice, MceStateMachine.this, record);
                        setDefaultMessageType(record);
                    }
                    }
                    break;
                    break;