Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ee5eb934 authored by Robin Lee's avatar Robin Lee
Browse files

Remove bool return from setAlwaysOnVpnPackage

Bug: 27533151
Change-Id: I4c656488e69cb5247dbb9cfd62d6f6f7043f9a90
parent 36e480cf
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -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> retrievePreRebootSecurityLogs(android.content.ComponentName);
    method public java.util.List<android.app.admin.SecurityLog.SecurityEvent> retrieveSecurityLogs(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 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 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 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;
    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 {
  }
  }
}
}
+2 −1
Original line number Original line Diff line number Diff line
@@ -6061,7 +6061,7 @@ package android.app.admin {
    method public java.util.List<android.app.admin.SecurityLog.SecurityEvent> retrieveSecurityLogs(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 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 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 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 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;
    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 {
  }
  }
}
}
+2 −1
Original line number Original line Diff line number Diff line
@@ -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> retrievePreRebootSecurityLogs(android.content.ComponentName);
    method public java.util.List<android.app.admin.SecurityLog.SecurityEvent> retrieveSecurityLogs(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 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 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 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;
    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 {
  }
  }
}
}
+8 −4
Original line number Original line Diff line number Diff line
@@ -2933,17 +2933,21 @@ public class DevicePolicyManager {
     * @return {@code true} if the package is set as always-on VPN controller; {@code false}
     * @return {@code true} if the package is set as always-on VPN controller; {@code false}
     *         otherwise.
     *         otherwise.
     * @throws SecurityException if {@code admin} is not a device or a profile owner.
     * @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,
    public void setAlwaysOnVpnPackage(@NonNull ComponentName admin, @Nullable String vpnPackage)
            @Nullable String vpnPackage) {
            throws NameNotFoundException, UnsupportedOperationException {
        if (mService != null) {
        if (mService != null) {
            try {
            try {
                return mService.setAlwaysOnVpnPackage(admin, vpnPackage);
                if (!mService.setAlwaysOnVpnPackage(admin, vpnPackage)) {
                    throw new NameNotFoundException(vpnPackage);
                }
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
                throw e.rethrowFromSystemServer();
            }
            }
        }
        }
        return false;
    }
    }


    /**
    /**
+15 −2
Original line number Original line Diff line number Diff line
@@ -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
    @Override
    public boolean setAlwaysOnVpnPackage(ComponentName admin, String vpnPackage)
    public boolean setAlwaysOnVpnPackage(ComponentName admin, String vpnPackage)
            throws SecurityException {
            throws SecurityException {
@@ -4295,12 +4302,18 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        final int userId = mInjector.userHandleGetCallingUserId();
        final int userId = mInjector.userHandleGetCallingUserId();
        final long token = mInjector.binderClearCallingIdentity();
        final long token = mInjector.binderClearCallingIdentity();
        try {
        try {
            if (vpnPackage != null && !isPackageInstalledForUser(vpnPackage, userId)) {
                return false;
            }
            ConnectivityManager connectivityManager = (ConnectivityManager)
            ConnectivityManager connectivityManager = (ConnectivityManager)
                    mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
                    mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
            return connectivityManager.setAlwaysOnVpnPackageForUser(userId, vpnPackage);
            if (!connectivityManager.setAlwaysOnVpnPackageForUser(userId, vpnPackage)) {
                throw new UnsupportedOperationException();
            }
        } finally {
        } finally {
            mInjector.binderRestoreCallingIdentity(token);
            mInjector.binderRestoreCallingIdentity(token);
        }
        }
        return true;
    }
    }


    @Override
    @Override