Add Bluetooth Contacts Sharing policy in DevicePolicyManager
Bug: 19990979
Change-Id: Ide9adf66eec5721e50573c03956a1b63b7e8b18b
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 68f4707..346e560 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -3214,6 +3214,73 @@
}
/**
+ * Called by a profile owner of a managed profile to set whether bluetooth
+ * devices can access enterprise contacts.
+ * <p>
+ * The calling device admin must be a profile owner. If it is not, a
+ * security exception will be thrown.
+ * <p>
+ * This API works on managed profile only.
+ *
+ * @param who Which {@link DeviceAdminReceiver} this request is associated
+ * with.
+ * @param disabled If true, bluetooth devices cannot access enterprise
+ * contacts.
+ */
+ public void setBluetoothContactSharingDisabled(ComponentName who, boolean disabled) {
+ if (mService != null) {
+ try {
+ mService.setBluetoothContactSharingDisabled(who, disabled);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed talking with device policy service", e);
+ }
+ }
+ }
+
+ /**
+ * Called by a profile owner of a managed profile to determine whether or
+ * not Bluetooth devices cannot access enterprise contacts.
+ * <p>
+ * The calling device admin must be a profile owner. If it is not, a
+ * security exception will be thrown.
+ * <p>
+ * This API works on managed profile only.
+ *
+ * @param who Which {@link DeviceAdminReceiver} this request is associated
+ * with.
+ */
+ public boolean getBluetoothContactSharingDisabled(ComponentName who) {
+ if (mService != null) {
+ try {
+ return mService.getBluetoothContactSharingDisabled(who);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed talking with device policy service", e);
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Determine whether or not Bluetooth devices cannot access contacts.
+ * <p>
+ * This API works on managed profile UserHandle only.
+ *
+ * @param userHandle The user for whom to check the caller-id permission
+ * @hide
+ */
+ public boolean getBluetoothContactSharingDisabled(UserHandle userHandle) {
+ if (mService != null) {
+ try {
+ return mService.getBluetoothContactSharingDisabledForUser(userHandle
+ .getIdentifier());
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed talking with device policy service", e);
+ }
+ }
+ return true;
+ }
+
+ /**
* Called by the profile owner of a managed profile so that some intents sent in the managed
* profile can also be resolved in the parent, or vice versa.
* Only activity intents are supported.
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index c68311e..10923fb 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -191,6 +191,10 @@
boolean getCrossProfileCallerIdDisabledForUser(int userId);
void startManagedQuickContact(String lookupKey, long contactId, in Intent originalIntent);
+ void setBluetoothContactSharingDisabled(in ComponentName who, boolean disabled);
+ boolean getBluetoothContactSharingDisabled(in ComponentName who);
+ boolean getBluetoothContactSharingDisabledForUser(int userId);
+
void setTrustAgentConfiguration(in ComponentName admin, in ComponentName agent,
in PersistableBundle args);
List<PersistableBundle> getTrustAgentConfiguration(in ComponentName admin,