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

Commit 4f2f84c3 authored by vnori's avatar vnori Committed by android-build-merger
Browse files

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

Merge "Add new hidden API to return SDP record's MapSupportedFeatures field. That field is documented in Bluetooth MAP 1.4 spec, page 114." am: 3a53e3dc am: c05073be
am: 20c8e697

Change-Id: I09ab1880b8dee4d7993bca0fbe88522177e76973
parents 64364db8 20c8e697
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -347,6 +347,20 @@ public class MapClientService extends ProfileService {
        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
    public void dump(StringBuilder sb) {
        super.dump(sb);
@@ -504,6 +518,21 @@ public class MapClientService extends ProfileService {
                    "Need READ_SMS permission");
            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 {
+4 −0
Original line number Diff line number Diff line
@@ -190,6 +190,10 @@ public class MasClient {
        NATIVE, UTF_8;
    }

    SdpMasRecord getSdpMasRecord() {
        return mSdpMasRecord;
    }

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

+17 −3
Original line number Diff line number Diff line
@@ -280,6 +280,15 @@ final class MceStateMachine extends StateMachine {
        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) {
        return PhoneAccount.SCHEME_TEL + ":" + number;
    }
@@ -349,9 +358,14 @@ final class MceStateMachine extends StateMachine {
                        Log.d(TAG, "SDP Complete");
                    }
                    if (mMasClient == null) {
                        mMasClient = new MasClient(mDevice, MceStateMachine.this,
                                (SdpMasRecord) message.obj);
                        setDefaultMessageType((SdpMasRecord) message.obj);
                        SdpMasRecord record = (SdpMasRecord) message.obj;
                        if (record == null) {
                            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;