Introduce APIs in DPM for setting/getting the device owner info
This information, if set, will be shown in the lock screen instead
of the user owner information and the settings tile will be made readonly
(implementation in following CLs).
Bug: 22547309
Change-Id: Ic826d8049bc67f5e8fcfa6a91aa2017247c93b11
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index d7ffcc4..2a738ee 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -2843,9 +2843,6 @@
*/
public boolean setProfileOwner(@NonNull ComponentName admin, @Deprecated String ownerName,
int userHandle) throws IllegalArgumentException {
- if (admin == null) {
- throw new NullPointerException("admin cannot be null");
- }
if (mService != null) {
try {
if (ownerName == null) {
@@ -2861,6 +2858,42 @@
}
/**
+ * Sets the device owner information to be shown on the lock screen.
+ *
+ * <p>If the device owner information is {@code null} or empty then the device owner info is
+ * cleared and the user owner info is shown on the lock screen if it is set.
+ *
+ * @param admin The name of the admin component to check.
+ * @param info Device owner information which will be displayed instead of the user
+ * owner info.
+ * @return Whether the device owner information has been set.
+ */
+ public boolean setDeviceOwnerLockScreenInfo(@NonNull ComponentName admin, String info) {
+ if (mService != null) {
+ try {
+ return mService.setDeviceOwnerLockScreenInfo(admin, info);
+ } catch (RemoteException re) {
+ Log.w(TAG, "Failed talking with device policy service", re);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @return The device owner information. If it is not set returns {@code null}.
+ */
+ public String getDeviceOwnerLockScreenInfo() {
+ if (mService != null) {
+ try {
+ return mService.getDeviceOwnerLockScreenInfo();
+ } catch (RemoteException re) {
+ Log.w(TAG, "Failed talking with device policy service", re);
+ }
+ }
+ return null;
+ }
+
+ /**
* Sets the enabled state of the profile. A profile should be enabled only once it is ready to
* be used. Only the profile owner can call this.
*