diff options
| author | 2016-04-05 16:27:15 +0100 | |
|---|---|---|
| committer | 2016-04-06 16:30:22 +0100 | |
| commit | ee5eb934e349ee6a01a028cb431afac9018b8e56 (patch) | |
| tree | 95ecf6ab847306726991d10072c3830dcf7a504a | |
| parent | 36e480cf8cec07a9204c2f50d7268c39e1c0aeae (diff) | |
Remove bool return from setAlwaysOnVpnPackage
Bug: 27533151
Change-Id: I4c656488e69cb5247dbb9cfd62d6f6f7043f9a90
| -rw-r--r-- | api/current.txt | 3 | ||||
| -rw-r--r-- | api/system-current.txt | 3 | ||||
| -rw-r--r-- | api/test-current.txt | 3 | ||||
| -rw-r--r-- | core/java/android/app/admin/DevicePolicyManager.java | 12 | ||||
| -rw-r--r-- | services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java | 17 |
5 files changed, 29 insertions, 9 deletions
diff --git a/api/current.txt b/api/current.txt index 0857c8bb696e..ccd22f468913 100644 --- a/api/current.txt +++ b/api/current.txt @@ -5913,7 +5913,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; @@ -66433,3 +66433,4 @@ package org.xmlpull.v1.sax2 { } } + diff --git a/api/system-current.txt b/api/system-current.txt index 99a4ad3c448a..3c7f0ae99ff8 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -6061,7 +6061,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; @@ -69498,3 +69498,4 @@ package org.xmlpull.v1.sax2 { } } + diff --git a/api/test-current.txt b/api/test-current.txt index 6cf047a2d411..95f989735572 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -5917,7 +5917,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; @@ -66507,3 +66507,4 @@ package org.xmlpull.v1.sax2 { } } + diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index e7427bfabe01..433f3c042ef9 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -2933,17 +2933,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 d8b856b9b753..b7d359032f7b 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -4285,6 +4285,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 { @@ -4294,13 +4301,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 |