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 // TODO(b/69122224): remove this 36 // For HidlBinderSupport and autogenerated code 37 extern DoNotDestruct<ConcurrentMap<const ::android::hidl::base::V1_0::IBase*, 38 wp<::android::hardware::BHwBinder>>> 39 gBnMap; 40 41 using BnConstructorMap = ConcurrentMap<std::string, std::function<sp<IBinder>(void*)>>; 42 // For HidlBinderSupport and autogenerated code 43 // value function receives reinterpret_cast<void *>(static_cast<IFoo *>(foo)), 44 // returns sp<IBinder> 45 BnConstructorMap& getBnConstructorMap(); 46 47 using BsConstructorMap = ConcurrentMap<std::string, 48 std::function<sp<::android::hidl::base::V1_0::IBase>(void*)>>; 49 // For HidlPassthroughSupport and autogenerated code 50 // value function receives reinterpret_cast<void *>(static_cast<IFoo *>(foo)), 51 // returns sp<IBase> 52 BsConstructorMap& getBsConstructorMap(); 53 } // namespace details 54 } // namespace hardware 55 } // namespace android 56 57 #endif 58