Discuz! Board

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 4|回复: 4
打印 上一主题 下一主题

修改line插入时候的事件

[复制链接]

1198

主题

2060

帖子

7058

积分

超级版主

Rank: 8Rank: 8

积分
7058
跳转到指定楼层
楼主
发表于 2016-4-6 15:46:48 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
1,当系统不在蓝牙的状态,那么:
插入linein发送android.intent.action.onkey.EXTAUD_STATE
:::
修改/media/doraemon/works/android/mtk/6572/QPlayer/eng/alps/mediatek/packages/apps/OOBE/src/com/mediatek/oobe/ExtAudioReceiver.java
添加定义:
    public static final String ONKEY_EXTAUD =
        "android.intent.action.onkey.EXTAUD_STATE";

如果蓝牙没有打开则发送该消息


    private void setExtAudioEnable(int extAudioStatus){
        EmGpio.setGpioOutput(135);
        SharedPreferences sp = ctx.getSharedPreferences("SP", Activity.MODE_PRIVATE);
        Editor editor = sp.edit();
        boolean btSwitch=sp.getBoolean("btSwitch", false);
        Intent intent = new Intent(Intent.ACTION_EXTAUD_EVENT);
        intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
        intent.putExtra(Intent.EXTRA_EXTAUD_STATE, extAudioStatus);

        if(extAudioStatus==1){
              editor.putBoolean("ExtAudStatus", true);
            if(btSwitch){
                Log.e("zcfdebug ExtAudioReceiver","we will send BTHW_STARTSTOP for extaudio in!");
                Intent btStartStopIntent = new Intent(BTHW_STARTSTOP);
                ctx.sendBroadcast(btStartStopIntent);
            }else{
                Log.e("zcfdebug ExtAudioReceiver","we will pull high 135 pin to turn on extaudio!");
                ctx.sendBroadcast(intent);    //发送外部linein插入的intent,给onetouch app接收
                //注释掉下面的代码,如果是插入的话,我需要等待onetouch app停止播放以后,再切换linein的音频开关
                //EmGpio.setGpioDataHigh(135);   
            }

        }else{
            Log.e("zcfdebug ExtAudioReceiver","here perform extAudPlugout action, set preference ExtAudStatus to false!");
            ctx.sendBroadcast(intent);    //发送外部linein拔出的intent,给onetouch app接收

            EmGpio.setGpioDataLow(135);
              editor.putBoolean("ExtAudStatus", false);
        }
            //for commit ExtAudStatus
            editor.commit();
    }
}

然后,等待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);
    }

}

回复

使用道具 举报

1198

主题

2060

帖子

7058

积分

超级版主

Rank: 8Rank: 8

积分
7058
沙发
 楼主| 发表于 2016-4-6 15:54:30 | 只看该作者
如果在蓝牙状态,插入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);
                        }
回复 支持 反对

使用道具 举报

1198

主题

2060

帖子

7058

积分

超级版主

Rank: 8Rank: 8

积分
7058
板凳
 楼主| 发表于 2016-4-6 16:06:02 | 只看该作者
在系统刚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();
    }
回复 支持 反对

使用道具 举报

1198

主题

2060

帖子

7058

积分

超级版主

Rank: 8Rank: 8

积分
7058
地板
 楼主| 发表于 2016-4-6 16:21:31 | 只看该作者
下面开始调试:
第一步,Onetouch播放的时候,插入linein,是否可以正常停止播放,并且切换到linein播放。
发现没有发送
    public static final String ONKEY_EXTAUD =
        "android.intent.action.onkey.EXTAUD_STATE";

原因是:
        Intent intent = new Intent(ONKEY_EXTAUD);
        intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
        intent.putExtra(Intent.EXTRA_EXTAUD_STATE, extAudioStatus);
上面yijing修改对了
回复 支持 反对

使用道具 举报

1198

主题

2060

帖子

7058

积分

超级版主

Rank: 8Rank: 8

积分
7058
5#
 楼主| 发表于 2016-4-6 16:26:20 | 只看该作者
目前可以显示linein模式,但是,音频没有切换过去。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Comsenz Inc.

GMT+8, 2025-12-15 02:07 , Processed in 0.012459 second(s), 7 queries , Apc On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表