diff options
author | 2015-07-11 01:08:28 -0700 | |
---|---|---|
committer | 2015-07-11 01:08:28 -0700 | |
commit | 5abefbb8d6e2a4bfe824d9c2d8904600d41f9387 (patch) | |
tree | 1c344e3a6deefc5bf4fd3fcc7a504f7b1491c5f8 /java/src/com/android/inputmethod/dictionarypack/ActionBatch.java | |
parent | 1791ce07522f938a349eedeb22223449abe6c380 (diff) | |
parent | 9cd60fe1bb67cec755c1cee6d541272e64129072 (diff) | |
download | latinime-5abefbb8d6e2a4bfe824d9c2d8904600d41f9387.tar.gz latinime-5abefbb8d6e2a4bfe824d9c2d8904600d41f9387.tar.xz latinime-5abefbb8d6e2a4bfe824d9c2d8904600d41f9387.zip |
resolved conflicts for merge of 9cd60fe1 to mnc-dev-plus-aosp
Change-Id: I1aad861d711170ab3dab0019d8e4ff02f058c423
Diffstat (limited to 'java/src/com/android/inputmethod/dictionarypack/ActionBatch.java')
-rw-r--r-- | java/src/com/android/inputmethod/dictionarypack/ActionBatch.java | 45 |
1 files changed, 14 insertions, 31 deletions
diff --git a/java/src/com/android/inputmethod/dictionarypack/ActionBatch.java b/java/src/com/android/inputmethod/dictionarypack/ActionBatch.java index 09f8032cc..1b526d453 100644 --- a/java/src/com/android/inputmethod/dictionarypack/ActionBatch.java +++ b/java/src/com/android/inputmethod/dictionarypack/ActionBatch.java @@ -25,8 +25,9 @@ import android.net.Uri; import android.text.TextUtils; import android.util.Log; -import com.android.inputmethod.compat.DownloadManagerCompatUtils; +import com.android.inputmethod.latin.BinaryDictionaryFileDumper; import com.android.inputmethod.latin.R; +import com.android.inputmethod.latin.common.LocaleUtils; import com.android.inputmethod.latin.utils.ApplicationUtils; import com.android.inputmethod.latin.utils.DebugLogUtils; @@ -84,7 +85,7 @@ public final class ActionBatch { * Execute this action NOW. * @param context the context to get system services, resources, databases */ - public void execute(final Context context); + void execute(final Context context); } /** @@ -96,13 +97,10 @@ public final class ActionBatch { private final String mClientId; // The data to download. May not be null. final WordListMetadata mWordList; - final boolean mForceStartNow; - public StartDownloadAction(final String clientId, - final WordListMetadata wordList, final boolean forceStartNow) { + public StartDownloadAction(final String clientId, final WordListMetadata wordList) { DebugLogUtils.l("New download action for client ", clientId, " : ", wordList); mClientId = clientId; mWordList = wordList; - mForceStartNow = forceStartNow; } @Override @@ -141,32 +139,9 @@ public final class ActionBatch { final Request request = new Request(uri); final Resources res = context.getResources(); - if (!mForceStartNow) { - if (DownloadManagerCompatUtils.hasSetAllowedOverMetered()) { - final boolean allowOverMetered; - switch (UpdateHandler.getDownloadOverMeteredSetting(context)) { - case UpdateHandler.DOWNLOAD_OVER_METERED_DISALLOWED: - // User said no: don't allow. - allowOverMetered = false; - break; - case UpdateHandler.DOWNLOAD_OVER_METERED_ALLOWED: - // User said yes: allow. - allowOverMetered = true; - break; - default: // UpdateHandler.DOWNLOAD_OVER_METERED_SETTING_UNKNOWN - // Don't know: use the default value from configuration. - allowOverMetered = res.getBoolean(R.bool.allow_over_metered); - } - DownloadManagerCompatUtils.setAllowedOverMetered(request, allowOverMetered); - } else { - request.setAllowedNetworkTypes(Request.NETWORK_WIFI); - } - request.setAllowedOverRoaming(res.getBoolean(R.bool.allow_over_roaming)); - } // if mForceStartNow, then allow all network types and roaming, which is the default. + request.setAllowedNetworkTypes(Request.NETWORK_WIFI | Request.NETWORK_MOBILE); request.setTitle(mWordList.mDescription); - request.setNotificationVisibility( - res.getBoolean(R.bool.display_notification_for_auto_update) - ? Request.VISIBILITY_VISIBLE : Request.VISIBILITY_HIDDEN); + request.setNotificationVisibility(Request.VISIBILITY_HIDDEN); request.setVisibleInDownloadsUi( res.getBoolean(R.bool.dict_downloads_visible_in_download_UI)); @@ -210,9 +185,17 @@ public final class ActionBatch { + " for an InstallAfterDownload action. Bailing out."); return; } + DebugLogUtils.l("Setting word list as installed"); final SQLiteDatabase db = MetadataDbHelper.getDb(context, mClientId); MetadataDbHelper.markEntryAsFinishedDownloadingAndInstalled(db, mWordListValues); + + // Install the downloaded file by un-compressing and moving it to the staging + // directory. Ideally, we should do this before updating the DB, but the + // installDictToStagingFromContentProvider() relies on the db being updated. + final String localeString = mWordListValues.getAsString(MetadataDbHelper.LOCALE_COLUMN); + BinaryDictionaryFileDumper.installDictToStagingFromContentProvider( + LocaleUtils.constructLocaleFromString(localeString), context, false); } } |