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

Commit de12c1bf authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Fix NPE due to the lack of null-check

The case that was not coverted well is that
CursorAnchorInfoCompatWrapper could be instantiated
with null object. In such situations, we should
do nothing.

BUG: 17682582
Change-Id: I6625a2f0ed8c5580ed9edfe4728f342da77a8e40
parent be4e0d0e
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -84,8 +84,8 @@ public final class CursorAnchorInfoCompatWrapper {
    }

    @UsedForTesting
    public static boolean isAvailable() {
        return sCursorAnchorInfoClass.exists();
    public boolean isAvailable() {
        return sCursorAnchorInfoClass.exists() && mInstance != null;
    }

    private Object mInstance;
@@ -96,7 +96,7 @@ public final class CursorAnchorInfoCompatWrapper {

    @UsedForTesting
    public static CursorAnchorInfoCompatWrapper fromObject(final Object instance) {
        if (!isAvailable()) {
        if (!sCursorAnchorInfoClass.exists()) {
            return new CursorAnchorInfoCompatWrapper(null);
        }
        return new CursorAnchorInfoCompatWrapper(instance);
+1 −1
Original line number Diff line number Diff line
@@ -182,7 +182,7 @@ public class TextDecorator {
    private void layoutMain() {
        final CursorAnchorInfoCompatWrapper info = mCursorAnchorInfoWrapper;

        if (info == null) {
        if (info == null || !info.isAvailable()) {
            cancelLayoutInternalExpectedly("CursorAnchorInfo isn't available.");
            return;
        }