Merge "Disable auto time checkbox if date/time locked down by DO." into lmp-dev
diff --git a/src/com/android/settings/DateTimeSettings.java b/src/com/android/settings/DateTimeSettings.java
index 77561bd..8eb9c52 100644
--- a/src/com/android/settings/DateTimeSettings.java
+++ b/src/com/android/settings/DateTimeSettings.java
@@ -16,6 +16,7 @@
package com.android.settings;
+import android.app.admin.DevicePolicyManager;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.DatePickerDialog;
@@ -89,12 +90,23 @@
boolean autoTimeEnabled = getAutoState(Settings.Global.AUTO_TIME);
boolean autoTimeZoneEnabled = getAutoState(Settings.Global.AUTO_TIME_ZONE);
+ mAutoTimePref = (CheckBoxPreference) findPreference(KEY_AUTO_TIME);
+
+ DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(Context
+ .DEVICE_POLICY_SERVICE);
+ if (dpm.getAutoTimeRequired()) {
+ mAutoTimePref.setEnabled(false);
+
+ // If Settings.Global.AUTO_TIME is false it will be set to true
+ // by the device policy manager very soon.
+ // Note that this app listens to that change.
+ }
+
Intent intent = getActivity().getIntent();
boolean isFirstRun = intent.getBooleanExtra(EXTRA_IS_FIRST_RUN, false);
mDummyDate = Calendar.getInstance();
- mAutoTimePref = (CheckBoxPreference) findPreference(KEY_AUTO_TIME);
mAutoTimePref.setChecked(autoTimeEnabled);
mAutoTimeZonePref = (CheckBoxPreference) findPreference(KEY_AUTO_TIME_ZONE);
// Override auto-timezone if it's a wifi-only device or if we're still in setup wizard.