summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorEran Messeri <eranm@google.com>2020-01-08 19:35:46 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-01-08 19:35:46 +0000
commit76a011ba2a5af42b5e87b754a4d7c46c5e3e0ff0 (patch)
tree6e69747ee1dba5e0499a0fa631f8a9b152b5c1cc /core/java
parent540f0030865815ee6434410999bf3f8d8373f756 (diff)
parenta1015c8c95cedb9b99bc93cd929675c7a3fd714a (diff)
Merge "DPM: Add method for Organization-owned device detection"
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/admin/DevicePolicyManager.java33
-rw-r--r--core/java/android/app/admin/IDevicePolicyManager.aidl1
2 files changed, 31 insertions, 3 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index f3028a10bb10..2aac94c6f5da 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -88,7 +88,6 @@ import android.telephony.data.ApnSetting;
import android.util.ArraySet;
import android.util.Log;
-import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.BackgroundThread;
import com.android.internal.util.Preconditions;
@@ -6757,6 +6756,34 @@ public class DevicePolicyManager {
}
/**
+ * @hide
+ * Privileged apps can use this method to find out if the device was provisioned as
+ * organization-owend device with a managed profile.
+ *
+ * This, together with checking whether the device has a device owner (by calling
+ * {@link #isDeviceManaged()}), could be used to learn whether the device is owned by an
+ * organization or an individual:
+ * If this method returns true OR {@link #isDeviceManaged()} returns true, then
+ * the device is owned by an organization. Otherwise, it's owned by an individual.
+ *
+ * @return {@code true} if the device was provisioned as organization-owned device,
+ * {@code false} otherwise.
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
+ public boolean isOrganizationOwnedDeviceWithManagedProfile() {
+ throwIfParentInstance("isOrganizationOwnedDeviceWithManagedProfile");
+ if (mService != null) {
+ try {
+ return mService.isOrganizationOwnedDeviceWithManagedProfile();
+ } catch (RemoteException re) {
+ throw re.rethrowFromSystemServer();
+ }
+ }
+ return false;
+ }
+
+ /**
* Returns whether the specified package can read the device identifiers.
*
* @param packageName The package name of the app to check for device identifier access.
@@ -11215,12 +11242,12 @@ public class DevicePolicyManager {
* #setCrossProfilePackages(ComponentName, Set)}.</li>
* <li>The default package names set by the OEM that are allowed to request user consent for
* cross-profile communication without being explicitly enabled by the admin, via
- * {@link R.array#cross_profile_apps}</li>
+ * {@link com.android.internal.R.array#cross_profile_apps}</li>
* </ul>
*
* @return the combined set of whitelisted package names set via
* {@link #setCrossProfilePackages(ComponentName, Set)} and
- * {@link R.array#cross_profile_apps}
+ * {@link com.android.internal.R.array#cross_profile_apps}
*
* @hide
*/
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index 55dfe2fec4c9..3eec46bd010e 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -156,6 +156,7 @@ interface IDevicePolicyManager {
void setProfileName(in ComponentName who, String profileName);
void clearProfileOwner(in ComponentName who);
boolean hasUserSetupCompleted();
+ boolean isOrganizationOwnedDeviceWithManagedProfile();
boolean checkDeviceIdentifierAccess(in String packageName, int pid, int uid);