Watch for changing enabled IMEs

This CL watches a change to Settings.Secure.ENABLED_INPUT_METHODS and
updates search index of IMEs.

Bug: 32643633
Test: After installing AOSP LatinIME.apk, enabling/disabling the IME
      and searching "AOSP", then verify the search landing page is
      correct depending on the IME's enabling state.
Test: Update robolectric test.

Change-Id: I85fa845238b89375e56b207a014af6432f9db647
This commit is contained in:
Tadashi G. Takaoka
2017-01-10 18:28:10 +09:00
parent e776821a8d
commit fd7b98c5ca
2 changed files with 28 additions and 3 deletions

View File

@@ -49,6 +49,7 @@ import android.os.Bundle;
import android.print.PrintManager;
import android.print.PrintServicesLoader;
import android.printservice.PrintServiceInfo;
import android.provider.Settings;
import android.provider.UserDictionary;
import android.view.inputmethod.InputMethodInfo;
@@ -340,6 +341,12 @@ public class DynamicIndexableContentMonitorTest {
verifyRebuildIndexing(VirtualKeyboardFragment.class);
verifyRebuildIndexing(AvailableVirtualKeyboardFragment.class);
final Uri enabledInputMethodsContentUri = Settings.Secure.getUriFor(
Settings.Secure.ENABLED_INPUT_METHODS);
// Content observer should be registered.
final ContentObserver observer = extractContentObserver(enabledInputMethodsContentUri);
assertThat(observer).isNotNull();
/*
* When an input method service package is installed, incremental indexing happen.
*/
@@ -411,6 +418,16 @@ public class DynamicIndexableContentMonitorTest {
verifyNoIndexing(VirtualKeyboardFragment.class);
verifyNoIndexing(AvailableVirtualKeyboardFragment.class);
/*
* When enabled IMEs list is changed, rebuild indexing happens.
*/
reset(mIndex);
observer.onChange(false /* selfChange */, enabledInputMethodsContentUri);
verifyRebuildIndexing(VirtualKeyboardFragment.class);
verifyRebuildIndexing(AvailableVirtualKeyboardFragment.class);
}
@Test