Android中的设备密码是否存在

发布于 2024-11-18 17:58:39 字数 364 浏览 5 评论 0原文

当我的应用程序启动时,我想知道屏幕锁定密码是否已经存在。

情况1:如果已经有屏幕锁定密码...我将使用设备管理器进行锁定(locknow())并要求用户再次登录。

情况 2:如果没有屏幕锁定密码....我会要求用户使用 devicepolicymanager 类设置密码。

但我不知道如何检查屏幕锁定密码是否已经存在。设备管理器 api 中是否有任何布尔返回方法?...我无法

知道是否存在活动管理员...现在,有人可以告诉我如何知道屏幕锁定密码是否存在是否已经存在...

这是不允许应用程序开发人员找到的安全事物吗?

有系统级方法吗?

设备策略管理器可以帮助我获取该信息吗?

提前致谢

I am trying to know whether a screen lock password is already present or not, when my app has started.

case 1: If there is a screen lock password already... I would do the locking (locknow()) using device manager and ask the user to login again.

case 2: If there is no screen lock password.... i would ask user to set a password using devicepolicymanager class.

But I was unable to know, how to check whether a screen lock password is already present or not. is there any boolean returning method in device manager api ?...i was unable any of such

I was able to know whether active admins are present or not.... now,can someone tell me how to know whether a screen lock password is already present or not ...

Is it a secuirty thing that app developers are not allowed to find?

Is there a system level approach?

can device policy manager help me to get that info?

thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

洋洋洒洒 2024-11-25 17:58:39
KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
if( keyguardManager.isKeyguardSecure()) {
   //it is password protected
} else {
   //it is not password protected 
}

API 级别 16 中引入了方法 isKeyguardSecure()

KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
if( keyguardManager.isKeyguardSecure()) {
   //it is password protected
} else {
   //it is not password protected 
}

The method isKeyguardSecure() is introduced in API Level 16

风吹雪碎 2024-11-25 17:58:39

请参阅此处如何显示屏幕已锁定?。这个问题在那里得到了广泛的讨论和解决

Look here How to reveal that screen is locked?. The matter was extensively discussed and resolved there

十六岁半 2024-11-25 17:58:39

尝试以下操作:

dpm.setPasswordMinimumLength(new ComponentName(<package>, <class>), 0);

Log.d("Log", "Reset done: " + dpm.resetPassword("", 0)); // i.e. clear password
Log.d("Log", "Sufficient: " + dpm.isActivePasswordSufficient());

Log.d("Log", "Reset done: " + dpm.resetPassword("0000", 0));
Log.d("Log", "Sufficient: " + dpm.isActivePasswordSufficient());

// of device admin receiver
dpm.setPasswordMinimumLength(new ComponentName(<package>, <class>), 1); 

Log.d("Log", "Reset done: " + dpm.resetPassword("", 0));
Log.d("Log", "Sufficient: " + dpm.isActivePasswordSufficient());

Log.d("Log", "Reset done: " + dpm.resetPassword("0000", 0));
Log.d("Log", "Sufficient: " + dpm.isActivePasswordSufficient());

结论:

  1. 使用 setPasswordMinimumLength(..., 1)

  2. 检查密码是否足够

  3. 如果没有使用resetPassword()设置密码

  4. 调用lockNow()

Try the following:

dpm.setPasswordMinimumLength(new ComponentName(<package>, <class>), 0);

Log.d("Log", "Reset done: " + dpm.resetPassword("", 0)); // i.e. clear password
Log.d("Log", "Sufficient: " + dpm.isActivePasswordSufficient());

Log.d("Log", "Reset done: " + dpm.resetPassword("0000", 0));
Log.d("Log", "Sufficient: " + dpm.isActivePasswordSufficient());

// of device admin receiver
dpm.setPasswordMinimumLength(new ComponentName(<package>, <class>), 1); 

Log.d("Log", "Reset done: " + dpm.resetPassword("", 0));
Log.d("Log", "Sufficient: " + dpm.isActivePasswordSufficient());

Log.d("Log", "Reset done: " + dpm.resetPassword("0000", 0));
Log.d("Log", "Sufficient: " + dpm.isActivePasswordSufficient());

Conclusion:

  1. use setPasswordMinimumLength(..., 1)

  2. check if password is sufficient

  3. if not set password with resetPassword()

  4. call lockNow()

唱一曲作罢 2024-11-25 17:58:39

也许您已经找到了解决方案。不过,我将其发布在这里以供将来参考。

您可以使用 DevicePolicyManager 中的 isActivePasswordSufficient() 方法来检查密码的当前状态以及可用性。

请参阅 http://developer.android.com/更多详情请参考/android/app/admin/DevicePolicyManager.html#isActivePasswordSufficient%28%29

May be you have already found the solution. However I'm posting here this for the future reference.

You can use isActivePasswordSufficient() method in DevicePolicyManager to check the current status of the password as well as the availability.

Refer http://developer.android.com/reference/android/app/admin/DevicePolicyManager.html#isActivePasswordSufficient%28%29 for more details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文