1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.bluetooth.mapclient;
17 
18 import android.os.SystemProperties;
19 
20 import com.android.bluetooth.Utils;
21 import com.android.internal.annotations.VisibleForTesting;
22 
23 class MapUtils {
24     private static MnsService sMnsService = null;
25     private static final String FETCH_MESSAGE_TYPE =
26             "persist.bluetooth.pts.mapclient.fetchmessagetype";
27     private static final String SEND_MESSAGE_TYPE =
28             "persist.bluetooth.pts.mapclient.sendmessagetype";
29 
30     @VisibleForTesting
setMnsService(MnsService service)31     static void setMnsService(MnsService service) {
32         sMnsService = service;
33     }
34 
newMnsServiceInstance(MapClientService mapClientService)35     static MnsService newMnsServiceInstance(MapClientService mapClientService) {
36         return (sMnsService == null) ? new MnsService(mapClientService) : sMnsService;
37     }
fetchMessageType()38     static byte fetchMessageType() {
39         if (Utils.isPtsTestMode()) {
40             return (byte) SystemProperties.getInt(FETCH_MESSAGE_TYPE,
41                     MessagesFilter.MESSAGE_TYPE_ALL);
42         } else {
43             return MessagesFilter.MESSAGE_TYPE_ALL;
44         }
45     }
46 
sendMessageType()47     static Bmessage.Type sendMessageType() {
48         if (Utils.isPtsTestMode()) {
49             int messageType = SystemProperties.getInt(SEND_MESSAGE_TYPE, -1);
50             if (messageType > 0 && messageType < Bmessage.Type.values().length) {
51                 return Bmessage.Type.values()[messageType];
52             }
53         }
54         return Bmessage.Type.MMS;
55     }
56 }
57