summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Robin Lee <rgl@google.com> 2016-04-06 17:01:23 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2016-04-06 17:01:24 +0000
commit589b855719ce89ba68ce1a93f15a4c79a2461adc (patch)
tree705beb9a0de38d3d2bd434a99be6641ea5324659
parentb2c8a4a06a29472f65b9f5a46fcedf106f5a3487 (diff)
parentee5eb934e349ee6a01a028cb431afac9018b8e56 (diff)
Merge "Remove bool return from setAlwaysOnVpnPackage" into nyc-dev
-rw-r--r--api/current.txt2
-rw-r--r--api/system-current.txt2
-rw-r--r--api/test-current.txt2
-rw-r--r--core/java/android/app/admin/DevicePolicyManager.java12
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java17
5 files changed, 26 insertions, 9 deletions
diff --git a/api/current.txt b/api/current.txt
index 18388b2d3a7c..40a92b977e38 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -5921,7 +5921,7 @@ package android.app.admin {
method public java.util.List<android.app.admin.SecurityLog.SecurityEvent> retrievePreRebootSecurityLogs(android.content.ComponentName);
method public java.util.List<android.app.admin.SecurityLog.SecurityEvent> retrieveSecurityLogs(android.content.ComponentName);
method public void setAccountManagementDisabled(android.content.ComponentName, java.lang.String, boolean);
- method public boolean setAlwaysOnVpnPackage(android.content.ComponentName, java.lang.String);
+ method public void setAlwaysOnVpnPackage(android.content.ComponentName, java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException, java.lang.UnsupportedOperationException;
method public boolean setApplicationHidden(android.content.ComponentName, java.lang.String, boolean);
method public void setApplicationRestrictions(android.content.ComponentName, java.lang.String, android.os.Bundle);
method public void setApplicationRestrictionsManagingPackage(android.content.ComponentName, java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
diff --git a/api/system-current.txt b/api/system-current.txt
index 051ed04fcdbc..9ed529fa4bf7 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -6070,7 +6070,7 @@ package android.app.admin {
method public java.util.List<android.app.admin.SecurityLog.SecurityEvent> retrieveSecurityLogs(android.content.ComponentName);
method public void setAccountManagementDisabled(android.content.ComponentName, java.lang.String, boolean);
method public deprecated boolean setActiveProfileOwner(android.content.ComponentName, java.lang.String) throws java.lang.IllegalArgumentException;
- method public boolean setAlwaysOnVpnPackage(android.content.ComponentName, java.lang.String);
+ method public void setAlwaysOnVpnPackage(android.content.ComponentName, java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException, java.lang.UnsupportedOperationException;
method public boolean setApplicationHidden(android.content.ComponentName, java.lang.String, boolean);
method public void setApplicationRestrictions(android.content.ComponentName, java.lang.String, android.os.Bundle);
method public void setApplicationRestrictionsManagingPackage(android.content.ComponentName, java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
diff --git a/api/test-current.txt b/api/test-current.txt
index fe7b4d38a9e8..dea7fc11a1d3 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -5925,7 +5925,7 @@ package android.app.admin {
method public java.util.List<android.app.admin.SecurityLog.SecurityEvent> retrievePreRebootSecurityLogs(android.content.ComponentName);
method public java.util.List<android.app.admin.SecurityLog.SecurityEvent> retrieveSecurityLogs(android.content.ComponentName);
method public void setAccountManagementDisabled(android.content.ComponentName, java.lang.String, boolean);
- method public boolean setAlwaysOnVpnPackage(android.content.ComponentName, java.lang.String);
+ method public void setAlwaysOnVpnPackage(android.content.ComponentName, java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException, java.lang.UnsupportedOperationException;
method public boolean setApplicationHidden(android.content.ComponentName, java.lang.String, boolean);
method public void setApplicationRestrictions(android.content.ComponentName, java.lang.String, android.os.Bundle);
method public void setApplicationRestrictionsManagingPackage(android.content.ComponentName, java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 571e982a906c..856a0f13e767 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -2977,17 +2977,21 @@ public class DevicePolicyManager {
* @return {@code true} if the package is set as always-on VPN controller; {@code false}
* otherwise.
* @throws SecurityException if {@code admin} is not a device or a profile owner.
+ * @throws NameNotFoundException if {@code vpnPackage} is not installed.
+ * @throws UnsupportedOperationException if {@code vpnPackage} exists but does not support being
+ * set as always-on, or if always-on VPN is not available.
*/
- public boolean setAlwaysOnVpnPackage(@NonNull ComponentName admin,
- @Nullable String vpnPackage) {
+ public void setAlwaysOnVpnPackage(@NonNull ComponentName admin, @Nullable String vpnPackage)
+ throws NameNotFoundException, UnsupportedOperationException {
if (mService != null) {
try {
- return mService.setAlwaysOnVpnPackage(admin, vpnPackage);
+ if (!mService.setAlwaysOnVpnPackage(admin, vpnPackage)) {
+ throw new NameNotFoundException(vpnPackage);
+ }
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
- return false;
}
/**
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 0d4887d65cfe..1d8c123f1f14 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -4357,6 +4357,13 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
}
}
+ /**
+ * @return {@code true} if the package is installed and set as always-on, {@code false} if it is
+ * not installed and therefore not available.
+ *
+ * @throws SecurityException if the caller is not a profile or device owner.
+ * @throws UnsupportedException if the package does not support being set as always-on.
+ */
@Override
public boolean setAlwaysOnVpnPackage(ComponentName admin, String vpnPackage)
throws SecurityException {
@@ -4366,13 +4373,19 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
final int userId = mInjector.userHandleGetCallingUserId();
final long token = mInjector.binderClearCallingIdentity();
- try{
+ try {
+ if (vpnPackage != null && !isPackageInstalledForUser(vpnPackage, userId)) {
+ return false;
+ }
ConnectivityManager connectivityManager = (ConnectivityManager)
mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
- return connectivityManager.setAlwaysOnVpnPackageForUser(userId, vpnPackage);
+ if (!connectivityManager.setAlwaysOnVpnPackageForUser(userId, vpnPackage)) {
+ throw new UnsupportedOperationException();
+ }
} finally {
mInjector.binderRestoreCallingIdentity(token);
}
+ return true;
}
@Override