summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorKenny Guy <kennyguy@google.com>2015-12-22 12:07:39 +0000
committerKenny Guy <kennyguy@google.com>2016-01-05 19:07:04 +0000
commit06de4e77c20be239384262b1508f0cf53bedb145 (patch)
treec8a6bcae32d26c001e80466c5fed6d4ffff3ec54 /core/java/android
parentc33f357b50f24cf1d2a05e594f4d4bd16a6c2f0c (diff)
Add support message for device admins
Allow admins to set a long and short support message for settings to display. Bug: 25659579 Change-Id: Ib645490785642e49c69d8dbc65455eb3398547ee
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/admin/DevicePolicyManager.java125
-rw-r--r--core/java/android/app/admin/IDevicePolicyManager.aidl8
2 files changed, 133 insertions, 0 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index eda098252aa0..f940bd6e8fed 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -4802,4 +4802,129 @@ public class DevicePolicyManager {
Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
}
}
+
+ /**
+ * Called by a device admin to set the short support message. This will
+ * be displayed to the user in settings screens where funtionality has
+ * been disabled by the admin.
+ *
+ * The message should be limited to a short statement such as
+ * "This setting is disabled by your administrator. Contact someone@example.com
+ * for support."
+ * If the message is longer than 200 characters it may be truncated.
+ *
+ * @see #setLongSupportMessage
+ *
+ * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
+ * @param message Short message to be displayed to the user in settings or null to
+ * clear the existing message.
+ */
+ public void setShortSupportMessage(@NonNull ComponentName admin,
+ @Nullable String message) {
+ if (mService != null) {
+ try {
+ mService.setShortSupportMessage(admin, message);
+ } catch (RemoteException e) {
+ Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ }
+ }
+ }
+
+ /**
+ * Called by a device admin to get the short support message.
+ *
+ * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
+ * @return The message set by {@link #setShortSupportMessage(ComponentName, String)}
+ * or null if no message has been set.
+ */
+ public String getShortSupportMessage(@NonNull ComponentName admin) {
+ if (mService != null) {
+ try {
+ return mService.getShortSupportMessage(admin);
+ } catch (RemoteException e) {
+ Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Called by a device admin to set the long support message. This will
+ * be displayed to the user in the device administators settings screen.
+ *
+ * @see #setShortSupportMessage
+ *
+ * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
+ * @param message Long message to be displayed to the user in settings or null to
+ * clear the existing message.
+ */
+ public void setLongSupportMessage(@NonNull ComponentName admin,
+ @Nullable String message) {
+ if (mService != null) {
+ try {
+ mService.setLongSupportMessage(admin, message);
+ } catch (RemoteException e) {
+ Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ }
+ }
+ }
+
+ /**
+ * Called by a device admin to get the long support message.
+ *
+ * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
+ * @return The message set by {@link #setLongSupportMessage(ComponentName, String)}
+ * or null if no message has been set.
+ */
+ public String getLongSupportMessage(@NonNull ComponentName admin) {
+ if (mService != null) {
+ try {
+ return mService.getLongSupportMessage(admin);
+ } catch (RemoteException e) {
+ Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Called by the system to get the short support message.
+ *
+ * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
+ * @param userHandle user id the admin is running as.
+ * @return The message set by {@link #setShortSupportMessage(ComponentName, String)}
+ *
+ * @hide
+ */
+ public String getShortSupportMessageForUser(@NonNull ComponentName admin, int userHandle) {
+ if (mService != null) {
+ try {
+ return mService.getShortSupportMessageForUser(admin, userHandle);
+ } catch (RemoteException e) {
+ Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ }
+ }
+ return null;
+ }
+
+
+ /**
+ * Called by the system to get the long support message.
+ *
+ * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
+ * @param userHandle user id the admin is running as.
+ * @return The message set by {@link #setLongSupportMessage(ComponentName, String)}
+ *
+ * @hide
+ */
+ public String getLongSupportMessageForUser(@NonNull ComponentName admin, int userHandle) {
+ if (mService != null) {
+ try {
+ return mService.getLongSupportMessageForUser(admin, userHandle);
+ } catch (RemoteException e) {
+ Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ }
+ }
+ return null;
+ }
}
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index 30ce682ef888..f480a02b21a0 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -245,4 +245,12 @@ interface IDevicePolicyManager {
boolean isSystemOnlyUser(in ComponentName admin);
String getWifiMacAddress();
void reboot(in ComponentName admin);
+
+ void setShortSupportMessage(in ComponentName admin, in String message);
+ String getShortSupportMessage(in ComponentName admin);
+ void setLongSupportMessage(in ComponentName admin, in String message);
+ String getLongSupportMessage(in ComponentName admin);
+
+ String getShortSupportMessageForUser(in ComponentName admin, int userHandle);
+ String getLongSupportMessageForUser(in ComponentName admin, int userHandle);
}