1 /* 2 * Copyright (C) 2015 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 17 #ifndef ANDROID_HARDWARE_RADIO_H 18 #define ANDROID_HARDWARE_RADIO_H 19 20 #include <binder/IBinder.h> 21 #include <utils/threads.h> 22 #include <radio/RadioCallback.h> 23 #include <radio/IRadio.h> 24 #include <radio/IRadioService.h> 25 #include <radio/IRadioClient.h> 26 #include <system/radio.h> 27 28 namespace android { 29 30 class MemoryDealer; 31 32 class Radio : public BnRadioClient, 33 public IBinder::DeathRecipient 34 { 35 public: 36 37 virtual ~Radio(); 38 39 static status_t listModules(struct radio_properties *properties, 40 uint32_t *numModules); 41 static sp<Radio> attach(radio_handle_t handle, 42 const struct radio_band_config *config, 43 bool withAudio, 44 const sp<RadioCallback>& callback); 45 46 47 void detach(); 48 49 status_t setConfiguration(const struct radio_band_config *config); 50 51 status_t getConfiguration(struct radio_band_config *config); 52 53 status_t setMute(bool mute); 54 55 status_t getMute(bool *mute); 56 57 status_t step(radio_direction_t direction, bool skipSubChannel); 58 59 status_t scan(radio_direction_t direction, bool skipSubChannel); 60 61 status_t tune(unsigned int channel, unsigned int subChannel); 62 63 status_t cancel(); 64 65 status_t getProgramInformation(struct radio_program_info *info); 66 67 status_t hasControl(bool *hasControl); 68 69 // BpRadioClient 70 virtual void onEvent(const sp<IMemory>& eventMemory); 71 72 //IBinder::DeathRecipient 73 virtual void binderDied(const wp<IBinder>& who); 74 75 private: 76 Radio(radio_handle_t handle, 77 const sp<RadioCallback>&); 78 static const sp<IRadioService> getRadioService(); 79 80 Mutex mLock; 81 sp<IRadio> mIRadio; 82 const radio_handle_t mHandle; 83 sp<RadioCallback> mCallback; 84 }; 85 86 }; // namespace android 87 88 #endif //ANDROID_HARDWARE_RADIO_H 89