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

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

Merge "Check if the tuner feature is supported before waiting for the TRM service" into sc-dev

parents 4208d1d0 c5eb8273
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ cc_library {
        "android.hardware.tv.tuner@1.0",
        "android.hardware.tv.tuner@1.1",
        "libbase",
        "libbinder",
        "libbinder_ndk",
        "libcutils",
        "libfmq",
+29 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
#define LOG_TAG "TunerService"

#include <android/binder_manager.h>
#include <android/content/pm/IPackageManagerNative.h>
#include <binder/IServiceManager.h>
#include <utils/Log.h>
#include "TunerService.h"
#include "TunerFrontend.h"
@@ -50,6 +52,33 @@ using ::android::hardware::tv::tuner::V1_1::FrontendDtmbCapabilities;
namespace android {

TunerService::TunerService() {
    sp<IServiceManager> serviceMgr = defaultServiceManager();
    sp<content::pm::IPackageManagerNative> packageMgr;
    if (serviceMgr.get() == nullptr) {
        ALOGE("%s: Cannot find service manager", __func__);
        return;
    } else {
        sp<IBinder> binder = serviceMgr->waitForService(String16("package_native"));
        packageMgr = interface_cast<content::pm::IPackageManagerNative>(binder);
    }

    bool hasFeature = false;
    if (packageMgr != nullptr) {
        binder::Status status = packageMgr->hasSystemFeature(FEATURE_TUNER, 0, &hasFeature);
        if (!status.isOk()) {
            ALOGE("%s: hasSystemFeature failed: %s",
                    __func__, status.exceptionMessage().c_str());
            return;
        }
        if (!hasFeature) {
            ALOGD("Current device does not support tuner feaure.");
            return;
        }
    } else {
        ALOGD("%s: Cannot find package manager.", __func__);
        return;
    }

    ::ndk::SpAIBinder binder(AServiceManager_waitForService("tv_tuner_resource_mgr"));
    mTunerResourceManager = ITunerResourceManager::fromBinder(binder);
    updateTunerResources();
+2 −0
Original line number Diff line number Diff line
@@ -72,6 +72,8 @@ namespace android {
const static int TUNER_HAL_VERSION_UNKNOWN = 0;
const static int TUNER_HAL_VERSION_1_0 = 1 << 16;
const static int TUNER_HAL_VERSION_1_1 = (1 << 16) | 1;
// System Feature defined in PackageManager
static const ::android::String16 FEATURE_TUNER(::android::String16("android.hardware.tv.tuner"));

typedef enum {
    FRONTEND,