isDeviceOwnerProvisioningAllowed implementation to match enforceCanSetDeviceOwnerLocked

The main purpose is to fix the security flaw that
user can force isDeviceOwnerProvisioningAllowed to return true
by setting the device_provisioned without factory reset

Check UserSetupComplete instead, as it's cached by DPMS if it's ever set to true

Refactor common code of isDeviceOwnerProvisioningAllowed and enforceCanSetDeviceOwnerLocked
The functionality of enforceCanSetDeviceOwnerLocked should be exactly the same.
DPM Unit Test all pass

Bug:27403225
Change-Id: I32dae8e222e01e08664abb313ead3a92d4186658
1 file changed