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

Commit cd14c0a9 authored by Victor Chang's avatar Victor Chang
Browse files

Api change of DPM.setApplicationRestrictionsManagingPackage()

Throws NameNotFoundException instead of IllegalArgumentException

Can't throw NameNotFoundException directly from DPMS as
aidl doesn't support checked exception

Bug: 27532565
Change-Id: I202721f41057f92ad2dd851d4769ba4502a8f9b3
parent eb62f7f3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5915,7 +5915,7 @@ package android.app.admin {
    method public boolean setAlwaysOnVpnPackage(android.content.ComponentName, java.lang.String);
    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);
    method public void setApplicationRestrictionsManagingPackage(android.content.ComponentName, java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
    method public void setAutoTimeRequired(android.content.ComponentName, boolean);
    method public void setBluetoothContactSharingDisabled(android.content.ComponentName, boolean);
    method public void setCameraDisabled(android.content.ComponentName, boolean);
+1 −1
Original line number Diff line number Diff line
@@ -6063,7 +6063,7 @@ package android.app.admin {
    method public boolean setAlwaysOnVpnPackage(android.content.ComponentName, java.lang.String);
    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);
    method public void setApplicationRestrictionsManagingPackage(android.content.ComponentName, java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
    method public void setAutoTimeRequired(android.content.ComponentName, boolean);
    method public void setBluetoothContactSharingDisabled(android.content.ComponentName, boolean);
    method public void setCameraDisabled(android.content.ComponentName, boolean);
+1 −1
Original line number Diff line number Diff line
@@ -5919,7 +5919,7 @@ package android.app.admin {
    method public boolean setAlwaysOnVpnPackage(android.content.ComponentName, java.lang.String);
    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);
    method public void setApplicationRestrictionsManagingPackage(android.content.ComponentName, java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
    method public void setAutoTimeRequired(android.content.ComponentName, boolean);
    method public void setBluetoothContactSharingDisabled(android.content.ComponentName, boolean);
    method public void setCameraDisabled(android.content.ComponentName, boolean);
+7 −3
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ParceledListSlice;
import android.content.pm.UserInfo;
import android.graphics.Bitmap;
@@ -3980,18 +3981,21 @@ public class DevicePolicyManager {
     * {@code null} value or uninstalling the managing package.
     * <p>
     * The supplied application restriction managing package must be installed when calling this
     * API, otherwise an {@link IllegalArgumentException} will be thrown.
     * API, otherwise an {@link NameNotFoundException} will be thrown.
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @param packageName The package name which will be given access to application restrictions
     *            APIs. If {@code null} is given the current package will be cleared.
     * @throws SecurityException if {@code admin} is not a device or profile owner.
     * @throws NameNotFoundException if {@code packageName} is not found
     */
    public void setApplicationRestrictionsManagingPackage(@NonNull ComponentName admin,
            @Nullable String packageName) {
            @Nullable String packageName) throws NameNotFoundException {
        if (mService != null) {
            try {
                mService.setApplicationRestrictionsManagingPackage(admin, packageName);
                if (!mService.setApplicationRestrictionsManagingPackage(admin, packageName)) {
                    throw new NameNotFoundException(packageName);
                }
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
+1 −1
Original line number Diff line number Diff line
@@ -161,7 +161,7 @@ interface IDevicePolicyManager {

    void setApplicationRestrictions(in ComponentName who, in String packageName, in Bundle settings);
    Bundle getApplicationRestrictions(in ComponentName who, in String packageName);
    void setApplicationRestrictionsManagingPackage(in ComponentName admin, in String packageName);
    boolean setApplicationRestrictionsManagingPackage(in ComponentName admin, in String packageName);
    String getApplicationRestrictionsManagingPackage(in ComponentName admin);
    boolean isCallerApplicationRestrictionsManagingPackage();

Loading