本文主要是介绍Keyguard模块CTS问题解决方案总结,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
cts测试源码中会发现都是如下格式的shell命令来实现的:
//灭屏 然后 亮屏
protected void gotoKeyguard() throws DeviceNotAvailableException {sleepDevice();//灭屏wakeUpDevice();//亮屏
}protected void sleepDevice() throws DeviceNotAvailableException {int retriesLeft = 5;runCommandAndPrintOutput("input keyevent 26");do {if (isDisplayOn()) {log("***Waiting for display to turn off...");try {Thread.sleep(1000);} catch (InterruptedException e) {log(e.toString());// Well I guess we are not waiting...}} else {break;}} while (retriesLeft-- > 0);
}protected void wakeUpDevice() throws DeviceNotAvailableException {runCommandAndPrintOutput("input keyevent 224");
}protected String runCommandAndPrintOutput(String command) throws DeviceNotAvailableException {final String output = executeShellCommand(command);log(output);return output;
}protected String executeShellCommand(String command) throws DeviceNotAvailableException {return executeShellCommand(mDevice, command);
}protected static String executeShellCommand(ITestDevice device, String command)throws DeviceNotAvailableException {log("adb shell " + command);return device.executeShellCommand(command);
}以上命令行相当于shell命令:
adb shell command
即:adb shell input keyevent 26 //灭屏adb shell input keyevent 224 //亮屏类似的还有如下命令行:adb shell input keyevent 3 //HOMEadb shell input keyevent 4 //BACKadb shell input keyevent 82 //MENUadb shell am stack list //列出stack中的activity,显示的activity在最上面am start -a android.intent.action.MAIN -c android.intent.categor
这篇关于Keyguard模块CTS问题解决方案总结的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!