Disable auto time checkbox if date/time locked down by DO.

Bug:16948504
Change-Id: I2a2b21684e17639233cd8c0dad7d3b44c4a2bd26
This commit is contained in:
Sander Alewijnse
2014-08-26 11:20:27 +01:00
parent c61aabfa22
commit fe4eff6a65

View File

@@ -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 @@ public class DateTimeSettings extends SettingsPreferenceFragment
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.