Device Policy Manager - Reset Password - Android 3.0 Problems

早过忘川 提交于 2019-12-06 16:03:28

I struggled with this also. The solution is also listed on one of your links, but I'll mention it here also in case it helps someone else.

  • If the device is brand new (or factory reset) the code fails as you describe.

  • If the user enters a password using the settings menu just once, somehow the same code starts working and keeps on working.

A very weird bug indeed!!

On Android Honeycomb 3.0 platform, the DevicePolicyServiceManager is very different from Gingerbread, the whole flow of resetPassword() is:

DevicePolicyServiceManager.resetPassword() --> 
LockPatternUtils.checkPasswordInHistory() --> 
LockPatternUtils.passwordToHash() --> 
LockPatternUtils.getSalt() --> 
LockPatternUtils.putLong(SALT_KEY, salt) --> 
Settings.Secure.putLong(SALT_KEY, salt)

Here you should know why WRITE_SETTINGS is required, it seems that this is Google's mistake, they did not put the LockPatternUtils.checkPasswordInHistory() method in Binder.clearCallingIndentity() block.

One more thing, even if you add WRITE_SETTINGS permission in your AndroidManifest.xml file, it will tell you that WRTITE_SECURE_SETTINGS permission is also required.

Hope Google can fix this issue ASAP.

P.S. It seems that this issue has been fixed on ICS platform, Google has removed the checkPasswordInHistory() from resetPassword() block. I do not think this is a good solutoin and i don't know why? Maybe they wanna release ICS as soon as possible?

I also faced this problem, what i can tell is if you didn't set the password manually even single time, the it will give force close asking for write_settings permission but if you try once by setting password manually from there on-wards it will work like charm.

I was looking at this problem (which is readily reproducible on 3.1 as well, btw), but it appears that you already figured it out, based upon the issue you filed. I just wanted to note that here in case anyone else tried to research the answer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!