Merge "Api change of DPM.setApplicationRestrictionsManagingPackage()" into nyc-dev
am: d3c0cf5
* commit 'd3c0cf50b6c8e71c0c409abcd3b8c32f98f7cb71':
Api change of DPM.setApplicationRestrictionsManagingPackage()
This commit is contained in:
@@ -5913,7 +5913,7 @@ package android.app.admin {
|
|||||||
method public boolean setAlwaysOnVpnPackage(android.content.ComponentName, java.lang.String);
|
method public boolean setAlwaysOnVpnPackage(android.content.ComponentName, java.lang.String);
|
||||||
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);
|
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 setAutoTimeRequired(android.content.ComponentName, boolean);
|
||||||
method public void setBluetoothContactSharingDisabled(android.content.ComponentName, boolean);
|
method public void setBluetoothContactSharingDisabled(android.content.ComponentName, boolean);
|
||||||
method public void setCameraDisabled(android.content.ComponentName, boolean);
|
method public void setCameraDisabled(android.content.ComponentName, boolean);
|
||||||
|
|||||||
@@ -6061,7 +6061,7 @@ package android.app.admin {
|
|||||||
method public boolean setAlwaysOnVpnPackage(android.content.ComponentName, java.lang.String);
|
method public boolean setAlwaysOnVpnPackage(android.content.ComponentName, java.lang.String);
|
||||||
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);
|
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 setAutoTimeRequired(android.content.ComponentName, boolean);
|
||||||
method public void setBluetoothContactSharingDisabled(android.content.ComponentName, boolean);
|
method public void setBluetoothContactSharingDisabled(android.content.ComponentName, boolean);
|
||||||
method public void setCameraDisabled(android.content.ComponentName, boolean);
|
method public void setCameraDisabled(android.content.ComponentName, boolean);
|
||||||
|
|||||||
@@ -5917,7 +5917,7 @@ package android.app.admin {
|
|||||||
method public boolean setAlwaysOnVpnPackage(android.content.ComponentName, java.lang.String);
|
method public boolean setAlwaysOnVpnPackage(android.content.ComponentName, java.lang.String);
|
||||||
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);
|
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 setAutoTimeRequired(android.content.ComponentName, boolean);
|
||||||
method public void setBluetoothContactSharingDisabled(android.content.ComponentName, boolean);
|
method public void setBluetoothContactSharingDisabled(android.content.ComponentName, boolean);
|
||||||
method public void setCameraDisabled(android.content.ComponentName, boolean);
|
method public void setCameraDisabled(android.content.ComponentName, boolean);
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.pm.ParceledListSlice;
|
import android.content.pm.ParceledListSlice;
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
@@ -3980,18 +3981,21 @@ public class DevicePolicyManager {
|
|||||||
* {@code null} value or uninstalling the managing package.
|
* {@code null} value or uninstalling the managing package.
|
||||||
* <p>
|
* <p>
|
||||||
* The supplied application restriction managing package must be installed when calling this
|
* 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 admin Which {@link DeviceAdminReceiver} this request is associated with.
|
||||||
* @param packageName The package name which will be given access to application restrictions
|
* @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.
|
* 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 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,
|
public void setApplicationRestrictionsManagingPackage(@NonNull ComponentName admin,
|
||||||
@Nullable String packageName) {
|
@Nullable String packageName) throws NameNotFoundException {
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
try {
|
try {
|
||||||
mService.setApplicationRestrictionsManagingPackage(admin, packageName);
|
if (!mService.setApplicationRestrictionsManagingPackage(admin, packageName)) {
|
||||||
|
throw new NameNotFoundException(packageName);
|
||||||
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw e.rethrowFromSystemServer();
|
throw e.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ interface IDevicePolicyManager {
|
|||||||
|
|
||||||
void setApplicationRestrictions(in ComponentName who, in String packageName, in Bundle settings);
|
void setApplicationRestrictions(in ComponentName who, in String packageName, in Bundle settings);
|
||||||
Bundle getApplicationRestrictions(in ComponentName who, in String packageName);
|
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);
|
String getApplicationRestrictionsManagingPackage(in ComponentName admin);
|
||||||
boolean isCallerApplicationRestrictionsManagingPackage();
|
boolean isCallerApplicationRestrictionsManagingPackage();
|
||||||
|
|
||||||
|
|||||||
@@ -6237,19 +6237,20 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setApplicationRestrictionsManagingPackage(ComponentName admin, String packageName) {
|
public boolean setApplicationRestrictionsManagingPackage(ComponentName admin,
|
||||||
|
String packageName) {
|
||||||
Preconditions.checkNotNull(admin, "ComponentName is null");
|
Preconditions.checkNotNull(admin, "ComponentName is null");
|
||||||
|
|
||||||
final int userHandle = mInjector.userHandleGetCallingUserId();
|
final int userHandle = mInjector.userHandleGetCallingUserId();
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
|
getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
|
||||||
if (packageName != null && !isPackageInstalledForUser(packageName, userHandle)) {
|
if (packageName != null && !isPackageInstalledForUser(packageName, userHandle)) {
|
||||||
throw new IllegalArgumentException("Package " + packageName + " is not installed "
|
return false;
|
||||||
+ "on the current user");
|
|
||||||
}
|
}
|
||||||
DevicePolicyData policy = getUserData(userHandle);
|
DevicePolicyData policy = getUserData(userHandle);
|
||||||
policy.mApplicationRestrictionsManagingPackage = packageName;
|
policy.mApplicationRestrictionsManagingPackage = packageName;
|
||||||
saveSettingsLocked(userHandle);
|
saveSettingsLocked(userHandle);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1117,9 +1117,9 @@ public class DevicePolicyManagerTest extends DpmTestBase {
|
|||||||
dpm.setApplicationRestrictionsManagingPackage(admin1,
|
dpm.setApplicationRestrictionsManagingPackage(admin1,
|
||||||
nonExistAppRestrictionsManagerPackage);
|
nonExistAppRestrictionsManagerPackage);
|
||||||
fail("Non-existent app set as app restriction manager.");
|
fail("Non-existent app set as app restriction manager.");
|
||||||
} catch (IllegalArgumentException expected) {
|
} catch (PackageManager.NameNotFoundException expected) {
|
||||||
MoreAsserts.assertContainsRegex(
|
MoreAsserts.assertContainsRegex(
|
||||||
"is not installed on the current user", expected.getMessage());
|
nonExistAppRestrictionsManagerPackage, expected.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let appRestrictionsManagerPackage manage app restrictions
|
// Let appRestrictionsManagerPackage manage app restrictions
|
||||||
|
|||||||
Reference in New Issue
Block a user