check for admin

This commit is contained in:
wesaphzt 2019-09-11 22:45:25 +01:00
parent 1cc68f0fff
commit 18018360d3

View file

@ -229,13 +229,20 @@ public class LockService extends JobIntentService {
if (total > SENSITIVITY) {
try {
if (isActiveAdmin()) {
mDPM.lockNow();
} else {
Toast.makeText(context, "Device admin not enabled", Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
Toast.makeText(context, "Error locking, does app have device admin permissions?", Toast.LENGTH_SHORT).show();
Toast.makeText(context, "Unknown locking error", Toast.LENGTH_SHORT).show();
}
}
}
}
private boolean isActiveAdmin() {
return mDPM.isAdminActive(mDeviceAdmin);
}
private void setNotification() {
//notification