1 /******************************************************************************
2  *
3  *  Copyright 2014 The Android Open Source Project
4 
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 /******************************************************************************
20  *
21  *  This is the main implementation file for the BTA MCE I/F
22  *
23  ******************************************************************************/
24 
25 #include <stdlib.h>
26 
27 #include "bta_api.h"
28 #include "bta_sdp_api.h"
29 #include "bta_sdp_int.h"
30 #include "bta_sys.h"
31 
32 /*****************************************************************************
33  * Constants and types
34  ****************************************************************************/
35 
36 tBTA_SDP_CB bta_sdp_cb;
37 
38 /* state machine action enumeration list */
39 #define BTA_SDP_NUM_ACTIONS (BTA_SDP_MAX_INT_EVT & 0x00ff)
40 
41 /* type for action functions */
42 typedef void (*tBTA_SDP_ACTION)(tBTA_SDP_MSG* p_data);
43 
44 /* action function list */
45 const tBTA_SDP_ACTION bta_sdp_action[] = {
46     bta_sdp_enable,        /* BTA_SDP_API_ENABLE_EVT */
47     bta_sdp_search,        /* BTA_SDP_API_SEARCH_EVT */
48     bta_sdp_create_record, /* BTA_SDP_API_CREATE_RECORD_USER_EVT */
49     bta_sdp_remove_record, /* BTA_SDP_API_REMOVE_RECORD_USER_EVT */
50 };
51 
52 /*******************************************************************************
53  * Function         bta_sdp_sm_execute
54  *
55  * Description      State machine event handling function for SDP search
56  *
57  * Returns          void
58  ******************************************************************************/
bta_sdp_sm_execute(BT_HDR * p_msg)59 bool bta_sdp_sm_execute(BT_HDR* p_msg) {
60   if (p_msg == NULL) return false;
61 
62   bool ret = false;
63   uint16_t action = (p_msg->event & 0x00ff);
64 
65   /* execute action functions */
66   if (action < BTA_SDP_NUM_ACTIONS) {
67     (*bta_sdp_action[action])((tBTA_SDP_MSG*)p_msg);
68     ret = true;
69   }
70 
71   return (ret);
72 }
73