aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java
diff options
context:
space:
mode:
authorMohammadinamul Sheik <inamul@google.com>2015-03-24 14:56:54 -0700
committerMohammadinamul Sheik <inamul@google.com>2015-03-24 14:56:54 -0700
commit3bc3bc7971f15438732933cfac0db6e766e6a3e9 (patch)
tree0bdd6a1041bcd982424626bc0ff6018de1c09dc8 /java/src/com/android/inputmethod/dictionarypack/DictionaryService.java
parente1b91d4138b4f5b7e83d09d506e0be4a6b78467b (diff)
downloadlatinime-3bc3bc7971f15438732933cfac0db6e766e6a3e9.tar.gz
latinime-3bc3bc7971f15438732933cfac0db6e766e6a3e9.tar.xz
latinime-3bc3bc7971f15438732933cfac0db6e766e6a3e9.zip
Force download the dictionaries after the apk package is updated.
- Also display the notification when the dictionaries are auto updated Bug: 19808828 Change-Id: If5c4efb73d8bb554d812afcf7deafec3ac40a462
Diffstat (limited to 'java/src/com/android/inputmethod/dictionarypack/DictionaryService.java')
-rw-r--r--java/src/com/android/inputmethod/dictionarypack/DictionaryService.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java b/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java
index c678f081d..bbdf2a380 100644
--- a/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java
+++ b/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java
@@ -25,6 +25,7 @@ import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;
+import com.android.inputmethod.latin.BinaryDictionaryFileDumper;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.common.LocaleUtils;
@@ -192,13 +193,26 @@ public final class DictionaryService extends Service {
static void dispatchBroadcast(final Context context, final Intent intent) {
if (DATE_CHANGED_INTENT_ACTION.equals(intent.getAction())) {
+ // Do not force download dictionaries on date change updates.
+ CommonPreferences.setForceDownloadDict(context, false);
// This happens when the date of the device changes. This normally happens
// at midnight local time, but it may happen if the user changes the date
// by hand or something similar happens.
checkTimeAndMaybeSetupUpdateAlarm(context);
} else if (DictionaryPackConstants.UPDATE_NOW_INTENT_ACTION.equals(intent.getAction())) {
// Intent to trigger an update now.
- UpdateHandler.tryUpdate(context, false);
+ UpdateHandler.tryUpdate(context, CommonPreferences.isForceDownloadDict(context));
+ } else if (DictionaryPackConstants.INIT_AND_UPDATE_NOW_INTENT_ACTION.equals(
+ intent.getAction())) {
+ // Enable force download of dictionaries irrespective of wifi or metered connection.
+ CommonPreferences.setForceDownloadDict(context, true);
+
+ // Initialize the client Db.
+ final String mClientId = context.getString(R.string.dictionary_pack_client_id);
+ BinaryDictionaryFileDumper.initializeClientRecordHelper(context, mClientId);
+
+ // Updates the metadata and the download the dictionaries.
+ UpdateHandler.tryUpdate(context, true);
} else {
UpdateHandler.downloadFinished(context, intent);
}
@@ -249,7 +263,7 @@ public final class DictionaryService extends Service {
*/
public static void updateNowIfNotUpdatedInAVeryLongTime(final Context context) {
if (!isLastUpdateAtLeastThisOld(context, VERY_LONG_TIME_MILLIS)) return;
- UpdateHandler.tryUpdate(context, false);
+ UpdateHandler.tryUpdate(context, CommonPreferences.isForceDownloadDict(context));
}
/**