然后,等待onetouch:::
public class OnetouchstopplayReciver extends BroadcastReceiver {
//private boolean btState;
@Override
public void onReceive(Context mContext, Intent arg1) {
//TODO: add code here!
boolean ret = EmGpio.gpioInit();
Log.e("zcfdebug","we will change to linein for OneTouch has stopped play!");
changeToLinein();
}
private void changeToLinein(){
Log.e("zcfdebug","we will pull up GPIO 135!");
EmGpio.setGpioOutput(135);
EmGpio.setGpioDataHigh(135);
}
}
作者: zangcf 时间: 2016-4-6 15:54
如果在蓝牙状态,插入linein:
那么:
1,首先发送蓝牙停止的硬件intent
Log.e("zcfdebug ExtAudioReceiver","we will send BTHW_STARTSTOP for extaudio in!");
Intent btStartStopIntent = new Intent(BTHW_STARTSTOP);
ctx.sendBroadcast(btStartStopIntent);
2,在关闭蓝牙之前,根据是否有外部接入linein,发送bt_stop的事件:
if(btSwitch && !btIsStarting && !btIsShutDowning){
Log.e("zcfdebug BtStartstopReciver","BT will be disabled!");
if(extAudioStatus){
Intent btStopIntent = new Intent(BT_STOP_FOR_EXTAUD);
}else{
Intent btStopIntent = new Intent(BT_STOP);
}
ctx.sendBroadcast(btStopIntent);
setBtEnable(false);
}作者: zangcf 时间: 2016-4-6 16:06
在系统刚bootcompleted的时候,检测linein状态,然后发送对应信息给onetouch,并注意设置extaud的数据库状态,这里拉高gpio135
1,定义:
public static final String EXTAUD_STATUS =
"android.intent.action.onkey.EXTAUD_STATE";
2,发送:
//检测外部linein开始状态,做相应的初始化设置
int extAudStatus=Ugpio.nativeGetExtAudStatus();
if(extAudStatus==1){
Log.e("zcfdebug BootCompletedReceiver","detect extAudIn and we will send Intent.ACTION_EXTAUD_EVENT late!");
editor.putBoolean("ExtAudStatus", true);
EmGpio.setGpioDataHigh(135);
sendExtAudPluginIntent();
}else{
Log.e("zcfdebug BootCompletedReceiver","didnot detect extAudio Plugin in BootCompletedReceiver");
editor.putBoolean("ExtAudStatus", false);
editor.commit();
}
private void sendExtAudPluginIntent(){
new Thread(new Runnable() {
public void run() {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.e("zcfdebug BootCompletedReceiver","we will send BTHW_STARTSTOP for extaudio in!");
Intent intent = new Intent(EXTAUD_STATUS);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.putExtra(Intent.EXTRA_EXTAUD_STATE, 1);
// Send the extaud event intent.
// There are many components in the system watching for this so as to
// adjust audio routing, screen orientation, etc.
ctx.sendBroadcast(intent);
}
}).start();
} 作者: zangcf 时间: 2016-4-6 16:21
下面开始调试:
第一步,Onetouch播放的时候,插入linein,是否可以正常停止播放,并且切换到linein播放。
发现没有发送
public static final String ONKEY_EXTAUD =
"android.intent.action.onkey.EXTAUD_STATE";