Merge "Exposed some DPM members as @TestApi."
This commit is contained in:
committed by
Android (Google) Code Review
commit
7344dac2f3
@@ -372,8 +372,15 @@ package android.app.admin {
|
||||
method public java.util.List<java.lang.String> getOwnerInstalledCaCerts(@NonNull android.os.UserHandle);
|
||||
method public boolean isCurrentInputMethodSetByOwner();
|
||||
method public boolean isFactoryResetProtectionPolicySupported();
|
||||
method @NonNull public static String operationToString(int);
|
||||
method @RequiresPermission("android.permission.MANAGE_DEVICE_ADMINS") public void setNextOperationSafety(int, boolean);
|
||||
field public static final String ACTION_DATA_SHARING_RESTRICTION_APPLIED = "android.app.action.DATA_SHARING_RESTRICTION_APPLIED";
|
||||
field public static final int OPERATION_CREATE_AND_MANAGE_USER = 5; // 0x5
|
||||
field public static final int OPERATION_LOCK_NOW = 1; // 0x1
|
||||
field public static final int OPERATION_REMOVE_USER = 6; // 0x6
|
||||
field public static final int OPERATION_START_USER_IN_BACKGROUND = 3; // 0x3
|
||||
field public static final int OPERATION_STOP_USER = 4; // 0x4
|
||||
field public static final int OPERATION_SWITCH_USER = 2; // 0x2
|
||||
}
|
||||
|
||||
public static final class SecurityLog.SecurityEvent implements android.os.Parcelable {
|
||||
|
||||
@@ -39,6 +39,7 @@ import android.annotation.WorkerThread;
|
||||
import android.app.Activity;
|
||||
import android.app.IServiceConnection;
|
||||
import android.app.KeyguardManager;
|
||||
import android.app.admin.DevicePolicyManager.DevicePolicyOperation;
|
||||
import android.app.admin.SecurityLog.SecurityEvent;
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
import android.content.ComponentName;
|
||||
@@ -2591,27 +2592,27 @@ public class DevicePolicyManager {
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface PersonalAppsSuspensionReason {}
|
||||
|
||||
// TODO(b/172376923) - make all (or none) @TestApi
|
||||
|
||||
/** @hide */
|
||||
@TestApi
|
||||
public static final int OPERATION_LOCK_NOW = 1;
|
||||
|
||||
/** @hide */
|
||||
@TestApi
|
||||
public static final int OPERATION_SWITCH_USER = 2;
|
||||
/** @hide */
|
||||
@TestApi
|
||||
public static final int OPERATION_START_USER_IN_BACKGROUND = 3;
|
||||
/** @hide */
|
||||
@TestApi
|
||||
public static final int OPERATION_STOP_USER = 4;
|
||||
/** @hide */
|
||||
@TestApi
|
||||
public static final int OPERATION_CREATE_AND_MANAGE_USER = 5;
|
||||
/** @hide */
|
||||
@TestApi
|
||||
public static final int OPERATION_REMOVE_USER = 6;
|
||||
|
||||
private static final String PREFIX_OPERATION = "OPERATION_";
|
||||
|
||||
|
||||
// TODO(b/172376923) - add all operations
|
||||
/** @hide */
|
||||
@IntDef(prefix = PREFIX_OPERATION, value = {
|
||||
OPERATION_LOCK_NOW,
|
||||
@@ -2626,6 +2627,8 @@ public class DevicePolicyManager {
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@TestApi
|
||||
@NonNull
|
||||
public static String operationToString(@DevicePolicyOperation int operation) {
|
||||
return DebugUtils.constantToString(DevicePolicyManager.class, PREFIX_OPERATION, operation);
|
||||
}
|
||||
@@ -12534,4 +12537,21 @@ public class DevicePolicyManager {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by CTS to set the result of the next safety operation check.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@RequiresPermission(android.Manifest.permission.MANAGE_DEVICE_ADMINS)
|
||||
public void setNextOperationSafety(@DevicePolicyOperation int operation, boolean safe) {
|
||||
if (mService != null) {
|
||||
try {
|
||||
mService.setNextOperationSafety(operation, safe);
|
||||
} catch (RemoteException re) {
|
||||
throw re.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -484,5 +484,7 @@ interface IDevicePolicyManager {
|
||||
|
||||
long getManagedProfileMaximumTimeOff(in ComponentName admin);
|
||||
void setManagedProfileMaximumTimeOff(in ComponentName admin, long timeoutMs);
|
||||
boolean canProfileOwnerResetPasswordWhenLocked(in int userId);
|
||||
boolean canProfileOwnerResetPasswordWhenLocked(int userId);
|
||||
|
||||
void setNextOperationSafety(int operation, boolean safe);
|
||||
}
|
||||
|
||||
@@ -1017,10 +1017,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
return mSafetyChecker == null || mSafetyChecker.isDevicePolicyOperationSafe(operation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by {@code cmd device_policy} to set the result of the next safety operation check.
|
||||
*/
|
||||
void setNextOperationSafety(@DevicePolicyOperation int operation, boolean safe) {
|
||||
@Override
|
||||
public void setNextOperationSafety(@DevicePolicyOperation int operation, boolean safe) {
|
||||
Preconditions.checkCallAuthorization(
|
||||
hasCallingOrSelfPermission(permission.MANAGE_DEVICE_ADMINS));
|
||||
Slog.i(LOG_TAG, "setNextOperationSafety(" + DevicePolicyManager.operationToString(operation)
|
||||
|
||||
Reference in New Issue
Block a user