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

Commit 4997c505 authored by Felipe Leme's avatar Felipe Leme
Browse files

Guarded access to mCallback and check for null before using it.

Fixes: 35143142

Test: manual verification
Test: CtsAutoFillServiceTestCases passes
Change-Id: I465538b896b617c518949611f963e350ee498f7b
parent fb0f3602
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -172,7 +172,7 @@ public abstract class AutoFillService extends Service {
     * <p>You should generally do initialization here rather than in {@link #onCreate}.
     */
    public void onConnected() {

        //TODO(b/33197203): is not called anymore, fix it!
    }

    /**
@@ -221,6 +221,6 @@ public abstract class AutoFillService extends Service {
     * <p> At this point this service may no longer be an active {@link AutoFillService}.
     */
    public void onDisconnected() {

        //TODO(b/33197203): is not called anymore, fix it!
    }
}
+5 −3
Original line number Diff line number Diff line
@@ -869,9 +869,11 @@ final class AutoFillManagerServiceImpl {
        }

        private AutoFillUI getUiForShowing() {
            mUi.setCallback(this, mActivityToken);
            synchronized (mLock) {
                mUi.setCallbackLocked(this, mActivityToken);
                return mUi;
            }
        }

        private ViewNode findViewNodeByIdLocked(AutoFillId id) {
            final int size = mStructure.getWindowNodeCount();
@@ -909,7 +911,7 @@ final class AutoFillManagerServiceImpl {
        private void destroyLocked() {
            mRemoteFillService.destroy();
            mUi.hideAll();
            mUi.setCallback(null, null);
            mUi.setCallbackLocked(null, null);
        }

        private void removeSelf() {
+6 −2
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ final class AutoFillUI {
        mWm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    }

    void setCallback(AutoFillUiCallback callback, IBinder activityToken) {
    void setCallbackLocked(AutoFillUiCallback callback, IBinder activityToken) {
        hideAll();
        mCallback = callback;
        mActivityToken = activityToken;
@@ -180,7 +180,11 @@ final class AutoFillUI {
                            synchronized (mLock) {
                                callback = mCallback;
                            }
                            if (callback != null) {
                                callback.fill(dataset);
                            } else {
                                Slog.w(TAG, "null callback on showFillUi() for " + viewState.mId);
                            }
                            hideFillUi();
                        });
                // TODO(b/33197203): No magical numbers