Restore enterprise policy checks

Restore enterprise policy checks removed by commit
fdab44f9e71f78a0c2809c03a8dd654c7dd3dd70 and not since restored by other
changes.

Bug: 325886855
Bug: 316584466
Bug: 235445309
Test: Treehugger only
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:5d80553a155524e73713348fc11b9f98bee0308b)
Merged-In: Id3d79805bb2289b84ad34ac05a97e50f0410502f
Change-Id: Id3d79805bb2289b84ad34ac05a97e50f0410502f
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());
     }