1 /* 2 * Copyright (C) 2015 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 #ifndef SYSTEM_CORE_LIBBINDERWRAPPER_REAL_BINDER_WRAPPER_H_ 18 #define SYSTEM_CORE_LIBBINDERWRAPPER_REAL_BINDER_WRAPPER_H_ 19 20 #include <map> 21 22 #include <binderwrapper/binder_wrapper.h> 23 24 namespace android { 25 26 class IBinder; 27 28 // Real implementation of BinderWrapper. 29 class RealBinderWrapper : public BinderWrapper { 30 public: 31 RealBinderWrapper(); 32 ~RealBinderWrapper() override; 33 34 // BinderWrapper: 35 sp<IBinder> GetService(const std::string& service_name) override; 36 bool RegisterService(const std::string& service_name, 37 const sp<IBinder>& binder) override; 38 sp<BBinder> CreateLocalBinder() override; 39 bool RegisterForDeathNotifications(const sp<IBinder>& binder, 40 const std::function<void()>& callback) override; 41 bool UnregisterForDeathNotifications(const sp<IBinder>& binder) override; 42 uid_t GetCallingUid() override; 43 pid_t GetCallingPid() override; 44 45 private: 46 class DeathRecipient; 47 48 // Map from binder handle to object that should be notified of the binder's 49 // death. 50 std::map<sp<IBinder>, sp<DeathRecipient>> death_recipients_; 51 52 RealBinderWrapper(const RealBinderWrapper&) = delete; 53 }; 54 55 } // namespace android 56 57 #endif // SYSTEM_CORE_LIBBINDER_WRAPPER_REAL_BINDER_WRAPPER_H_ 58