diff options
Diffstat (limited to 'java/src/com/android/inputmethod/dictionarypack/DictionaryService.java')
-rw-r--r-- | java/src/com/android/inputmethod/dictionarypack/DictionaryService.java | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java b/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java index 6e3dd7109..767f895dc 100644 --- a/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java +++ b/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java @@ -22,7 +22,6 @@ import android.app.Service; import android.content.Context; import android.content.Intent; import android.os.IBinder; -import android.text.format.DateUtils; import android.util.Log; import android.widget.Toast; @@ -30,6 +29,7 @@ import com.android.inputmethod.latin.R; import java.util.Locale; import java.util.Random; +import java.util.concurrent.TimeUnit; /** * Service that handles background tasks for the dictionary provider. @@ -77,19 +77,19 @@ public final class DictionaryService extends Service { * How often, in milliseconds, we want to update the metadata. This is a * floor value; actually, it may happen several hours later, or even more. */ - private static final long UPDATE_FREQUENCY = 4 * DateUtils.DAY_IN_MILLIS; + private static final long UPDATE_FREQUENCY = TimeUnit.DAYS.toMillis(4); /** * We are waked around midnight, local time. We want to wake between midnight and 6 am, * roughly. So use a random time between 0 and this delay. */ - private static final int MAX_ALARM_DELAY = 6 * ((int)AlarmManager.INTERVAL_HOUR); + private static final int MAX_ALARM_DELAY = (int)TimeUnit.HOURS.toMillis(6); /** * How long we consider a "very long time". If no update took place in this time, * the content provider will trigger an update in the background. */ - private static final long VERY_LONG_TIME = 14 * DateUtils.DAY_IN_MILLIS; + private static final long VERY_LONG_TIME = TimeUnit.DAYS.toMillis(14); /** * The last seen start Id. This must be stored because we must only call stopSelfResult() with @@ -170,7 +170,7 @@ public final class DictionaryService extends Service { checkTimeAndMaybeSetupUpdateAlarm(context); } else if (DictionaryPackConstants.UPDATE_NOW_INTENT_ACTION.equals(intent.getAction())) { // Intent to trigger an update now. - UpdateHandler.update(context, false); + UpdateHandler.tryUpdate(context, false); } else { UpdateHandler.downloadFinished(context, intent); } @@ -221,7 +221,7 @@ public final class DictionaryService extends Service { */ public static void updateNowIfNotUpdatedInAVeryLongTime(final Context context) { if (!isLastUpdateAtLeastThisOld(context, VERY_LONG_TIME)) return; - UpdateHandler.update(context, false); + UpdateHandler.tryUpdate(context, false); } /** |