1 /*
2  * Copyright 2023 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 
17 #pragma once
18 
19 #include "btif/include/btif_common.h"
20 #include "common/postable_context.h"
21 #include "include/hardware/bluetooth.h"
22 
23 void jni_thread_startup();
24 void jni_thread_shutdown();
25 
26 /*******************************************************************************
27  *
28  * Function         btif_transfer_context
29  *
30  * Description      This function switches context to btif task
31  *
32  *                  p_cback   : callback used to process message in btif context
33  *                  event     : event id of message
34  *                  p_params  : parameter area passed to callback (copied)
35  *                  param_len : length of parameter area
36  *                  p_copy_cback : If set this function will be invoked for deep
37  *                                 copy
38  *
39  * Returns          void
40  *
41  ******************************************************************************/
42 
43 bt_status_t btif_transfer_context(tBTIF_CBACK* p_cback, uint16_t event,
44                                   char* p_params, int param_len,
45                                   tBTIF_COPY_CBACK* p_copy_cback);
46 
47 /**
48  * This function posts a task into the btif message loop, that executes it in
49  * the JNI message loop.
50  **/
51 bt_status_t do_in_jni_thread(base::OnceClosure task);
52 
53 bool is_on_jni_thread();
54 
55 void post_on_bt_jni(BtJniClosure closure);
56 
57 bluetooth::common::PostableContext* get_jni();
58