getevent 脚本测试


1.adb shell getevent -t  > camera.sh

2.操作Device 录入event,ctrl + V 结束

3.将camera.sh 转换成device 支持的脚本语言(java 代码 如下)

编写执行 camera.sh 的脚本 stress.sh

# stress.sh shell

#!/system/bin/sh
# Test Result
echo "***************start camera activity ***************"
#am start -e FactoryTest true -e camera-id 0 -a android.media.action.IMAGE_CAPTURE
am start -n com.android.camera/com.android.camera.Camera
sleep 6
TIMES=2
mtime=1

while true
do
echo "********************This is the $mtime camera switch stress*************"

. /data/bin/camera.sh
sleep 8
mtime=$(($mtime+1))
done
echo "result is $TEST_RESULT"

//Java 转换代码

package com.event;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;

public class Event{
public static void parseEvent(String inFile,String outFile){
        BufferedReader reader = null;
        FileWriter fw = null;
        BufferedWriter bw = null;
        try {
            System.out.println("start:" + inFile);
            reader = new BufferedReader(new FileReader(inFile));
            fw = new FileWriter(outFile);
            bw = new BufferedWriter(fw);
            String tempString = null;
            int line = 1;    
        String separator = " ";
            // 一次读入一行,直到读入null为文件结束
            while ((tempString = reader.readLine()) != null) {
            if (tempString.isEmpty() || tempString.contains("add")
            || tempString.contains("name:"))
            continue;
            String newLine = "sendevent";
            String arrs[] = tempString.split(separator);
            for (int i = 1;i < arrs.length;i++){
            if (arrs[i].endsWith(":")){
            newLine += separator;
            newLine += arrs[i].substring(0, arrs[i].length()-1);
            }else{
            String hex  = arrs[i];
            //int vaule = Long.parseLong(hex, 16);
            newLine += separator;
            newLine +=  Long.toString(Long.parseLong(hex, 16));
            }
            }
            // 显示行号
                //System.out.println("line " + line + ": " + newLine);
                line++;
                               
            bw.write(newLine);
            bw.newLine();
            bw.flush();
                
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
            if (reader != null)
            reader.close();
            if (fw != null)
            fw.close();
            if (bw != null)
            bw.close();
                } catch (IOException e1) {
                }
            }        
}
public static void main(String [] args){

String fileInArr[] = {
"E:/temp_data/shell/camera.sh",
};
String fileOutArr[] = {
"E:/temp_data/shell/out/camera.sh",
};
for (int i = 0;i<fileInArr.length;i++){
parseEvent(fileInArr[i],fileOutArr[i]);
}

}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值