From 9a4716d20e4c0b19e7642a043b6a450918090591 Mon Sep 17 00:00:00 2001 From: Julia Tuttle Date: Fri, 28 Jan 2022 20:08:32 -0500 Subject: New Pipeline: resume spinning after RemoteInputView is moved The new pipeline uses the "spinning" (sending) state of remote inputs to decide whether to extend their lifetime. The goal is that a user will be able to see the reply they sent, even if the app immediately cancels the notification they replied to (as is apparently common). Unfortunately, this breaks in (at least) one case: if an app posts a group of messages, the user replies to one, and then the app cancels the *summary* notification of the group, then the pipeline promotes the individual messages to top-level notifications. In the process, their RemoteInputViews are detached and reattached, which causes them to stop spinning. Notification rows have an isChangingPosition flag for the (as far as I can tell) sole purpose of letting RemoteInputView know that it should save and restore a bit of state on detach and attach, including the spinning state, but the new pipeline doesn't set this flag properly, and doing so might require a bunch of unpleasant plumbing in ShadeViewDiffer and/or NodeController. As an easier fix, try *unconditionally* saving and restoring the spinning state in RemoteInputView. It shouldn't hurt if the view is never reattached, it will handle the view being briefly detached during a pipeline run, and (as far as I know, and I hope) won't cause a problem if a notification is detached and reattached much later for some other reason. Bug: 211161595 Test: manual Change-Id: I78de3a3a5259d8e9cc3faa26d664260b6d4eb94f --- .../com/android/systemui/statusbar/policy/RemoteInputView.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java index 48949f92413d..3205e097c03b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java @@ -118,6 +118,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene private boolean mColorized; private int mTint; private boolean mResetting; + private boolean mWasSpinning; // TODO(b/193539698): move these to a Controller private RemoteInputController mController; @@ -439,6 +440,10 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene mEditText.requestFocus(); } } + if (mWasSpinning) { + mController.addSpinning(mEntry.getKey(), mToken); + mWasSpinning = false; + } } @Override @@ -447,6 +452,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene mEditText.removeTextChangedListener(mTextWatcher); mEditText.setOnEditorActionListener(null); mEditText.mRemoteInputView = null; + mWasSpinning = mController.isSpinning(mEntry.getKey(), mToken); if (mEntry.getRow().isChangingPosition() || isTemporarilyDetached()) { return; } @@ -533,6 +539,8 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene if (isActive() && mWrapper != null) { mWrapper.setRemoteInputVisible(true); } + + mWasSpinning = false; } private void reset() { -- cgit v1.2.3-59-g8ed1b