mirror of https://github.com/x13a/Wasted.git
ref
This commit is contained in:
parent
8ffac1070d
commit
85fcc22463
|
@ -9,7 +9,11 @@ import android.widget.Toast
|
|||
class DeviceAdminReceiver : DeviceAdminReceiver() {
|
||||
override fun onPasswordFailed(context: Context, intent: Intent, user: UserHandle) {
|
||||
super.onPasswordFailed(context, intent, user)
|
||||
onPasswordFailedInternal(context)
|
||||
val prefs = Preferences(context)
|
||||
if (!prefs.isServiceEnabled || prefs.maxFailedPasswordAttempts <= 0) return
|
||||
val admin = DeviceAdminManager(context)
|
||||
if (admin.getCurrentFailedPasswordAttempts() >= prefs.maxFailedPasswordAttempts)
|
||||
admin.wipeData()
|
||||
}
|
||||
|
||||
override fun onDisabled(context: Context, intent: Intent) {
|
||||
|
@ -17,12 +21,4 @@ class DeviceAdminReceiver : DeviceAdminReceiver() {
|
|||
if (Preferences(context).isServiceEnabled)
|
||||
Toast.makeText(context, R.string.service_unavailable_popup, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
private fun onPasswordFailedInternal(ctx: Context) {
|
||||
val prefs = Preferences(ctx)
|
||||
if (!prefs.isServiceEnabled || prefs.maxFailedPasswordAttempts <= 0) return
|
||||
val admin = DeviceAdminManager(ctx)
|
||||
if (admin.getCurrentFailedPasswordAttempts() >= prefs.maxFailedPasswordAttempts)
|
||||
admin.wipeData()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue