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

Commit 31661dfe authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Revert "Implement dumpsys for BufferHubBinderService""

parents 352789b9 2bf2988f
Loading
Loading
Loading
Loading
+8 −38
Original line number Diff line number Diff line
#include <stdio.h>

#include <binder/IServiceManager.h>
#include <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
#include <log/log.h>
#include <private/dvr/buffer_hub_binder.h>

namespace android {
namespace dvr {

status_t BufferHubBinderService::start(
    const std::shared_ptr<BufferHubService> &pdx_service) {
status_t BufferHubBinderService::start() {
  ProcessState::self()->startThreadPool();
  IPCThreadState::self()->disableBackgroundScheduling(true);

  BufferHubBinderService* service = new BufferHubBinderService();
  service->pdx_service_ = pdx_service;

  // Not using BinderService::publish because need to get an instance of this
  // class (above). Following code is the same as
  // BinderService::publishAndJoinThreadPool
  sp<IServiceManager> sm = defaultServiceManager();
  status_t result = sm->addService(String16(getServiceName()), service,
      /*allowIsolated =*/ false,
      /*dump flags =*/ IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT);
  if (result != NO_ERROR) {
  status_t result = BinderService<BufferHubBinderService>::publish();
  if (result != OK) {
    ALOGE("Publishing bufferhubd failed with error %d", result);
    return result;
  }

  sp<ProcessState> process_self(ProcessState::self());
  process_self->startThreadPool();
  process_self->giveThreadPoolName();
  IPCThreadState::self()->joinThreadPool();

  return result;
}

status_t BufferHubBinderService::dump(int fd, const Vector<String16> &args) {
status_t BufferHubBinderService::dump(int fd, const Vector<String16> & /* args */) {
  // TODO(b/115435506): not implemented yet
  FILE *out = fdopen(dup(fd), "w");

  // Currently not supporting args, so notify the user.
  if (!args.isEmpty()){
    fprintf(out, "Note: dumpsys bufferhubd currently does not support args."
        "Input arguments are ignored.\n");
  }

  // TODO(b/116526156): output real data in this class once we have it
  if (pdx_service_){
    // BufferHubService::Dumpstate(size_t) is not actually using the param
    // So just using 0 as the length
    fprintf(out, "%s", pdx_service_->DumpState(0).c_str());
  } else {
    fprintf(out, "PDX service not registered or died.\n");
  }
  fprintf(out, "BufferHubBinderService::dump(): Not Implemented.\n");

  fclose(out);
  return NO_ERROR;
+7 −8
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@

int main(int, char**) {
  int ret = -1;
  std::shared_ptr<android::dvr::BufferHubService> pdx_service;
  std::shared_ptr<android::pdx::Service> service;
  std::unique_ptr<android::pdx::ServiceDispatcher> dispatcher;

  // We need to be able to create endpoints with full perms.
@@ -33,16 +33,15 @@ int main(int, char**) {
  else
    ALOGI("New nofile limit is %llu/%llu.", rlim.rlim_cur, rlim.rlim_max);

  CHECK_ERROR(android::dvr::BufferHubBinderService::start() != android::OK,
              error, "Failed to create bufferhub binder service\n");

  dispatcher = android::pdx::ServiceDispatcher::Create();
  CHECK_ERROR(!dispatcher, error, "Failed to create service dispatcher\n");

  pdx_service = android::dvr::BufferHubService::Create();
  CHECK_ERROR(!pdx_service, error, "Failed to create bufferhub pdx service\n");
  dispatcher->AddService(pdx_service);

  ret = android::dvr::BufferHubBinderService::start(pdx_service);
  CHECK_ERROR(ret != android::NO_ERROR, error,
              "Failed to create bufferhub binder service\n");
  service = android::dvr::BufferHubService::Create();
  CHECK_ERROR(!service, error, "Failed to create bufferhubd service\n");
  dispatcher->AddService(service);

  ret = dvrSetSchedulerClass(0, "graphics");
  CHECK_ERROR(ret < 0, error, "Failed to set thread priority");
+2 −6
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@
#define ANDROID_DVR_BUFFER_HUB_BINDER_H

#include <binder/BinderService.h>
#include <private/dvr/buffer_hub.h>

#include "android/dvr/BnBufferHub.h"

@@ -11,14 +10,11 @@ namespace dvr {

class BufferHubBinderService : public BinderService<BufferHubBinderService>, public BnBufferHub {
 public:
  static status_t start(const std::shared_ptr<BufferHubService> &pdx_service);
  static status_t start();
  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;

 private:
  std::shared_ptr<BufferHubService> pdx_service_;
};

}  // namespace dvr
+1 −8
Original line number Diff line number Diff line
@@ -6,18 +6,11 @@ cc_test {
        "-DTRACE=0",
        "-DATRACE_TAG=ATRACE_TAG_GRAPHICS",
    ],
    header_libs: ["libdvr_headers"],
    static_libs: [
        "libbufferhub",
        "libbufferhubd",
        "libgmock",
    ],
    static_libs: ["libbufferhubd"],
    shared_libs: [
        "libbase",
        "libbinder",
        "liblog",
        "libpdx_default_transport",
        "libui",
        "libutils",
    ],
}
 No newline at end of file
+4 −9
Original line number Diff line number Diff line
#include <binder/IServiceManager.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <private/dvr/buffer_hub_binder.h>

#include <gtest/gtest.h>

namespace android {
namespace dvr {

@@ -13,12 +12,8 @@ class BufferHubBinderServiceTest : public ::testing::Test {
};

TEST_F(BufferHubBinderServiceTest, TestInitialize) {
  // Create a new service will kill the current one.
  // So just check if Binder service is running
  sp<IServiceManager> sm = defaultServiceManager();
  sp<IBinder> service = sm->checkService(
      String16(BufferHubBinderService::getServiceName()));
  EXPECT_THAT(service, ::testing::Ne(nullptr));
  // Test if start binder server returns OK
  EXPECT_EQ(BufferHubBinderService::start(), OK);
}

}  // namespace