Skip to content

Commit

Permalink
Merge cherrypicks of ['googleplex-android-review.googlesource.com/301…
Browse files Browse the repository at this point in the history
…34293', 'googleplex-android-review.googlesource.com/30153908', 'googleplex-android-review.googlesource.com/30200589'] into 24Q4-release.

Change-Id: I32459190d4938abf8c3eacd52754a41d1ed3f88f
  • Loading branch information
Android Build Coastguard Worker committed Nov 4, 2024
2 parents 6a58e01 + 73d475b commit 2103ff4
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 123 deletions.
10 changes: 10 additions & 0 deletions packages/SystemUI/aconfig/systemui.aconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1431,4 +1431,14 @@ flag {
metadata {
purpose: PURPOSE_BUGFIX
}
}

flag {
name: "ignore_touches_next_to_notification_shelf"
namespace: "systemui"
description: "The shelf can vertically overlap the unlock icon. Ignore touches if so."
bug: "358424256"
metadata {
purpose: PURPOSE_BUGFIX
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fun isSameMediaData(
context: Context,
newController: MediaController,
new: MediaData,
old: MediaData?
old: MediaData?,
): Boolean {
if (old == null || !mediaControlsPostsOptimization()) return false

Expand Down Expand Up @@ -71,7 +71,7 @@ fun isSameMediaData(
/** Returns whether actions lists are equal. */
fun areCustomActionListsEqual(
first: List<PlaybackState.CustomAction>?,
second: List<PlaybackState.CustomAction>?
second: List<PlaybackState.CustomAction>?,
): Boolean {
// Same object, or both null
if (first === second) {
Expand All @@ -94,7 +94,7 @@ fun areCustomActionListsEqual(

private fun areCustomActionsEqual(
firstAction: PlaybackState.CustomAction,
secondAction: PlaybackState.CustomAction
secondAction: PlaybackState.CustomAction,
): Boolean {
if (
firstAction.action != secondAction.action ||
Expand Down Expand Up @@ -139,7 +139,7 @@ private fun areActionsEqual(
context: Context,
newController: MediaController,
new: MediaData,
old: MediaData
old: MediaData,
): Boolean {
val oldState = MediaController(context, old.token!!).playbackState
return if (
Expand All @@ -150,8 +150,7 @@ private fun areActionsEqual(
var same = true
new.actions.asSequence().zip(old.actions.asSequence()).forEach {
if (
it.first.actionIntent?.intent?.filterEquals(it.second.actionIntent?.intent) !=
true ||
it.first.actionIntent?.intent != it.second.actionIntent?.intent ||
it.first.icon != it.second.icon ||
it.first.contentDescription != it.second.contentDescription
) {
Expand All @@ -164,16 +163,13 @@ private fun areActionsEqual(
oldState?.actions == newController.playbackState?.actions &&
areCustomActionListsEqual(
oldState?.customActions,
newController.playbackState?.customActions
newController.playbackState?.customActions,
)
} else {
false
}
}

private fun areClickIntentsEqual(newIntent: PendingIntent?, oldIntent: PendingIntent?): Boolean {
if ((newIntent == null && oldIntent == null) || newIntent === oldIntent) return true
if (newIntent == null || oldIntent == null) return false

return newIntent.intent?.filterEquals(oldIntent.intent) == true
return newIntent == oldIntent
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static com.android.server.notification.Flags.screenshareNotificationHiding;
import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME;
import static com.android.systemui.Flags.confineNotificationTouchToViewWidth;
import static com.android.systemui.Flags.ignoreTouchesNextToNotificationShelf;
import static com.android.systemui.statusbar.StatusBarState.KEYGUARD;
import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.OnEmptySpaceClickListener;
import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.OnOverscrollTopChangedListener;
Expand Down Expand Up @@ -604,6 +605,16 @@ public View getChildAtPosition(MotionEvent ev) {
true /* requireMinHeight */,
false /* ignoreDecors */,
!confineNotificationTouchToViewWidth() /* ignoreWidth */);

// Verify the MotionEvent x,y are actually inside the touch area of the shelf,
// since the shelf may be animated down to a collapsed size on keyguard.
if (ignoreTouchesNextToNotificationShelf()) {
if (child instanceof NotificationShelf shelf) {
if (!NotificationSwipeHelper.isTouchInView(ev, shelf)) {
return null;
}
}
}
if (child instanceof ExpandableNotificationRow row) {
ExpandableNotificationRow parent = row.getNotificationParent();
if (parent != null && parent.areChildrenExpanded()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.android.systemui.statusbar.notification.stack;

import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_ROW_SWIPE;
import static com.android.systemui.Flags.ignoreTouchesNextToNotificationShelf;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
Expand All @@ -39,6 +40,7 @@
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper;
import com.android.systemui.statusbar.NotificationShelf;
import com.android.systemui.statusbar.notification.SourceType;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.ExpandableView;
Expand Down Expand Up @@ -503,13 +505,21 @@ public static boolean isTouchInView(MotionEvent ev, View view) {
final int height = (view instanceof ExpandableView)
? ((ExpandableView) view).getActualHeight()
: view.getHeight();
final int width;
if (ignoreTouchesNextToNotificationShelf()) {
width = (view instanceof NotificationShelf)
? ((NotificationShelf) view).getActualWidth()
: view.getWidth();
} else {
width = view.getWidth();
}
final int rx = (int) ev.getRawX();
final int ry = (int) ev.getRawY();
int[] temp = new int[2];
view.getLocationOnScreen(temp);
final int x = temp[0];
final int y = temp[1];
Rect rect = new Rect(x, y, x + view.getWidth(), y + height);
Rect rect = new Rect(x, y, x + width, y + height);
boolean ret = rect.contains(rx, ry);
return ret;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

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

import static com.android.systemui.Flags.FLAG_IGNORE_TOUCHES_NEXT_TO_NOTIFICATION_SHELF;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
Expand All @@ -36,6 +38,7 @@
import android.animation.Animator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.os.Handler;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.service.notification.StatusBarNotification;
import android.testing.TestableLooper;
Expand All @@ -52,6 +55,7 @@
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper.SnoozeOption;
import com.android.systemui.statusbar.NotificationShelf;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.shared.NotificationContentAlphaOptimization;

Expand Down Expand Up @@ -85,6 +89,7 @@ public class NotificationSwipeHelperTest extends SysuiTestCase {
private NotificationMenuRowPlugin mMenuRow;
private Handler mHandler;
private ExpandableNotificationRow mNotificationRow;
private NotificationShelf mShelf;
private Runnable mFalsingCheck;
private final FeatureFlags mFeatureFlags = new FakeFeatureFlags();

Expand All @@ -111,6 +116,7 @@ public void setUp() throws Exception {
mEvent = mock(MotionEvent.class);
mMenuRow = mock(NotificationMenuRowPlugin.class);
mNotificationRow = mock(ExpandableNotificationRow.class);
mShelf = mock(NotificationShelf.class);
mHandler = mock(Handler.class);
mFalsingCheck = mock(Runnable.class);
}
Expand Down Expand Up @@ -664,6 +670,54 @@ public void testIsTouchInView_expandable() {
mSwipeHelper.isTouchInView(mEvent, mNotificationRow));
}

@Test
@EnableFlags(FLAG_IGNORE_TOUCHES_NEXT_TO_NOTIFICATION_SHELF)
public void testIsTouchInView_notificationShelf_flagEnabled() {
doReturn(500).when(mShelf).getWidth();
doReturn(FAKE_ROW_WIDTH).when(mShelf).getActualWidth();
doReturn(FAKE_ROW_HEIGHT).when(mShelf).getHeight();
doReturn(FAKE_ROW_HEIGHT).when(mShelf).getActualHeight();

Answer answer = (Answer) invocation -> {
int[] arr = invocation.getArgument(0);
arr[0] = 0;
arr[1] = 0;
return null;
};

doReturn(5f).when(mEvent).getRawX();
doReturn(10f).when(mEvent).getRawY();
doAnswer(answer).when(mShelf).getLocationOnScreen(any());
assertTrue("Touch is within the view", mSwipeHelper.isTouchInView(mEvent, mShelf));

doReturn(50f).when(mEvent).getRawX();
assertFalse("Touch is not within the view", mSwipeHelper.isTouchInView(mEvent, mShelf));
}

@Test
@DisableFlags(FLAG_IGNORE_TOUCHES_NEXT_TO_NOTIFICATION_SHELF)
public void testIsTouchInView_notificationShelf_flagDisabled() {
doReturn(500).when(mShelf).getWidth();
doReturn(FAKE_ROW_WIDTH).when(mShelf).getActualWidth();
doReturn(FAKE_ROW_HEIGHT).when(mShelf).getHeight();
doReturn(FAKE_ROW_HEIGHT).when(mShelf).getActualHeight();

Answer answer = (Answer) invocation -> {
int[] arr = invocation.getArgument(0);
arr[0] = 0;
arr[1] = 0;
return null;
};

doReturn(5f).when(mEvent).getRawX();
doReturn(10f).when(mEvent).getRawY();
doAnswer(answer).when(mShelf).getLocationOnScreen(any());
assertTrue("Touch is within the view", mSwipeHelper.isTouchInView(mEvent, mShelf));

doReturn(50f).when(mEvent).getRawX();
assertTrue("Touch is within the view", mSwipeHelper.isTouchInView(mEvent, mShelf));
}

@Test
public void testContentAlphaRemainsUnchangedWhenNotificationIsNotDismissible() {
doReturn(FAKE_ROW_WIDTH).when(mNotificationRow).getMeasuredWidth();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1321,9 +1321,9 @@ private void reapplyAudioHalBluetoothState() {
sendLMsgNoDelay(MSG_II_SET_LE_AUDIO_OUT_VOLUME, SENDMSG_REPLACE, info);
}

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

/*package*/ void postBluetoothDeviceConfigChange(@NonNull BtDeviceInfo info) {
Expand Down Expand Up @@ -2025,7 +2025,7 @@ public void handleMessage(Message msg) {
mBtHelper.setAvrcpAbsoluteVolumeIndex(msg.arg1);
}
break;
case MSG_IL_SET_MODE_OWNER:
case MSG_I_SET_MODE_OWNER:
synchronized (mSetModeLock) {
synchronized (mDeviceStateLock) {
int btScoRequesterUid = bluetoothScoRequestOwnerUid();
Expand All @@ -2036,9 +2036,6 @@ public void handleMessage(Message msg) {
}
}
}
if (msg.arg1 == 1 /*signal*/) {
mAudioService.decrementAudioModeResetCount();
}
break;

case MSG_L_SET_COMMUNICATION_DEVICE_FOR_CLIENT:
Expand Down Expand Up @@ -2227,7 +2224,7 @@ public void handleMessage(Message msg) {
private static final int MSG_REPORT_NEW_ROUTES = 13;
private static final int MSG_II_SET_HEARING_AID_VOLUME = 14;
private static final int MSG_I_SET_AVRCP_ABSOLUTE_VOLUME = 15;
private static final int MSG_IL_SET_MODE_OWNER = 16;
private static final int MSG_I_SET_MODE_OWNER = 16;

private static final int MSG_I_BT_SERVICE_DISCONNECTED_PROFILE = 22;
private static final int MSG_IL_BT_SERVICE_CONNECTED_PROFILE = 23;
Expand Down
Loading

0 comments on commit 2103ff4

Please sign in to comment.