1 /******************************************************************************
2  *
3  *  Copyright (C) 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 #include "common/bt_target.h"
27 #include "bta/bta_api.h"
28 #include "bta/bta_sys.h"
29 #include "bta/bta_sdp_api.h"
30 #include "bta_sdp_int.h"
31 
32 #if defined(BTA_SDP_INCLUDED) && (BTA_SDP_INCLUDED == TRUE)
33 
34 /*****************************************************************************
35 ** Constants and types
36 *****************************************************************************/
37 
38 #if BTA_DYNAMIC_MEMORY == FALSE
39 tBTA_SDP_CB bta_sdp_cb;
40 #else
41 tBTA_SDP_CB *bta_sdp_cb_ptr;
42 #endif
43 
44 /* state machine action enumeration list */
45 #define BTA_SDP_NUM_ACTIONS  (BTA_SDP_MAX_INT_EVT & 0x00ff)
46 
47 /* type for action functions */
48 typedef void (*tBTA_SDP_ACTION)(tBTA_SDP_MSG *p_data);
49 
50 /* action function list */
51 const tBTA_SDP_ACTION bta_sdp_action[] = {
52     bta_sdp_enable,        /* BTA_SDP_API_ENABLE_EVT */
53     bta_sdp_search,        /* BTA_SDP_API_SEARCH_EVT */
54     bta_sdp_create_record, /* BTA_SDP_API_CREATE_RECORD_USER_EVT */
55     bta_sdp_remove_record, /* BTA_SDP_API_REMOVE_RECORD_USER_EVT */
56     bta_sdp_disable,       /* BTA_SDP_API_DISABLE_EVT */
57 };
58 
59 /*******************************************************************************
60 ** Function         bta_sdp_sm_execute
61 **
62 ** Description      State machine event handling function for SDP search
63 **
64 ** Returns          void
65 *******************************************************************************/
bta_sdp_sm_execute(BT_HDR * p_msg)66 BOOLEAN bta_sdp_sm_execute(BT_HDR *p_msg)
67 {
68     if (p_msg == NULL) {
69         return FALSE;
70     }
71 
72     BOOLEAN ret = FALSE;
73     UINT16 action = (p_msg->event & 0x00ff);
74 
75     /* execute action functions */
76     if (action < BTA_SDP_NUM_ACTIONS) {
77         (*bta_sdp_action[action])((tBTA_SDP_MSG *)p_msg);
78         ret = TRUE;
79     }
80 
81     return (ret);
82 }
83 
84 #endif /* #if defined(BTA_SDP_INCLUDED) && (BTA_SDP_INCLUDED == TRUE) */
85