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

Commit eb2b87ba authored by Tomasz Wasilczyk's avatar Tomasz Wasilczyk Committed by Android (Google) Code Review
Browse files

Merge "Implement program list fetching."

parents a557df85 bceb8858
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -21,9 +21,11 @@ hidl_interface {
        "IdentifierType",
        "Metadata",
        "MetadataKey",
        "ProgramFilter",
        "ProgramIdentifier",
        "ProgramInfo",
        "ProgramInfoFlags",
        "ProgramListChunk",
        "ProgramSelector",
        "Properties",
        "Result",
+15 −0
Original line number Diff line number Diff line
@@ -38,6 +38,21 @@ interface ITunerCallback {
     */
    oneway onCurrentProgramInfoChanged(ProgramInfo info);

    /**
     * A delta update of the program list, called whenever there's a change in
     * the list.
     *
     * If there are frequent changes, HAL implementation must throttle the rate
     * of the updates.
     *
     * There is a hard limit on binder transaction buffer, and the list must
     * not exceed it. For large lists, HAL implementation must split them to
     * multiple chunks, no larger than 500kiB each.
     *
     * @param chunk A chunk of the program list update.
     */
    oneway onProgramListUpdated(ProgramListChunk chunk);

    /**
     * Method called by the HAL when the antenna gets connected or disconnected.
     *
+26 −0
Original line number Diff line number Diff line
@@ -76,6 +76,32 @@ interface ITunerSession {
     */
    cancel();

    /**
     * Applies a filter to the program list and starts sending program list
     * updates over onProgramListUpdated callback.
     *
     * There may be only one updates stream active at the moment. Calling this
     * method again must result in cancelling the previous update request.
     *
     * This call clears the program list on the client side, the HAL must send
     * the whole list again.
     *
     * If the program list scanning hardware (i.e. background tuner) is
     * unavailable at the moment, the call must succeed and start updates
     * when it becomes available.
     *
     * @param filter Filter to apply on the fetched program list.
     * @return result OK successfully started fetching list updates.
     *                NOT_SUPPORTED program list scanning is not supported
     *                by the hardware.
     */
    startProgramListUpdates(ProgramFilter filter) generates (Result result);

    /**
     * Stops sending program list updates.
     */
    stopProgramListUpdates();

    /**
     * Fetches the current setting of a given config flag.
     *
+33 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ namespace delay {
static constexpr auto scan = 200ms;
static constexpr auto step = 100ms;
static constexpr auto tune = 150ms;
static constexpr auto list = 1s;

}  // namespace delay

@@ -205,6 +206,38 @@ Return<void> TunerSession::cancel() {
    return {};
}

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

    auto list = virtualRadio().getProgramList();
    vector<VirtualProgram> filteredList;
    auto filterCb = [&filter](const VirtualProgram& program) {
        return utils::satisfies(filter, program.selector);
    };
    std::copy_if(list.begin(), list.end(), std::back_inserter(filteredList), filterCb);

    auto task = [this, list]() {
        lock_guard<mutex> lk(mMut);

        ProgramListChunk chunk = {};
        chunk.purge = true;
        chunk.complete = true;
        chunk.modified = hidl_vec<ProgramInfo>(list.begin(), list.end());

        mCallback->onProgramListUpdated(chunk);
    };
    mThread.schedule(task, delay::list);

    return Result::OK;
}

Return<void> TunerSession::stopProgramListUpdates() {
    ALOGV("%s", __func__);
    return {};
}

Return<void> TunerSession::getConfigFlag(ConfigFlag flag, getConfigFlag_cb _hidl_cb) {
    ALOGV("%s(%s)", __func__, toString(flag).c_str());

+2 −0
Original line number Diff line number Diff line
@@ -38,6 +38,8 @@ struct TunerSession : public ITunerSession {
    virtual Return<Result> scan(bool directionUp, bool skipSubChannel) override;
    virtual Return<Result> step(bool directionUp) override;
    virtual Return<void> cancel() override;
    virtual Return<Result> startProgramListUpdates(const ProgramFilter& filter);
    virtual Return<void> stopProgramListUpdates();
    virtual Return<void> getConfigFlag(ConfigFlag flag, getConfigFlag_cb _hidl_cb);
    virtual Return<Result> setConfigFlag(ConfigFlag flag, bool value);
    virtual Return<void> setParameters(const hidl_vec<VendorKeyValue>& parameters,
Loading