Merge cherrypicks of ['googleplex-android-review.googlesource.com/26908656'] into 24Q2-release.

Change-Id: I1d252cb9fd8b85080f5d06552f1787609fa15923
diff --git a/src/com/android/settings/datetime/DatePreferenceController.java b/src/com/android/settings/datetime/DatePreferenceController.java
index 02aba6e..f9e3b8f 100644
--- a/src/com/android/settings/datetime/DatePreferenceController.java
+++ b/src/com/android/settings/datetime/DatePreferenceController.java
@@ -34,6 +34,7 @@
 import androidx.preference.Preference;
 
 import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.RestrictedPreference;
 
 import java.util.Calendar;
 
@@ -68,6 +69,11 @@
     @Override
     public void updateState(Preference preference) {
         super.updateState(preference);
+
+        if (preference instanceof RestrictedPreference
+                && ((RestrictedPreference) preference).isDisabledByAdmin()) {
+            return;
+        }
         preference.setEnabled(isEnabled());
     }
 
diff --git a/src/com/android/settings/datetime/TimePreferenceController.java b/src/com/android/settings/datetime/TimePreferenceController.java
index 1923d55..f0a69ea 100644
--- a/src/com/android/settings/datetime/TimePreferenceController.java
+++ b/src/com/android/settings/datetime/TimePreferenceController.java
@@ -32,6 +32,7 @@
 import androidx.preference.Preference;
 
 import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.RestrictedPreference;
 
 import java.util.Calendar;
 
@@ -66,6 +67,11 @@
     @Override
     public void updateState(Preference preference) {
         super.updateState(preference);
+
+        if (preference instanceof RestrictedPreference
+                && ((RestrictedPreference) preference).isDisabledByAdmin()) {
+            return;
+        }
         preference.setEnabled(isEnabled());
     }