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

Commit 4039454f authored by Abodunrinwa Toki's avatar Abodunrinwa Toki
Browse files

TextClassificationManager: Make certain methods thread-safe

1. getDefaultTextClassifier()
2. getLanguageDetector()

Test: CtsWidgetTestCases passes
Change-Id: Ie0cb866cdefea2839efb38a1113e434a3e8159b0
parent ddb80216
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ public final class TextClassificationManager {
    /**
     * Returns the default text classifier.
     */
    public TextClassifier getDefaultTextClassifier() {
    public synchronized TextClassifier getDefaultTextClassifier() {
        if (mDefault == null) {
            try {
                mFd = ParcelFileDescriptor.open(
@@ -95,7 +95,7 @@ public final class TextClassificationManager {
        return Collections.emptyList();
    }

    private LangId getLanguageDetector() {
    private synchronized LangId getLanguageDetector() {
        if (mLangId == null) {
            // TODO: Use a file descriptor as soon as we start to depend on a model file
            // for language detection.