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

Commit 84ec4e14 authored by Tomasz Wasilczyk's avatar Tomasz Wasilczyk
Browse files

Migrate broadcast radio default HAL to the new logging API.

Bug: 112540729
Test: flash and boot
Change-Id: I18d8b508971cd9a9b7b2c9c221674d862ff351d6
parent 3fdc002b
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@ cc_binary {
        "libbase",
        "libhidlbase",
        "libhidltransport",
        "liblog",
        "libutils",
    ],
}
+7 −15
Original line number Diff line number Diff line
@@ -13,15 +13,12 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#define LOG_TAG "BcRadioDef.module"
#define LOG_NDEBUG 0

#include "BroadcastRadio.h"

#include <log/log.h>

#include "resources.h"

#include <android-base/logging.h>

namespace android {
namespace hardware {
namespace broadcastradio {
@@ -66,7 +63,6 @@ BroadcastRadio::BroadcastRadio(const VirtualRadio& virtualRadio)
      mAmFmConfig(gDefaultAmFmConfig) {}

Return<void> BroadcastRadio::getProperties(getProperties_cb _hidl_cb) {
    ALOGV("%s", __func__);
    _hidl_cb(mProperties);
    return {};
}
@@ -77,8 +73,6 @@ AmFmRegionConfig BroadcastRadio::getAmFmConfig() const {
}

Return<void> BroadcastRadio::getAmFmRegionConfig(bool full, getAmFmRegionConfig_cb _hidl_cb) {
    ALOGV("%s(%d)", __func__, full);

    if (full) {
        AmFmRegionConfig config = {};
        config.ranges = hidl_vec<AmFmBandRange>({
@@ -96,8 +90,6 @@ Return<void> BroadcastRadio::getAmFmRegionConfig(bool full, getAmFmRegionConfig_
}

Return<void> BroadcastRadio::getDabRegionConfig(getDabRegionConfig_cb _hidl_cb) {
    ALOGV("%s", __func__);

    hidl_vec<DabTableEntry> config = {
        {"5A", 174928},  {"7D", 194064},  {"8A", 195936},  {"8B", 197648},  {"9A", 202928},
        {"9B", 204640},  {"9C", 206352},  {"10B", 211648}, {"10C", 213360}, {"10D", 215072},
@@ -111,7 +103,7 @@ Return<void> BroadcastRadio::getDabRegionConfig(getDabRegionConfig_cb _hidl_cb)

Return<void> BroadcastRadio::openSession(const sp<ITunerCallback>& callback,
                                         openSession_cb _hidl_cb) {
    ALOGV("%s", __func__);
    LOG(DEBUG) << "opening new session...";

    /* For the needs of default implementation it's fine to instantiate new session object
     * out of the lock scope. If your implementation needs it, use reentrant lock.
@@ -122,7 +114,7 @@ Return<void> BroadcastRadio::openSession(const sp<ITunerCallback>& callback,

    auto oldSession = mSession.promote();
    if (oldSession != nullptr) {
        ALOGI("Closing previously opened tuner");
        LOG(INFO) << "closing previously opened tuner";
        oldSession->close();
        mSession = nullptr;
    }
@@ -134,14 +126,14 @@ Return<void> BroadcastRadio::openSession(const sp<ITunerCallback>& callback,
}

Return<void> BroadcastRadio::getImage(uint32_t id, getImage_cb _hidl_cb) {
    ALOGV("%s(%x)", __func__, id);
    LOG(DEBUG) << "fetching image " << std::hex << id;

    if (id == resources::demoPngId) {
        _hidl_cb(std::vector<uint8_t>(resources::demoPng, std::end(resources::demoPng)));
        return {};
    }

    ALOGI("Image %x doesn't exists", id);
    LOG(INFO) << "image " << std::hex << id << " doesn't exists";
    _hidl_cb({});
    return {};
}
@@ -149,7 +141,7 @@ Return<void> BroadcastRadio::getImage(uint32_t id, getImage_cb _hidl_cb) {
Return<void> BroadcastRadio::registerAnnouncementListener(
    const hidl_vec<AnnouncementType>& enabled, const sp<IAnnouncementListener>& /* listener */,
    registerAnnouncementListener_cb _hidl_cb) {
    ALOGV("%s(%s)", __func__, toString(enabled).c_str());
    LOG(DEBUG) << "registering announcement listener for " << toString(enabled);

    _hidl_cb(Result::NOT_SUPPORTED, nullptr);
    return {};
+23 −29
Original line number Diff line number Diff line
@@ -14,15 +14,12 @@
 * limitations under the License.
 */

#define LOG_TAG "BcRadioDef.tuner"
#define LOG_NDEBUG 0

#include "TunerSession.h"

#include "BroadcastRadio.h"

#include <android-base/logging.h>
#include <broadcastradio-utils-2x/Utils.h>
#include <log/log.h>

namespace android {
namespace hardware {
@@ -68,7 +65,7 @@ static ProgramInfo makeDummyProgramInfo(const ProgramSelector& selector) {
}

void TunerSession::tuneInternalLocked(const ProgramSelector& sel) {
    ALOGV("%s(%s)", __func__, toString(sel).c_str());
    LOG(VERBOSE) << "tune (internal) to " << toString(sel);

    VirtualProgram virtualProgram;
    ProgramInfo programInfo;
@@ -93,17 +90,18 @@ const VirtualRadio& TunerSession::virtualRadio() const {
}

Return<Result> TunerSession::tune(const ProgramSelector& sel) {
    ALOGV("%s(%s)", __func__, toString(sel).c_str());
    LOG(DEBUG) << "tune to " << toString(sel);

    lock_guard<mutex> lk(mMut);
    if (mIsClosed) return Result::INVALID_STATE;

    if (!utils::isSupported(module().mProperties, sel)) {
        ALOGW("Selector not supported");
        LOG(WARNING) << "selector not supported: " << toString(sel);
        return Result::NOT_SUPPORTED;
    }

    if (!utils::isValid(sel)) {
        ALOGE("ProgramSelector is not valid");
        LOG(ERROR) << "selector is not valid: " << toString(sel);
        return Result::INVALID_ARGUMENTS;
    }

@@ -119,8 +117,9 @@ Return<Result> TunerSession::tune(const ProgramSelector& sel) {
    return Result::OK;
}

Return<Result> TunerSession::scan(bool directionUp, bool /* skipSubChannel */) {
    ALOGV("%s", __func__);
Return<Result> TunerSession::scan(bool directionUp, bool skipSubChannel) {
    LOG(DEBUG) << "seek up=" << directionUp << " skipSubChannel=" << skipSubChannel;

    lock_guard<mutex> lk(mMut);
    if (mIsClosed) return Result::INVALID_STATE;

@@ -130,8 +129,8 @@ Return<Result> TunerSession::scan(bool directionUp, bool /* skipSubChannel */) {

    if (list.empty()) {
        mIsTuneCompleted = false;
        auto task = [this, directionUp]() {
            ALOGI("Performing failed seek up=%d", directionUp);
        auto task = [this]() {
            LOG(DEBUG) << "program list is empty, seek couldn't stop";

            mCallback->onTuneFailed(Result::TIMEOUT, {});
        };
@@ -162,7 +161,7 @@ Return<Result> TunerSession::scan(bool directionUp, bool /* skipSubChannel */) {

    mIsTuneCompleted = false;
    auto task = [this, tuneTo, directionUp]() {
        ALOGI("Performing seek up=%d", directionUp);
        LOG(VERBOSE) << "executing seek up=" << directionUp;

        lock_guard<mutex> lk(mMut);
        tuneInternalLocked(tuneTo);
@@ -173,21 +172,21 @@ Return<Result> TunerSession::scan(bool directionUp, bool /* skipSubChannel */) {
}

Return<Result> TunerSession::step(bool directionUp) {
    ALOGV("%s", __func__);
    LOG(DEBUG) << "step up=" << directionUp;
    lock_guard<mutex> lk(mMut);
    if (mIsClosed) return Result::INVALID_STATE;

    cancelLocked();

    if (!utils::hasId(mCurrentProgram, IdentifierType::AMFM_FREQUENCY)) {
        ALOGE("Can't step in anything else than AM/FM");
        LOG(WARNING) << "can't step in anything else than AM/FM";
        return Result::NOT_SUPPORTED;
    }

    auto stepTo = utils::getId(mCurrentProgram, IdentifierType::AMFM_FREQUENCY);
    auto range = getAmFmRangeLocked();
    if (!range) {
        ALOGE("Can't find current band");
        LOG(ERROR) << "can't find current band";
        return Result::INTERNAL_ERROR;
    }

@@ -201,7 +200,7 @@ Return<Result> TunerSession::step(bool directionUp) {

    mIsTuneCompleted = false;
    auto task = [this, stepTo]() {
        ALOGI("Performing step to %s", std::to_string(stepTo).c_str());
        LOG(VERBOSE) << "executing step to " << stepTo;

        lock_guard<mutex> lk(mMut);

@@ -213,7 +212,7 @@ Return<Result> TunerSession::step(bool directionUp) {
}

void TunerSession::cancelLocked() {
    ALOGV("%s", __func__);
    LOG(VERBOSE) << "cancelling current operations...";

    mThread.cancelAll();
    if (utils::getType(mCurrentProgram.primaryId) != IdentifierType::INVALID) {
@@ -222,7 +221,6 @@ void TunerSession::cancelLocked() {
}

Return<void> TunerSession::cancel() {
    ALOGV("%s", __func__);
    lock_guard<mutex> lk(mMut);
    if (mIsClosed) return {};

@@ -232,7 +230,7 @@ Return<void> TunerSession::cancel() {
}

Return<Result> TunerSession::startProgramListUpdates(const ProgramFilter& filter) {
    ALOGV("%s(%s)", __func__, toString(filter).c_str());
    LOG(DEBUG) << "requested program list updates, filter=" << toString(filter);
    lock_guard<mutex> lk(mMut);
    if (mIsClosed) return Result::INVALID_STATE;

@@ -259,41 +257,37 @@ Return<Result> TunerSession::startProgramListUpdates(const ProgramFilter& filter
}

Return<void> TunerSession::stopProgramListUpdates() {
    ALOGV("%s", __func__);
    LOG(DEBUG) << "requested program list updates to stop";
    return {};
}

Return<void> TunerSession::isConfigFlagSet(ConfigFlag flag, isConfigFlagSet_cb _hidl_cb) {
    ALOGV("%s(%s)", __func__, toString(flag).c_str());
    LOG(VERBOSE) << __func__ << " " << toString(flag);

    _hidl_cb(Result::NOT_SUPPORTED, false);
    return {};
}

Return<Result> TunerSession::setConfigFlag(ConfigFlag flag, bool value) {
    ALOGV("%s(%s, %d)", __func__, toString(flag).c_str(), value);
    LOG(VERBOSE) << __func__ << " " << toString(flag) << " " << value;

    return Result::NOT_SUPPORTED;
}

Return<void> TunerSession::setParameters(const hidl_vec<VendorKeyValue>& /* parameters */,
                                         setParameters_cb _hidl_cb) {
    ALOGV("%s", __func__);

    _hidl_cb({});
    return {};
}

Return<void> TunerSession::getParameters(const hidl_vec<hidl_string>& /* keys */,
                                         getParameters_cb _hidl_cb) {
    ALOGV("%s", __func__);

    _hidl_cb({});
    return {};
}

Return<void> TunerSession::close() {
    ALOGV("%s", __func__);
    LOG(DEBUG) << "closing session...";
    lock_guard<mutex> lk(mMut);
    if (mIsClosed) return {};

@@ -304,7 +298,7 @@ Return<void> TunerSession::close() {

std::optional<AmFmBandRange> TunerSession::getAmFmRangeLocked() const {
    if (!mIsTuneCompleted) {
        ALOGW("tune operation in process");
        LOG(WARNING) << "tune operation is in process";
        return {};
    }
    if (!utils::hasId(mCurrentProgram, IdentifierType::AMFM_FREQUENCY)) return {};
+1 −4
Original line number Diff line number Diff line
@@ -13,15 +13,12 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#define LOG_TAG "BcRadioDef.VirtualProgram"

#include "VirtualProgram.h"

#include "resources.h"

#include <android-base/logging.h>
#include <broadcastradio-utils-2x/Utils.h>
#include <log/log.h>

namespace android {
namespace hardware {
@@ -72,7 +69,7 @@ VirtualProgram::operator ProgramInfo() const {
            info.physicallyTunedTo = selectId(IdentifierType::SXM_CHANNEL);
            break;
        default:
            LOG(FATAL) << "Unsupported program type: " << toString(pType);
            LOG(FATAL) << "unsupported program type: " << toString(pType);
    }

    info.infoFlags |= ProgramInfoFlags::TUNED;
+0 −4
Original line number Diff line number Diff line
@@ -13,13 +13,9 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#define LOG_TAG "BcRadioDef.VirtualRadio"
//#define LOG_NDEBUG 0

#include "VirtualRadio.h"

#include <broadcastradio-utils-2x/Utils.h>
#include <log/log.h>

namespace android {
namespace hardware {
Loading