android FM手动调频流程
2016-02-19 13:32
471 查看
首先来看一下流程图:
2.滑动刻度盘HorizontalNumberPicker控件在监听事件里使用方法valueToFrequency(newVal)
1.长按左右箭头居中的频率字符串,弹出FrequencyPickerDialog调频对话框确定调用tuneRadio(frequency)调频。
获取到频率
[java] view
plain copy
print?
protected int valueToFrequency(int value) {
mFrequency = mPrefs.getLowerLimit() + value *
mPrefs.getFrequencyStepSize();
return mFrequency;
}
发送一个handler 回调一个tuneRadio(frequency)调频。
[java] view
plain copy
print?
Runnable mRadioChangeFrequency = new Runnable(){
public void run() {
mUpdatePickerValue = false;
tuneRadio(mFrequency);
}
};
3.手动点击按钮左右箭头, 通过监听调用:
int frequency =FmSharedPreferences.getNextTuneFrequency();
int frequency =FmSharedPreferences.getPrevTuneFrequency();
tuneRadio(frequency);进行调频
getNextTuneFrequency()方法通过判断频率最大限制范围,后加200(刻度)
getPrevTuneFrequency()方法通过判断频率最小限制范围,后减200(刻度)
调频方法分析
private void tuneRadio(int frequency)
[java] view
plain copy
print?
private void tuneRadio(int frequency){
/* Issue the tune command only if tuneCommand is already not active */
if((mService != null) && (mCommandActive != CMD_TUNE) && isFmOn()) {
boolean bStatus = false;
try {
bStatus = mService.tune(frequency);
if (bStatus) {
postTimeoutHandler(CMD_TUNE);
}else {
if (isFmOn()) {
mCommandFailed = CMD_TUNE;
Log.e(LOGTAG, "mService.tune failed");
showDialog(DIALOG_CMD_FAILED);
}
}mTunedStation.setName("");
mTunedStation.setPI(0);
mTunedStation.setPty(0);
updateStationInfoToUI();
}catch (RemoteException e) {
e.printStackTrace();
}
}else {
Log.e(LOGTAG, "Delayed Tune handler stopped");
}
}
通过回调引用类调用FMRadioService类的tune()方法进行调频
bStatus = mService.tune(frequency);
发送一个广播连接是否超时
postTimeoutHandler(CMD_TUNE);
设置调频名字,更新FMRadioUI界面信息
mTunedStation.setName("");
mTunedStation.setPI(0);
mTunedStation.setPty(0);
updateStationInfoToUI()
(通过IFMRadioSrevice.aidl通信机制onbind返回的类的引用调用FMRadioService中的调频方法)
FMRadioService中的tune方法
public boolean tune(int frequency)
[java] view
plain copy
print?
public boolean tune(int frequency) {
boolean bCommandSent=false;
double doubleFrequency = frequency/1000.00;
Log.d(LOGTAG, "tuneRadio: " + doubleFrequency);
if (mReceiver != null)
{
mReceiver.setStation(frequency);
bCommandSent = true;
}
return bCommandSent;
}
调用FMReceiver类的setStation方法调频
public boolean setStation (intfrequencyKHz)
[java] view
plain copy
print?
public boolean setStation (int frequencyKHz) {
int ret;
mControl.setFreq(frequencyKHz);
ret = mControl.setStation(sFd);
if(ret < 0 )
{
return false;
}
else
{
return true;
}
}
调用FMRxControls类(FM读取控制台信息)设置频率
mControl.setFreq(frequencyKHz);
设置优化调频核心指定的频率
ret = mControl.setStation(sFd);
[java] view
plain copy
print?
public int setStation(int fd) {
Log.d(TAG, "** Tune Using: "+fd);
int ret = FmReceiverJNI.setFreqNative(fd, mFreq);
Log.d(TAG, "** Returned: "+ret);
return ret;
}
最后调用FmReceiverJNI类
setFreqNative(fd, mFreq); 本地方法 JNI到 cpp文件
[cpp] view
plain copy
print?
/*native interface */
static jint android_hardware_fmradio_FmReceiverJNI_setFreqNative
(JNIEnv * env, jobject thiz, jint fd, jint freq)
{
int err;
double tune;
struct v4l2_frequency freq_struct;
freq_struct.type = V4L2_TUNER_RADIO;
freq_struct.frequency = (freq*TUNE_MULT/1000);
err = ioctl(fd, VIDIOC_S_FREQUENCY, &freq_struct);
if(err < 0){
return FM_JNI_FAILURE;
}
return FM_JNI_SUCCESS;
}
首先来看一下流程图:
2.滑动刻度盘HorizontalNumberPicker控件在监听事件里使用方法valueToFrequency(newVal)
1.长按左右箭头居中的频率字符串,弹出FrequencyPickerDialog调频对话框确定调用tuneRadio(frequency)调频。
获取到频率
[java] view
plain copy
print?
protected int valueToFrequency(int value) {
mFrequency = mPrefs.getLowerLimit() + value *
mPrefs.getFrequencyStepSize();
return mFrequency;
}
发送一个handler 回调一个tuneRadio(frequency)调频。
[java] view
plain copy
print?
Runnable mRadioChangeFrequency = new Runnable(){
public void run() {
mUpdatePickerValue = false;
tuneRadio(mFrequency);
}
};
3.手动点击按钮左右箭头, 通过监听调用:
int frequency =FmSharedPreferences.getNextTuneFrequency();
int frequency =FmSharedPreferences.getPrevTuneFrequency();
tuneRadio(frequency);进行调频
getNextTuneFrequency()方法通过判断频率最大限制范围,后加200(刻度)
getPrevTuneFrequency()方法通过判断频率最小限制范围,后减200(刻度)
调频方法分析
private void tuneRadio(int frequency)
[java] view
plain copy
print?
private void tuneRadio(int frequency){
/* Issue the tune command only if tuneCommand is already not active */
if((mService != null) && (mCommandActive != CMD_TUNE) && isFmOn()) {
boolean bStatus = false;
try {
bStatus = mService.tune(frequency);
if (bStatus) {
postTimeoutHandler(CMD_TUNE);
}else {
if (isFmOn()) {
mCommandFailed = CMD_TUNE;
Log.e(LOGTAG, "mService.tune failed");
showDialog(DIALOG_CMD_FAILED);
}
}mTunedStation.setName("");
mTunedStation.setPI(0);
mTunedStation.setPty(0);
updateStationInfoToUI();
}catch (RemoteException e) {
e.printStackTrace();
}
}else {
Log.e(LOGTAG, "Delayed Tune handler stopped");
}
}
通过回调引用类调用FMRadioService类的tune()方法进行调频
bStatus = mService.tune(frequency);
发送一个广播连接是否超时
postTimeoutHandler(CMD_TUNE);
设置调频名字,更新FMRadioUI界面信息
mTunedStation.setName("");
mTunedStation.setPI(0);
mTunedStation.setPty(0);
updateStationInfoToUI()
(通过IFMRadioSrevice.aidl通信机制onbind返回的类的引用调用FMRadioService中的调频方法)
FMRadioService中的tune方法
public boolean tune(int frequency)
[java] view
plain copy
print?
public boolean tune(int frequency) {
boolean bCommandSent=false;
double doubleFrequency = frequency/1000.00;
Log.d(LOGTAG, "tuneRadio: " + doubleFrequency);
if (mReceiver != null)
{
mReceiver.setStation(frequency);
bCommandSent = true;
}
return bCommandSent;
}
调用FMReceiver类的setStation方法调频
public boolean setStation (intfrequencyKHz)
[java] view
plain copy
print?
public boolean setStation (int frequencyKHz) {
int ret;
mControl.setFreq(frequencyKHz);
ret = mControl.setStation(sFd);
if(ret < 0 )
{
return false;
}
else
{
return true;
}
}
调用FMRxControls类(FM读取控制台信息)设置频率
mControl.setFreq(frequencyKHz);
设置优化调频核心指定的频率
ret = mControl.setStation(sFd);
[java] view
plain copy
print?
public int setStation(int fd) {
Log.d(TAG, "** Tune Using: "+fd);
int ret = FmReceiverJNI.setFreqNative(fd, mFreq);
Log.d(TAG, "** Returned: "+ret);
return ret;
}
最后调用FmReceiverJNI类
setFreqNative(fd, mFreq); 本地方法 JNI到 cpp文件
[cpp] view
plain copy
print?
/*native interface */
static jint android_hardware_fmradio_FmReceiverJNI_setFreqNative
(JNIEnv * env, jobject thiz, jint fd, jint freq)
{
int err;
double tune;
struct v4l2_frequency freq_struct;
freq_struct.type = V4L2_TUNER_RADIO;
freq_struct.frequency = (freq*TUNE_MULT/1000);
err = ioctl(fd, VIDIOC_S_FREQUENCY, &freq_struct);
if(err < 0){
return FM_JNI_FAILURE;
}
return FM_JNI_SUCCESS;
}
2.滑动刻度盘HorizontalNumberPicker控件在监听事件里使用方法valueToFrequency(newVal)
1.长按左右箭头居中的频率字符串,弹出FrequencyPickerDialog调频对话框确定调用tuneRadio(frequency)调频。
获取到频率
[java] view
plain copy
print?
protected int valueToFrequency(int value) {
mFrequency = mPrefs.getLowerLimit() + value *
mPrefs.getFrequencyStepSize();
return mFrequency;
}
发送一个handler 回调一个tuneRadio(frequency)调频。
[java] view
plain copy
print?
Runnable mRadioChangeFrequency = new Runnable(){
public void run() {
mUpdatePickerValue = false;
tuneRadio(mFrequency);
}
};
3.手动点击按钮左右箭头, 通过监听调用:
int frequency =FmSharedPreferences.getNextTuneFrequency();
int frequency =FmSharedPreferences.getPrevTuneFrequency();
tuneRadio(frequency);进行调频
getNextTuneFrequency()方法通过判断频率最大限制范围,后加200(刻度)
getPrevTuneFrequency()方法通过判断频率最小限制范围,后减200(刻度)
调频方法分析
private void tuneRadio(int frequency)
[java] view
plain copy
print?
private void tuneRadio(int frequency){
/* Issue the tune command only if tuneCommand is already not active */
if((mService != null) && (mCommandActive != CMD_TUNE) && isFmOn()) {
boolean bStatus = false;
try {
bStatus = mService.tune(frequency);
if (bStatus) {
postTimeoutHandler(CMD_TUNE);
}else {
if (isFmOn()) {
mCommandFailed = CMD_TUNE;
Log.e(LOGTAG, "mService.tune failed");
showDialog(DIALOG_CMD_FAILED);
}
}mTunedStation.setName("");
mTunedStation.setPI(0);
mTunedStation.setPty(0);
updateStationInfoToUI();
}catch (RemoteException e) {
e.printStackTrace();
}
}else {
Log.e(LOGTAG, "Delayed Tune handler stopped");
}
}
通过回调引用类调用FMRadioService类的tune()方法进行调频
bStatus = mService.tune(frequency);
发送一个广播连接是否超时
postTimeoutHandler(CMD_TUNE);
设置调频名字,更新FMRadioUI界面信息
mTunedStation.setName("");
mTunedStation.setPI(0);
mTunedStation.setPty(0);
updateStationInfoToUI()
(通过IFMRadioSrevice.aidl通信机制onbind返回的类的引用调用FMRadioService中的调频方法)
FMRadioService中的tune方法
public boolean tune(int frequency)
[java] view
plain copy
print?
public boolean tune(int frequency) {
boolean bCommandSent=false;
double doubleFrequency = frequency/1000.00;
Log.d(LOGTAG, "tuneRadio: " + doubleFrequency);
if (mReceiver != null)
{
mReceiver.setStation(frequency);
bCommandSent = true;
}
return bCommandSent;
}
调用FMReceiver类的setStation方法调频
public boolean setStation (intfrequencyKHz)
[java] view
plain copy
print?
public boolean setStation (int frequencyKHz) {
int ret;
mControl.setFreq(frequencyKHz);
ret = mControl.setStation(sFd);
if(ret < 0 )
{
return false;
}
else
{
return true;
}
}
调用FMRxControls类(FM读取控制台信息)设置频率
mControl.setFreq(frequencyKHz);
设置优化调频核心指定的频率
ret = mControl.setStation(sFd);
[java] view
plain copy
print?
public int setStation(int fd) {
Log.d(TAG, "** Tune Using: "+fd);
int ret = FmReceiverJNI.setFreqNative(fd, mFreq);
Log.d(TAG, "** Returned: "+ret);
return ret;
}
最后调用FmReceiverJNI类
setFreqNative(fd, mFreq); 本地方法 JNI到 cpp文件
[cpp] view
plain copy
print?
/*native interface */
static jint android_hardware_fmradio_FmReceiverJNI_setFreqNative
(JNIEnv * env, jobject thiz, jint fd, jint freq)
{
int err;
double tune;
struct v4l2_frequency freq_struct;
freq_struct.type = V4L2_TUNER_RADIO;
freq_struct.frequency = (freq*TUNE_MULT/1000);
err = ioctl(fd, VIDIOC_S_FREQUENCY, &freq_struct);
if(err < 0){
return FM_JNI_FAILURE;
}
return FM_JNI_SUCCESS;
}
首先来看一下流程图:
2.滑动刻度盘HorizontalNumberPicker控件在监听事件里使用方法valueToFrequency(newVal)
1.长按左右箭头居中的频率字符串,弹出FrequencyPickerDialog调频对话框确定调用tuneRadio(frequency)调频。
获取到频率
[java] view
plain copy
print?
protected int valueToFrequency(int value) {
mFrequency = mPrefs.getLowerLimit() + value *
mPrefs.getFrequencyStepSize();
return mFrequency;
}
发送一个handler 回调一个tuneRadio(frequency)调频。
[java] view
plain copy
print?
Runnable mRadioChangeFrequency = new Runnable(){
public void run() {
mUpdatePickerValue = false;
tuneRadio(mFrequency);
}
};
3.手动点击按钮左右箭头, 通过监听调用:
int frequency =FmSharedPreferences.getNextTuneFrequency();
int frequency =FmSharedPreferences.getPrevTuneFrequency();
tuneRadio(frequency);进行调频
getNextTuneFrequency()方法通过判断频率最大限制范围,后加200(刻度)
getPrevTuneFrequency()方法通过判断频率最小限制范围,后减200(刻度)
调频方法分析
private void tuneRadio(int frequency)
[java] view
plain copy
print?
private void tuneRadio(int frequency){
/* Issue the tune command only if tuneCommand is already not active */
if((mService != null) && (mCommandActive != CMD_TUNE) && isFmOn()) {
boolean bStatus = false;
try {
bStatus = mService.tune(frequency);
if (bStatus) {
postTimeoutHandler(CMD_TUNE);
}else {
if (isFmOn()) {
mCommandFailed = CMD_TUNE;
Log.e(LOGTAG, "mService.tune failed");
showDialog(DIALOG_CMD_FAILED);
}
}mTunedStation.setName("");
mTunedStation.setPI(0);
mTunedStation.setPty(0);
updateStationInfoToUI();
}catch (RemoteException e) {
e.printStackTrace();
}
}else {
Log.e(LOGTAG, "Delayed Tune handler stopped");
}
}
通过回调引用类调用FMRadioService类的tune()方法进行调频
bStatus = mService.tune(frequency);
发送一个广播连接是否超时
postTimeoutHandler(CMD_TUNE);
设置调频名字,更新FMRadioUI界面信息
mTunedStation.setName("");
mTunedStation.setPI(0);
mTunedStation.setPty(0);
updateStationInfoToUI()
(通过IFMRadioSrevice.aidl通信机制onbind返回的类的引用调用FMRadioService中的调频方法)
FMRadioService中的tune方法
public boolean tune(int frequency)
[java] view
plain copy
print?
public boolean tune(int frequency) {
boolean bCommandSent=false;
double doubleFrequency = frequency/1000.00;
Log.d(LOGTAG, "tuneRadio: " + doubleFrequency);
if (mReceiver != null)
{
mReceiver.setStation(frequency);
bCommandSent = true;
}
return bCommandSent;
}
调用FMReceiver类的setStation方法调频
public boolean setStation (intfrequencyKHz)
[java] view
plain copy
print?
public boolean setStation (int frequencyKHz) {
int ret;
mControl.setFreq(frequencyKHz);
ret = mControl.setStation(sFd);
if(ret < 0 )
{
return false;
}
else
{
return true;
}
}
调用FMRxControls类(FM读取控制台信息)设置频率
mControl.setFreq(frequencyKHz);
设置优化调频核心指定的频率
ret = mControl.setStation(sFd);
[java] view
plain copy
print?
public int setStation(int fd) {
Log.d(TAG, "** Tune Using: "+fd);
int ret = FmReceiverJNI.setFreqNative(fd, mFreq);
Log.d(TAG, "** Returned: "+ret);
return ret;
}
最后调用FmReceiverJNI类
setFreqNative(fd, mFreq); 本地方法 JNI到 cpp文件
[cpp] view
plain copy
print?
/*native interface */
static jint android_hardware_fmradio_FmReceiverJNI_setFreqNative
(JNIEnv * env, jobject thiz, jint fd, jint freq)
{
int err;
double tune;
struct v4l2_frequency freq_struct;
freq_struct.type = V4L2_TUNER_RADIO;
freq_struct.frequency = (freq*TUNE_MULT/1000);
err = ioctl(fd, VIDIOC_S_FREQUENCY, &freq_struct);
if(err < 0){
return FM_JNI_FAILURE;
}
return FM_JNI_SUCCESS;
}
相关文章推荐
- android FM搜索频率流程
- Android Studio中xml使用自定义属性
- android开发之popupwindow半透明
- android自适应屏幕方向和大小
- android FM启动流程
- Android 无需root实现apk的静默安装
- android RecycleView解决多线程情况下图片错乱问题与OOM问题(原生代码,无插件)
- android Spinner控件详解
- Android安全攻防战,反编译与混淆技术完全解析(上)
- android AChartEngine源代码
- Android线控的使用
- Android调用系统相机以及自定义相机
- android notes
- android—匿名binder
- Android_获取手机IP和MAC地址
- Android基础--Android Studio中使用Gradle发布aar项目到JCenter仓库
- android persistent属性研究
- android:自定义HorizontalScrollView实现qq侧滑菜单 标签: HorizontalScrollView自定义viewqq侧滑菜单 2016
- Android 开源项目分类汇总
- 【Android学习笔记】判断字符串的字符数