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

Commit cfd12747 authored by Fan Xu's avatar Fan Xu
Browse files

Add a binder service to bufferhubd

First step of migrating for UDS(PDX) to Binder.
The binder interface is defined in the 'IBufferHub.aidl' file (now
empty class).

Provide with a simple test to check if the service could start normally.

Move all bufferhubd source files into a new cc_library_static build
rule.

Fixes: 115429751
Test: run "atest buffer_hub_binder_service-test". Passed.

Change-Id: I5f54796e2ff0bcf8f6827c9aeb229290ce127d42
parent c90c13c0
Loading
Loading
Loading
Loading
+43 −24
Original line number Diff line number Diff line
@@ -12,46 +12,65 @@
// See the License for the specific language governing permissions and
// limitations under the License.

sourceFiles = [
    "buffer_channel.cpp",
    "buffer_hub.cpp",
    "buffer_node.cpp",
    "bufferhubd.cpp",
    "consumer_channel.cpp",
    "producer_channel.cpp",
    "consumer_queue_channel.cpp",
    "producer_queue_channel.cpp",
]

headerLibraries = ["libdvr_headers"]

staticLibraries = [
    "libperformance",
    "libbufferhub",
]

sharedLibraries = [
    "libbase",
    "libbinder",
    "libcutils",
    "libgui",
    "liblog",
    "libpdx_default_transport",
    "libsync",
    "libutils",
    "libgui",
    "libui",
    "libpdx_default_transport",
    "libutils",
]

cc_library_static {
    name: "libbufferhubd",
    srcs: [
        "binder/android/dvr/IBufferHub.aidl",
        "buffer_channel.cpp",
        "buffer_hub.cpp",
        "buffer_hub_binder.cpp",
        "buffer_node.cpp",
        "consumer_channel.cpp",
        "consumer_queue_channel.cpp",
        "producer_channel.cpp",
        "producer_queue_channel.cpp",
    ],
    cflags: [
        "-DLOG_TAG=\"libbufferhubd\"",
        "-DTRACE=0",
        "-DATRACE_TAG=ATRACE_TAG_GRAPHICS",
    ],
    export_include_dirs: ["include"],
    header_libs: ["libdvr_headers"],
    shared_libs: sharedLibraries,
    static_libs: [
        "libbufferhub",
    ],
    aidl: {
        local_include_dirs: ["binder"],
        include_dirs: ["frameworks/native/aidl/binder"],
        export_aidl_headers: true,
    },
}

cc_binary {
    srcs: sourceFiles,
    srcs: ["bufferhubd.cpp"],
    cflags: [
        "-DLOG_TAG=\"bufferhubd\"",
        "-DTRACE=0",
        "-DATRACE_TAG=ATRACE_TAG_GRAPHICS",
    ],
    header_libs: headerLibraries,
    static_libs: staticLibraries,
    header_libs: ["libdvr_headers"],
    shared_libs: sharedLibraries,
    static_libs: [
        "libbufferhub",
        "libbufferhubd",
        "libperformance",
    ],
    name: "bufferhubd",
    init_rc: ["bufferhubd.rc"],
}

subdirs = ["tests"]
 No newline at end of file
+5 −0
Original line number Diff line number Diff line
package android.dvr;

/** {@hide} */
interface IBufferHub {
}
 No newline at end of file
+34 −0
Original line number Diff line number Diff line
#include <private/dvr/buffer_hub_binder.h>

#include <stdio.h>

#include <log/log.h>

namespace android {
namespace dvr {

status_t BufferHubBinderService::start() {
  ProcessState::self()->startThreadPool();
  IPCThreadState::self()->disableBackgroundScheduling(true);
  status_t result = BinderService<BufferHubBinderService>::publish();
  if (result != OK) {
    ALOGE("Publishing bufferhubd failed with error %d", result);
    return result;
  }

  return result;
}

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

  fprintf(out, "BufferHubBinderService::dump(): Not Implemented.\n");

  fclose(out);
  return NO_ERROR;
}


}  // namespace dvr
}  // namespace android
 No newline at end of file
+5 −1
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@

#include <dvr/performance_client_api.h>
#include <pdx/service_dispatcher.h>
#include <private/dvr/buffer_hub_binder.h>

#include "buffer_hub.h"

@@ -34,11 +35,14 @@ 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");

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

  ret = dvrSetSchedulerClass(0, "graphics");
+23 −0
Original line number Diff line number Diff line
#ifndef ANDROID_DVR_BUFFER_HUB_BINDER_H
#define ANDROID_DVR_BUFFER_HUB_BINDER_H

#include <binder/BinderService.h>

#include "android/dvr/BnBufferHub.h"

namespace android {
namespace dvr {

class BufferHubBinderService : public BinderService<BufferHubBinderService>, public BnBufferHub {
 public:
  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;
};

}  // namespace dvr
}  // namespace android

#endif // ANDROID_DVR_BUFFER_HUB_BINDER_H
 No newline at end of file
Loading