How to add extra protection in my device owner application so that if someone tries bypassing the FRP they can't use the phone. I have seen this in some devices. they show a notification 'Device managed by admin automatically resetting soon' like this: screenshot1
The app that showed this was using 'Android Management API'. I read about this but what I understood is that I think they install their own app as device owner in the device to add the FRP policy. In that case I think I will not be able to install my device owner app (or is it possible?).
I am using this code and it adds FRP (asks for the required gMail address during device setup) but it can be easily bypassed by following some YouTube videos and after that device does not show above notification.
try {
Bundle bundle = new Bundle();
bundle.putString("factoryResetProtectionAdmin", 432112340987654321234);//google Id
devicePolicyManager.setApplicationRestrictions(adminComponentName, "com.google.android.gms", bundle);
// send broadcast
Intent broadcastIntent = new Intent("com.google.android.gms.auth.FRP_CONFIG_CHANGED");
broadcastIntent.setPackage("com.google.android.gms");
broadcastIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
getApplicationContext().sendBroadcast(broadcastIntent);
} catch (Exception e) {
Log.d("FRP", e.getLocalizedMessage());
e.printStackTrace();
}