From 710d06cea91a8e6bf04a27f0bcd88d76a5cc5acd Mon Sep 17 00:00:00 2001
From: Ken Wakasa <kwakasa@google.com>
Date: Fri, 9 Nov 2012 12:59:06 +0900
Subject: [PATCH] Suppress dictionary pack support when IS_EXPERIMENTAL is true

Change-Id: If8813cb989c1fa8744a3bf36e8514ced3c8f46a3
---
 .../latin/BinaryDictionaryGetter.java         |  8 +++--
 .../android/inputmethod/latin/LatinIME.java   | 30 ++++++++++++-------
 .../android/inputmethod/latin/Settings.java   |  3 +-
 3 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
index ecb61b46f1..83dabbede4 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
@@ -16,6 +16,7 @@
 
 package com.android.inputmethod.latin;
 
+import com.android.inputmethod.latin.define.ProductionFlag;
 import com.android.inputmethod.latin.makedict.BinaryDictInputOutput;
 import com.android.inputmethod.latin.makedict.FormatSpec;
 
@@ -422,8 +423,11 @@ final class BinaryDictionaryGetter {
         // cacheWordListsFromContentProvider returns the list of files it copied to local
         // storage, but we don't really care about what was copied NOW: what we want is the
         // list of everything we ever cached, so we ignore the return value.
-        BinaryDictionaryFileDumper.cacheWordListsFromContentProvider(locale, context,
-                hasDefaultWordList);
+        // TODO: The experimental version is not supported by the Dictionary Pack Service yet
+        if (!ProductionFlag.IS_EXPERIMENTAL) {
+            BinaryDictionaryFileDumper.cacheWordListsFromContentProvider(locale, context,
+                    hasDefaultWordList);
+        }
         final File[] cachedWordLists = getCachedWordLists(locale.toString(), context);
         final String mainDictId = getMainDictId(locale);
         final DictPackSettings dictPackSettings = new DictPackSettings(context);
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 5f87c8c910..fa93357a4b 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -168,8 +168,10 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
     private int mDisplayOrientation;
 
     // Object for reacting to adding/removing a dictionary pack.
+    // TODO: The experimental version is not supported by the Dictionary Pack Service yet.
     private BroadcastReceiver mDictionaryPackInstallReceiver =
-            new DictionaryPackInstallBroadcastReceiver(this);
+            ProductionFlag.IS_EXPERIMENTAL
+                    ? null : new DictionaryPackInstallBroadcastReceiver(this);
 
     // Keeps track of most recently inserted text (multi-character key) for reverting
     private String mEnteredText;
@@ -410,16 +412,19 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
         filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
         registerReceiver(mReceiver, filter);
 
-        final IntentFilter packageFilter = new IntentFilter();
-        packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
-        packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
-        packageFilter.addDataScheme(SCHEME_PACKAGE);
-        registerReceiver(mDictionaryPackInstallReceiver, packageFilter);
+        // TODO: The experimental version is not supported by the Dictionary Pack Service yet.
+        if (!ProductionFlag.IS_EXPERIMENTAL) {
+            final IntentFilter packageFilter = new IntentFilter();
+            packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
+            packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
+            packageFilter.addDataScheme(SCHEME_PACKAGE);
+            registerReceiver(mDictionaryPackInstallReceiver, packageFilter);
 
-        final IntentFilter newDictFilter = new IntentFilter();
-        newDictFilter.addAction(
-                DictionaryPackInstallBroadcastReceiver.NEW_DICTIONARY_INTENT_ACTION);
-        registerReceiver(mDictionaryPackInstallReceiver, newDictFilter);
+            final IntentFilter newDictFilter = new IntentFilter();
+            newDictFilter.addAction(
+                    DictionaryPackInstallBroadcastReceiver.NEW_DICTIONARY_INTENT_ACTION);
+            registerReceiver(mDictionaryPackInstallReceiver, newDictFilter);
+        }
     }
 
     // Has to be package-visible for unit tests
@@ -539,7 +544,10 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
             mSuggest = null;
         }
         unregisterReceiver(mReceiver);
-        unregisterReceiver(mDictionaryPackInstallReceiver);
+        // TODO: The experimental version is not supported by the Dictionary Pack Service yet.
+        if (!ProductionFlag.IS_EXPERIMENTAL) {
+            unregisterReceiver(mDictionaryPackInstallReceiver);
+        }
         LatinImeLogger.commit();
         LatinImeLogger.onDestroy();
         super.onDestroy();
diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java
index 348928df87..fdad5430a3 100644
--- a/java/src/com/android/inputmethod/latin/Settings.java
+++ b/java/src/com/android/inputmethod/latin/Settings.java
@@ -203,7 +203,8 @@ public final class Settings extends InputMethodSettingsFragment
         final Intent intent = dictionaryLink.getIntent();
 
         final int number = context.getPackageManager().queryIntentActivities(intent, 0).size();
-        if (0 >= number) {
+        // TODO: The experimental version is not supported by the Dictionary Pack Service yet
+        if (ProductionFlag.IS_EXPERIMENTAL || 0 >= number) {
             textCorrectionGroup.removePreference(dictionaryLink);
         }
 
-- 
GitLab