Simplify ImeSwitcherFactory

Now we can assume that subtype mechanism is always available.  We do not need to change the behvior at runtime anymore.  No behavior change is intended in the supported platforms.

BUG=none
TEST=compile

git-svn-id: https://mozc.googlecode.com/svn/trunk@406 a6090854-d499-a067-5803-1114d4e51264
diff --git a/src/android/src/com/google/android/inputmethod/japanese/util/ImeSwitcherFactory.java b/src/android/src/com/google/android/inputmethod/japanese/util/ImeSwitcherFactory.java
index ed5f000..2e924b2 100644
--- a/src/android/src/com/google/android/inputmethod/japanese/util/ImeSwitcherFactory.java
+++ b/src/android/src/com/google/android/inputmethod/japanese/util/ImeSwitcherFactory.java
@@ -31,6 +31,8 @@
 
 import org.mozc.android.inputmethod.japanese.MozcLog;
 import org.mozc.android.inputmethod.japanese.MozcUtil;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
 
 import android.annotation.TargetApi;
 import android.inputmethodservice.InputMethodService;
@@ -60,11 +62,6 @@
  */
 public class ImeSwitcherFactory {
 
-  // Subtype is available since API Level 11
-  // but InputMethodSubtype#isAuxiliary is since API Level 14.
-  // isAuxiliary is important for aux IME (e.g. voice IME) and such devices of which API Level is
-  // 11, 12 or 13 are not so many. Thus we limit this feature since 14.
-  static final int SUBTYPE_TARGTET_API_LEVEL = 14;
   static final int SWITCH_NEXT_TARGTET_API_LEVEL = 16;
 
   private static final String GOOGLE_PACKAGE_ID_PREFIX = "com.google.android";
@@ -73,7 +70,6 @@
   /**
    * A container of an InputMethodInfo and an InputMethodSubtype.
    */
-  @TargetApi(SUBTYPE_TARGTET_API_LEVEL)
   private static class InputMethodSubtypeInfo {
 
     private final InputMethodInfo inputMethodInfo;
@@ -99,8 +95,6 @@
 
   /**
    * A class to switch default (==current) input method subtype.
-   *
-   * This class handles only subtype and its newer API so works only since API Level 14.
    */
   public interface ImeSwitcher {
 
@@ -142,36 +136,9 @@
   }
 
   /**
-   * A switcher for lower API Level where IME switching is not available.
-   */
-  static class StubImeSwitcher implements ImeSwitcher {
-    public StubImeSwitcher(InputMethodService inputMethodService) {
-      if (inputMethodService == null) {
-        throw new NullPointerException("inputMethodService must be non-null.");
-      }
-    }
-
-    @Override
-    public boolean isVoiceImeAvailable() {
-      return false;
-    }
-
-    @Override
-    public boolean switchToVoiceIme(String locale) {
-      return false;
-    }
-
-    @Override
-    public boolean switchToNextInputMethod(boolean onlyCurrentIme) {
-      return false;
-    }
-  }
-
-  /**
    * A switcher for later OS where IME subtype is available.
    */
-  @TargetApi(SUBTYPE_TARGTET_API_LEVEL)
-  static class SubtypeImeSwitcher extends StubImeSwitcher {
+  static class SubtypeImeSwitcher implements ImeSwitcher {
 
     interface InputMethodManagerProxy {
       Map<InputMethodInfo, List<InputMethodSubtype>> getShortcutInputMethodsAndSubtypes();
@@ -196,10 +163,9 @@
       });
     }
 
-    // For testing
+    @VisibleForTesting
     SubtypeImeSwitcher(InputMethodService inputMethodService,
                        InputMethodManagerProxy inputMethodManagerProxy) {
-      super(inputMethodService);
       this.inputMethodService = inputMethodService;
       this.inputMethodManagerProxy = inputMethodManagerProxy;
     }
@@ -251,6 +217,11 @@
           inputMethod.getSubtype());
       return true;
     }
+
+    @Override
+    public boolean switchToNextInputMethod(boolean onlyCurrentIme) {
+      return false;
+    }
   }
 
   /**
@@ -259,7 +230,7 @@
   @TargetApi(SWITCH_NEXT_TARGTET_API_LEVEL)
   static class NextInputSwitchableImeSwitcher extends SubtypeImeSwitcher {
 
-    public NextInputSwitchableImeSwitcher(final InputMethodService inputMethodService) {
+    public NextInputSwitchableImeSwitcher(InputMethodService inputMethodService) {
       super(inputMethodService);
     }
 
@@ -278,10 +249,8 @@
     Class<? extends ImeSwitcher> clazz;
     if (Build.VERSION.SDK_INT >= SWITCH_NEXT_TARGTET_API_LEVEL) {
       clazz = NextInputSwitchableImeSwitcher.class;
-    } else if (Build.VERSION.SDK_INT >= SUBTYPE_TARGTET_API_LEVEL) {
-      clazz = SubtypeImeSwitcher.class;
     } else {
-      clazz = StubImeSwitcher.class;
+      clazz = SubtypeImeSwitcher.class;
     }
     Constructor<? extends ImeSwitcher> constructor = null;
     try {
@@ -294,15 +263,9 @@
 
   /**
    * Gets an {@link ImeSwitcher}.
-   *
-   * ImeSwitcher handles only subtype and its newer API so concrete factory will be returned
-   * only since API Level 14.
-   * On older OS *stub* factory will be returned.
    */
   public static ImeSwitcher getImeSwitcher(InputMethodService inputMethodService) {
-    if (inputMethodService == null) {
-      throw new NullPointerException("inputMethodService must be non-null.");
-    }
+    Preconditions.checkNotNull(inputMethodService);
     if (switcherConstructor != null) {
       try {
         return switcherConstructor.newInstance(inputMethodService);
@@ -316,6 +279,6 @@
         MozcLog.e(e.getMessage(), e);
       }
     }
-    return new StubImeSwitcher(inputMethodService);
+    return new SubtypeImeSwitcher(inputMethodService);
   }
 }
diff --git a/src/android/tests/src/com/google/android/inputmethod/japanese/util/ImeSwitcherFactoryTest.java b/src/android/tests/src/com/google/android/inputmethod/japanese/util/ImeSwitcherFactoryTest.java
index dde6802..bbb2504 100644
--- a/src/android/tests/src/com/google/android/inputmethod/japanese/util/ImeSwitcherFactoryTest.java
+++ b/src/android/tests/src/com/google/android/inputmethod/japanese/util/ImeSwitcherFactoryTest.java
@@ -34,7 +34,6 @@
 import static org.easymock.EasyMock.isA;
 import static org.easymock.EasyMock.same;
 
-import org.mozc.android.inputmethod.japanese.testing.ApiLevel;
 import org.mozc.android.inputmethod.japanese.testing.InstrumentationTestCaseWithMock;
 import org.mozc.android.inputmethod.japanese.testing.Parameter;
 import org.mozc.android.inputmethod.japanese.util.ImeSwitcherFactory.ImeSwitcher;
@@ -60,7 +59,6 @@
 public class ImeSwitcherFactoryTest extends InstrumentationTestCaseWithMock {
 
   @SmallTest
-  @ApiLevel(ImeSwitcherFactory.SUBTYPE_TARGTET_API_LEVEL)
   public void testIsVoiceImeAvailable() {
     class TestData extends Parameter {
       final Map<InputMethodInfo, List<InputMethodSubtype>> availableImes;
@@ -91,16 +89,22 @@
         new ComponentName(googleIme2.getPackageName(), googleIme2.getServiceName())
             .flattenToShortString();
 
+    @SuppressWarnings("deprecation")
     InputMethodSubtype jaKeyboardAux =
         new InputMethodSubtype(0, 0, "ja", "keyboard", "", true, false);
+    @SuppressWarnings("deprecation")
     InputMethodSubtype jaVoiceNonaux =
         new InputMethodSubtype(0, 0, "ja", "voice", "", false, false);
+    @SuppressWarnings("deprecation")
     InputMethodSubtype jaVoiceAux =
         new InputMethodSubtype(0, 0, "ja", "voice", "", true, false);
+    @SuppressWarnings("deprecation")
     InputMethodSubtype enKeyboardAux =
         new InputMethodSubtype(0, 0, "en", "keyboard", "", true, false);
+    @SuppressWarnings("deprecation")
     InputMethodSubtype enVoiceNonaux =
         new InputMethodSubtype(0, 0, "en", "voice", "", false, false);
+    @SuppressWarnings("deprecation")
     InputMethodSubtype enVoiceAux =
         new InputMethodSubtype(0, 0, "en", "voice", "", true, false);
 
@@ -159,9 +163,4 @@
       verifyAll();
     }
   }
-
-  @SmallTest
-  public void testSmokeTest() {
-    ImeSwitcherFactory.getImeSwitcher(new InputMethodService());
-  }
 }
diff --git a/src/mozc_version_template.txt b/src/mozc_version_template.txt
index a0ae0b3..765932d 100644
--- a/src/mozc_version_template.txt
+++ b/src/mozc_version_template.txt
@@ -1,6 +1,6 @@
 MAJOR=2
 MINOR=16
-BUILD=1946
+BUILD=1947
 REVISION=102
 # NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
 # downloaded by NaCl Mozc.