Add dictionary dump buttons in debug settings.
Bug: 11736680 Bug: 12810574 Change-Id: I1f797b5ac6acf94b40d9698d4535e8f5da2bfb17main
parent
99b7242f78
commit
36c7a62dff
|
@ -498,6 +498,14 @@ mobile devices. [CHAR LIMIT=25] -->
|
||||||
<string name="read_external_dictionary_confirm_install_message">Really install this file for <xliff:g id="locale_name">%s</xliff:g>?</string>
|
<string name="read_external_dictionary_confirm_install_message">Really install this file for <xliff:g id="locale_name">%s</xliff:g>?</string>
|
||||||
<!-- Title for an error dialog that contains the details of the error in the body [CHAR LIMIT=80] -->
|
<!-- Title for an error dialog that contains the details of the error in the body [CHAR LIMIT=80] -->
|
||||||
<string name="error">There was an error</string>
|
<string name="error">There was an error</string>
|
||||||
|
<!-- Title of the settings for dumpping contacts dictionary file [CHAR LIMIT=35] -->
|
||||||
|
<string name="prefs_dump_contacts_dict">Dump contacts dictionary</string>
|
||||||
|
<!-- Title of the settings for dumpping personal dictionary file [CHAR LIMIT=35] -->
|
||||||
|
<string name="prefs_dump_user_dict">Dump personal dictionary</string>
|
||||||
|
<!-- Title of the settings for dumpping user history dictionary file [CHAR LIMIT=35] -->
|
||||||
|
<string name="prefs_dump_user_history_dict">Dump user history dictionary</string>
|
||||||
|
<!-- Title of the settings for dumpping personalization dictionary file [CHAR LIMIT=35] -->
|
||||||
|
<string name="prefs_dump_personalization_dict">Dump personalization dictionary</string>
|
||||||
|
|
||||||
<!-- Title of the button to revert to the default value of the device in the settings dialog [CHAR LIMIT=15] -->
|
<!-- Title of the button to revert to the default value of the device in the settings dialog [CHAR LIMIT=15] -->
|
||||||
<string name="button_default">Default</string>
|
<string name="button_default">Default</string>
|
||||||
|
|
|
@ -61,4 +61,21 @@
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:key="read_external_dictionary"
|
android:key="read_external_dictionary"
|
||||||
android:title="@string/prefs_read_external_dictionary" />
|
android:title="@string/prefs_read_external_dictionary" />
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:key="dump_contacts_dict"
|
||||||
|
android:title="@string/prefs_dump_contacts_dict" />
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:key="dump_user_dict"
|
||||||
|
android:title="@string/prefs_dump_user_dict" />
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:key="dump_user_history_dict"
|
||||||
|
android:title="@string/prefs_dump_user_history_dict" />
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:key="dump_personalization_dict"
|
||||||
|
android:title="@string/prefs_dump_personalization_dict" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.inputmethod.latin;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
public class DictionaryDumpBroadcastReceiver extends BroadcastReceiver {
|
||||||
|
private static final String TAG = DictionaryDumpBroadcastReceiver.class.getSimpleName();
|
||||||
|
|
||||||
|
private static final String DOMAIN = "com.android.inputmethod.latin";
|
||||||
|
public static final String DICTIONARY_DUMP_INTENT_ACTION = DOMAIN + ".DICT_DUMP";
|
||||||
|
public static final String DICTIONARY_NAME_KEY = "dictName";
|
||||||
|
|
||||||
|
final LatinIME mLatinIme;
|
||||||
|
|
||||||
|
public DictionaryDumpBroadcastReceiver(final LatinIME latinIme) {
|
||||||
|
mLatinIme = latinIme;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
final String action = intent.getAction();
|
||||||
|
if (action.equals(DICTIONARY_DUMP_INTENT_ACTION)) {
|
||||||
|
final String dictName = intent.getStringExtra(DICTIONARY_NAME_KEY);
|
||||||
|
if (dictName == null) {
|
||||||
|
Log.e(TAG, "Received dictionary dump intent action " +
|
||||||
|
"but the dictionary name is not set.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mLatinIme.dumpDictionaryForDebug(dictName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -534,4 +534,25 @@ public class DictionaryFacilitatorForSuggest {
|
||||||
mPersonalizationDictionary.addMultipleDictionaryEntriesToDictionary(languageModelParams,
|
mPersonalizationDictionary.addMultipleDictionaryEntriesToDictionary(languageModelParams,
|
||||||
callback);
|
callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void dumpDictionaryForDebug(final String dictName) {
|
||||||
|
final ExpandableBinaryDictionary dictToDump;
|
||||||
|
if (dictName.equals(Dictionary.TYPE_CONTACTS)) {
|
||||||
|
dictToDump = mContactsDictionary;
|
||||||
|
} else if (dictName.equals(Dictionary.TYPE_USER)) {
|
||||||
|
dictToDump = mUserDictionary;
|
||||||
|
} else if (dictName.equals(Dictionary.TYPE_USER_HISTORY)) {
|
||||||
|
dictToDump = mUserHistoryDictionary;
|
||||||
|
} else if (dictName.equals(Dictionary.TYPE_PERSONALIZATION)) {
|
||||||
|
dictToDump = mPersonalizationDictionary;
|
||||||
|
} else {
|
||||||
|
dictToDump = null;
|
||||||
|
}
|
||||||
|
if (dictToDump == null) {
|
||||||
|
Log.e(TAG, "Cannot dump " + dictName + ". "
|
||||||
|
+ "The dictionary is not being used for suggestion or cannot be dumped.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dictToDump.dumpAllWordsForDebug();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,6 +133,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
private BroadcastReceiver mDictionaryPackInstallReceiver =
|
private BroadcastReceiver mDictionaryPackInstallReceiver =
|
||||||
new DictionaryPackInstallBroadcastReceiver(this);
|
new DictionaryPackInstallBroadcastReceiver(this);
|
||||||
|
|
||||||
|
private BroadcastReceiver mDictionaryDumpBroadcastReceiver =
|
||||||
|
new DictionaryDumpBroadcastReceiver(this);
|
||||||
|
|
||||||
private AlertDialog mOptionsDialog;
|
private AlertDialog mOptionsDialog;
|
||||||
|
|
||||||
private final boolean mIsHardwareAcceleratedDrawingEnabled;
|
private final boolean mIsHardwareAcceleratedDrawingEnabled;
|
||||||
|
@ -487,6 +490,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
newDictFilter.addAction(DictionaryPackConstants.NEW_DICTIONARY_INTENT_ACTION);
|
newDictFilter.addAction(DictionaryPackConstants.NEW_DICTIONARY_INTENT_ACTION);
|
||||||
registerReceiver(mDictionaryPackInstallReceiver, newDictFilter);
|
registerReceiver(mDictionaryPackInstallReceiver, newDictFilter);
|
||||||
|
|
||||||
|
final IntentFilter dictDumpFilter = new IntentFilter();
|
||||||
|
dictDumpFilter.addAction(DictionaryDumpBroadcastReceiver.DICTIONARY_DUMP_INTENT_ACTION);
|
||||||
|
registerReceiver(mDictionaryDumpBroadcastReceiver, dictDumpFilter);
|
||||||
|
|
||||||
DictionaryDecayBroadcastReciever.setUpIntervalAlarmForDictionaryDecaying(this);
|
DictionaryDecayBroadcastReciever.setUpIntervalAlarmForDictionaryDecaying(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1758,6 +1765,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
resetSuggest(new Suggest(locale, dictionaryFacilitator));
|
resetSuggest(new Suggest(locale, dictionaryFacilitator));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void dumpDictionaryForDebug(final String dictName) {
|
||||||
|
if (mInputLogic.mSuggest == null) {
|
||||||
|
initSuggest();
|
||||||
|
}
|
||||||
|
mInputLogic.mSuggest.mDictionaryFacilitator.dumpDictionaryForDebug(dictName);
|
||||||
|
}
|
||||||
|
|
||||||
public void debugDumpStateAndCrashWithException(final String context) {
|
public void debugDumpStateAndCrashWithException(final String context) {
|
||||||
final SettingsValues settingsValues = mSettings.getCurrent();
|
final SettingsValues settingsValues = mSettings.getCurrent();
|
||||||
final StringBuilder s = new StringBuilder(settingsValues.toString());
|
final StringBuilder s = new StringBuilder(settingsValues.toString());
|
||||||
|
|
|
@ -16,15 +16,18 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin.settings;
|
package com.android.inputmethod.latin.settings;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
|
import android.preference.Preference.OnPreferenceClickListener;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
import com.android.inputmethod.latin.Dictionary;
|
||||||
|
import com.android.inputmethod.latin.DictionaryDumpBroadcastReceiver;
|
||||||
import com.android.inputmethod.latin.LatinImeLogger;
|
import com.android.inputmethod.latin.LatinImeLogger;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
import com.android.inputmethod.latin.debug.ExternalDictionaryGetterForDebug;
|
import com.android.inputmethod.latin.debug.ExternalDictionaryGetterForDebug;
|
||||||
|
@ -40,6 +43,11 @@ public final class DebugSettings extends PreferenceFragment
|
||||||
public static final String PREF_USE_ONLY_PERSONALIZATION_DICTIONARY_FOR_DEBUG =
|
public static final String PREF_USE_ONLY_PERSONALIZATION_DICTIONARY_FOR_DEBUG =
|
||||||
"use_only_personalization_dictionary_for_debug";
|
"use_only_personalization_dictionary_for_debug";
|
||||||
private static final String PREF_READ_EXTERNAL_DICTIONARY = "read_external_dictionary";
|
private static final String PREF_READ_EXTERNAL_DICTIONARY = "read_external_dictionary";
|
||||||
|
private static final String PREF_DUMP_CONTACTS_DICT = "dump_contacts_dict";
|
||||||
|
private static final String PREF_DUMP_USER_DICT = "dump_user_dict";
|
||||||
|
private static final String PREF_DUMP_USER_HISTORY_DICT = "dump_user_history_dict";
|
||||||
|
private static final String PREF_DUMP_PERSONALIZATION_DICT = "dump_personalization_dict";
|
||||||
|
|
||||||
private static final boolean SHOW_STATISTICS_LOGGING = false;
|
private static final boolean SHOW_STATISTICS_LOGGING = false;
|
||||||
|
|
||||||
private boolean mServiceNeedsRestart = false;
|
private boolean mServiceNeedsRestart = false;
|
||||||
|
@ -83,11 +91,53 @@ public final class DebugSettings extends PreferenceFragment
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final OnPreferenceClickListener dictDumpPrefClickListener =
|
||||||
|
new DictDumpPrefClickListener(this);
|
||||||
|
findPreference(PREF_DUMP_CONTACTS_DICT).setOnPreferenceClickListener(
|
||||||
|
dictDumpPrefClickListener);
|
||||||
|
findPreference(PREF_DUMP_USER_DICT).setOnPreferenceClickListener(
|
||||||
|
dictDumpPrefClickListener);
|
||||||
|
findPreference(PREF_DUMP_USER_HISTORY_DICT).setOnPreferenceClickListener(
|
||||||
|
dictDumpPrefClickListener);
|
||||||
|
findPreference(PREF_DUMP_PERSONALIZATION_DICT).setOnPreferenceClickListener(
|
||||||
|
dictDumpPrefClickListener);
|
||||||
|
|
||||||
mServiceNeedsRestart = false;
|
mServiceNeedsRestart = false;
|
||||||
mDebugMode = (CheckBoxPreference) findPreference(PREF_DEBUG_MODE);
|
mDebugMode = (CheckBoxPreference) findPreference(PREF_DEBUG_MODE);
|
||||||
updateDebugMode();
|
updateDebugMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class DictDumpPrefClickListener implements OnPreferenceClickListener {
|
||||||
|
final PreferenceFragment mPreferenceFragment;
|
||||||
|
|
||||||
|
public DictDumpPrefClickListener(final PreferenceFragment preferenceFragment) {
|
||||||
|
mPreferenceFragment = preferenceFragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(final Preference arg0) {
|
||||||
|
final String dictName;
|
||||||
|
if (arg0.getKey().equals(PREF_DUMP_CONTACTS_DICT)) {
|
||||||
|
dictName = Dictionary.TYPE_CONTACTS;
|
||||||
|
} else if (arg0.getKey().equals(PREF_DUMP_USER_DICT)) {
|
||||||
|
dictName = Dictionary.TYPE_USER;
|
||||||
|
} else if (arg0.getKey().equals(PREF_DUMP_USER_HISTORY_DICT)) {
|
||||||
|
dictName = Dictionary.TYPE_USER_HISTORY;
|
||||||
|
} else if (arg0.getKey().equals(PREF_DUMP_PERSONALIZATION_DICT)) {
|
||||||
|
dictName = Dictionary.TYPE_PERSONALIZATION;
|
||||||
|
} else {
|
||||||
|
dictName = null;
|
||||||
|
}
|
||||||
|
if (dictName != null) {
|
||||||
|
final Intent intent =
|
||||||
|
new Intent(DictionaryDumpBroadcastReceiver.DICTIONARY_DUMP_INTENT_ACTION);
|
||||||
|
intent.putExtra(DictionaryDumpBroadcastReceiver.DICTIONARY_NAME_KEY, dictName);
|
||||||
|
mPreferenceFragment.getActivity().sendBroadcast(intent);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
|
|
Loading…
Reference in New Issue