summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2020-09-08 18:49:41 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-09-08 18:49:41 +0000
commit75f48b12542e190bf7bbcd524e40bdd968fc788a (patch)
treea8094fe30a4677d586470bb060c9c4509f3039c3
parenta32bde83cd86be4db96802afd138e9743f257c8c (diff)
parent2695df2069b62909d42490550d42aa811cbd9f5a (diff)
Merge "Logs a warning on some setters called when the device doesn't support the feature."
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 80455833a3eb..b6f0f9ffe001 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -7132,9 +7132,22 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
return (deviceOwner != null) ? deviceOwner.keepUninstalledPackages : null;
}
+ /**
+ * Logs a warning when the device doesn't have {@code PackageManager.FEATURE_DEVICE_ADMIN}.
+ *
+ * @param message action that was not executed; should not end with a period because the missing
+ * feature will be appended to it.
+ */
+ private void logMissingFeatureAction(String message) {
+ Slog.w(LOG_TAG, message + " because device does not have the "
+ + PackageManager.FEATURE_DEVICE_ADMIN + " feature.");
+ }
+
@Override
public boolean setDeviceOwner(ComponentName admin, String ownerName, int userId) {
if (!mHasFeature) {
+ logMissingFeatureAction("Cannot set " + ComponentName.flattenToShortString(admin)
+ + " as device owner for user " + userId);
return false;
}
if (admin == null
@@ -7456,6 +7469,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
@Override
public boolean setProfileOwner(ComponentName who, String ownerName, int userHandle) {
if (!mHasFeature) {
+ logMissingFeatureAction("Cannot set " + ComponentName.flattenToShortString(who)
+ + " as profile owner for user " + userHandle);
return false;
}
if (who == null
@@ -7676,6 +7691,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
@Override
public void setUserProvisioningState(int newState, int userHandle) {
if (!mHasFeature) {
+ logMissingFeatureAction("Cannot set provisioning state " + newState + " for user "
+ + userHandle);
return;
}
@@ -7753,6 +7770,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
@Override
public void setProfileEnabled(ComponentName who) {
if (!mHasFeature) {
+ logMissingFeatureAction("Cannot enable profile for "
+ + ComponentName.flattenToShortString(who));
return;
}
Objects.requireNonNull(who, "ComponentName is null");