Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7abed29a authored by Satoshi Kataoka's avatar Satoshi Kataoka Committed by Android Git Automerger
Browse files

am 33f5f0df: Merge "Add a functionality to boost scores of personalization dictionary"

* commit '33f5f0df':
  Add a functionality to boost scores of personalization dictionary
parents f5fd990f 33f5f0df
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -493,6 +493,8 @@ mobile devices. [CHAR LIMIT=25] -->
    <string name="prefs_read_external_dictionary">Read external dictionary file</string>
    <!-- Title of the settings for using only personalization dictionary -->
    <string name="prefs_use_only_personalization_dictionary" translatable="false">Use only personalization dictionary</string>
    <!-- Title of the settings for boosting personalization dictionary -->
    <string name="prefs_boost_personalization_dictionary" translatable="false">Boost personalization dictionary</string>
    <!-- Message to show when there are no files to install as an external dictionary [CHAR LIMIT=100] -->
    <string name="read_external_dictionary_no_files_message">No dictionary files in the Downloads folder</string>
    <!-- Title of the dialog that selects a file to install as an external dictionary [CHAR LIMIT=50] -->
+31 −1
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ import com.android.inputmethod.latin.utils.RecapitalizeStatus;
import com.android.inputmethod.latin.utils.StaticInnerHandlerWrapper;
import com.android.inputmethod.latin.utils.TargetPackageInfoGetterTask;
import com.android.inputmethod.latin.utils.TextRange;
import com.android.inputmethod.latin.utils.UserHistoryForgettingCurveUtils;
import com.android.inputmethod.research.ResearchLogger;

import java.io.FileDescriptor;
@@ -191,7 +192,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
    private boolean mExpectingUpdateSelection;
    private int mDeleteCount;
    private long mLastKeyTime;
    private TreeSet<Long> mCurrentlyPressedHardwareKeys = CollectionUtils.newTreeSet();
    private final TreeSet<Long> mCurrentlyPressedHardwareKeys = CollectionUtils.newTreeSet();
    // Personalization debugging params
    private boolean mUseOnlyPersonalizationDictionaryForDebug = false;
    private boolean mBoostPersonalizationDictionaryForDebug = false;

    // Member variables for remembering the current device orientation.
    private int mDisplayOrientation;
@@ -874,9 +878,35 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
        // be replaced when the user dictionary reports back with the actual word, which ends
        // up calling #onWordAddedToUserDictionary() in this class.

        initPersonalizationDebugSettings(currentSettingsValues);

        if (TRACE) Debug.startMethodTracing("/data/trace/latinime");
    }

    // Initialization of personalization debug settings. This must be called inside
    // onStartInputView.
    private void initPersonalizationDebugSettings(SettingsValues currentSettingsValues) {
        if (mUseOnlyPersonalizationDictionaryForDebug
                != currentSettingsValues.mUseOnlyPersonalizationDictionaryForDebug) {
            // Only for debug
            initSuggest();
            mUseOnlyPersonalizationDictionaryForDebug =
                    currentSettingsValues.mUseOnlyPersonalizationDictionaryForDebug;
        }

        if (mBoostPersonalizationDictionaryForDebug !=
                currentSettingsValues.mBoostPersonalizationDictionaryForDebug) {
            // Only for debug
            mBoostPersonalizationDictionaryForDebug =
                    currentSettingsValues.mBoostPersonalizationDictionaryForDebug;
            if (mBoostPersonalizationDictionaryForDebug) {
                UserHistoryForgettingCurveUtils.boostMaxFreqForDebug();
            } else {
                UserHistoryForgettingCurveUtils.resetMaxFreqForDebug();
            }
        }
    }

    // Callback for the TargetPackageInfoGetterTask
    @Override
    public void onTargetPackageInfoKnown(final PackageInfo info) {
+2 −0
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ public final class DebugSettings extends PreferenceFragment
    public static final String PREF_STATISTICS_LOGGING = "enable_logging";
    public static final String PREF_USE_ONLY_PERSONALIZATION_DICTIONARY_FOR_DEBUG =
            "use_only_personalization_dictionary_for_debug";
    public static final String PREF_BOOST_PERSONALIZATION_DICTIONARY_FOR_DEBUG =
            "boost_personalization_dictionary_for_debug";
    private static final String PREF_READ_EXTERNAL_DICTIONARY = "read_external_dictionary";
    private static final boolean SHOW_STATISTICS_LOGGING = false;

+6 −0
Original line number Diff line number Diff line
@@ -346,6 +346,12 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
                DebugSettings.PREF_USE_ONLY_PERSONALIZATION_DICTIONARY_FOR_DEBUG, false);
    }

    public static boolean readBoostPersonalizationDictionaryForDebug(
            final SharedPreferences prefs) {
        return prefs.getBoolean(
                DebugSettings.PREF_BOOST_PERSONALIZATION_DICTIONARY_FOR_DEBUG, false);
    }

    public void writeLastUsedPersonalizationToken(byte[] token) {
        final String tokenStr = StringUtils.byteArrayToHexString(token);
        mPrefs.edit().putString(PREF_LAST_USED_PERSONALIZATION_TOKEN, tokenStr).apply();
+8 −0
Original line number Diff line number Diff line
@@ -92,6 +92,8 @@ public final class SettingsValues {
    public final int mSuggestionVisibility;
    private final boolean mVoiceKeyEnabled;
    private final boolean mVoiceKeyOnMain;
    public final boolean mBoostPersonalizationDictionaryForDebug;
    public final boolean mUseOnlyPersonalizationDictionaryForDebug;

    // Setting values for additional features
    public final int[] mAdditionalFeaturesSettingValues =
@@ -171,6 +173,10 @@ public final class SettingsValues {
        AdditionalFeaturesSettingUtils.readAdditionalFeaturesPreferencesIntoArray(
                prefs, mAdditionalFeaturesSettingValues);
        mIsInternal = Settings.isInternal(prefs);
        mBoostPersonalizationDictionaryForDebug =
                Settings.readBoostPersonalizationDictionaryForDebug(prefs);
        mUseOnlyPersonalizationDictionaryForDebug =
                Settings.readUseOnlyPersonalizationDictionaryForDebug(prefs);
    }

    // Only for tests
@@ -216,6 +222,8 @@ public final class SettingsValues {
        mCorrectionEnabled = mAutoCorrectEnabled && !mInputAttributes.mInputTypeNoAutoCorrect;
        mSuggestionVisibility = 0;
        mIsInternal = false;
        mBoostPersonalizationDictionaryForDebug = false;
        mUseOnlyPersonalizationDictionaryForDebug = false;
    }

    @UsedForTesting
Loading