/* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include "VirtualRadio.h" #include #include #include #include #include #include #include #include #include #include #include #include namespace aidl::android::hardware::broadcastradio { class BroadcastRadio final : public BnBroadcastRadio { public: explicit BroadcastRadio(const VirtualRadio& virtualRadio); ~BroadcastRadio(); ndk::ScopedAStatus getAmFmRegionConfig(bool full, AmFmRegionConfig* returnConfigs) override; ndk::ScopedAStatus getDabRegionConfig(std::vector* returnConfigs) override; ndk::ScopedAStatus getImage(int32_t id, std::vector* returnImage) override; ndk::ScopedAStatus getProperties(Properties* returnProperties) override; ndk::ScopedAStatus setTunerCallback(const std::shared_ptr& callback) override; ndk::ScopedAStatus unsetTunerCallback() override; ndk::ScopedAStatus tune(const ProgramSelector& program) override; ndk::ScopedAStatus seek(bool directionUp, bool skipSubChannel) override; ndk::ScopedAStatus step(bool directionUp) override; ndk::ScopedAStatus cancel() override; ndk::ScopedAStatus startProgramListUpdates(const ProgramFilter& filter) override; ndk::ScopedAStatus stopProgramListUpdates() override; ndk::ScopedAStatus isConfigFlagSet(ConfigFlag flag, bool* returnIsSet) override; ndk::ScopedAStatus setConfigFlag(ConfigFlag flag, bool in_value) override; ndk::ScopedAStatus setParameters(const std::vector& parameters, std::vector* returnParameters) override; ndk::ScopedAStatus getParameters(const std::vector& keys, std::vector* returnParameters) override; ndk::ScopedAStatus registerAnnouncementListener( const std::shared_ptr& listener, const std::vector& enabled, std::shared_ptr* returnCloseHandle) override; binder_status_t dump(int fd, const char** args, uint32_t numArgs) override; private: 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>(new ::android::WorkerThread()); bool mIsTuneCompleted GUARDED_BY(mMutex) = true; Properties mProperties GUARDED_BY(mMutex); ProgramSelector mCurrentProgram GUARDED_BY(mMutex) = {}; std::shared_ptr mCallback GUARDED_BY(mMutex); std::optional getAmFmRangeLocked() const; void cancelLocked(); ProgramInfo tuneInternalLocked(const ProgramSelector& sel); binder_status_t cmdHelp(int fd) const; binder_status_t cmdTune(int fd, const char** args, uint32_t numArgs); binder_status_t cmdSeek(int fd, const char** args, uint32_t numArgs); binder_status_t cmdStep(int fd, const char** args, uint32_t numArgs); binder_status_t cmdCancel(int fd, uint32_t numArgs); binder_status_t cmdStartProgramListUpdates(int fd, const char** args, uint32_t numArgs); binder_status_t cmdStopProgramListUpdates(int fd, uint32_t numArgs); binder_status_t dumpsys(int fd); }; } // namespace aidl::android::hardware::broadcastradio