Communicate right error code from DPMS to MP in response to STATUS_HEADLESS_SYSTEM_USER_MODE_NOT_SUPPORTED

This status code occurs when an user attempts  to provision an unsupported DPC into DO on a headless device

Bug: 268168017
Test: manual
Change-Id: If97998a628279ca4e7c2fba8633f5af1ae408000
This commit is contained in:
shreyacsingh
2023-05-10 15:11:33 +00:00
parent 750d5d6837
commit 77b0bb5295

View File

@@ -10907,8 +10907,13 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
/* deviceOwnerUserId= */ deviceOwnerUserId, /* callingUserId*/ caller.getUserId(),
isAdb(caller), hasIncompatibleAccountsOrNonAdb);
if (code != STATUS_OK) {
throw new IllegalStateException(computeProvisioningErrorStringLocked(code,
deviceOwnerUserId, owner, showComponentOnError));
final String provisioningErrorStringLocked = computeProvisioningErrorStringLocked(code,
deviceOwnerUserId, owner, showComponentOnError);
if (code == STATUS_HEADLESS_SYSTEM_USER_MODE_NOT_SUPPORTED) {
throw new ServiceSpecificException(code, provisioningErrorStringLocked);
} else {
throw new IllegalStateException(provisioningErrorStringLocked);
}
}
}
@@ -10962,6 +10967,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
case STATUS_HAS_PAIRED:
return "Not allowed to set the device owner because this device has already "
+ "paired.";
case STATUS_HEADLESS_SYSTEM_USER_MODE_NOT_SUPPORTED:
return "Cannot provision an unsupported DPC into DO on a"
+ " headless device";
default:
return "Unexpected @ProvisioningPreCondition: " + code;
}