blob: fa05383fbfcf80eb9cfac4282c5574f61542a6ad [file] [log] [blame]
Daniel Eratbe43a392015-09-08 13:20:02 -06001/*
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
Luis Hector Chavez623ce742016-05-20 23:12:14 -070020#include <map>
21
Daniel Eratbe43a392015-09-08 13:20:02 -060022#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,
Christopher Wiley09910f42016-04-12 09:23:40 -070041 const ::base::Closure& callback) override;
Daniel Eratbe43a392015-09-08 13:20:02 -060042 bool UnregisterForDeathNotifications(const sp<IBinder>& binder) override;
Daniel Erat7cba9db2015-10-16 09:04:33 -060043 uid_t GetCallingUid() override;
44 pid_t GetCallingPid() override;
Daniel Eratbe43a392015-09-08 13:20:02 -060045
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_