am c21a94ce: am 928febf7: Check that the user that started the provisioning is owner
* commit 'c21a94cea37938a565c677540e28faa951eb533e':
Check that the user that started the provisioning is owner
diff --git a/res/values/strings.xml b/res/values/strings.xml
index a5aab2e..34aa71a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -68,6 +68,8 @@
<string name="managed_provisioning_error_text">Couldn\'t set up your work profile. Contact your IT department or try again later.</string>
<!-- Error string displayed if this device doesn't support managed profiles. -->
<string name="managed_provisioning_not_supported">Your device doesn\'t support work profiles.</string>
+ <!-- Error string displayed if the user that initiated the provisioning is not the user owner. -->
+ <string name="user_is_not_owner">Work profiles can only be set up by the owner user of the device.</string>
<!-- Device owner provisioning flow UI. -->
diff --git a/src/com/android/managedprovisioning/ManagedProvisioningActivity.java b/src/com/android/managedprovisioning/ManagedProvisioningActivity.java
index 798fbc7..f9531cc 100644
--- a/src/com/android/managedprovisioning/ManagedProvisioningActivity.java
+++ b/src/com/android/managedprovisioning/ManagedProvisioningActivity.java
@@ -31,7 +31,9 @@
import android.content.pm.UserInfo;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import android.os.Process;
import android.os.SystemProperties;
+import android.os.UserHandle;
import android.os.UserManager;
import android.support.v4.content.LocalBroadcastManager;
import android.text.TextUtils;
@@ -88,6 +90,11 @@
"Exiting managed provisioning, managed profiles feature is not available");
return;
}
+ if (Process.myUserHandle().getIdentifier() != UserHandle.USER_OWNER) {
+ showErrorAndClose(R.string.user_is_not_owner,
+ "Exiting managed provisioning, calling user is not owner.");
+ return;
+ }
// Setup broadcast receiver for feedback from service.
mServiceMessageReceiver = new ServiceMessageReceiver();