Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78d08719 authored by Alex Vakulenko's avatar Alex Vakulenko Committed by android-build-merger
Browse files

Merge "libbinderwrapper: Add BinderWrapper::GetOrCreateInstance()" am: 946d8152

am: 1a0a184a

* commit '1a0a184a':
  libbinderwrapper: Add BinderWrapper::GetOrCreateInstance()
parents 26c804fa 1a0a184a
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -30,6 +30,7 @@ class BBinder;
class IBinder;
class IBinder;


// Wraps libbinder to make it testable.
// Wraps libbinder to make it testable.
// NOTE: Static methods of this class are not thread-safe.
class BinderWrapper {
class BinderWrapper {
 public:
 public:
  virtual ~BinderWrapper() {}
  virtual ~BinderWrapper() {}
@@ -50,6 +51,10 @@ class BinderWrapper {
  // InitForTesting().
  // InitForTesting().
  static BinderWrapper* Get();
  static BinderWrapper* Get();


  // Returns the singleton instance if it was previously created by Create() or
  // set by InitForTesting(), or creates a new one by calling Create().
  static BinderWrapper* GetOrCreateInstance();

  // Gets the binder for communicating with the service identified by
  // Gets the binder for communicating with the service identified by
  // |service_name|, returning null immediately if it doesn't exist.
  // |service_name|, returning null immediately if it doesn't exist.
  virtual sp<IBinder> GetService(const std::string& service_name) = 0;
  virtual sp<IBinder> GetService(const std::string& service_name) = 0;
+7 −0
Original line number Original line Diff line number Diff line
@@ -50,4 +50,11 @@ BinderWrapper* BinderWrapper::Get() {
  return instance_;
  return instance_;
}
}


// static
BinderWrapper* BinderWrapper::GetOrCreateInstance() {
  if (!instance_)
    instance_ = new RealBinderWrapper();
  return instance_;
}

}  // namespace android
}  // namespace android