Pawin Vongmasa | 270dd6a | 2019-04-06 04:41:15 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 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 ANDROID_MEDIASERVICE_DEATHNOTIFIER_H |
| 18 | #define ANDROID_MEDIASERVICE_DEATHNOTIFIER_H |
| 19 | |
Wonsik Kim | e8e9815 | 2022-12-16 16:04:17 -0800 | [diff] [blame] | 20 | #include <android/binder_auto_utils.h> |
Pawin Vongmasa | 270dd6a | 2019-04-06 04:41:15 -0700 | [diff] [blame] | 21 | #include <android/hidl/base/1.0/IBase.h> |
| 22 | #include <binder/Binder.h> |
| 23 | #include <hidl/HidlSupport.h> |
| 24 | |
| 25 | #include <variant> |
| 26 | |
| 27 | namespace android { |
| 28 | |
| 29 | class DeathNotifier { |
| 30 | public: |
| 31 | using HBase = hidl::base::V1_0::IBase; |
| 32 | using Notify = std::function<void()>; |
| 33 | |
| 34 | DeathNotifier(sp<IBinder> const& service, Notify const& notify); |
| 35 | DeathNotifier(sp<HBase> const& service, Notify const& notify); |
Wonsik Kim | e8e9815 | 2022-12-16 16:04:17 -0800 | [diff] [blame] | 36 | DeathNotifier(::ndk::SpAIBinder const& service, Notify const& notify); |
Pawin Vongmasa | 270dd6a | 2019-04-06 04:41:15 -0700 | [diff] [blame] | 37 | DeathNotifier(DeathNotifier&& other); |
| 38 | ~DeathNotifier(); |
| 39 | |
Devin Moore | 55128e7 | 2024-03-18 22:37:53 +0000 | [diff] [blame] | 40 | class DeathRecipient; |
| 41 | |
Pawin Vongmasa | 270dd6a | 2019-04-06 04:41:15 -0700 | [diff] [blame] | 42 | private: |
Wonsik Kim | e8e9815 | 2022-12-16 16:04:17 -0800 | [diff] [blame] | 43 | std::variant<std::monostate, sp<IBinder>, sp<HBase>, ::ndk::SpAIBinder> mService; |
Pawin Vongmasa | 270dd6a | 2019-04-06 04:41:15 -0700 | [diff] [blame] | 44 | |
Pawin Vongmasa | 270dd6a | 2019-04-06 04:41:15 -0700 | [diff] [blame] | 45 | sp<DeathRecipient> mDeathRecipient; |
| 46 | }; |
| 47 | |
| 48 | } // namespace android |
| 49 | |
| 50 | #endif // ANDROID_MEDIASERVICE_DEATHNOTIFIER_H |
| 51 | |