|
|
5#

楼主 |
发表于 2016-4-5 20:22:43
|
只看该作者
本帖最后由 zangcf 于 2016-4-5 21:33 编辑
试验外部音频的可用性:
修改:/media/doraemon/works/android/mtk/6572/QPlayer/eng/alps/mediatek/kernel/drivers/ugpio/ugpio.h
#define GET_ExtAud_STATUS _IO ('k',4)
修改:/media/doraemon/works/android/mtk/6572/QPlayer/eng/alps/mediatek/kernel/drivers/ugpio/ugpio.c
long ugpio_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) {
int err = 0;
int res=0;
printk(KERN_ALERT "zcfdebug ugpio ioctl:cmd=%d, arg=%d.\n", cmd, arg);
switch(cmd){
case GET_BT_STATUS:
printk(KERN_ALERT "zcfdebug getBTStatus ioctl:cmd=%d, arg=%d.\n", cmd, arg);
res=getBtStatus();
return res;
break;
case GET_ExtAud_STATUS:
printk(KERN_ALERT "zcfdebug getUnlockedStatus ioctl:cmd=%d, arg=%d.\n", cmd, arg);
res=getExtAudStatus();
return res;
break;
default:
return -EINVAL;
break;
}
return err;
}
和:::
int getExtAudStatus(){
int res=0;
printk(KERN_ALERT "zcfdebug in get GPIO 100!\n");
mt_set_gpio_mode(GPIO100, GPIO_MODE_GPIO);
mt_set_gpio_dir(GPIO100, GPIO_DIR_IN);
res=mt_get_gpio_in(GPIO100);
if(!res){
printk("zcfdebug the GPIO 100 is low\n");
return 1;
}
}
编译看看::编译通过,加入乱码看看,是不是fail:
===============================
修改jni部分的代码
#define GET_ExtAud_STATUS _IO ('k',4)
/*
* Class: com_mediatek_engineermode_io_Ugpio
* Method: nativeGetBTStatus
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_com_mediatek_engineermode_io_Ugpio_nativeGetExtAudStatus
(JNIEnv *, jobject);
JNIEXPORT jboolean JNICALL Java_com_mediatek_engineermode_io_Ugpio_nativeGetExtAudStatus
(JNIEnv * env, jobject thiz)
{
int i;
LOGI("test enter jni nativeGetBTStatus");
if((fd=open("/dev/ugpio",O_RDWR))==-1)
{
LOGI("zcfdebug warning: open /dev/ugpio fail, may cause by device access permission!");
return false;
}
else{
LOGI("zcfdebug /dev/ugpio open ok!");
i=ioctl(fd,GET_ExtAud_STATUS,NULL);
close(fd);
return i;
}
}
把编译好的文件放到/media/doraemon/works/android/mtk/6572/QPlayer/eng/alps/vendor/mediatek/konka72_i110s_emmc/artifacts/out/target/product/konka72_i110s_emmc/system/lib/libugpio.so
=============================
修改文件:/media/doraemon/works/android/mtk/6572/QPlayer/eng/alps/mediatek/packages/apps/OOBE/src/com/mediatek/engineermode/io/Ugpio.java
package com.mediatek.engineermode.io;
public class Ugpio {
public static native int nativeGetBTStatus();
public static native int nativeGetExtAudStatus();
static {
System.loadLibrary("ugpio");
}
}
=======================下面修改检测代码:
修改/media/doraemon/works/android/mtk/6572/QPlayer/eng/alps/mediatek/packages/apps/OOBE/src/com/mediatek/oobe/BootCompletedReceiver.java
int extAudStatus=Ugpio.nativeGetExtAudStatus();
if(extAudStatus==1){
Log.e("zcfdebug BootCompletedReceiver","detect extAudIn and we will send Intent.ACTION_EXTAUD_EVENT late!");
sendExtAudPluginIntent();
}else{
Log.e("zcfdebug BootCompletedReceiver","didnot detect extAudio Plugin in BootCompletedReceiver");
editor.putBoolean("ExtAudStatus", false);
editor.commit();
}
利用nativeGetExtAudStatus,取得外部line插入状态
如果有外部插入,怎三秒之后发送外部插入信息。
如果没有,则初始化外部插入数据库的值。
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(Intent.ACTION_EXTAUD_EVENT);
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();
}
|
|