Check if FRP policy is supported in Settings

* Check if FRP policy is supported before
  erasing a device via settings.
* Call DPM TestAPI isFactoryResetProtectionPolicySupported
* If FRP policy is not supported, then do not
  erase the device.

Bug: 155057616
Test: atest com.android.settings.MasterClearConfirmTest
Change-Id: I56e4a6566457f31932658188646abe21701637fc
diff --git a/src/com/android/settings/MasterClearConfirm.java b/src/com/android/settings/MasterClearConfirm.java
index cac18f7..3ace436 100644
--- a/src/com/android/settings/MasterClearConfirm.java
+++ b/src/com/android/settings/MasterClearConfirm.java
@@ -151,11 +151,16 @@
         if (isOemUnlockedAllowed()) {
             return false;
         }
+        final DevicePolicyManager dpm = (DevicePolicyManager) getActivity()
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
+        // Do not erase the factory reset protection data (from Settings) if factory reset
+        // protection policy is not supported on the device.
+        if (!dpm.isFactoryResetProtectionPolicySupported()) {
+            return false;
+        }
         // Do not erase the factory reset protection data (from Settings) if the
         // device is an organization-owned managed profile device and a factory
         // reset protection policy has been set.
-        final DevicePolicyManager dpm = (DevicePolicyManager) getActivity()
-                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         FactoryResetProtectionPolicy frpPolicy = dpm.getFactoryResetProtectionPolicy(null);
         if (dpm.isOrganizationOwnedDeviceWithManagedProfile() && frpPolicy != null
                 && frpPolicy.isNotEmpty()) {