Hello everyone, I followed these steps:
1- Create a project using the Administrator library.
2- Activate device manager.
I can lock the device with manager.LockScreen, but if I enter this command:
I get this error:
java.lang.SecurityException: Device admin can no longer call resetPassword()
The complete error:
I read that there is a method that should be used now (resetPasswordWithToken()) but I don't know how to use it. I found this example:
Could someone help me with something?
Thank you very much and greetings.
1- Create a project using the Administrator library.
2- Activate device manager.
I can lock the device with manager.LockScreen, but if I enter this command:
B4X:
manager.ResetPassword("0000")
I get this error:
java.lang.SecurityException: Device admin can no longer call resetPassword()
The complete error:
B4X:
main_btndisable_longclick (java line: 369)
java.lang.SecurityException: Device admin can no longer call resetPassword()
at android.os.Parcel.createExceptionOrNull(Parcel.java:3011)
at android.os.Parcel.createException(Parcel.java:2995)
at android.os.Parcel.readException(Parcel.java:2978)
at android.os.Parcel.readException(Parcel.java:2920)
at android.app.admin.IDevicePolicyManager$Stub$Proxy.resetPassword(IDevicePolicyManager.java:6712)
at android.app.admin.DevicePolicyManager.resetPassword(DevicePolicyManager.java:5728)
at anywheresoftware.b4a.objects.AdminManager.ResetPassword(AdminManager.java:73)
at mx.vmagic.ghost.main._btndisable_longclick(main.java:369)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:205)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.objects.ViewWrapper$2.onLongClick(ViewWrapper.java:90)
at android.view.View.performLongClickInternal(View.java:7661)
at android.view.View.performLongClick(View.java:7619)
at android.widget.TextView.performLongClick(TextView.java:13010)
at android.view.View.performLongClick(View.java:7637)
at android.view.View$CheckForLongPress.run(View.java:29774)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:211)
at android.os.Looper.loop(Looper.java:300)
at android.app.ActivityThread.main(ActivityThread.java:8445)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:560)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:954)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.devicepolicy.DevicePolicyManagerService.resetPassword(DevicePolicyManagerService.java:5014)
at android.app.admin.IDevicePolicyManager$Stub.onTransact(IDevicePolicyManager.java:3178)
at android.os.Binder.execTransactInternal(Binder.java:1285)
at android.os.Binder.execTransact(Binder.java:1249)
java.lang.SecurityException: Device admin can no longer call resetPassword()
** Activity (main) Pause, UserClosed = false **
I read that there is a method that should be used now (resetPasswordWithToken()) but I don't know how to use it. I found this example:
B4X:
private void changePassword() {
byte[] token = generateRandomPasswordToken();
DevicePolicyManager devicePolicyManager = (DevicePolicyManager) getApplicationContext().getSystemService(
DEVICE_POLICY_SERVICE);
KeyguardManager keyguardManager = (KeyguardManager) this.getSystemService(KEYGUARD_SERVICE);
keyguardManager.createConfirmDeviceCredentialIntent(null, null);
if (devicePolicyManager != null) {
devicePolicyManager.setResetPasswordToken(MyAdmin.getComponentName(this), token);
devicePolicyManager.resetPasswordWithToken(MyAdmin.getComponentName(this), "9876", token, 0);
}
}
private byte[] generateRandomPasswordToken() {
try {
return SecureRandom.getInstance("SHA1PRNG").generateSeed(32);
} catch (NoSuchAlgorithmException e) {
return null;
}
}
Could someone help me with something?
Thank you very much and greetings.