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

Commit f646be06 authored by Peter Kalauskas's avatar Peter Kalauskas
Browse files

Add separate lazy service target to cas

Test: Run cts test android.media.cts.MediaCasTest
Bug: 119050069
Change-Id: I5117e4d10931affe85f2a0bb437d2fefb291e18f
parent f919d0a0
Loading
Loading
Loading
Loading
+18 −4
Original line number Diff line number Diff line
cc_binary {
    name: "android.hardware.cas@1.0-service",
    vintf_fragments: ["android.hardware.cas@1.0-service.xml"],
cc_defaults {
    name: "cas_service_defaults",
    defaults: ["hidl_defaults"],
    vendor: true,
    relative_install_path: "hw",
@@ -14,7 +13,6 @@ cc_binary {
    ],

    compile_multilib: "32",
    init_rc: ["android.hardware.cas@1.0-service.rc"],

    shared_libs: [
      "android.hardware.cas@1.0",
@@ -32,3 +30,19 @@ cc_binary {
      "media_plugin_headers",
    ],
}

cc_binary {
    name: "android.hardware.cas@1.0-service",
    vintf_fragments: ["android.hardware.cas@1.0-service.xml"],
    defaults: ["cas_service_defaults"],
    init_rc: ["android.hardware.cas@1.0-service.rc"],
}

cc_binary {
    name: "android.hardware.cas@1.0-service-lazy",
    vintf_fragments: ["android.hardware.cas@1.0-service-lazy.xml"],
    overrides: ["android.hardware.cas@1.0-service"],
    defaults: ["cas_service_defaults"],
    init_rc: ["android.hardware.cas@1.0-service-lazy.rc"],
    cflags: ["-DLAZY_SERVICE"],
}
+9 −0
Original line number Diff line number Diff line
service vendor.cas-hal-1-0 /vendor/bin/hw/android.hardware.cas@1.0-service
    interface android.hardware.cas@1.0::IMediaCasService default
    oneshot
    disabled
    class hal
    user media
    group mediadrm drmrpc
    ioprio rt 4
    writepid /dev/cpuset/foreground/tasks
+11 −0
Original line number Diff line number Diff line
<manifest version="1.0" type="device">
    <hal format="hidl">
        <name>android.hardware.cas</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IMediaCasService</name>
            <instance>default</instance>
        </interface>
    </hal>
</manifest>
+21 −11
Original line number Diff line number Diff line
@@ -15,7 +15,11 @@
 */

//#define LOG_NDEBUG 0
#ifdef LAZY_SERVICE
#define LOG_TAG "android.hardware.cas@1.0-service-lazy"
#else
#define LOG_TAG "android.hardware.cas@1.0-service"
#endif

#include <binder/ProcessState.h>
#include <hidl/HidlTransportSupport.h>
@@ -25,24 +29,30 @@

using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using android::hardware::cas::V1_0::implementation::MediaCasService;
using android::hardware::LazyServiceRegistrar;
using android::hardware::cas::V1_0::IMediaCasService;
using android::hardware::cas::V1_0::implementation::MediaCasService;

int main() {
    ALOGD("android.hardware.cas@1.0-service starting...");

    // The CAS HAL may communicate to other vendor components via
    // /dev/vndbinder
    android::ProcessState::initWithDriver("/dev/vndbinder");
#ifdef LAZY_SERVICE
const bool kLazyService = true;
#else
const bool kLazyService = false;
#endif

int main() {
    configureRpcThreadpool(8, true /* callerWillJoin */);

    // Setup hwbinder service
    android::sp<IMediaCasService> service = new MediaCasService();
    android::status_t status = service->registerAsService();
    LOG_ALWAYS_FATAL_IF(
            status != android::OK,
            "Error while registering cas service: %d", status);
    android::status_t status;
    if (kLazyService) {
        auto serviceRegistrar = std::make_shared<LazyServiceRegistrar>();
        status = serviceRegistrar->registerServiceWithCallback(service);
    } else {
        status = service->registerAsService();
    }
    LOG_ALWAYS_FATAL_IF(status != android::OK, "Error while registering cas service: %d", status);

    joinRpcThreadpool();
    return 0;
}