Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_TUNER_H |
| 17 | #define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_TUNER_H |
| 18 | |
Tomasz Wasilczyk | 4837755 | 2017-06-22 10:45:33 -0700 | [diff] [blame] | 19 | #include "VirtualRadio.h" |
| 20 | |
| 21 | #include <WorkerThread.h> |
Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 22 | #include <android/hardware/broadcastradio/1.1/ITuner.h> |
| 23 | #include <android/hardware/broadcastradio/1.1/ITunerCallback.h> |
| 24 | |
| 25 | namespace android { |
| 26 | namespace hardware { |
| 27 | namespace broadcastradio { |
| 28 | namespace V1_1 { |
| 29 | namespace implementation { |
| 30 | |
Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 31 | struct Tuner : public ITuner { |
Tomasz Wasilczyk | 4837755 | 2017-06-22 10:45:33 -0700 | [diff] [blame] | 32 | Tuner(const sp<V1_0::ITunerCallback>& callback); |
Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 33 | |
Tomasz Wasilczyk | 4837755 | 2017-06-22 10:45:33 -0700 | [diff] [blame] | 34 | void forceClose(); |
Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 35 | |
Tomasz Wasilczyk | 4837755 | 2017-06-22 10:45:33 -0700 | [diff] [blame] | 36 | // V1_1::ITuner methods |
Tomasz Wasilczyk | 2418009 | 2017-07-14 10:44:52 -0700 | [diff] [blame^] | 37 | virtual Return<Result> setConfiguration(const V1_0::BandConfig& config) override; |
| 38 | virtual Return<void> getConfiguration(getConfiguration_cb _hidl_cb) override; |
| 39 | virtual Return<Result> scan(V1_0::Direction direction, bool skipSubChannel) override; |
| 40 | virtual Return<Result> step(V1_0::Direction direction, bool skipSubChannel) override; |
| 41 | virtual Return<Result> tune(uint32_t channel, uint32_t subChannel) override; |
| 42 | virtual Return<Result> tune_1_1(const ProgramSelector& program) override; |
| 43 | virtual Return<Result> cancel() override; |
| 44 | virtual Return<Result> cancelAnnouncement() override; |
| 45 | virtual Return<void> getProgramInformation(getProgramInformation_cb _hidl_cb) override; |
| 46 | virtual Return<void> getProgramInformation_1_1(getProgramInformation_1_1_cb _hidl_cb) override; |
| 47 | virtual Return<ProgramListResult> startBackgroundScan() override; |
| 48 | virtual Return<void> getProgramList(const hidl_string& filter, |
| 49 | getProgramList_cb _hidl_cb) override; |
| 50 | virtual Return<void> isAnalogForced(isAnalogForced_cb _hidl_cb) override; |
| 51 | virtual Return<Result> setAnalogForced(bool isForced) override; |
Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 52 | |
Tomasz Wasilczyk | 4837755 | 2017-06-22 10:45:33 -0700 | [diff] [blame] | 53 | private: |
| 54 | std::mutex mMut; |
| 55 | WorkerThread mThread; |
| 56 | bool mIsClosed = false; // TODO(b/36864090): use it |
Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 57 | |
Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 58 | const sp<V1_0::ITunerCallback> mCallback; |
| 59 | const sp<V1_1::ITunerCallback> mCallback1_1; |
Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 60 | |
Tomasz Wasilczyk | 4837755 | 2017-06-22 10:45:33 -0700 | [diff] [blame] | 61 | VirtualRadio mVirtualFm; |
| 62 | |
| 63 | bool mIsAmfmConfigSet = false; |
| 64 | V1_0::BandConfig mAmfmConfig; |
| 65 | bool mIsTuneCompleted = false; |
Tomasz Wasilczyk | a02b6ef | 2017-07-05 11:23:30 -0700 | [diff] [blame] | 66 | ProgramSelector mCurrentProgram = {}; |
Tomasz Wasilczyk | 4837755 | 2017-06-22 10:45:33 -0700 | [diff] [blame] | 67 | ProgramInfo mCurrentProgramInfo = {}; |
| 68 | |
Tomasz Wasilczyk | a02b6ef | 2017-07-05 11:23:30 -0700 | [diff] [blame] | 69 | void tuneInternalLocked(const ProgramSelector& sel); |
Tomasz Wasilczyk | c9ba646 | 2017-07-07 13:28:00 -0700 | [diff] [blame] | 70 | bool isFmLocked(); // TODO(b/36864090): make it generic, not FM only |
Tomasz Wasilczyk | 4837755 | 2017-06-22 10:45:33 -0700 | [diff] [blame] | 71 | }; |
Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 72 | |
| 73 | } // namespace implementation |
| 74 | } // namespace V1_1 |
| 75 | } // namespace broadcastradio |
| 76 | } // namespace hardware |
| 77 | } // namespace android |
| 78 | |
| 79 | #endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_TUNER_H |