• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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 // All static variables go here, to control initialization and
18 // destruction order in the library.
19 
20 #ifndef ANDROID_HARDWARE_HIDL_STATIC_H
21 #define ANDROID_HARDWARE_HIDL_STATIC_H
22 
23 #include <functional>
24 
25 #include <android/hidl/base/1.0/IBase.h>
26 #include <hidl/ConcurrentMap.h>
27 #include <hwbinder/IBinder.h>
28 #include <hwbinder/IInterface.h>
29 #include <utils/StrongPointer.h>
30 
31 namespace android {
32 namespace hardware {
33 namespace details {
34 
35 struct SchedPrio {
36     int sched_policy;
37     int prio;
38 };
39 
40 // TODO(b/69122224): remove this
41 extern DoNotDestruct<ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, SchedPrio>>
42         gServicePrioMap;
43 // TODO(b/69122224): remove this
44 extern DoNotDestruct<ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, bool>> gServiceSidMap;
45 
46 // TODO(b/69122224): remove this
47 // For HidlBinderSupport and autogenerated code
48 extern DoNotDestruct<ConcurrentMap<const ::android::hidl::base::V1_0::IBase*,
49                                    wp<::android::hardware::BHwBinder>>>
50         gBnMap;
51 
52 using BnConstructorMap = ConcurrentMap<std::string, std::function<sp<IBinder>(void*)>>;
53 // For HidlBinderSupport and autogenerated code
54 // value function receives reinterpret_cast<void *>(static_cast<IFoo *>(foo)),
55 // returns sp<IBinder>
56 BnConstructorMap& getBnConstructorMap();
57 
58 using BsConstructorMap = ConcurrentMap<std::string,
59         std::function<sp<::android::hidl::base::V1_0::IBase>(void*)>>;
60 // For HidlPassthroughSupport and autogenerated code
61 // value function receives reinterpret_cast<void *>(static_cast<IFoo *>(foo)),
62 // returns sp<IBase>
63 BsConstructorMap& getBsConstructorMap();
64 }  // namespace details
65 }  // namespace hardware
66 }  // namespace android
67 
68 #endif
69