简体   繁体   English

以编程方式禁用 android 安全键盘锁

[英]Disable android secure keyguard programmatically

I have an app with an alarm.我有一个带闹钟的应用程序。 When alarm trigger the app loads with the following code:当警报触发应用程序加载以下代码:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
    setShowWhenLocked(true);
    setTurnScreenOn(true);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | 
    WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
} else {
    getWindow().addFlags( WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | 
    WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | 
    WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | 
    WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
}

but I want to remove the locker screen after exit my app.但我想在退出我的应用程序后删除更衣室屏幕。 If is a non secure keyguard works well but with a secure keyguard after exit app I have to insert the keyguard pattern.如果是非安全键盘锁运行良好,但在退出应用程序后使用安全键盘锁,我必须插入键盘锁模式。 There's any way to remove the secure keyguard or this code only works for a non secure keyguard?有什么方法可以移除安全键盘锁,或者此代码仅适用于非安全键盘锁? I'm testing in a Samsung Galaxy with android pie.我正在使用 android pie 在三星 Galaxy 中进行测试。

You can only request a dismissal but if it's secured, it would ask the user to unlock it.您只能请求解雇,但如果它是安全的,它会要求用户解锁。 Also, we shouldn't be allowed to do that (it can act as a vulnerability, imagine a thief-developer who creates an app with location permission and the feature you're seeking. He tracks victims using the app and can unlock their phones by the app and do whatever he wants).此外,我们不应该被允许这样做(它可以作为一个漏洞,想象一个小偷开发者创建了一个具有位置权限和您正在寻找的功能的应用程序。他使用该应用程序跟踪受害者并可以解锁他们的手机通过应用程序并做他想做的任何事情)。 Also you can use KeyguardManager.requestDismissKeyguard() to achieve the same thing you're facing right now (just a bit more standard)你也可以使用KeyguardManager.requestDismissKeyguard()来实现你现在面临的同样的事情(只是更标准一点)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM