real_binder_wrapper.h 1.8 KB

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