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

Commit da1e7e56 authored by Kohsuke Yatoh's avatar Kohsuke Yatoh
Browse files

Return an empty list instead of null.

TextServicesManager#getEnabledSpellCheckerInfos() was introduced in
  commit 4c742373
as #getEnabledSpellCheckersList().
Then, the following commit added SuppressLint("NullableCollections"):
  commit d7f33cd6

As this API has been introduced recently in Android S timeframe, I think
it's better to fix the API behavior before it's finalized.

Bug: 180625329
Test: m checkapi
Change-Id: I33d3c86a0c19c0082299e383e50d3860b072e79d
parent e5262784
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -52287,7 +52287,7 @@ package android.view.textservice {
  public final class TextServicesManager {
    method @Nullable public android.view.textservice.SpellCheckerInfo getCurrentSpellCheckerInfo();
    method @Nullable public java.util.List<android.view.textservice.SpellCheckerInfo> getEnabledSpellCheckerInfos();
    method @NonNull public java.util.List<android.view.textservice.SpellCheckerInfo> getEnabledSpellCheckerInfos();
    method public boolean isSpellCheckerEnabled();
    method @Nullable public android.view.textservice.SpellCheckerSession newSpellCheckerSession(@Nullable android.os.Bundle, @Nullable java.util.Locale, @NonNull android.view.textservice.SpellCheckerSession.SpellCheckerSessionListener, boolean);
    method @Nullable public android.view.textservice.SpellCheckerSession newSpellCheckerSession(@Nullable android.os.Bundle, @Nullable java.util.Locale, @NonNull android.view.textservice.SpellCheckerSession.SpellCheckerSessionListener, boolean, int);
+5 −4
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import com.android.internal.textservice.ISpellCheckerSessionListener;
import com.android.internal.textservice.ITextServicesManager;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;

@@ -288,15 +289,15 @@ public final class TextServicesManager {
    }

    /**
     * Retrieve the list of currently enabled spell checkers, or null if there is none.
     * Retrieve the list of currently enabled spell checkers.
     *
     * @return The list of currently enabled spell checkers.
     */
    @Nullable
    @SuppressLint("NullableCollection")
    @NonNull
    public List<SpellCheckerInfo> getEnabledSpellCheckerInfos() {
        final SpellCheckerInfo[] enabledSpellCheckers = getEnabledSpellCheckers();
        return enabledSpellCheckers != null ? Arrays.asList(enabledSpellCheckers) : null;
        return enabledSpellCheckers != null
                ? Arrays.asList(enabledSpellCheckers) : Collections.emptyList();
    }

    /**