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

Commit cc2d440d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix NPE in InlineContentView" into rvc-dev am: 854b0d1a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11784246

Change-Id: I4de5d2e6d2d8d84d3acdc8144cdfc0b384577805
parents 7d04ec7a 854b0d1a
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -317,8 +317,24 @@ public final class InlineSuggestion implements Parcelable {
         */
        @MainThread
        private void handleOnSurfacePackage(SurfaceControlViewHost.SurfacePackage surfacePackage) {
            if (surfacePackage == null) {
                return;
            }
            if (mSurfacePackage != null || mSurfacePackageConsumer == null) {
                // The surface package is not consumed, release it immediately.
                surfacePackage.release();
                try {
                    mInlineContentProvider.onSurfacePackageReleased();
                } catch (RemoteException e) {
                    Slog.w(TAG, "Error calling onSurfacePackageReleased(): " + e);
                }
                return;
            }
            mSurfacePackage = surfacePackage;
            if (mSurfacePackage != null && mSurfacePackageConsumer != null) {
            if (mSurfacePackage == null) {
                return;
            }
            if (mSurfacePackageConsumer != null) {
                mSurfacePackageConsumer.accept(mSurfacePackage);
                mSurfacePackageConsumer = null;
            }
@@ -334,6 +350,10 @@ public final class InlineSuggestion implements Parcelable {
                }
                mSurfacePackage = null;
            }
            // Clear the pending surface package consumer, if any. This can happen if the IME
            // attaches the view to window and then quickly detaches it from the window, before
            // the surface package requested upon attaching to window was returned.
            mSurfacePackageConsumer = null;
        }

        @MainThread
+3 −1
Original line number Diff line number Diff line
@@ -197,7 +197,9 @@ public class InlineContentView extends ViewGroup {
            mSurfacePackageUpdater.getSurfacePackage(
                    sp -> {
                        if (DEBUG) Log.v(TAG, "Received new SurfacePackage");
                        if (getViewRootImpl() != null) {
                            mSurfaceView.setChildSurfacePackage(sp);
                        }
                    });
        }
    }