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

Commit 784264f5 authored by Joseph Pirozzo's avatar Joseph Pirozzo Committed by Gerrit Code Review
Browse files

Merge "MapClient compatibility updates"

parents 7f562329 4214efdf
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -15,10 +15,17 @@
 */
package com.android.bluetooth.mapclient;

import android.os.SystemProperties;

import com.android.bluetooth.Utils;
import com.android.internal.annotations.VisibleForTesting;

class MapUtils {
    private static MnsService sMnsService = null;
    private static final String FETCH_MESSAGE_TYPE =
            "persist.bluetooth.pts.mapclient.fetchmessagetype";
    private static final String SEND_MESSAGE_TYPE =
            "persist.bluetooth.pts.mapclient.sendmessagetype";

    @VisibleForTesting
    static void setMnsService(MnsService service) {
@@ -28,4 +35,22 @@ class MapUtils {
    static MnsService newMnsServiceInstance(MapClientService mapClientService) {
        return (sMnsService == null) ? new MnsService(mapClientService) : sMnsService;
    }
    static byte fetchMessageType() {
        if (Utils.isPtsTestMode()) {
            return (byte) SystemProperties.getInt(FETCH_MESSAGE_TYPE,
                    MessagesFilter.MESSAGE_TYPE_ALL);
        } else {
            return MessagesFilter.MESSAGE_TYPE_ALL;
        }
    }

    static Bmessage.Type sendMessageType() {
        if (Utils.isPtsTestMode()) {
            int messageType = SystemProperties.getInt(SEND_MESSAGE_TYPE, -1);
            if (messageType > 0 && messageType < Bmessage.Type.values().length) {
                return Bmessage.Type.values()[messageType];
            }
        }
        return Bmessage.Type.MMS;
    }
}
+20 −5
Original line number Diff line number Diff line
@@ -64,10 +64,16 @@ public class MasClient {
            0x66
    };
    private static final byte OAP_TAGID_MAP_SUPPORTED_FEATURES = 0x29;
    private static final int L2CAP_INVALID_PSM = -1;
    private static final int MAP_FEATURE_NOTIFICATION_REGISTRATION = 0x00000001;
    private static final int MAP_FEATURE_NOTIFICATION = 0x00000002;
    private static final int MAP_FEATURE_BROWSING = 0x00000004;
    private static final int MAP_FEATURE_UPLOADING = 0x00000008;
    private static final int MAP_FEATURE_EXTENDED_EVENT_REPORT_1_1 = 0x00000040;
    static final int MAP_SUPPORTED_FEATURES =
            MAP_FEATURE_NOTIFICATION_REGISTRATION | MAP_FEATURE_NOTIFICATION;
            MAP_FEATURE_NOTIFICATION_REGISTRATION | MAP_FEATURE_NOTIFICATION
            | MAP_FEATURE_BROWSING | MAP_FEATURE_UPLOADING
            | MAP_FEATURE_EXTENDED_EVENT_REPORT_1_1;

    private final StateMachine mCallback;
    private Handler mHandler;
@@ -99,11 +105,20 @@ public class MasClient {

    private void connect() {
        try {
            int l2capSocket = mSdpMasRecord.getL2capPsm();

            if (l2capSocket != L2CAP_INVALID_PSM) {
                if (DBG) {
                    Log.d(TAG, "Connecting to OBEX on L2CAP channel " + l2capSocket);
                }
                mSocket = mRemoteDevice.createL2capSocket(l2capSocket);
            } else {
                if (DBG) {
                    Log.d(TAG, "Connecting to OBEX on RFCOM channel "
                            + mSdpMasRecord.getRfcommCannelNumber());
                }
                mSocket = mRemoteDevice.createRfcommSocket(mSdpMasRecord.getRfcommCannelNumber());
            }
            if (DBG) Log.d(TAG, mRemoteDevice.toString() + "Socket: " + mSocket.toString());
            mSocket.connect();
            mTransport = new BluetoothObexTransport(mSocket);
+6 −1
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import android.telephony.SmsManager;
import android.util.Log;

import com.android.bluetooth.BluetoothMetricsProto;
import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.MetricsLogger;
import com.android.bluetooth.btservice.ProfileService;
import com.android.bluetooth.map.BluetoothMapbMessageMime;
@@ -341,6 +342,9 @@ final class MceStateMachine extends StateMachine {

    Bmessage.Type getDefaultMessageType() {
        synchronized (mDefaultMessageType) {
            if (Utils.isPtsTestMode()) {
                return MapUtils.sendMessageType();
            }
            return mDefaultMessageType;
        }
    }
@@ -458,6 +462,7 @@ final class MceStateMachine extends StateMachine {
                Log.d(TAG, "Enter Connected: " + getCurrentMessage().what);
            }
            onConnectionStateChanged(mPreviousState, BluetoothProfile.STATE_CONNECTED);
            if (Utils.isPtsTestMode()) return;

            mMasClient.makeRequest(new RequestSetPath(FOLDER_TELECOM));
            mMasClient.makeRequest(new RequestSetPath(FOLDER_MSG));
@@ -504,7 +509,7 @@ final class MceStateMachine extends StateMachine {
                case MSG_GET_MESSAGE_LISTING:
                    // Get latest 50 Unread messages in the last week
                    MessagesFilter filter = new MessagesFilter();
                    filter.setMessageType((byte) 0);
                    filter.setMessageType(MapUtils.fetchMessageType());
                    filter.setReadStatus(MessagesFilter.READ_STATUS_UNREAD);
                    Calendar calendar = Calendar.getInstance();
                    calendar.add(Calendar.DATE, -7);
+3 −3
Original line number Diff line number Diff line
@@ -42,8 +42,8 @@ public class MnsService {
    private static final String TAG = "MnsService";
    private static final Boolean DBG = MapClientService.DBG;
    private static final Boolean VDBG = MapClientService.VDBG;
    /* MAP version 1.1 */
    private static final int MNS_VERSION = 0x0101;
    /* MAP version 1.4 */
    private static final int MNS_VERSION = 0x0104;
    /* these are shared across instances */
    private static SocketAcceptor sAcceptThread = null;
    private static Handler sSessionHandler = null;
@@ -67,7 +67,7 @@ public class MnsService {
            return;
        }
        mSdpHandle = sdpManager.createMapMnsRecord("MAP Message Notification Service",
                sServerSockets.getRfcommChannel(), -1, MNS_VERSION,
                sServerSockets.getRfcommChannel(), sServerSockets.getL2capPsm(), MNS_VERSION,
                MasClient.MAP_SUPPORTED_FEATURES);
    }

+7 −2
Original line number Diff line number Diff line
@@ -206,8 +206,13 @@ public class EventReport {
        MEMORY_FULL("MemoryFull"),
        MEMORY_AVAILABLE("MemoryAvailable"),
        MESSAGE_DELETED("MessageDeleted"),
        MESSAGE_SHIFT("MessageShift");

        MESSAGE_SHIFT("MessageShift"),
        READ_STATUS_CHANGED("ReadStatusChanged"),
        MESSAGE_REMOVED("MessageRemoved"),
        MESSAGE_EXTENDED_DATA_CHANGED("MessageExtendedDataChanged"),
        PARTICIPANT_PRESENCE_CHANGED("ParticipantPresenceChanged"),
        PARTICIPANT_CHAT_STATE_CHANGED("ParticipantChatStateChanged"),
        CONCERSATION_CHANGED("ConversationChanged");
        private final String mSpecName;

        Type(String specName) {