1 /* 2 * Copyright (c) 2022, 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 CPP_WATCHDOG_SERVER_SRC_AIBINDERDEATHREGISTRATIONWRAPPER_H_ 18 #define CPP_WATCHDOG_SERVER_SRC_AIBINDERDEATHREGISTRATIONWRAPPER_H_ 19 20 #include <android/binder_auto_utils.h> 21 #include <utils/RefBase.h> 22 23 namespace android { 24 namespace automotive { 25 namespace watchdog { 26 27 class AIBinderDeathRegistrationWrapperInterface : public virtual android::RefBase { 28 public: 29 /** 30 * Links the recipient to the binder's death. The cookie is passed to the recipient in case 31 * the binder dies. 32 */ 33 virtual ndk::ScopedAStatus linkToDeath(AIBinder* binder, AIBinder_DeathRecipient* recipient, 34 void* cookie) const = 0; 35 /** 36 * Unlinks the recipient from the binder's death. Pass the same cookie that was used to link to 37 * the binder's death. 38 */ 39 virtual ndk::ScopedAStatus unlinkToDeath(AIBinder* binder, AIBinder_DeathRecipient* recipient, 40 void* cookie) const = 0; 41 }; 42 43 class AIBinderDeathRegistrationWrapper final : public AIBinderDeathRegistrationWrapperInterface { 44 public: 45 ndk::ScopedAStatus linkToDeath(AIBinder* binder, AIBinder_DeathRecipient* recipient, 46 void* cookie) const override; 47 ndk::ScopedAStatus unlinkToDeath(AIBinder* binder, AIBinder_DeathRecipient* recipient, 48 void* cookie) const override; 49 }; 50 51 } // namespace watchdog 52 } // namespace automotive 53 } // namespace android 54 55 #endif // CPP_WATCHDOG_SERVER_SRC_AIBINDERDEATHREGISTRATIONWRAPPER_H_ 56