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

Commit 8d9d33ee authored by Fan Xu's avatar Fan Xu
Browse files

Remove getServiceProxy() on BufferHubBinderService

We didn't notice that binder has already defined a getService(name,
outref*) function to get a binder service when originnally writing
getServiceProxy(). Therefore, keep the function there is unnecessary.

Test: "atest buffer_hub_binder_service-test" passed.
Bug: 112338294
Change-Id: I8ec8e452f577867e0f345d61f096456fea1456ac
parent 3cc66c91
Loading
Loading
Loading
Loading
+0 −19
Original line number Diff line number Diff line
@@ -59,25 +59,6 @@ status_t BufferHubBinderService::dump(int fd, const Vector<String16>& args) {
  return NO_ERROR;
}

sp<IBufferHub> BufferHubBinderService::getServiceProxy() {
  sp<IServiceManager> sm = defaultServiceManager();
  sp<IBinder> service = sm->checkService(String16(getServiceName()));

  if (service == nullptr) {
    ALOGE("getServiceProxy(): %s binder service not found!", getServiceName());
    return nullptr;
  }

  sp<IBufferHub> ret = interface_cast<IBufferHub>(service);
  if (ret == nullptr) {
    ALOGE("getServiceProxy(): %s binder service type casting error!",
          getServiceName());
    return nullptr;
  }

  return ret;
}

sp<IBufferClient> BufferHubBinderService::createBuffer(
    uint32_t width, uint32_t height, uint32_t layer_count, uint32_t format,
    uint64_t usage, uint64_t user_metadata_size) {
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ class IBufferHub : public IInterface {
 public:
  DECLARE_META_INTERFACE(BufferHub);

  static const char* getServiceName() { return "bufferhubd"; }
  virtual sp<IBufferClient> createBuffer(uint32_t width, uint32_t height,
                                         uint32_t layer_count, uint32_t format,
                                         uint64_t usage,
+0 −4
Original line number Diff line number Diff line
@@ -15,14 +15,10 @@ class BufferHubBinderService : public BinderService<BufferHubBinderService>,
                               public BnBufferHub {
 public:
  static status_t start(const std::shared_ptr<BufferHubService>& pdx_service);
  static const char* getServiceName() { return "bufferhubd"; }
  // Dump bufferhub related information to given fd (usually stdout)
  // usage: adb shell dumpsys bufferhubd
  virtual status_t dump(int fd, const Vector<String16>& args) override;

  // Helper function to get the BpReference to this service
  static sp<IBufferHub> getServiceProxy();

  // Binder IPC functions
  sp<IBufferClient> createBuffer(uint32_t width, uint32_t height,
                                 uint32_t layer_count, uint32_t format,
+6 −4
Original line number Diff line number Diff line
#include <binder/IServiceManager.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <private/dvr/IBufferClient.h>
#include <private/dvr/buffer_hub_binder.h>
#include <private/dvr/IBufferHub.h>
#include <ui/PixelFormat.h>

namespace android {
@@ -9,7 +10,6 @@ namespace dvr {

namespace {

using testing::Ne;
using testing::NotNull;

const int kWidth = 640;
@@ -22,8 +22,10 @@ const size_t kUserMetadataSize = 0;
class BufferHubBinderServiceTest : public ::testing::Test {
 protected:
  void SetUp() override {
    service = BufferHubBinderService::getServiceProxy();
    ASSERT_THAT(service, Ne(nullptr));
    status_t ret = getService<IBufferHub>(
        String16(IBufferHub::getServiceName()), &service);
    ASSERT_EQ(ret, OK);
    ASSERT_THAT(service, NotNull());
  }

  sp<IBufferHub> service;