From 500263a9bc4f833e3897597d692e09d33af2240d Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Mon, 23 Jan 2017 14:49:54 -0800 Subject: [PATCH] AOD: Delay wakeup until interaction with notification Instead of immediately waking upon touching the screen, the wakeup now happens when interacting with the notification. Also adds feedback for the first tap of the double tap gesture on the content view. Bug: 30876804 Fixes: 34498705 Fixes: 34500641 Fixes: 34500802 Test: manual Change-Id: I75ea86a6009dd7efab480738584c96bb8743b2ba --- packages/SystemUI/res/values/colors.xml | 3 +++ .../statusbar/ActivatableNotificationView.java | 8 ++++++-- .../systemui/statusbar/BaseStatusBar.java | 18 ++++++++++++++++++ .../statusbar/phone/PhoneStatusBar.java | 5 +++-- .../statusbar/phone/StatusBarWindowView.java | 7 ++----- 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml index b18b6acb6a35f..30408143e30d7 100644 --- a/packages/SystemUI/res/values/colors.xml +++ b/packages/SystemUI/res/values/colors.xml @@ -75,6 +75,9 @@ #ccffffff + + #ff333333 + #fff5f5f5 diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java index b5358bfb6f6e1..b9ed72522bdba 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java @@ -463,6 +463,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView } mDark = dark; updateBackground(); + updateBackgroundTint(fade); if (!dark && fade && !shouldHideBackground()) { fadeInFromDark(delay); } @@ -700,8 +701,8 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView protected void updateBackground() { cancelFadeAnimations(); if (shouldHideBackground()) { - mBackgroundDimmed.setVisibility(View.INVISIBLE); - mBackgroundNormal.setVisibility(View.INVISIBLE); + mBackgroundDimmed.setVisibility(INVISIBLE); + mBackgroundNormal.setVisibility(mActivated ? VISIBLE : INVISIBLE); } else if (mDimmed) { // When groups are animating to the expanded state from the lockscreen, show the // normal background instead of the dimmed background @@ -940,6 +941,9 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView * @return the calculated background color */ private int calculateBgColor(boolean withTint, boolean withOverRide) { + if (mDark) { + return getContext().getColor(R.color.notification_material_background_dark_color); + } if (withOverRide && mOverrideTint != NO_COLOR) { int defaultTint = calculateBgColor(withTint, false); return NotificationUtils.interpolateColors(defaultTint, mOverrideTint, mOverrideAmount); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 6ac5cb8d35162..7dd8d78e7897c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -41,6 +41,7 @@ import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.UserInfo; import android.content.res.Configuration; import android.database.ContentObserver; +import android.graphics.PointF; import android.graphics.Rect; import android.os.AsyncTask; import android.os.Build; @@ -51,6 +52,7 @@ import android.os.Message; import android.os.PowerManager; import android.os.RemoteException; import android.os.ServiceManager; +import android.os.SystemClock; import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserManager; @@ -316,9 +318,16 @@ public abstract class BaseStatusBar extends SystemUI implements }; private RemoteViews.OnClickHandler mOnClickHandler = new RemoteViews.OnClickHandler() { + private final int[] mTmpInt2 = new int[2]; + @Override public boolean onClickHandler( final View view, final PendingIntent pendingIntent, final Intent fillInIntent) { + view.getLocationInWindow(mTmpInt2); + wakeUpIfDozing(SystemClock.uptimeMillis(), new PointF( + mTmpInt2[0] + view.getWidth() / 2, mTmpInt2[1] + view.getHeight() / 2)); + + if (handleRemoteInput(view, pendingIntent, fillInIntent)) { return true; } @@ -1785,13 +1794,22 @@ public abstract class BaseStatusBar extends SystemUI implements return false; } + public void wakeUpIfDozing(long time, PointF where) { + } + private final class NotificationClicker implements View.OnClickListener { + private final int[] mTmpInt2 = new int[2]; + public void onClick(final View v) { if (!(v instanceof ExpandableNotificationRow)) { Log.e(TAG, "NotificationClicker called on a view that is not a notification row."); return; } + v.getLocationInWindow(mTmpInt2); + wakeUpIfDozing(SystemClock.uptimeMillis(), + new PointF(mTmpInt2[0] + v.getWidth() / 2, mTmpInt2[1] + v.getHeight() / 2)); + final ExpandableNotificationRow row = (ExpandableNotificationRow) v; final StatusBarNotification sbn = row.getStatusBarNotification(); if (sbn == null) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index cb9fbb9694466..2a96db8fd159b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -4605,12 +4605,13 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, return !mNotificationData.getActiveNotifications().isEmpty(); } - public void wakeUpIfDozing(long time, MotionEvent event) { + @Override + public void wakeUpIfDozing(long time, PointF where) { if (mDozing && mDozeScrimController.isPulsing()) { PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); pm.wakeUp(time, "com.android.systemui:NODOZE"); mWakeUpComingFromTouch = true; - mWakeUpTouchLocation = new PointF(event.getX(), event.getY()); + mWakeUpTouchLocation = where; mNotificationPanel.setTouchDisabled(false); mStatusBarKeyguardViewManager.notifyDeviceWakeUpRequested(); mFalsingManager.onScreenOnFromTouch(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java index 1b73a3f53997e..aa29e43be4677 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java @@ -263,12 +263,9 @@ public class StatusBarWindowView extends FrameLayout { if (mNotificationPanel.isFullyExpanded() && mStackScrollLayout.getVisibility() == View.VISIBLE && mService.getBarState() == StatusBarState.KEYGUARD - && !mService.isBouncerShowing()) { + && !mService.isBouncerShowing() + && !mService.isDozing()) { intercept = mDragDownHelper.onInterceptTouchEvent(ev); - // wake up on a touch down event, if dozing - if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) { - mService.wakeUpIfDozing(ev.getEventTime(), ev); - } } if (!intercept) { super.onInterceptTouchEvent(ev);