mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 05:49:27 +00:00
Implement default radio HAL stopProgramListUpdates
Implemented stopProgramListUpdates method in default AIDL broadcast radio HAL. Created a separate thread for program list updates, so that canceling pending tuning operations and canceling pending program list updates are independent. Bug: 243681584 Test: atest VtsHalBroadcastradioAidlTargetTest Change-Id: I9e09f267a2264fa0cbc280d0d6ea71037db519ac
This commit is contained in:
@@ -115,7 +115,8 @@ BroadcastRadio::BroadcastRadio(const VirtualRadio& virtualRadio)
|
||||
}
|
||||
|
||||
BroadcastRadio::~BroadcastRadio() {
|
||||
mThread.reset();
|
||||
mTuningThread.reset();
|
||||
mProgramListThread.reset();
|
||||
}
|
||||
|
||||
ScopedAStatus BroadcastRadio::getAmFmRegionConfig(bool full, AmFmRegionConfig* returnConfigs) {
|
||||
@@ -239,7 +240,7 @@ ScopedAStatus BroadcastRadio::tune(const ProgramSelector& program) {
|
||||
callback->onCurrentProgramInfoChanged(programInfo);
|
||||
};
|
||||
auto cancelTask = [program, callback]() { callback->onTuneFailed(Result::CANCELED, program); };
|
||||
mThread->schedule(task, cancelTask, kTuneDelayTimeMs);
|
||||
mTuningThread->schedule(task, cancelTask, kTuneDelayTimeMs);
|
||||
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
@@ -267,7 +268,7 @@ ScopedAStatus BroadcastRadio::seek(bool directionUp, bool skipSubChannel) {
|
||||
|
||||
callback->onTuneFailed(Result::TIMEOUT, {});
|
||||
};
|
||||
mThread->schedule(task, cancelTask, kSeekDelayTimeMs);
|
||||
mTuningThread->schedule(task, cancelTask, kSeekDelayTimeMs);
|
||||
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
@@ -300,7 +301,7 @@ ScopedAStatus BroadcastRadio::seek(bool directionUp, bool skipSubChannel) {
|
||||
}
|
||||
callback->onCurrentProgramInfoChanged(programInfo);
|
||||
};
|
||||
mThread->schedule(task, cancelTask, kSeekDelayTimeMs);
|
||||
mTuningThread->schedule(task, cancelTask, kSeekDelayTimeMs);
|
||||
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
@@ -355,15 +356,15 @@ ScopedAStatus BroadcastRadio::step(bool directionUp) {
|
||||
callback->onCurrentProgramInfoChanged(programInfo);
|
||||
};
|
||||
auto cancelTask = [callback]() { callback->onTuneFailed(Result::CANCELED, {}); };
|
||||
mThread->schedule(task, cancelTask, kStepDelayTimeMs);
|
||||
mTuningThread->schedule(task, cancelTask, kStepDelayTimeMs);
|
||||
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
void BroadcastRadio::cancelLocked() {
|
||||
LOG(DEBUG) << __func__ << ": cancelling current operations...";
|
||||
LOG(DEBUG) << __func__ << ": cancelling current tuning operations...";
|
||||
|
||||
mThread->cancelAll();
|
||||
mTuningThread->cancelAll();
|
||||
if (mCurrentProgram.primaryId.type != IdentifierType::INVALID) {
|
||||
mIsTuneCompleted = true;
|
||||
}
|
||||
@@ -388,6 +389,8 @@ ScopedAStatus BroadcastRadio::startProgramListUpdates(const ProgramFilter& filte
|
||||
|
||||
lock_guard<mutex> lk(mMutex);
|
||||
|
||||
cancelProgramListUpdateLocked();
|
||||
|
||||
const auto& list = mVirtualRadio.getProgramList();
|
||||
vector<VirtualProgram> filteredList;
|
||||
std::copy_if(list.begin(), list.end(), std::back_inserter(filteredList), filterCb);
|
||||
@@ -410,14 +413,20 @@ ScopedAStatus BroadcastRadio::startProgramListUpdates(const ProgramFilter& filte
|
||||
|
||||
callback->onProgramListUpdated(chunk);
|
||||
};
|
||||
mThread->schedule(task, kListDelayTimeS);
|
||||
mProgramListThread->schedule(task, kListDelayTimeS);
|
||||
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
void BroadcastRadio::cancelProgramListUpdateLocked() {
|
||||
LOG(DEBUG) << __func__ << ": cancelling current program list update operations...";
|
||||
mProgramListThread->cancelAll();
|
||||
}
|
||||
|
||||
ScopedAStatus BroadcastRadio::stopProgramListUpdates() {
|
||||
LOG(DEBUG) << __func__ << ": requested program list updates to stop...";
|
||||
// TODO(b/243681584) Implement stop program list updates method
|
||||
lock_guard<mutex> lk(mMutex);
|
||||
cancelProgramListUpdateLocked();
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,9 @@ class BroadcastRadio final : public BnBroadcastRadio {
|
||||
const VirtualRadio& mVirtualRadio;
|
||||
std::mutex mMutex;
|
||||
AmFmRegionConfig mAmFmConfig GUARDED_BY(mMutex);
|
||||
std::unique_ptr<::android::WorkerThread> mThread GUARDED_BY(mMutex) =
|
||||
std::unique_ptr<::android::WorkerThread> mTuningThread GUARDED_BY(mMutex) =
|
||||
std::unique_ptr<::android::WorkerThread>(new ::android::WorkerThread());
|
||||
std::unique_ptr<::android::WorkerThread> mProgramListThread GUARDED_BY(mMutex) =
|
||||
std::unique_ptr<::android::WorkerThread>(new ::android::WorkerThread());
|
||||
bool mIsTuneCompleted GUARDED_BY(mMutex) = true;
|
||||
Properties mProperties GUARDED_BY(mMutex);
|
||||
@@ -81,6 +83,7 @@ class BroadcastRadio final : public BnBroadcastRadio {
|
||||
std::optional<AmFmBandRange> getAmFmRangeLocked() const;
|
||||
void cancelLocked();
|
||||
ProgramInfo tuneInternalLocked(const ProgramSelector& sel);
|
||||
void cancelProgramListUpdateLocked();
|
||||
|
||||
binder_status_t cmdHelp(int fd) const;
|
||||
binder_status_t cmdTune(int fd, const char** args, uint32_t numArgs);
|
||||
|
||||
Reference in New Issue
Block a user