Skip to content

Commit 2103ff4

Browse files
author
Android Build Coastguard Worker
committed
Merge cherrypicks of ['googleplex-android-review.googlesource.com/30134293', 'googleplex-android-review.googlesource.com/30153908', 'googleplex-android-review.googlesource.com/30200589'] into 24Q4-release.
Change-Id: I32459190d4938abf8c3eacd52754a41d1ed3f88f
2 parents 6a58e01 + 73d475b commit 2103ff4

File tree

7 files changed

+125
-123
lines changed

7 files changed

+125
-123
lines changed

packages/SystemUI/aconfig/systemui.aconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,4 +1431,14 @@ flag {
14311431
metadata {
14321432
purpose: PURPOSE_BUGFIX
14331433
}
1434+
}
1435+
1436+
flag {
1437+
name: "ignore_touches_next_to_notification_shelf"
1438+
namespace: "systemui"
1439+
description: "The shelf can vertically overlap the unlock icon. Ignore touches if so."
1440+
bug: "358424256"
1441+
metadata {
1442+
purpose: PURPOSE_BUGFIX
1443+
}
14341444
}

packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/MediaProcessingHelper.kt

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fun isSameMediaData(
4242
context: Context,
4343
newController: MediaController,
4444
new: MediaData,
45-
old: MediaData?
45+
old: MediaData?,
4646
): Boolean {
4747
if (old == null || !mediaControlsPostsOptimization()) return false
4848

@@ -71,7 +71,7 @@ fun isSameMediaData(
7171
/** Returns whether actions lists are equal. */
7272
fun areCustomActionListsEqual(
7373
first: List<PlaybackState.CustomAction>?,
74-
second: List<PlaybackState.CustomAction>?
74+
second: List<PlaybackState.CustomAction>?,
7575
): Boolean {
7676
// Same object, or both null
7777
if (first === second) {
@@ -94,7 +94,7 @@ fun areCustomActionListsEqual(
9494

9595
private fun areCustomActionsEqual(
9696
firstAction: PlaybackState.CustomAction,
97-
secondAction: PlaybackState.CustomAction
97+
secondAction: PlaybackState.CustomAction,
9898
): Boolean {
9999
if (
100100
firstAction.action != secondAction.action ||
@@ -139,7 +139,7 @@ private fun areActionsEqual(
139139
context: Context,
140140
newController: MediaController,
141141
new: MediaData,
142-
old: MediaData
142+
old: MediaData,
143143
): Boolean {
144144
val oldState = MediaController(context, old.token!!).playbackState
145145
return if (
@@ -150,8 +150,7 @@ private fun areActionsEqual(
150150
var same = true
151151
new.actions.asSequence().zip(old.actions.asSequence()).forEach {
152152
if (
153-
it.first.actionIntent?.intent?.filterEquals(it.second.actionIntent?.intent) !=
154-
true ||
153+
it.first.actionIntent?.intent != it.second.actionIntent?.intent ||
155154
it.first.icon != it.second.icon ||
156155
it.first.contentDescription != it.second.contentDescription
157156
) {
@@ -164,16 +163,13 @@ private fun areActionsEqual(
164163
oldState?.actions == newController.playbackState?.actions &&
165164
areCustomActionListsEqual(
166165
oldState?.customActions,
167-
newController.playbackState?.customActions
166+
newController.playbackState?.customActions,
168167
)
169168
} else {
170169
false
171170
}
172171
}
173172

174173
private fun areClickIntentsEqual(newIntent: PendingIntent?, oldIntent: PendingIntent?): Boolean {
175-
if ((newIntent == null && oldIntent == null) || newIntent === oldIntent) return true
176-
if (newIntent == null || oldIntent == null) return false
177-
178-
return newIntent.intent?.filterEquals(oldIntent.intent) == true
174+
return newIntent == oldIntent
179175
}

packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import static com.android.server.notification.Flags.screenshareNotificationHiding;
2525
import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME;
2626
import static com.android.systemui.Flags.confineNotificationTouchToViewWidth;
27+
import static com.android.systemui.Flags.ignoreTouchesNextToNotificationShelf;
2728
import static com.android.systemui.statusbar.StatusBarState.KEYGUARD;
2829
import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.OnEmptySpaceClickListener;
2930
import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.OnOverscrollTopChangedListener;
@@ -604,6 +605,16 @@ public View getChildAtPosition(MotionEvent ev) {
604605
true /* requireMinHeight */,
605606
false /* ignoreDecors */,
606607
!confineNotificationTouchToViewWidth() /* ignoreWidth */);
608+
609+
// Verify the MotionEvent x,y are actually inside the touch area of the shelf,
610+
// since the shelf may be animated down to a collapsed size on keyguard.
611+
if (ignoreTouchesNextToNotificationShelf()) {
612+
if (child instanceof NotificationShelf shelf) {
613+
if (!NotificationSwipeHelper.isTouchInView(ev, shelf)) {
614+
return null;
615+
}
616+
}
617+
}
607618
if (child instanceof ExpandableNotificationRow row) {
608619
ExpandableNotificationRow parent = row.getNotificationParent();
609620
if (parent != null && parent.areChildrenExpanded()

packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package com.android.systemui.statusbar.notification.stack;
1919

2020
import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_ROW_SWIPE;
21+
import static com.android.systemui.Flags.ignoreTouchesNextToNotificationShelf;
2122

2223
import android.animation.Animator;
2324
import android.animation.AnimatorListenerAdapter;
@@ -39,6 +40,7 @@
3940
import com.android.systemui.plugins.FalsingManager;
4041
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
4142
import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper;
43+
import com.android.systemui.statusbar.NotificationShelf;
4244
import com.android.systemui.statusbar.notification.SourceType;
4345
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
4446
import com.android.systemui.statusbar.notification.row.ExpandableView;
@@ -503,13 +505,21 @@ public static boolean isTouchInView(MotionEvent ev, View view) {
503505
final int height = (view instanceof ExpandableView)
504506
? ((ExpandableView) view).getActualHeight()
505507
: view.getHeight();
508+
final int width;
509+
if (ignoreTouchesNextToNotificationShelf()) {
510+
width = (view instanceof NotificationShelf)
511+
? ((NotificationShelf) view).getActualWidth()
512+
: view.getWidth();
513+
} else {
514+
width = view.getWidth();
515+
}
506516
final int rx = (int) ev.getRawX();
507517
final int ry = (int) ev.getRawY();
508518
int[] temp = new int[2];
509519
view.getLocationOnScreen(temp);
510520
final int x = temp[0];
511521
final int y = temp[1];
512-
Rect rect = new Rect(x, y, x + view.getWidth(), y + height);
522+
Rect rect = new Rect(x, y, x + width, y + height);
513523
boolean ret = rect.contains(rx, ry);
514524
return ret;
515525
}

packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelperTest.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
package com.android.systemui.statusbar.notification.stack;
1515

16+
import static com.android.systemui.Flags.FLAG_IGNORE_TOUCHES_NEXT_TO_NOTIFICATION_SHELF;
17+
1618
import static junit.framework.Assert.assertEquals;
1719
import static junit.framework.Assert.assertFalse;
1820
import static junit.framework.Assert.assertTrue;
@@ -36,6 +38,7 @@
3638
import android.animation.Animator;
3739
import android.animation.ValueAnimator.AnimatorUpdateListener;
3840
import android.os.Handler;
41+
import android.platform.test.annotations.DisableFlags;
3942
import android.platform.test.annotations.EnableFlags;
4043
import android.service.notification.StatusBarNotification;
4144
import android.testing.TestableLooper;
@@ -52,6 +55,7 @@
5255
import com.android.systemui.flags.FeatureFlags;
5356
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
5457
import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper.SnoozeOption;
58+
import com.android.systemui.statusbar.NotificationShelf;
5559
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
5660
import com.android.systemui.statusbar.notification.shared.NotificationContentAlphaOptimization;
5761

@@ -85,6 +89,7 @@ public class NotificationSwipeHelperTest extends SysuiTestCase {
8589
private NotificationMenuRowPlugin mMenuRow;
8690
private Handler mHandler;
8791
private ExpandableNotificationRow mNotificationRow;
92+
private NotificationShelf mShelf;
8893
private Runnable mFalsingCheck;
8994
private final FeatureFlags mFeatureFlags = new FakeFeatureFlags();
9095

@@ -111,6 +116,7 @@ public void setUp() throws Exception {
111116
mEvent = mock(MotionEvent.class);
112117
mMenuRow = mock(NotificationMenuRowPlugin.class);
113118
mNotificationRow = mock(ExpandableNotificationRow.class);
119+
mShelf = mock(NotificationShelf.class);
114120
mHandler = mock(Handler.class);
115121
mFalsingCheck = mock(Runnable.class);
116122
}
@@ -664,6 +670,54 @@ public void testIsTouchInView_expandable() {
664670
mSwipeHelper.isTouchInView(mEvent, mNotificationRow));
665671
}
666672

673+
@Test
674+
@EnableFlags(FLAG_IGNORE_TOUCHES_NEXT_TO_NOTIFICATION_SHELF)
675+
public void testIsTouchInView_notificationShelf_flagEnabled() {
676+
doReturn(500).when(mShelf).getWidth();
677+
doReturn(FAKE_ROW_WIDTH).when(mShelf).getActualWidth();
678+
doReturn(FAKE_ROW_HEIGHT).when(mShelf).getHeight();
679+
doReturn(FAKE_ROW_HEIGHT).when(mShelf).getActualHeight();
680+
681+
Answer answer = (Answer) invocation -> {
682+
int[] arr = invocation.getArgument(0);
683+
arr[0] = 0;
684+
arr[1] = 0;
685+
return null;
686+
};
687+
688+
doReturn(5f).when(mEvent).getRawX();
689+
doReturn(10f).when(mEvent).getRawY();
690+
doAnswer(answer).when(mShelf).getLocationOnScreen(any());
691+
assertTrue("Touch is within the view", mSwipeHelper.isTouchInView(mEvent, mShelf));
692+
693+
doReturn(50f).when(mEvent).getRawX();
694+
assertFalse("Touch is not within the view", mSwipeHelper.isTouchInView(mEvent, mShelf));
695+
}
696+
697+
@Test
698+
@DisableFlags(FLAG_IGNORE_TOUCHES_NEXT_TO_NOTIFICATION_SHELF)
699+
public void testIsTouchInView_notificationShelf_flagDisabled() {
700+
doReturn(500).when(mShelf).getWidth();
701+
doReturn(FAKE_ROW_WIDTH).when(mShelf).getActualWidth();
702+
doReturn(FAKE_ROW_HEIGHT).when(mShelf).getHeight();
703+
doReturn(FAKE_ROW_HEIGHT).when(mShelf).getActualHeight();
704+
705+
Answer answer = (Answer) invocation -> {
706+
int[] arr = invocation.getArgument(0);
707+
arr[0] = 0;
708+
arr[1] = 0;
709+
return null;
710+
};
711+
712+
doReturn(5f).when(mEvent).getRawX();
713+
doReturn(10f).when(mEvent).getRawY();
714+
doAnswer(answer).when(mShelf).getLocationOnScreen(any());
715+
assertTrue("Touch is within the view", mSwipeHelper.isTouchInView(mEvent, mShelf));
716+
717+
doReturn(50f).when(mEvent).getRawX();
718+
assertTrue("Touch is within the view", mSwipeHelper.isTouchInView(mEvent, mShelf));
719+
}
720+
667721
@Test
668722
public void testContentAlphaRemainsUnchangedWhenNotificationIsNotDismissible() {
669723
doReturn(FAKE_ROW_WIDTH).when(mNotificationRow).getMeasuredWidth();

services/core/java/com/android/server/audio/AudioDeviceBroker.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,9 +1321,9 @@ private void reapplyAudioHalBluetoothState() {
13211321
sendLMsgNoDelay(MSG_II_SET_LE_AUDIO_OUT_VOLUME, SENDMSG_REPLACE, info);
13221322
}
13231323

1324-
/*package*/ void postSetModeOwner(int mode, int pid, int uid, boolean signal) {
1325-
sendILMsgNoDelay(MSG_IL_SET_MODE_OWNER, SENDMSG_REPLACE,
1326-
signal ? 1 : 0, new AudioModeInfo(mode, pid, uid));
1324+
/*package*/ void postSetModeOwner(int mode, int pid, int uid) {
1325+
sendLMsgNoDelay(MSG_I_SET_MODE_OWNER, SENDMSG_REPLACE,
1326+
new AudioModeInfo(mode, pid, uid));
13271327
}
13281328

13291329
/*package*/ void postBluetoothDeviceConfigChange(@NonNull BtDeviceInfo info) {
@@ -2025,7 +2025,7 @@ public void handleMessage(Message msg) {
20252025
mBtHelper.setAvrcpAbsoluteVolumeIndex(msg.arg1);
20262026
}
20272027
break;
2028-
case MSG_IL_SET_MODE_OWNER:
2028+
case MSG_I_SET_MODE_OWNER:
20292029
synchronized (mSetModeLock) {
20302030
synchronized (mDeviceStateLock) {
20312031
int btScoRequesterUid = bluetoothScoRequestOwnerUid();
@@ -2036,9 +2036,6 @@ public void handleMessage(Message msg) {
20362036
}
20372037
}
20382038
}
2039-
if (msg.arg1 == 1 /*signal*/) {
2040-
mAudioService.decrementAudioModeResetCount();
2041-
}
20422039
break;
20432040

20442041
case MSG_L_SET_COMMUNICATION_DEVICE_FOR_CLIENT:
@@ -2227,7 +2224,7 @@ public void handleMessage(Message msg) {
22272224
private static final int MSG_REPORT_NEW_ROUTES = 13;
22282225
private static final int MSG_II_SET_HEARING_AID_VOLUME = 14;
22292226
private static final int MSG_I_SET_AVRCP_ABSOLUTE_VOLUME = 15;
2230-
private static final int MSG_IL_SET_MODE_OWNER = 16;
2227+
private static final int MSG_I_SET_MODE_OWNER = 16;
22312228

22322229
private static final int MSG_I_BT_SERVICE_DISCONNECTED_PROFILE = 22;
22332230
private static final int MSG_IL_BT_SERVICE_CONNECTED_PROFILE = 23;

0 commit comments

Comments
 (0)