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