• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 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 NETD_SERVER_OEM_NETD_LISTENER_H
18 #define NETD_SERVER_OEM_NETD_LISTENER_H
19 
20 #include <map>
21 #include <mutex>
22 
23 #include <android-base/thread_annotations.h>
24 #include "com/android/internal/net/BnOemNetd.h"
25 #include "com/android/internal/net/IOemNetdUnsolicitedEventListener.h"
26 
27 namespace com {
28 namespace android {
29 namespace internal {
30 namespace net {
31 
32 class OemNetdListener : public BnOemNetd {
33   public:
34     using OemUnsolListenerMap = std::map<const ::android::sp<IOemNetdUnsolicitedEventListener>,
35                                          const ::android::sp<::android::IBinder::DeathRecipient>>;
36 
37     OemNetdListener() = default;
38     ~OemNetdListener() = default;
39     static ::android::sp<::android::IBinder> getListener();
40 
41     ::android::binder::Status isAlive(bool* alive) override;
42     ::android::binder::Status registerOemUnsolicitedEventListener(
43             const ::android::sp<IOemNetdUnsolicitedEventListener>& listener) override;
44 
45   private:
46     std::mutex mOemUnsolicitedMutex;
47 
48     OemUnsolListenerMap mOemUnsolListenerMap GUARDED_BY(mOemUnsolicitedMutex);
49 
50     void registerOemUnsolicitedEventListenerInternal(
51             const ::android::sp<IOemNetdUnsolicitedEventListener>& listener)
52             EXCLUDES(mOemUnsolicitedMutex);
53     void unregisterOemUnsolicitedEventListenerInternal(
54             const ::android::sp<IOemNetdUnsolicitedEventListener>& listener)
55             EXCLUDES(mOemUnsolicitedMutex);
56 };
57 
58 }  // namespace net
59 }  // namespace internal
60 }  // namespace android
61 }  // namespace com
62 
63 #endif  // NETD_SERVER_OEM_NETD_LISTENER_H
64