Keyguard模块CTS问题解决方案总结

本文总结了在CTS测试中遇到的Keyguard模块问题,特别是关于`KeyguardLockedTests`测试用例失败的情况。问题在于解锁屏后未回调相应接口。解决方案包括编译测试服务、启动特定活动并模拟测试流程,以及针对画中画功能的适配调整。通过调整,确保在设置锁屏密码时正确加载解锁屏界面。
摘要由CSDN通过智能技术生成

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    //HOME
   adb shell input keyevent 4    //BACK
   adb shell input keyevent 82   //MENU
   adb shell am stack list       //列出stack中的activity,显示的activity在最上面
   am start -a android.intent.action.MAIN -c a
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值