Add minimum date

Change-Id: I928c99b7b2eb3dc35b2e25034dfe32a784355239
Fixes: 26346842
This commit is contained in:
Jason Monk
2016-04-20 15:44:21 -04:00
parent 0e048a11c7
commit 78f7b416c0

View File

@@ -27,8 +27,6 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
@@ -68,6 +66,9 @@ public class DateTimeSettings extends SettingsPreferenceFragment
// have we been launched from the setup wizard?
protected static final String EXTRA_IS_FIRST_RUN = "firstRun";
// Minimum time is Nov 5, 2007, 0:00.
private static final long MIN_DATE = 1194220800000L;
private RestrictedSwitchPreference mAutoTimePref;
private Preference mTimePref;
private Preference mTime24Pref;
@@ -320,7 +321,7 @@ public class DateTimeSettings extends SettingsPreferenceFragment
c.set(Calendar.YEAR, year);
c.set(Calendar.MONTH, month);
c.set(Calendar.DAY_OF_MONTH, day);
long when = c.getTimeInMillis();
long when = Math.max(c.getTimeInMillis(), MIN_DATE);
if (when / 1000 < Integer.MAX_VALUE) {
((AlarmManager) context.getSystemService(Context.ALARM_SERVICE)).setTime(when);
@@ -334,7 +335,7 @@ public class DateTimeSettings extends SettingsPreferenceFragment
c.set(Calendar.MINUTE, minute);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
long when = c.getTimeInMillis();
long when = Math.max(c.getTimeInMillis(), MIN_DATE);
if (when / 1000 < Integer.MAX_VALUE) {
((AlarmManager) context.getSystemService(Context.ALARM_SERVICE)).setTime(when);