Hardware information 修改方法

来源:互联网 发布:淘宝个体工商户的优势 编辑:程序博客网 时间:2024/05/23 14:15

Hardware information是手机使用工程号码可以打开的,一个可以测试查看手机硬件的app,叫做Emode。

以A165为例,工程号码为:*983*7#。A165是以MTK6735为处理器的Android6.0手机。这里的主要任务是在Emode界面中添加一条光感距传感器的型号信息。需要java层添加一个项,确定驱动文件的内容,并显示出来。

主要修改了5个文件分别是:

Z:\A165\kernel-3.18\drivers\misc\mediatek\wind_device_info\wind_device_info.c

Z:\A165\kernel-3.18\drivers\misc\mediatek\alsps\epl259x\epl259x.c

Z:\A165\vendor\mediatek\proprietary\packages\apps\Emode\src\com\wind\emode\testcase\HardwareInfo.java

Z:\A165\vendor\mediatek\proprietary\packages\apps\Emode\res\values-zh-rCN\string.xml

Z:\A165\vendor\mediatek\proprietary\packages\apps\Emode\res\values\string.xml

HardwareInfo.java里面添加如下内容:

        //----------alsps info----------add by shaomingliang@wind-mobi.com 20160223 start        String alspsInfo = getString(R.string.unknown);;        try {            is = new FileInputStream("/sys/class/wind_device/device_info/alsps_info");            count = is.read(bytes);            is.close();            alspsInfo = new String(bytes, 0, count);            alspsInfo = alspsInfo.substring(alspsInfo.indexOf(':') + 1);        } catch (FileNotFoundException e) {            e.printStackTrace();        } catch (IOException ie) {            ie.printStackTrace();        }        TextView txtAlspsInfo = new TextView(this);            txtAlspsInfo.setText(getString(R.string.alsps_type) + alspsInfo);        LinearLayout.LayoutParams alspslp = new LinearLayout.LayoutParams(                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);        alspslp.topMargin = 20;        ll.addView(txtAlspsInfo, alspslp);        //----------alsps info----------add by shaomingliang@wind-mobi.com 20160223 end===========

1、  确定了驱动层生成的属性文件"/sys/class/wind_device/device_info/alsps_info"读取文件内容,赋值alspsInfo。

2、  定义变量alsps_type 在两个string.xml文件中定义,分别是中文内容和英文内容,如下:

\values\string.xml

<stringname="alsps_type">"AlspsType:"</string>

\values-zh-rCN\string.xml

<stringname="alsps_type">"光感距传感器: "</string>

3、  显示信息

getString(R.string.alsps_type)+ alspsInfo

驱动层的内容放在Z:\A165\kernel-3.18\drivers\misc\mediatek\wind_device_info\wind_device_info.c

Z:\A165\kernel-3.18\drivers\misc\mediatek\alsps\epl259x\epl259x.c

两个文件中,在wind_device_info.c中主要是创建/sys/class/wind_device/device_info/alsps_info:

char *g_alsps_name = "";……static ssize_t show_alsps_info(struct device *dev,struct device_attribute *attr, char *buf){    size_t size = 0;    DEVICE_INFO_FUN();    if(NULL != g_alsps_name)        size = sprintf(buf, "%s\n", g_alsps_name);    return size;}static ssize_t store_alsps_info(struct device *dev,struct device_attribute *attr, const char *buf, size_t size){    DEVICE_INFO_FUN();    return size;}……static DEVICE_ATTR(alsps_info, 0664, show_alsps_info, store_alsps_info);……device_create_file(device, &dev_attr_alsps_info);   ……

如何创建属性文件及路径名称设置可参考:

http://blog.csdn.net/eliot_shao/article/details/50058287

epl259x.c文件是真正传感器驱动文件,驱动名称从此文件取:

 

extern char *g_alsps_name ;……g_alsps_name = EPL_DEV_NAME;


实际效果图:





1 0
原创粉丝点击