花屏黑屏log机制

来源:互联网 发布:java读取word文件内容 编辑:程序博客网 时间:2024/05/19 05:01

  在测试手机各项功能过程中,经常会遇到概率性复现“屏幕画花了,界面画错乱了等绘制异常问题”,而且概率还非常小。

  为了在复现问题的时候能够及时抓到关键log,现在在项目中引入一个脚本,只要复现出问题的时候触发截屏(音量下+电源键)就可以执行这个脚本然后导出所需要的log到指定sd卡目录下。

修改方式简单记录如下。

一、vendor\Tecnon_BuildIn目录下创建自定义文件夹dumpfiles,并添加dumpfile.sh脚本和Android.mk文件

dumpfile.sh脚本内容如下:

#!/system/bin/shPRELOAD_DEST=/storage/sdcard0DUMPFILE_DEST=${PRELOAD_DEST}/Dumpfileif [ ! -d ${DUMPFILE_DEST} ]then    mkdir -p ${DUMPFILE_DEST}fiTIMESTAMP=`date +%Y%m%d%H%M%S`setprop debug.bq.dump "@surface"dumpsys SurfaceFlinger > ${DUMPFILE_DEST}/SF_layerdump_${TIMESTAMP}.logsetprop debug.bq.dump ""dumpsys GuiExtService --detail > ${DUMPFILE_DEST}/GuiExtService_${TIMESTAMP}.logcat /dev/graphics/fb0 > ${DUMPFILE_DEST}/fb_${TIMESTAMP}.bincat /proc/kmsg > ${DUMPFILE_DEST}/kernel_log_${TIMESTAMP}.txt


Android.mk文件配置如下:

LOCAL_PATH:= $(call my-dir)include $(CLEAR_VARS)LOCAL_MODULE_TAGS := optionalLOCAL_MODULE := dumpfile.shLOCAL_MODULE_CLASS := EXECUTABLESLOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)LOCAL_SRC_FILES := dumpfile.shinclude $(BUILD_PREBUILT)


二、device\mediatek\common\sepolicy\basic路径下添加定义文件类型的策略文件dumpfile.te

# ==============================================# Policy File of /system/xbin/dumpfile Executable File# ==============================================# Type Declaration# ==============================================type dumpfile_exec , exec_type, file_type;type dumpfile ,domain;# ==============================================# MTK Policy Rule# ==============================================init_daemon_domain(dumpfile)#binder_use(dumpfile)#binder_service(dumpfile)# permission for android N policyallow dumpfile toolbox_exec:file {rx_file_perms};# purpose: allow dumpfile to access storage in N versionallow dumpfile shell_exec:file{rx_file_perms};allow dumpfile storage_file:lnk_file{read};allow dumpfile tmpfs:dir{search};allow dumpfile mnt_user_file:dir{search};allow dumpfile mnt_user_file:lnk_file{read};allow dumpfile sdcardfs:dir{search write add_name};allow dumpfile media_rw_data_file:dir{search};allow dumpfile sdcardfs:file{create write open};allow dumpfile media_rw_data_file:file{write open};allow dumpfile selinuxfs:file{read write};allow dumpfile property_socket:sock_file{write};allow dumpfile init:unix_stream_socket{connectto};allow sn media_rw_data_file:dir{read open};allow dumpfile system_file:file{execute_no_trans};allow dumpfile servicemanager:binder{call};allow servicemanager dumpfile:dir{search};allow servicemanager dumpfile:file{read open};allow servicemanager dumpfile:process{getattr};allow dumpfile surfaceflinger_service:service_manager{find};allow dumpfile surfaceflinger:binder{call};allow surfaceflinger dumpfile:fd{use};allow surfaceflinger dumpfile:fifo_file{write};allow dumpfile graphics_device:dir{search};allow dumpfile dumpfile:capability{dac_override dac_read_search sys_admin};allow dumpfile proc:file{read open};allow dumpfile graphics_device:chr_file{read open};allow dumpfile dumpfile:capability2{syslog};allow dumpfile kernel:system{syslog_mod};

三、device\mediatek\common\sepolicy\basic\file_contexts 对文件匹配进行设定

/system/xbin/dumpfile.sh u:object_r:dumpfile_exec:s0

四、device\reallytek\rlk6757_66_n\init.project.rc 注册脚本服务

service dumpfile /system/xbin/dumpfile.sh    class main    disabledseclabel u:r:dumpfile:s0

五、device\mediatek\common\device.mk 添加脚本的调用

PRODUCT_PACKAGES += dumpfile.sh

六、frameworks\base\services\core\java\com\android\server\policy\ PhoneWindowManager.java 在截屏事件流中启动脚本并在十秒后停止脚本运行

android.os.SystemProperties.set("ctl.start", "dumpfile");mHandler.postDelayed(new Runnable() {       @Override       public void run() {             android.os.SystemProperties.set("ctl.stop", "dumpfile");       }}, 10 * 1000);