diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2019-07-25 04:12:51 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2019-07-25 04:12:51 +0000 |
commit | 7f91561b59d74fa9a495ab94c0568c467e13e8e3 (patch) | |
tree | 5b22775c58c5b7abf7ad9cea5662be30bcb6f226 | |
parent | 05c1c7a8186e763efcd680be2c681b45783b305b (diff) | |
parent | 9c9c2893c2513498fc23f0b66049276d95038e02 (diff) | |
download | base-7f91561b59d74fa9a495ab94c0568c467e13e8e3.tar.gz |
Merge cherrypicks of [8828839, 8824129, 8828883, 8828885, 8828888, 8828891, 8829076, 8828998, 8828999, 8828607, 8828957] into qt-release
Change-Id: If570741fe9a0b40e60b4da0765f117d9841d3bea
19 files changed, 293 insertions, 74 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index bf6191ec61eb..1275e46ed421 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -967,6 +967,19 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ static boolean sBrokenInsetsDispatch; + /** + * Prior to Q, calling + * {@link com.android.internal.policy.DecorView#setBackgroundDrawable(Drawable)} + * did not call update the window format so the opacity of the background was not correctly + * applied to the window. Some applications rely on this misbehavior to work properly. + * <p> + * From Q, {@link com.android.internal.policy.DecorView#setBackgroundDrawable(Drawable)} is + * the same as {@link com.android.internal.policy.DecorView#setWindowBackground(Drawable)} + * which updates the window format. + * @hide + */ + protected static boolean sBrokenWindowBackground; + /** @hide */ @IntDef({NOT_FOCUSABLE, FOCUSABLE, FOCUSABLE_AUTO}) @Retention(RetentionPolicy.SOURCE) @@ -5104,6 +5117,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, sBrokenInsetsDispatch = ViewRootImpl.sNewInsetsMode != NEW_INSETS_MODE_FULL || targetSdkVersion < Build.VERSION_CODES.Q; + sBrokenWindowBackground = targetSdkVersion < Build.VERSION_CODES.Q; + sCompatibilityDone = true; } } diff --git a/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java b/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java index 4daddfbfb204..8dc47a401580 100644 --- a/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java +++ b/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java @@ -186,6 +186,89 @@ public final class SystemUiDeviceConfigFlags { */ public static final String BRIGHTLINE_FALSING_MANAGER_ENABLED = "brightline_falsing_manager_enabled"; + /** + * (float) Maximum fraction of the screen required to qualify as a real swipe. + */ + public static final String BRIGHTLINE_FALSING_DISTANCE_SCREEN_FRACTION_MAX_DISTANCE = + "brightline_falsing_distance_screen_fraction_max_distance"; + + /** + * (float) Multiplier for swipe velocity to convert it to pixels for a fling. + */ + public static final String BRIGHTLINE_FALSING_DISTANCE_VELOCITY_TO_DISTANCE = + "brightline_falsing_distance_velcoity_to_distance"; + + /** + * (float) How far, in inches, must a fling travel horizontally to qualify as intentional. + */ + public static final String BRIGHTLINE_FALSING_DISTANCE_HORIZONTAL_FLING_THRESHOLD_IN = + "brightline_falsing_distance_horizontal_fling_threshold_in"; + + /** + * (float) Maximum fraction of the screen required to qualify as a real swipe. + */ + public static final String BRIGHTLINE_FALSING_DISTANCE_VERTICAL_FLING_THRESHOLD_IN = + "brightline_falsing_distance_vertical_fling_threshold_in"; + + /** + * (float) How far, in inches, must a continuous swipe travel horizontally to be intentional. + */ + public static final String BRIGHTLINE_FALSING_DISTANCE_HORIZONTAL_SWIPE_THRESHOLD_IN = + "brightline_falsing_distance_horizontal_swipe_threshold_in"; + + /** + * (float) How far, in inches, must a continuous swipe travel vertically to be intentional. + */ + public static final String BRIGHTLINE_FALSING_DISTANCE_VERTICAL_SWIPE_THRESHOLD_IN = + "brightline_falsing_distance_horizontal_swipe_threshold_in"; + + /** + * (float) Percentage of swipe with the proximity sensor covered that triggers a higher + * swipe distance requirement. + */ + public static final String BRIGHTLINE_FALSING_PROXIMITY_PERCENT_COVERED_THRESHOLD = + "brightline_falsing_proximity_percent_covered_threshold"; + + /** + * (float) Angle, in radians, that a swipe can vary from horizontal and sill be intentional. + */ + public static final String BRIGHTLINE_FALSING_DIAGONAL_HORIZONTAL_ANGLE_RANGE = + "brightline_falsing_diagonal_horizontal_angle_range"; + + /** + * (float) Angle, in radians, that a swipe can vary from vertical and sill be intentional. + */ + public static final String BRIGHTLINE_FALSING_DIAGONAL_VERTICAL_ANGLE_RANGE = + "brightline_falsing_diagonal_horizontal_angle_range"; + + /** + * (float) Distance, in inches, that a swipe is allowed to vary in the horizontal direction for + * horizontal swipes. + */ + public static final String BRIGHTLINE_FALSING_ZIGZAG_X_PRIMARY_DEVIANCE = + "brightline_falsing_zigzag_x_primary_deviance"; + + /** + * (float) Distance, in inches, that a swipe is allowed to vary in the vertical direction for + * vertical swipes. + */ + public static final String BRIGHTLINE_FALSING_ZIGZAG_Y_PRIMARY_DEVIANCE = + "brightline_falsing_zigzag_y_primary_deviance"; + + /** + * (float) Distance, in inches, that a swipe is allowed to vary in the horizontal direction for + * horizontal swipes. + */ + public static final String BRIGHTLINE_FALSING_ZIGZAG_X_SECONDARY_DEVIANCE = + "brightline_falsing_zigzag_x_secondary_deviance"; + + /** + * (float) Distance, in inches, that a swipe is allowed to vary in the vertical direction for + * vertical swipes. + */ + public static final String BRIGHTLINE_FALSING_ZIGZAG_Y_SECONDARY_DEVIANCE = + "brightline_falsing_zigzag_y_secondary_deviance"; + private SystemUiDeviceConfigFlags() { } } diff --git a/core/java/com/android/internal/policy/DecorView.java b/core/java/com/android/internal/policy/DecorView.java index fe66cf9aab7d..7c52a40d4494 100644 --- a/core/java/com/android/internal/policy/DecorView.java +++ b/core/java/com/android/internal/policy/DecorView.java @@ -983,13 +983,14 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind @Override public void setBackgroundDrawable(Drawable background) { - // TODO: This should route through setWindowBackground, but late in the release to make this // change. if (mOriginalBackgroundDrawable != background) { mOriginalBackgroundDrawable = background; updateBackgroundDrawable(); - drawableChanged(); + if (!View.sBrokenWindowBackground) { + drawableChanged(); + } } } diff --git a/packages/SystemUI/src/com/android/systemui/classifier/brightline/BrightLineFalsingManager.java b/packages/SystemUI/src/com/android/systemui/classifier/brightline/BrightLineFalsingManager.java index 3d869bcc2e4b..6280c9f7c00f 100644 --- a/packages/SystemUI/src/com/android/systemui/classifier/brightline/BrightLineFalsingManager.java +++ b/packages/SystemUI/src/com/android/systemui/classifier/brightline/BrightLineFalsingManager.java @@ -98,10 +98,12 @@ public class BrightLineFalsingManager implements FalsingManager { } private void sessionStart() { - logDebug("Starting Session"); - mSessionStarted = true; - registerSensors(); - mClassifiers.forEach(FalsingClassifier::onSessionStarted); + if (!mSessionStarted) { + logDebug("Starting Session"); + mSessionStarted = true; + registerSensors(); + mClassifiers.forEach(FalsingClassifier::onSessionStarted); + } } private void sessionEnd() { diff --git a/packages/SystemUI/src/com/android/systemui/classifier/brightline/DiagonalClassifier.java b/packages/SystemUI/src/com/android/systemui/classifier/brightline/DiagonalClassifier.java index 730907e1fa9c..cc6645415fd8 100644 --- a/packages/SystemUI/src/com/android/systemui/classifier/brightline/DiagonalClassifier.java +++ b/packages/SystemUI/src/com/android/systemui/classifier/brightline/DiagonalClassifier.java @@ -16,9 +16,13 @@ package com.android.systemui.classifier.brightline; +import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_DIAGONAL_HORIZONTAL_ANGLE_RANGE; +import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_DIAGONAL_VERTICAL_ANGLE_RANGE; import static com.android.systemui.classifier.Classifier.LEFT_AFFORDANCE; import static com.android.systemui.classifier.Classifier.RIGHT_AFFORDANCE; +import android.provider.DeviceConfig; + /** * False on swipes that are too close to 45 degrees. * @@ -35,8 +39,20 @@ class DiagonalClassifier extends FalsingClassifier { private static final float ONE_HUNDRED_EIGHTY_DEG = (float) (Math.PI); private static final float THREE_HUNDRED_SIXTY_DEG = (float) (2 * Math.PI); + private final float mHorizontalAngleRange; + private final float mVerticalAngleRange; + DiagonalClassifier(FalsingDataProvider dataProvider) { super(dataProvider); + + mHorizontalAngleRange = DeviceConfig.getFloat( + DeviceConfig.NAMESPACE_SYSTEMUI, + BRIGHTLINE_FALSING_DIAGONAL_HORIZONTAL_ANGLE_RANGE, + HORIZONTAL_ANGLE_RANGE); + mVerticalAngleRange = DeviceConfig.getFloat( + DeviceConfig.NAMESPACE_SYSTEMUI, + BRIGHTLINE_FALSING_DIAGONAL_VERTICAL_ANGLE_RANGE, + VERTICAL_ANGLE_RANGE); } @Override @@ -52,11 +68,11 @@ class DiagonalClassifier extends FalsingClassifier { return false; } - float minAngle = DIAGONAL - HORIZONTAL_ANGLE_RANGE; - float maxAngle = DIAGONAL + HORIZONTAL_ANGLE_RANGE; + float minAngle = DIAGONAL - mHorizontalAngleRange; + float maxAngle = DIAGONAL + mHorizontalAngleRange; if (isVertical()) { - minAngle = DIAGONAL - VERTICAL_ANGLE_RANGE; - maxAngle = DIAGONAL + VERTICAL_ANGLE_RANGE; + minAngle = DIAGONAL - mVerticalAngleRange; + maxAngle = DIAGONAL + mVerticalAngleRange; } return angleBetween(angle, minAngle, maxAngle) diff --git a/packages/SystemUI/src/com/android/systemui/classifier/brightline/DistanceClassifier.java b/packages/SystemUI/src/com/android/systemui/classifier/brightline/DistanceClassifier.java index 005ee12c4f61..a6a617dc51de 100644 --- a/packages/SystemUI/src/com/android/systemui/classifier/brightline/DistanceClassifier.java +++ b/packages/SystemUI/src/com/android/systemui/classifier/brightline/DistanceClassifier.java @@ -16,6 +16,14 @@ package com.android.systemui.classifier.brightline; +import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_DISTANCE_HORIZONTAL_FLING_THRESHOLD_IN; +import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_DISTANCE_HORIZONTAL_SWIPE_THRESHOLD_IN; +import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_DISTANCE_SCREEN_FRACTION_MAX_DISTANCE; +import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_DISTANCE_VELOCITY_TO_DISTANCE; +import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_DISTANCE_VERTICAL_FLING_THRESHOLD_IN; +import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_DISTANCE_VERTICAL_SWIPE_THRESHOLD_IN; + +import android.provider.DeviceConfig; import android.view.MotionEvent; import android.view.VelocityTracker; @@ -31,12 +39,13 @@ class DistanceClassifier extends FalsingClassifier { private static final float HORIZONTAL_SWIPE_THRESHOLD_DISTANCE_IN = 3; private static final float VERTICAL_SWIPE_THRESHOLD_DISTANCE_IN = 3; private static final float VELOCITY_TO_DISTANCE = 80f; - private static final float SCREEN_FRACTION_MIN_DISTANCE = 0.8f; + private static final float SCREEN_FRACTION_MAX_DISTANCE = 0.8f; private final float mVerticalFlingThresholdPx; private final float mHorizontalFlingThresholdPx; private final float mVerticalSwipeThresholdPx; private final float mHorizontalSwipeThresholdPx; + private final float mVelocityToDistanceMultiplier; private boolean mDistanceDirty; private DistanceVectors mCachedDistance; @@ -44,18 +53,48 @@ class DistanceClassifier extends FalsingClassifier { DistanceClassifier(FalsingDataProvider dataProvider) { super(dataProvider); + mVelocityToDistanceMultiplier = DeviceConfig.getFloat( + DeviceConfig.NAMESPACE_SYSTEMUI, + BRIGHTLINE_FALSING_DISTANCE_VELOCITY_TO_DISTANCE, + VELOCITY_TO_DISTANCE); + + float horizontalFlingThresholdIn = DeviceConfig.getFloat( + DeviceConfig.NAMESPACE_SYSTEMUI, + BRIGHTLINE_FALSING_DISTANCE_HORIZONTAL_FLING_THRESHOLD_IN, + HORIZONTAL_FLING_THRESHOLD_DISTANCE_IN); + + float verticalFlingThresholdIn = DeviceConfig.getFloat( + DeviceConfig.NAMESPACE_SYSTEMUI, + BRIGHTLINE_FALSING_DISTANCE_VERTICAL_FLING_THRESHOLD_IN, + VERTICAL_FLING_THRESHOLD_DISTANCE_IN); + + float horizontalSwipeThresholdIn = DeviceConfig.getFloat( + DeviceConfig.NAMESPACE_SYSTEMUI, + BRIGHTLINE_FALSING_DISTANCE_HORIZONTAL_SWIPE_THRESHOLD_IN, + HORIZONTAL_SWIPE_THRESHOLD_DISTANCE_IN); + + float verticalSwipeThresholdIn = DeviceConfig.getFloat( + DeviceConfig.NAMESPACE_SYSTEMUI, + BRIGHTLINE_FALSING_DISTANCE_VERTICAL_SWIPE_THRESHOLD_IN, + VERTICAL_SWIPE_THRESHOLD_DISTANCE_IN); + + float screenFractionMaxDistance = DeviceConfig.getFloat( + DeviceConfig.NAMESPACE_SYSTEMUI, + BRIGHTLINE_FALSING_DISTANCE_SCREEN_FRACTION_MAX_DISTANCE, + SCREEN_FRACTION_MAX_DISTANCE); + mHorizontalFlingThresholdPx = Math - .min(getWidthPixels() * SCREEN_FRACTION_MIN_DISTANCE, - HORIZONTAL_FLING_THRESHOLD_DISTANCE_IN * getXdpi()); + .min(getWidthPixels() * screenFractionMaxDistance, + horizontalFlingThresholdIn * getXdpi()); mVerticalFlingThresholdPx = Math - .min(getHeightPixels() * SCREEN_FRACTION_MIN_DISTANCE, - VERTICAL_FLING_THRESHOLD_DISTANCE_IN * getYdpi()); + .min(getHeightPixels() * screenFractionMaxDistance, + verticalFlingThresholdIn * getYdpi()); mHorizontalSwipeThresholdPx = Math - .min(getWidthPixels() * SCREEN_FRACTION_MIN_DISTANCE, - HORIZONTAL_SWIPE_THRESHOLD_DISTANCE_IN * getXdpi()); + .min(getWidthPixels() * screenFractionMaxDistance, + horizontalSwipeThresholdIn * getXdpi()); mVerticalSwipeThresholdPx = Math - .min(getHeightPixels() * SCREEN_FRACTION_MIN_DISTANCE, - VERTICAL_SWIPE_THRESHOLD_DISTANCE_IN * getYdpi()); + .min(getHeightPixels() * screenFractionMaxDistance, + verticalSwipeThresholdIn * getYdpi()); mDistanceDirty = true; } @@ -139,18 +178,18 @@ class DistanceClassifier extends FalsingClassifier { } boolean getPassedFlingThreshold() { - float dX = this.mDx + this.mVx * VELOCITY_TO_DISTANCE; - float dY = this.mDy + this.mVy * VELOCITY_TO_DISTANCE; + float dX = this.mDx + this.mVx * mVelocityToDistanceMultiplier; + float dY = this.mDy + this.mVy * mVelocityToDistanceMultiplier; if (isHorizontal()) { logDebug("Horizontal swipe and fling distance: " + this.mDx + ", " - + this.mVx * VELOCITY_TO_DISTANCE); + + this.mVx * mVelocityToDistanceMultiplier); logDebug("Threshold: " + mHorizontalFlingThresholdPx); return Math.abs(dX) >= mHorizontalFlingThresholdPx; } logDebug("Vertical swipe and fling distance: " + this.mDy + ", " - + this.mVy * VELOCITY_TO_DISTANCE); + + this.mVy * mVelocityToDistanceMultiplier); logDebug("Threshold: " + mVerticalFlingThresholdPx); return Math.abs(dY) >= mVerticalFlingThresholdPx; } diff --git a/packages/SystemUI/src/com/android/systemui/classifier/brightline/ProximityClassifier.java b/packages/SystemUI/src/com/android/systemui/classifier/brightline/ProximityClassifier.java index 94a8ac85b724..2644bf9f26ce 100644 --- a/packages/SystemUI/src/com/android/systemui/classifier/brightline/ProximityClassifier.java +++ b/packages/SystemUI/src/com/android/systemui/classifier/brightline/ProximityClassifier.java @@ -16,10 +16,12 @@ package com.android.systemui.classifier.brightline; +import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_PROXIMITY_PERCENT_COVERED_THRESHOLD; import static com.android.systemui.classifier.Classifier.QUICK_SETTINGS; import android.hardware.Sensor; import android.hardware.SensorEvent; +import android.provider.DeviceConfig; import android.view.MotionEvent; @@ -31,8 +33,9 @@ import android.view.MotionEvent; */ class ProximityClassifier extends FalsingClassifier { - private static final double PERCENT_COVERED_THRESHOLD = 0.1; + private static final float PERCENT_COVERED_THRESHOLD = 0.1f; private final DistanceClassifier mDistanceClassifier; + private final float mPercentCoveredThreshold; private boolean mNear; private long mGestureStartTimeNs; @@ -44,6 +47,11 @@ class ProximityClassifier extends FalsingClassifier { FalsingDataProvider dataProvider) { super(dataProvider); this.mDistanceClassifier = distanceClassifier; + + mPercentCoveredThreshold = DeviceConfig.getFloat( + DeviceConfig.NAMESPACE_SYSTEMUI, + BRIGHTLINE_FALSING_PROXIMITY_PERCENT_COVERED_THRESHOLD, + PERCENT_COVERED_THRESHOLD); } @Override @@ -107,7 +115,7 @@ class ProximityClassifier extends FalsingClassifier { logInfo("Percent of gesture in proximity: " + mPercentNear); - if (mPercentNear > PERCENT_COVERED_THRESHOLD) { + if (mPercentNear > mPercentCoveredThreshold) { return !mDistanceClassifier.isLongSwipe(); } diff --git a/packages/SystemUI/src/com/android/systemui/classifier/brightline/ZigZagClassifier.java b/packages/SystemUI/src/com/android/systemui/classifier/brightline/ZigZagClassifier.java index a62574f26399..c58b7db451b0 100644 --- a/packages/SystemUI/src/com/android/systemui/classifier/brightline/ZigZagClassifier.java +++ b/packages/SystemUI/src/com/android/systemui/classifier/brightline/ZigZagClassifier.java @@ -16,7 +16,13 @@ package com.android.systemui.classifier.brightline; +import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_ZIGZAG_X_PRIMARY_DEVIANCE; +import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_ZIGZAG_X_SECONDARY_DEVIANCE; +import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_ZIGZAG_Y_PRIMARY_DEVIANCE; +import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BRIGHTLINE_FALSING_ZIGZAG_Y_SECONDARY_DEVIANCE; + import android.graphics.Point; +import android.provider.DeviceConfig; import android.view.MotionEvent; import java.util.ArrayList; @@ -37,8 +43,34 @@ class ZigZagClassifier extends FalsingClassifier { private static final float MAX_X_SECONDARY_DEVIANCE = .3f; private static final float MAX_Y_SECONDARY_DEVIANCE = .3f; + private final float mMaxXPrimaryDeviance; + private final float mMaxYPrimaryDeviance; + private final float mMaxXSecondaryDeviance; + private final float mMaxYSecondaryDeviance; + ZigZagClassifier(FalsingDataProvider dataProvider) { super(dataProvider); + + mMaxXPrimaryDeviance = DeviceConfig.getFloat( + DeviceConfig.NAMESPACE_SYSTEMUI, + BRIGHTLINE_FALSING_ZIGZAG_X_PRIMARY_DEVIANCE, + MAX_X_PRIMARY_DEVIANCE); + + mMaxYPrimaryDeviance = DeviceConfig.getFloat( + DeviceConfig.NAMESPACE_SYSTEMUI, + BRIGHTLINE_FALSING_ZIGZAG_Y_PRIMARY_DEVIANCE, + MAX_Y_PRIMARY_DEVIANCE); + + mMaxXSecondaryDeviance = DeviceConfig.getFloat( + DeviceConfig.NAMESPACE_SYSTEMUI, + BRIGHTLINE_FALSING_ZIGZAG_X_SECONDARY_DEVIANCE, + MAX_X_SECONDARY_DEVIANCE); + + mMaxYSecondaryDeviance = DeviceConfig.getFloat( + DeviceConfig.NAMESPACE_SYSTEMUI, + BRIGHTLINE_FALSING_ZIGZAG_Y_SECONDARY_DEVIANCE, + MAX_Y_SECONDARY_DEVIANCE); + } @Override @@ -98,11 +130,11 @@ class ZigZagClassifier extends FalsingClassifier { float maxXDeviance; float maxYDeviance; if (actualDx > actualDy) { - maxXDeviance = MAX_X_PRIMARY_DEVIANCE * totalDistanceIn * getXdpi(); - maxYDeviance = MAX_Y_SECONDARY_DEVIANCE * totalDistanceIn * getYdpi(); + maxXDeviance = mMaxXPrimaryDeviance * totalDistanceIn * getXdpi(); + maxYDeviance = mMaxYSecondaryDeviance * totalDistanceIn * getYdpi(); } else { - maxXDeviance = MAX_X_SECONDARY_DEVIANCE * totalDistanceIn * getXdpi(); - maxYDeviance = MAX_Y_PRIMARY_DEVIANCE * totalDistanceIn * getYdpi(); + maxXDeviance = mMaxXSecondaryDeviance * totalDistanceIn * getXdpi(); + maxYDeviance = mMaxYPrimaryDeviance * totalDistanceIn * getYdpi(); } logDebug("Straightness Deviance: (" + devianceX + "," + devianceY + ") vs " diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManager.java index 0fe5f8a6af5a..4cc5b2144adc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManager.java @@ -15,7 +15,6 @@ package com.android.systemui.statusbar; import android.content.pm.UserInfo; -import android.service.notification.StatusBarNotification; import android.util.SparseArray; import com.android.systemui.statusbar.notification.collection.NotificationEntry; @@ -58,7 +57,7 @@ public interface NotificationLockscreenUserManager { boolean shouldHideNotifications(int userId); boolean shouldHideNotifications(String key); - boolean shouldShowOnKeyguard(StatusBarNotification sbn); + boolean shouldShowOnKeyguard(NotificationEntry entry); boolean isAnyProfilePublicMode(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java index 4ea1ed5b9451..e08a5ae07bd8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java @@ -33,7 +33,6 @@ import android.os.ServiceManager; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; -import android.service.notification.StatusBarNotification; import android.util.Log; import android.util.SparseArray; import android.util.SparseBooleanArray; @@ -302,7 +301,7 @@ public class NotificationLockscreenUserManagerImpl implements Notification.VISIBILITY_SECRET; } - public boolean shouldShowOnKeyguard(StatusBarNotification sbn) { + public boolean shouldShowOnKeyguard(NotificationEntry entry) { if (getEntryManager() == null) { Log.wtf(TAG, "mEntryManager was null!", new Throwable()); return false; @@ -310,10 +309,10 @@ public class NotificationLockscreenUserManagerImpl implements boolean exceedsPriorityThreshold; if (NotificationUtils.useNewInterruptionModel(mContext) && hideSilentNotificationsOnLockscreen()) { - exceedsPriorityThreshold = getEntryManager().getNotificationData().isHighPriority(sbn); + exceedsPriorityThreshold = entry.isTopBucket(); } else { exceedsPriorityThreshold = - !getEntryManager().getNotificationData().isAmbient(sbn.getKey()); + !getEntryManager().getNotificationData().isAmbient(entry.key); } return mShowLockscreenNotifications && exceedsPriorityThreshold; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java index 404920187351..9c3ee96fe25b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java @@ -394,15 +394,13 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle int userId = entry.notification.getUserId(); boolean suppressedSummary = mGroupManager.isSummaryOfSuppressedGroup( entry.notification) && !entry.isRowRemoved(); - boolean showOnKeyguard = mLockscreenUserManager.shouldShowOnKeyguard(entry - .notification); + boolean showOnKeyguard = mLockscreenUserManager.shouldShowOnKeyguard(entry); if (!showOnKeyguard) { // min priority notifications should show if their summary is showing if (mGroupManager.isChildInGroupWithSummary(entry.notification)) { NotificationEntry summary = mGroupManager.getLogicalGroupSummary( entry.notification); - if (summary != null && mLockscreenUserManager.shouldShowOnKeyguard( - summary.notification)) { + if (summary != null && mLockscreenUserManager.shouldShowOnKeyguard(summary)) { showOnKeyguard = true; } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationData.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationData.java index 64b2f048ce2e..13f8f1a6a548 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationData.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationData.java @@ -25,7 +25,6 @@ import android.service.notification.NotificationListenerService.RankingMap; import android.service.notification.SnoozeCriterion; import android.service.notification.StatusBarNotification; import android.util.ArrayMap; -import android.util.Slog; import com.android.internal.annotations.VisibleForTesting; import com.android.systemui.Dependency; @@ -108,10 +107,19 @@ public class NotificationData { boolean bSystemMax = bImportance >= NotificationManager.IMPORTANCE_HIGH && isSystemNotification(nb); - boolean isHeadsUp = a.getRow().isHeadsUp(); - if (isHeadsUp != b.getRow().isHeadsUp()) { - return isHeadsUp ? -1 : 1; - } else if (isHeadsUp) { + + boolean aHeadsUp = a.getRow().isHeadsUp(); + boolean bHeadsUp = b.getRow().isHeadsUp(); + + // HACK: This should really go elsewhere, but it's currently not straightforward to + // extract the comparison code and we're guaranteed to touch every element, so this is + // the best place to set the buckets for the moment. + a.setIsTopBucket(aHeadsUp || aMedia || aSystemMax || a.isHighPriority()); + b.setIsTopBucket(bHeadsUp || bMedia || bSystemMax || b.isHighPriority()); + + if (aHeadsUp != bHeadsUp) { + return aHeadsUp ? -1 : 1; + } else if (aHeadsUp) { // Provide consistent ranking with headsUpManager return mHeadsUpManager.compare(a, b); } else if (a.getRow().showingAmbientPulsing() != b.getRow().showingAmbientPulsing()) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java index 92c261c4cad7..d157f06c03e9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java @@ -173,6 +173,8 @@ public final class NotificationEntry { */ private boolean mHighPriority; + private boolean mIsTopBucket; + public NotificationEntry(StatusBarNotification n) { this(n, null); } @@ -220,6 +222,18 @@ public final class NotificationEntry { this.mHighPriority = highPriority; } + /** + * @return True if the notif should appear in the "top" or "important" section of notifications + * (as opposed to the "bottom" or "silent" section). This is usually the same as + * {@link #isHighPriority()}, but there are certain exceptions, such as media notifs. + */ + public boolean isTopBucket() { + return mIsTopBucket; + } + public void setIsTopBucket(boolean isTopBucket) { + mIsTopBucket = isTopBucket; + } + public boolean isBubble() { return (notification.getNotification().flags & FLAG_BUBBLE) != 0; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java index 170a4d570688..d119fb79e4c6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java @@ -133,7 +133,7 @@ class NotificationSectionsManager implements StackScrollAlgorithm.SectionProvide if (child instanceof ExpandableNotificationRow && child.getVisibility() != View.GONE) { ExpandableNotificationRow row = (ExpandableNotificationRow) child; - if (!row.getEntry().isHighPriority()) { + if (!row.getEntry().isTopBucket()) { firstGentleNotifIndex = i; mFirstGentleNotif = row; break; @@ -248,7 +248,7 @@ class NotificationSectionsManager implements StackScrollAlgorithm.SectionProvide View child = mParent.getChildAt(i); if (child.getVisibility() != View.GONE && child instanceof ExpandableNotificationRow) { ExpandableNotificationRow row = (ExpandableNotificationRow) child; - if (!row.getEntry().isHighPriority()) { + if (!row.getEntry().isTopBucket()) { break; } else { lastChildBeforeGap = row; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index 80e1ac10e319..09352cfd17a3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -5776,7 +5776,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd currentIndex++; boolean beforeSpeedBump; if (mHighPriorityBeforeSpeedBump) { - beforeSpeedBump = row.getEntry().isHighPriority(); + beforeSpeedBump = row.getEntry().isTopBucket(); } else { beforeSpeedBump = !row.getEntry().ambient; } @@ -5834,9 +5834,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd case ROWS_ALL: return true; case ROWS_HIGH_PRIORITY: - return row.getEntry().isHighPriority(); + return row.getEntry().isTopBucket(); case ROWS_GENTLE: - return !row.getEntry().isHighPriority(); + return !row.getEntry().isTopBucket(); default: throw new IllegalArgumentException("Unknown selection: " + selection); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index a423adfd34b7..bc205d676914 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -734,8 +734,7 @@ public class NotificationPanelView extends PanelView implements if (suppressedSummary) { continue; } - if (!mLockscreenUserManager.shouldShowOnKeyguard( - row.getStatusBarNotification())) { + if (!mLockscreenUserManager.shouldShowOnKeyguard(row.getEntry())) { continue; } if (row.isRemoved()) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java index 49a263a8d781..57dd8c94c790 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java @@ -38,7 +38,6 @@ import android.os.Handler; import android.os.Looper; import android.os.UserManager; import android.provider.Settings; -import android.service.notification.StatusBarNotification; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; @@ -48,6 +47,7 @@ import com.android.systemui.Dependency; import com.android.systemui.SysuiTestCase; import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.collection.NotificationData; +import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.statusbar.policy.DeviceProvisionedController; @@ -166,7 +166,7 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase { Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 1); when(mNotificationData.isHighPriority(any())).thenReturn(false); - assertTrue(mLockscreenUserManager.shouldShowOnKeyguard(mock(StatusBarNotification.class))); + assertTrue(mLockscreenUserManager.shouldShowOnKeyguard(mock(NotificationEntry.class))); } @Test @@ -179,7 +179,7 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase { Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0); when(mNotificationData.isHighPriority(any())).thenReturn(false); - assertFalse(mLockscreenUserManager.shouldShowOnKeyguard(mock(StatusBarNotification.class))); + assertFalse(mLockscreenUserManager.shouldShowOnKeyguard(mock(NotificationEntry.class))); } private class TestNotificationLockscreenUserManager diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java index 73abda9a5da7..59d0f912d38e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java @@ -263,6 +263,8 @@ public class NotificationSectionsManagerTest extends SysuiTestCase { when(notifRow.getVisibility()).thenReturn(View.VISIBLE); when(notifRow.getEntry().isHighPriority()) .thenReturn(children[i] == ChildType.HIPRI); + when(notifRow.getEntry().isTopBucket()) + .thenReturn(children[i] == ChildType.HIPRI); when(notifRow.getParent()).thenReturn(mNssl); child = notifRow; break; diff --git a/services/core/java/com/android/server/om/OverlayManagerServiceImpl.java b/services/core/java/com/android/server/om/OverlayManagerServiceImpl.java index 6f28675d051b..934511bf88d1 100644 --- a/services/core/java/com/android/server/om/OverlayManagerServiceImpl.java +++ b/services/core/java/com/android/server/om/OverlayManagerServiceImpl.java @@ -296,22 +296,12 @@ final class OverlayManagerServiceImpl { */ private void updateAndRefreshOverlaysForTarget(@NonNull final String targetPackageName, final int userId, final int flags) { - final List<OverlayInfo> ois = new ArrayList<>(); - - // Framework overlays added first because order matters when resolving a resource - if (!"android".equals(targetPackageName)) { - ois.addAll(mSettings.getOverlaysForTarget("android", userId)); - } - - // Then add the targeted, non-framework overlays which have higher priority - ois.addAll(mSettings.getOverlaysForTarget(targetPackageName, userId)); - - final List<String> enabledBaseCodePaths = new ArrayList<>(ois.size()); + final List<OverlayInfo> targetOverlays = mSettings.getOverlaysForTarget(targetPackageName, + userId); + // Update the state for any overlay that targets this package. boolean modified = false; - final int n = ois.size(); - for (int i = 0; i < n; i++) { - final OverlayInfo oi = ois.get(i); + for (final OverlayInfo oi : targetOverlays) { final PackageInfo overlayPackage = mPackageManager.getPackageInfo(oi.packageName, userId); if (overlayPackage == null) { @@ -324,25 +314,39 @@ final class OverlayManagerServiceImpl { Slog.e(TAG, "failed to update settings", e); modified |= mSettings.remove(oi.packageName, userId); } - - if (oi.isEnabled() && overlayPackage.applicationInfo != null) { - enabledBaseCodePaths.add(overlayPackage.applicationInfo.getBaseCodePath()); - } } } if (!modified) { + // Update the overlay paths of the target within package manager if necessary. + final List<String> enabledOverlayPaths = new ArrayList<>(targetOverlays.size()); + + // Framework overlays are first in the overlay paths of a package within PackageManager. + for (final OverlayInfo oi : mSettings.getOverlaysForTarget("android", userId)) { + if (oi.isEnabled()) { + enabledOverlayPaths.add(oi.baseCodePath); + } + } + + for (final OverlayInfo oi : targetOverlays) { + if (oi.isEnabled()) { + enabledOverlayPaths.add(oi.baseCodePath); + } + } + + // TODO(): Use getEnabledOverlayPaths(userId, targetPackageName) instead of + // resourceDirs if in the future resourceDirs contains APKs other than overlays PackageInfo packageInfo = mPackageManager.getPackageInfo(targetPackageName, userId); ApplicationInfo appInfo = packageInfo == null ? null : packageInfo.applicationInfo; String[] resourceDirs = appInfo == null ? null : appInfo.resourceDirs; // If the lists aren't the same length, the enabled overlays have changed - if (ArrayUtils.size(resourceDirs) != enabledBaseCodePaths.size()) { + if (ArrayUtils.size(resourceDirs) != enabledOverlayPaths.size()) { modified = true; } else if (resourceDirs != null) { // If any element isn't equal, an overlay or the order of overlays has changed for (int index = 0; index < resourceDirs.length; index++) { - if (!resourceDirs[index].equals(enabledBaseCodePaths.get(index))) { + if (!resourceDirs[index].equals(enabledOverlayPaths.get(index))) { modified = true; break; } |