diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index ebe6c4fa0adcb..9c352dfa76cd2 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -3437,6 +3437,9 @@ public class DevicePolicyManager {
* set on the primary {@link DevicePolicyManager} must be cleared first by calling
* {@link #setRequiredPasswordComplexity} with {@link #PASSWORD_COMPLEXITY_NONE) first.
*
+ *
Note: this method is ignored on
+ * {PackageManager#FEATURE_AUTOMOTIVE automotive builds}.
+ *
* @deprecated Prefer using {@link #setRequiredPasswordComplexity(int)}, to require a password
* that satisfies a complexity level defined by the platform, rather than specifying custom
* password requirement.
@@ -3527,12 +3530,14 @@ public class DevicePolicyManager {
* {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call this method; if it has
* not, a security exception will be thrown.
*
- *
* Apps targeting {@link android.os.Build.VERSION_CODES#R} and below can call this method on the
* {@link DevicePolicyManager} instance returned by
* {@link #getParentProfileInstance(ComponentName)} in order to set restrictions on the parent
* profile.
*
+ *
Note: this method is ignored on
+ * {PackageManager#FEATURE_AUTOMOTIVE automotive builds}.
+ *
* @deprecated see {@link #setPasswordQuality(ComponentName, int)} for details.
*
* @param admin Which {@link DeviceAdminReceiver} this request is associated with.
@@ -3610,12 +3615,14 @@ public class DevicePolicyManager {
* {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call this method; if it has
* not, a security exception will be thrown.
*
- *
* Apps targeting {@link android.os.Build.VERSION_CODES#R} and below can call this method on the
* {@link DevicePolicyManager} instance returned by
* {@link #getParentProfileInstance(ComponentName)} in order to set restrictions on the parent
* profile.
*
+ *
Note: this method is ignored on
+ * {PackageManager#FEATURE_AUTOMOTIVE automotive builds}.
+ *
* @deprecated see {@link #setPasswordQuality(ComponentName, int)} for details.
*
* @param admin Which {@link DeviceAdminReceiver} this request is associated with.
@@ -3700,12 +3707,14 @@ public class DevicePolicyManager {
* {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call this method; if it has
* not, a security exception will be thrown.
*
- *
* Apps targeting {@link android.os.Build.VERSION_CODES#R} and below can call this method on the
* {@link DevicePolicyManager} instance returned by
* {@link #getParentProfileInstance(ComponentName)} in order to set restrictions on the parent
* profile.
*
+ *
Note: this method is ignored on
+ * {PackageManager#FEATURE_AUTOMOTIVE automotive builds}.
+ *
* @deprecated see {@link #setPasswordQuality(ComponentName, int)} for details.
*
* @param admin Which {@link DeviceAdminReceiver} this request is associated with.
@@ -3790,12 +3799,14 @@ public class DevicePolicyManager {
* {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call this method; if it has
* not, a security exception will be thrown.
*
- *
* Apps targeting {@link android.os.Build.VERSION_CODES#R} and below can call this method on the
* {@link DevicePolicyManager} instance returned by
* {@link #getParentProfileInstance(ComponentName)} in order to set restrictions on the parent
* profile.
*
+ *
Note: this method is ignored on
+ * {PackageManager#FEATURE_AUTOMOTIVE automotive builds}.
+ *
* @deprecated see {@link #setPasswordQuality(ComponentName, int)} for details.
*
* @param admin Which {@link DeviceAdminReceiver} this request is associated with.
@@ -3879,12 +3890,14 @@ public class DevicePolicyManager {
* {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call this method; if it has
* not, a security exception will be thrown.
*
- *
* Apps targeting {@link android.os.Build.VERSION_CODES#R} and below can call this method on the
* {@link DevicePolicyManager} instance returned by
* {@link #getParentProfileInstance(ComponentName)} in order to set restrictions on the parent
* profile.
*
+ *
Note: this method is ignored on
+ * {PackageManager#FEATURE_AUTOMOTIVE automotive builds}.
+ *
* @deprecated see {@link #setPasswordQuality(ComponentName, int)} for details.
*
* @param admin Which {@link DeviceAdminReceiver} this request is associated with.
@@ -3968,12 +3981,14 @@ public class DevicePolicyManager {
* {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call this method; if it has
* not, a security exception will be thrown.
*
- *
* Apps targeting {@link android.os.Build.VERSION_CODES#R} and below can call this method on the
* {@link DevicePolicyManager} instance returned by
* {@link #getParentProfileInstance(ComponentName)} in order to set restrictions on the parent
* profile.
*
+ *
Note: this method is ignored on
+ * {PackageManager#FEATURE_AUTOMOTIVE automotive builds}.
+ *
* @deprecated see {@link #setPasswordQuality(ComponentName, int)} for details.
*
* @param admin Which {@link DeviceAdminReceiver} this request is associated with.
@@ -4056,12 +4071,14 @@ public class DevicePolicyManager {
* {@link DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD} to be able to call this method; if it has
* not, a security exception will be thrown.
*
- *
* Apps targeting {@link android.os.Build.VERSION_CODES#R} and below can call this method on the
* {@link DevicePolicyManager} instance returned by
* {@link #getParentProfileInstance(ComponentName)} in order to set restrictions on the parent
* profile.
*
+ *
Note: this method is ignored on
+ * {PackageManager#FEATURE_AUTOMOTIVE automotive builds}.
+ *
* @deprecated see {@link #setPasswordQuality(ComponentName, int)} for details.
*
* @param admin Which {@link DeviceAdminReceiver} this request is associated with.
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 31b030c97ba9e..18073875c6488 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -3844,9 +3844,17 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
}
}
+ private boolean notSupportedOnAutomotive(String method) {
+ if (mIsAutomotive) {
+ Slogf.i(LOG_TAG, "%s is not supported on automotive builds", method);
+ return true;
+ }
+ return false;
+ }
+
@Override
public void setPasswordQuality(ComponentName who, int quality, boolean parent) {
- if (!mHasFeature) {
+ if (!mHasFeature || notSupportedOnAutomotive("setPasswordQuality")) {
return;
}
Objects.requireNonNull(who, "ComponentName is null");
@@ -4081,7 +4089,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
@Override
public void setPasswordMinimumLength(ComponentName who, int length, boolean parent) {
- if (!mHasFeature) {
+ if (!mHasFeature || notSupportedOnAutomotive("setPasswordMinimumLength")) {
return;
}
Objects.requireNonNull(who, "ComponentName is null");
@@ -4363,7 +4371,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
@Override
public void setPasswordMinimumUpperCase(ComponentName who, int length, boolean parent) {
- if (!mHasFeature) {
+ if (!mHasFeature || notSupportedOnAutomotive("setPasswordMinimumUpperCase")) {
return;
}
Objects.requireNonNull(who, "ComponentName is null");
@@ -4396,6 +4404,9 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
@Override
public void setPasswordMinimumLowerCase(ComponentName who, int length, boolean parent) {
+ if (notSupportedOnAutomotive("setPasswordMinimumLowerCase")) {
+ return;
+ }
Objects.requireNonNull(who, "ComponentName is null");
final int userId = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
@@ -4426,7 +4437,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
@Override
public void setPasswordMinimumLetters(ComponentName who, int length, boolean parent) {
- if (!mHasFeature) {
+ if (!mHasFeature || notSupportedOnAutomotive("setPasswordMinimumLetters")) {
return;
}
Objects.requireNonNull(who, "ComponentName is null");
@@ -4458,7 +4469,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
@Override
public void setPasswordMinimumNumeric(ComponentName who, int length, boolean parent) {
- if (!mHasFeature) {
+ if (!mHasFeature || notSupportedOnAutomotive("setPasswordMinimumNumeric")) {
return;
}
Objects.requireNonNull(who, "ComponentName is null");
@@ -4490,7 +4501,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
@Override
public void setPasswordMinimumSymbols(ComponentName who, int length, boolean parent) {
- if (!mHasFeature) {
+ if (!mHasFeature || notSupportedOnAutomotive("setPasswordMinimumSymbols")) {
return;
}
Objects.requireNonNull(who, "ComponentName is null");
@@ -4522,7 +4533,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
@Override
public void setPasswordMinimumNonLetter(ComponentName who, int length, boolean parent) {
- if (!mHasFeature) {
+ if (!mHasFeature || notSupportedOnAutomotive("setPasswordMinimumNonLetter")) {
return;
}
Objects.requireNonNull(who, "ComponentName is null");