diff options
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java | 116 |
1 files changed, 88 insertions, 28 deletions
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 81d9bf4..9c817fd 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -22,7 +22,10 @@ import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.animation.ValueAnimator; import android.content.ContentResolver; +import android.app.ActivityManager; +import android.app.StatusBarManager; import android.content.Context; +import android.content.pm.ResolveInfo; import android.content.res.Configuration; import android.database.ContentObserver; import android.graphics.Canvas; @@ -68,6 +71,8 @@ import com.android.systemui.statusbar.policy.KeyguardUserSwitcher; import com.android.systemui.statusbar.stack.NotificationStackScrollLayout; import com.android.systemui.statusbar.stack.StackStateAnimator; +import java.util.List; + public class NotificationPanelView extends PanelView implements ExpandableView.OnHeightChangedListener, ObservableScrollView.Listener, View.OnClickListener, NotificationStackScrollLayout.OnOverscrollTopChangedListener, @@ -113,12 +118,6 @@ public class NotificationPanelView extends PanelView implements private boolean mQsTracking; /** - * Handles launching the secure camera properly even when other applications may be using the - * camera hardware. - */ - private SecureCameraLaunchManager mSecureCameraLaunchManager; - - /** * If set, the ongoing touch gesture might both trigger the expansion in {@link PanelView} and * the expansion for quick settings. */ @@ -210,6 +209,8 @@ public class NotificationPanelView extends PanelView implements private int mLastOrientation = -1; private boolean mClosingWithAlphaFadeOut; private boolean mHeadsUpAnimatingAway; + private boolean mLaunchingAffordance; + private String mLastCameraLaunchSource = KeyguardBottomAreaView.CAMERA_LAUNCH_SOURCE_AFFORDANCE; private Runnable mHeadsUpExistenceChangedRunnable = new Runnable() { @Override @@ -282,8 +283,6 @@ public class NotificationPanelView extends PanelView implements mKeyguardBottomArea = (KeyguardBottomAreaView) findViewById(R.id.keyguard_bottom_area); mQsNavbarScrim = findViewById(R.id.qs_navbar_scrim); mAfforanceHelper = new KeyguardAffordanceHelper(this, getContext()); - mSecureCameraLaunchManager = - new SecureCameraLaunchManager(getContext(), mKeyguardBottomArea); mLastOrientation = getResources().getConfiguration().orientation; // recompute internal state when qspanel height changes @@ -389,19 +388,6 @@ public class NotificationPanelView extends PanelView implements updateMaxHeadsUpTranslation(); } - @Override - public void onAttachedToWindow() { - mSecureCameraLaunchManager.create(); - mSettingsObserver.observe(); - - } - - @Override - public void onDetachedFromWindow() { - mSecureCameraLaunchManager.destroy(); - mSettingsObserver.unobserve(); - } - private void startQsSizeChangeAnimation(int oldHeight, final int newHeight) { if (mQsSizeChangeAnimator != null) { oldHeight = (int) mQsSizeChangeAnimator.getAnimatedValue(); @@ -518,7 +504,10 @@ public class NotificationPanelView extends PanelView implements mIsLaunchTransitionFinished = false; mBlockTouches = false; mUnlockIconActive = false; - mAfforanceHelper.reset(true); + if (!mLaunchingAffordance) { + mAfforanceHelper.reset(false); + mLastCameraLaunchSource = KeyguardBottomAreaView.CAMERA_LAUNCH_SOURCE_AFFORDANCE; + } closeQs(); mStatusBar.dismissPopups(); mNotificationStackScroller.setOverScrollAmount(0f, true /* onTop */, false /* animate */, @@ -959,7 +948,7 @@ public class NotificationPanelView extends PanelView implements } private int getFalsingThreshold() { - float factor = mStatusBar.isScreenOnComingFromTouch() ? 1.5f : 1.0f; + float factor = mStatusBar.isWakeUpComingFromTouch() ? 1.5f : 1.0f; return (int) (mQsFalsingThreshold * factor); } @@ -2006,9 +1995,13 @@ public class NotificationPanelView extends PanelView implements EventLogConstants.SYSUI_LOCKSCREEN_GESTURE_SWIPE_DIALER, lengthDp, velocityDp); mKeyguardBottomArea.launchLeftAffordance(); } else { - EventLogTags.writeSysuiLockscreenGesture( - EventLogConstants.SYSUI_LOCKSCREEN_GESTURE_SWIPE_CAMERA, lengthDp, velocityDp); - mSecureCameraLaunchManager.startSecureCameraLaunch(); + if (KeyguardBottomAreaView.CAMERA_LAUNCH_SOURCE_AFFORDANCE.equals( + mLastCameraLaunchSource)) { + EventLogTags.writeSysuiLockscreenGesture( + EventLogConstants.SYSUI_LOCKSCREEN_GESTURE_SWIPE_CAMERA, + lengthDp, velocityDp); + } + mKeyguardBottomArea.launchCamera(mLastCameraLaunchSource); } mStatusBar.startLaunchTransitionTimeout(); mBlockTouches = true; @@ -2055,7 +2048,6 @@ public class NotificationPanelView extends PanelView implements boolean camera = getLayoutDirection() == LAYOUT_DIRECTION_RTL ? !rightIcon : rightIcon; if (camera) { - mSecureCameraLaunchManager.onSwipingStarted(); mKeyguardBottomArea.bindCameraPrewarmService(); } requestDisallowInterceptTouchEvent(true); @@ -2128,7 +2120,7 @@ public class NotificationPanelView extends PanelView implements @Override public float getAffordanceFalsingFactor() { - return mStatusBar.isScreenOnComingFromTouch() ? 1.5f : 1.0f; + return mStatusBar.isWakeUpComingFromTouch() ? 1.5f : 1.0f; } @Override @@ -2484,4 +2476,72 @@ public class NotificationPanelView extends PanelView implements resolver, Settings.System.DOUBLE_TAP_SLEEP_GESTURE, 1) == 1; } } + + @Override + public boolean hasOverlappingRendering() { + return !mDozing; + } + + public void launchCamera(boolean animate, int source) { + if (source == StatusBarManager.CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP) { + mLastCameraLaunchSource = KeyguardBottomAreaView.CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP; + } else if (source == StatusBarManager.CAMERA_LAUNCH_SOURCE_WIGGLE) { + mLastCameraLaunchSource = KeyguardBottomAreaView.CAMERA_LAUNCH_SOURCE_WIGGLE; + } else { + + // Default. + mLastCameraLaunchSource = KeyguardBottomAreaView.CAMERA_LAUNCH_SOURCE_AFFORDANCE; + } + + // If we are launching it when we are occluded already we don't want it to animate, + // nor setting these flags, since the occluded state doesn't change anymore, hence it's + // never reset. + if (!isFullyCollapsed()) { + mLaunchingAffordance = true; + setLaunchingAffordance(true); + } else { + animate = false; + } + mAfforanceHelper.launchAffordance(animate, getLayoutDirection() == LAYOUT_DIRECTION_RTL); + } + + public void onAffordanceLaunchEnded() { + mLaunchingAffordance = false; + setLaunchingAffordance(false); + } + + /** + * Set whether we are currently launching an affordance. This is currently only set when + * launched via a camera gesture. + */ + private void setLaunchingAffordance(boolean launchingAffordance) { + getLeftIcon().setLaunchingAffordance(launchingAffordance); + getRightIcon().setLaunchingAffordance(launchingAffordance); + getCenterIcon().setLaunchingAffordance(launchingAffordance); + } + + /** + * Whether the camera application can be launched for the camera launch gesture. + * + * @param keyguardIsShowing whether keyguard is being shown + */ + public boolean canCameraGestureBeLaunched(boolean keyguardIsShowing) { + ResolveInfo resolveInfo = mKeyguardBottomArea.resolveCameraIntent(); + String packageToLaunch = (resolveInfo == null || resolveInfo.activityInfo == null) + ? null : resolveInfo.activityInfo.packageName; + return packageToLaunch != null && + (keyguardIsShowing || !isForegroundApp(packageToLaunch)) && + !mAfforanceHelper.isSwipingInProgress(); + } + + /** + * Return true if the applications with the package name is running in foreground. + * + * @param pkgName application package name. + */ + private boolean isForegroundApp(String pkgName) { + ActivityManager am = getContext().getSystemService(ActivityManager.class); + List<ActivityManager.RunningTaskInfo> tasks = am.getRunningTasks(1); + return !tasks.isEmpty() && pkgName.equals(tasks.get(0).topActivity.getPackageName()); + } } |