Merge "Launching the camera now from systemUI including animations" into mnc-dr-dev

This commit is contained in:
Selim Cinek
2015-08-26 17:20:50 +00:00
committed by Android (Google) Code Review
14 changed files with 261 additions and 59 deletions

View File

@@ -69,5 +69,10 @@ oneway interface IStatusBar
void showAssistDisclosure(); void showAssistDisclosure();
void startAssist(in Bundle args); void startAssist(in Bundle args);
/**
* Notifies the status bar that a camera launch gesture has been detected.
*/
void onCameraLaunchGestureDetected();
} }

View File

@@ -64,6 +64,7 @@ public class CommandQueue extends IStatusBar.Stub {
private static final int MSG_APP_TRANSITION_STARTING = 21 << MSG_SHIFT; private static final int MSG_APP_TRANSITION_STARTING = 21 << MSG_SHIFT;
private static final int MSG_ASSIST_DISCLOSURE = 22 << MSG_SHIFT; private static final int MSG_ASSIST_DISCLOSURE = 22 << MSG_SHIFT;
private static final int MSG_START_ASSIST = 23 << MSG_SHIFT; private static final int MSG_START_ASSIST = 23 << MSG_SHIFT;
private static final int MSG_CAMERA_LAUNCH_GESTURE = 24 << MSG_SHIFT;
public static final int FLAG_EXCLUDE_NONE = 0; public static final int FLAG_EXCLUDE_NONE = 0;
public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0; public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
@@ -109,6 +110,7 @@ public class CommandQueue extends IStatusBar.Stub {
public void appTransitionStarting(long startTime, long duration); public void appTransitionStarting(long startTime, long duration);
public void showAssistDisclosure(); public void showAssistDisclosure();
public void startAssist(Bundle args); public void startAssist(Bundle args);
public void onCameraLaunchGestureDetected();
} }
public CommandQueue(Callbacks callbacks, StatusBarIconList list) { public CommandQueue(Callbacks callbacks, StatusBarIconList list) {
@@ -293,6 +295,14 @@ public class CommandQueue extends IStatusBar.Stub {
} }
} }
@Override
public void onCameraLaunchGestureDetected() {
synchronized (mList) {
mHandler.removeMessages(MSG_CAMERA_LAUNCH_GESTURE);
mHandler.obtainMessage(MSG_CAMERA_LAUNCH_GESTURE).sendToTarget();
}
}
private final class H extends Handler { private final class H extends Handler {
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
final int what = msg.what & MSG_MASK; final int what = msg.what & MSG_MASK;
@@ -391,6 +401,9 @@ public class CommandQueue extends IStatusBar.Stub {
case MSG_START_ASSIST: case MSG_START_ASSIST:
mCallbacks.startAssist((Bundle) msg.obj); mCallbacks.startAssist((Bundle) msg.obj);
break; break;
case MSG_CAMERA_LAUNCH_GESTURE:
mCallbacks.onCameraLaunchGestureDetected();
break;
} }
} }
} }

View File

@@ -36,6 +36,7 @@ import android.view.ViewAnimationUtils;
import android.view.animation.AnimationUtils; import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator; import android.view.animation.Interpolator;
import android.widget.ImageView; import android.widget.ImageView;
import com.android.systemui.R; import com.android.systemui.R;
import com.android.systemui.statusbar.phone.KeyguardAffordanceHelper; import com.android.systemui.statusbar.phone.KeyguardAffordanceHelper;
import com.android.systemui.statusbar.phone.PhoneStatusBar; import com.android.systemui.statusbar.phone.PhoneStatusBar;
@@ -79,6 +80,7 @@ public class KeyguardAffordanceView extends ImageView {
private float mRestingAlpha = KeyguardAffordanceHelper.SWIPE_RESTING_ALPHA_AMOUNT; private float mRestingAlpha = KeyguardAffordanceHelper.SWIPE_RESTING_ALPHA_AMOUNT;
private boolean mSupportHardware; private boolean mSupportHardware;
private boolean mFinishing; private boolean mFinishing;
private boolean mLaunchingAffordance;
private CanvasProperty<Float> mHwCircleRadius; private CanvasProperty<Float> mHwCircleRadius;
private CanvasProperty<Float> mHwCenterX; private CanvasProperty<Float> mHwCenterX;
@@ -152,7 +154,7 @@ public class KeyguardAffordanceView extends ImageView {
@Override @Override
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
mSupportHardware = canvas.isHardwareAccelerated(); mSupportHardware = false;//canvas.isHardwareAccelerated();
drawBackgroundCircle(canvas); drawBackgroundCircle(canvas);
canvas.save(); canvas.save();
canvas.scale(mImageScale, mImageScale, getWidth() / 2, getHeight() / 2); canvas.scale(mImageScale, mImageScale, getWidth() / 2, getHeight() / 2);
@@ -161,9 +163,11 @@ public class KeyguardAffordanceView extends ImageView {
} }
public void setPreviewView(View v) { public void setPreviewView(View v) {
View oldPreviewView = mPreviewView;
mPreviewView = v; mPreviewView = v;
if (mPreviewView != null) { if (mPreviewView != null) {
mPreviewView.setVisibility(INVISIBLE); mPreviewView.setVisibility(mLaunchingAffordance
? oldPreviewView.getVisibility() : INVISIBLE);
} }
} }
@@ -176,7 +180,7 @@ public class KeyguardAffordanceView extends ImageView {
} }
private void drawBackgroundCircle(Canvas canvas) { private void drawBackgroundCircle(Canvas canvas) {
if (mCircleRadius > 0) { if (mCircleRadius > 0 || mFinishing) {
if (mFinishing && mSupportHardware) { if (mFinishing && mSupportHardware) {
DisplayListCanvas displayListCanvas = (DisplayListCanvas) canvas; DisplayListCanvas displayListCanvas = (DisplayListCanvas) canvas;
displayListCanvas.drawCircle(mHwCenterX, mHwCenterY, mHwCircleRadius, displayListCanvas.drawCircle(mHwCenterX, mHwCenterY, mHwCircleRadius,
@@ -207,11 +211,12 @@ public class KeyguardAffordanceView extends ImageView {
cancelAnimator(mPreviewClipper); cancelAnimator(mPreviewClipper);
mFinishing = true; mFinishing = true;
mCircleStartRadius = mCircleRadius; mCircleStartRadius = mCircleRadius;
float maxCircleSize = getMaxCircleSize(); final float maxCircleSize = getMaxCircleSize();
Animator animatorToRadius; Animator animatorToRadius;
if (mSupportHardware) { if (mSupportHardware) {
initHwProperties(); initHwProperties();
animatorToRadius = getRtAnimatorToRadius(maxCircleSize); animatorToRadius = getRtAnimatorToRadius(maxCircleSize);
startRtAlphaFadeIn();
} else { } else {
animatorToRadius = getAnimatorToRadius(maxCircleSize); animatorToRadius = getAnimatorToRadius(maxCircleSize);
} }
@@ -222,6 +227,8 @@ public class KeyguardAffordanceView extends ImageView {
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
mAnimationEndRunnable.run(); mAnimationEndRunnable.run();
mFinishing = false; mFinishing = false;
mCircleRadius = maxCircleSize;
invalidate();
} }
}); });
animatorToRadius.start(); animatorToRadius.start();
@@ -241,6 +248,36 @@ public class KeyguardAffordanceView extends ImageView {
} }
} }
/**
* Fades in the Circle on the RenderThread. It's used when finishing the circle when it had
* alpha 0 in the beginning.
*/
private void startRtAlphaFadeIn() {
if (mCircleRadius == 0 && mPreviewView == null) {
Paint modifiedPaint = new Paint(mCirclePaint);
modifiedPaint.setColor(mCircleColor);
modifiedPaint.setAlpha(0);
mHwCirclePaint = CanvasProperty.createPaint(modifiedPaint);
RenderNodeAnimator animator = new RenderNodeAnimator(mHwCirclePaint,
RenderNodeAnimator.PAINT_ALPHA, 255);
animator.setTarget(this);
animator.setInterpolator(PhoneStatusBar.ALPHA_IN);
animator.setDuration(250);
animator.start();
}
}
public void instantFinishAnimation() {
cancelAnimator(mPreviewClipper);
if (mPreviewView != null) {
mPreviewView.setClipBounds(null);
mPreviewView.setVisibility(View.VISIBLE);
}
mCircleRadius = getMaxCircleSize();
setImageAlpha(0, false);
invalidate();
}
private void startRtCircleFadeOut(long duration) { private void startRtCircleFadeOut(long duration) {
RenderNodeAnimator animator = new RenderNodeAnimator(mHwCirclePaint, RenderNodeAnimator animator = new RenderNodeAnimator(mHwCirclePaint,
RenderNodeAnimator.PAINT_ALPHA, 0); RenderNodeAnimator.PAINT_ALPHA, 0);
@@ -443,6 +480,7 @@ public class KeyguardAffordanceView extends ImageView {
public void setImageAlpha(float alpha, boolean animate, long duration, public void setImageAlpha(float alpha, boolean animate, long duration,
Interpolator interpolator, Runnable runnable) { Interpolator interpolator, Runnable runnable) {
cancelAnimator(mAlphaAnimator); cancelAnimator(mAlphaAnimator);
alpha = mLaunchingAffordance ? 0 : alpha;
int endAlpha = (int) (alpha * 255); int endAlpha = (int) (alpha * 255);
final Drawable background = getBackground(); final Drawable background = getBackground();
if (!animate) { if (!animate) {
@@ -509,4 +547,8 @@ public class KeyguardAffordanceView extends ImageView {
return false; return false;
} }
} }
public void setLaunchingAffordance(boolean launchingAffordance) {
mLaunchingAffordance = launchingAffordance;
}
} }

View File

@@ -86,9 +86,9 @@ public class KeyguardAffordanceHelper {
mContext = context; mContext = context;
mCallback = callback; mCallback = callback;
initIcons(); initIcons();
updateIcon(mLeftIcon, 0.0f, mLeftIcon.getRestingAlpha(), false, false, true); updateIcon(mLeftIcon, 0.0f, mLeftIcon.getRestingAlpha(), false, false, true, false);
updateIcon(mCenterIcon, 0.0f, mCenterIcon.getRestingAlpha(), false, false, true); updateIcon(mCenterIcon, 0.0f, mCenterIcon.getRestingAlpha(), false, false, true, false);
updateIcon(mRightIcon, 0.0f, mRightIcon.getRestingAlpha(), false, false, true); updateIcon(mRightIcon, 0.0f, mRightIcon.getRestingAlpha(), false, false, true, false);
initDimens(); initDimens();
} }
@@ -144,9 +144,7 @@ public class KeyguardAffordanceHelper {
} else { } else {
mTouchSlopExeeded = false; mTouchSlopExeeded = false;
} }
mCallback.onSwipingStarted(targetView == mRightIcon); startSwiping(targetView);
mSwipingInProgress = true;
mTargetedView = targetView;
mInitialTouchX = x; mInitialTouchX = x;
mInitialTouchY = y; mInitialTouchY = y;
mTranslationOnDown = mTranslation; mTranslationOnDown = mTranslation;
@@ -192,6 +190,12 @@ public class KeyguardAffordanceHelper {
return true; return true;
} }
private void startSwiping(View targetView) {
mCallback.onSwipingStarted(targetView == mRightIcon);
mSwipingInProgress = true;
mTargetedView = targetView;
}
private View getIconAtPosition(float x, float y) { private View getIconAtPosition(float x, float y) {
if (leftSwipePossible() && isOnIcon(mLeftIcon, x, y)) { if (leftSwipePossible() && isOnIcon(mLeftIcon, x, y)) {
return mLeftIcon; return mLeftIcon;
@@ -324,7 +328,7 @@ public class KeyguardAffordanceHelper {
boolean velIsInWrongDirection = vel * mTranslation < 0; boolean velIsInWrongDirection = vel * mTranslation < 0;
snapBack |= Math.abs(vel) > mMinFlingVelocity && velIsInWrongDirection; snapBack |= Math.abs(vel) > mMinFlingVelocity && velIsInWrongDirection;
vel = snapBack ^ velIsInWrongDirection ? 0 : vel; vel = snapBack ^ velIsInWrongDirection ? 0 : vel;
fling(vel, snapBack || forceSnapBack); fling(vel, snapBack || forceSnapBack, mTranslation < 0);
} }
private boolean isBelowFalsingThreshold() { private boolean isBelowFalsingThreshold() {
@@ -336,9 +340,8 @@ public class KeyguardAffordanceHelper {
return (int) (mMinTranslationAmount * factor); return (int) (mMinTranslationAmount * factor);
} }
private void fling(float vel, final boolean snapBack) { private void fling(float vel, final boolean snapBack, boolean right) {
float target = mTranslation < 0 float target = right ? -mCallback.getMaxTranslationDistance()
? -mCallback.getMaxTranslationDistance()
: mCallback.getMaxTranslationDistance(); : mCallback.getMaxTranslationDistance();
target = snapBack ? 0 : target; target = snapBack ? 0 : target;
@@ -352,8 +355,8 @@ public class KeyguardAffordanceHelper {
}); });
animator.addListener(mFlingEndListener); animator.addListener(mFlingEndListener);
if (!snapBack) { if (!snapBack) {
startFinishingCircleAnimation(vel * 0.375f, mAnimationEndRunnable); startFinishingCircleAnimation(vel * 0.375f, mAnimationEndRunnable, right);
mCallback.onAnimationToSideStarted(mTranslation < 0, mTranslation, vel); mCallback.onAnimationToSideStarted(right, mTranslation, vel);
} else { } else {
reset(true); reset(true);
} }
@@ -364,8 +367,9 @@ public class KeyguardAffordanceHelper {
} }
} }
private void startFinishingCircleAnimation(float velocity, Runnable mAnimationEndRunnable) { private void startFinishingCircleAnimation(float velocity, Runnable mAnimationEndRunnable,
KeyguardAffordanceView targetView = mTranslation > 0 ? mLeftIcon : mRightIcon; boolean right) {
KeyguardAffordanceView targetView = right ? mRightIcon : mLeftIcon;
targetView.finishAnimation(velocity, mAnimationEndRunnable); targetView.finishAnimation(velocity, mAnimationEndRunnable);
} }
@@ -383,19 +387,20 @@ public class KeyguardAffordanceHelper {
fadeOutAlpha = Math.max(fadeOutAlpha, 0.0f); fadeOutAlpha = Math.max(fadeOutAlpha, 0.0f);
boolean animateIcons = isReset && animateReset; boolean animateIcons = isReset && animateReset;
boolean forceNoCircleAnimation = isReset && !animateReset;
float radius = getRadiusFromTranslation(absTranslation); float radius = getRadiusFromTranslation(absTranslation);
boolean slowAnimation = isReset && isBelowFalsingThreshold(); boolean slowAnimation = isReset && isBelowFalsingThreshold();
if (!isReset) { if (!isReset) {
updateIcon(targetView, radius, alpha + fadeOutAlpha * targetView.getRestingAlpha(), updateIcon(targetView, radius, alpha + fadeOutAlpha * targetView.getRestingAlpha(),
false, false, false); false, false, false, false);
} else { } else {
updateIcon(targetView, 0.0f, fadeOutAlpha * targetView.getRestingAlpha(), updateIcon(targetView, 0.0f, fadeOutAlpha * targetView.getRestingAlpha(),
animateIcons, slowAnimation, false); animateIcons, slowAnimation, false, forceNoCircleAnimation);
} }
updateIcon(otherView, 0.0f, fadeOutAlpha * otherView.getRestingAlpha(), updateIcon(otherView, 0.0f, fadeOutAlpha * otherView.getRestingAlpha(),
animateIcons, slowAnimation, false); animateIcons, slowAnimation, false, forceNoCircleAnimation);
updateIcon(mCenterIcon, 0.0f, fadeOutAlpha * mCenterIcon.getRestingAlpha(), updateIcon(mCenterIcon, 0.0f, fadeOutAlpha * mCenterIcon.getRestingAlpha(),
animateIcons, slowAnimation, false); animateIcons, slowAnimation, false, forceNoCircleAnimation);
mTranslation = translation; mTranslation = translation;
} }
@@ -431,16 +436,21 @@ public class KeyguardAffordanceHelper {
public void animateHideLeftRightIcon() { public void animateHideLeftRightIcon() {
cancelAnimation(); cancelAnimation();
updateIcon(mRightIcon, 0f, 0f, true, false, false); updateIcon(mRightIcon, 0f, 0f, true, false, false, false);
updateIcon(mLeftIcon, 0f, 0f, true, false, false); updateIcon(mLeftIcon, 0f, 0f, true, false, false, false);
} }
private void updateIcon(KeyguardAffordanceView view, float circleRadius, float alpha, private void updateIcon(KeyguardAffordanceView view, float circleRadius, float alpha,
boolean animate, boolean slowRadiusAnimation, boolean force) { boolean animate, boolean slowRadiusAnimation, boolean force,
boolean forceNoCircleAnimation) {
if (view.getVisibility() != View.VISIBLE && !force) { if (view.getVisibility() != View.VISIBLE && !force) {
return; return;
} }
if (forceNoCircleAnimation) {
view.setCircleRadiusWithoutAnimation(circleRadius);
} else {
view.setCircleRadius(circleRadius, slowRadiusAnimation); view.setCircleRadius(circleRadius, slowRadiusAnimation);
}
updateIconAlpha(view, alpha, animate); updateIconAlpha(view, alpha, animate);
} }
@@ -503,9 +513,37 @@ public class KeyguardAffordanceHelper {
mMotionCancelled = true; mMotionCancelled = true;
if (mSwipingInProgress) { if (mSwipingInProgress) {
mCallback.onSwipingAborted(); mCallback.onSwipingAborted();
}
mSwipingInProgress = false; mSwipingInProgress = false;
} }
}
public boolean isSwipingInProgress() {
return mSwipingInProgress;
}
public void launchAffordance(boolean animate, boolean left) {
if (mSwipingInProgress) {
// We don't want to mess with the state if the user is actually swiping already.
return;
}
KeyguardAffordanceView targetView = left ? mLeftIcon : mRightIcon;
KeyguardAffordanceView otherView = left ? mRightIcon : mLeftIcon;
startSwiping(targetView);
if (animate) {
fling(0, false, !left);
updateIcon(otherView, 0.0f, 0, true, false, true, false);
updateIcon(mCenterIcon, 0.0f, 0, true, false, true, false);
} else {
mCallback.onAnimationToSideStarted(!left, mTranslation, 0);
mTranslation = left ? mCallback.getMaxTranslationDistance()
: mCallback.getMaxTranslationDistance();
updateIcon(mCenterIcon, 0.0f, 0.0f, false, false, true, false);
updateIcon(otherView, 0.0f, 0.0f, false, false, true, false);
targetView.instantFinishAnimation();
mFlingEndListener.onAnimationEnd(null);
mAnimationEndRunnable.run();
}
}
public interface Callback { public interface Callback {

View File

@@ -80,7 +80,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
private static final Intent SECURE_CAMERA_INTENT = private static final Intent SECURE_CAMERA_INTENT =
new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE) new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE)
.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); .addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
private static final Intent INSECURE_CAMERA_INTENT = public static final Intent INSECURE_CAMERA_INTENT =
new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA); new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
private static final Intent PHONE_INTENT = new Intent(Intent.ACTION_DIAL); private static final Intent PHONE_INTENT = new Intent(Intent.ACTION_DIAL);
private static final int DOZE_ANIMATION_STAGGER_DELAY = 48; private static final int DOZE_ANIMATION_STAGGER_DELAY = 48;

View File

@@ -203,6 +203,7 @@ public class NotificationPanelView extends PanelView implements
private int mLastOrientation = -1; private int mLastOrientation = -1;
private boolean mClosingWithAlphaFadeOut; private boolean mClosingWithAlphaFadeOut;
private boolean mHeadsUpAnimatingAway; private boolean mHeadsUpAnimatingAway;
private boolean mLaunchingAffordance;
private Runnable mHeadsUpExistenceChangedRunnable = new Runnable() { private Runnable mHeadsUpExistenceChangedRunnable = new Runnable() {
@Override @Override
@@ -488,7 +489,9 @@ public class NotificationPanelView extends PanelView implements
mIsLaunchTransitionFinished = false; mIsLaunchTransitionFinished = false;
mBlockTouches = false; mBlockTouches = false;
mUnlockIconActive = false; mUnlockIconActive = false;
mAfforanceHelper.reset(true); if (!mLaunchingAffordance) {
mAfforanceHelper.reset(false);
}
closeQs(); closeQs();
mStatusBar.dismissPopups(); mStatusBar.dismissPopups();
mNotificationStackScroller.setOverScrollAmount(0f, true /* onTop */, false /* animate */, mNotificationStackScroller.setOverScrollAmount(0f, true /* onTop */, false /* animate */,
@@ -2393,4 +2396,36 @@ public class NotificationPanelView extends PanelView implements
public boolean hasOverlappingRendering() { public boolean hasOverlappingRendering() {
return !mDozing; return !mDozing;
} }
public void launchCamera(boolean animate) {
// 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);
}
public boolean canCameraGestureBeLaunched() {
return !mAfforanceHelper.isSwipingInProgress();
}
} }

View File

@@ -482,6 +482,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
private Runnable mLaunchTransitionEndRunnable; private Runnable mLaunchTransitionEndRunnable;
private boolean mLaunchTransitionFadingAway; private boolean mLaunchTransitionFadingAway;
private ExpandableNotificationRow mDraggedDownRow; private ExpandableNotificationRow mDraggedDownRow;
private boolean mLaunchCameraOnScreenTurningOn;
private PowerManager.WakeLock mGestureWakeLock;
// Fingerprint (as computed by getLoggingFingerprint() of the last logged state. // Fingerprint (as computed by getLoggingFingerprint() of the last logged state.
private int mLastLoggedStateFingerprint; private int mLastLoggedStateFingerprint;
@@ -903,7 +905,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
mBroadcastReceiver.onReceive(mContext, mBroadcastReceiver.onReceive(mContext,
new Intent(pm.isScreenOn() ? Intent.ACTION_SCREEN_ON : Intent.ACTION_SCREEN_OFF)); new Intent(pm.isScreenOn() ? Intent.ACTION_SCREEN_ON : Intent.ACTION_SCREEN_OFF));
mGestureWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK,
"GestureWakeLock");
// receive broadcasts // receive broadcasts
IntentFilter filter = new IntentFilter(); IntentFilter filter = new IntentFilter();
@@ -3385,6 +3388,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
private void onLaunchTransitionFadingEnded() { private void onLaunchTransitionFadingEnded() {
mNotificationPanel.setAlpha(1.0f); mNotificationPanel.setAlpha(1.0f);
mNotificationPanel.onAffordanceLaunchEnded();
releaseGestureWakeLock();
runLaunchTransitionEndRunnable(); runLaunchTransitionEndRunnable();
mLaunchTransitionFadingAway = false; mLaunchTransitionFadingAway = false;
mScrimController.forceHideScrims(false /* hide */); mScrimController.forceHideScrims(false /* hide */);
@@ -3472,6 +3477,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
private void onLaunchTransitionTimeout() { private void onLaunchTransitionTimeout() {
Log.w(TAG, "Launch transition: Timeout!"); Log.w(TAG, "Launch transition: Timeout!");
mNotificationPanel.onAffordanceLaunchEnded();
releaseGestureWakeLock();
mNotificationPanel.resetViews(); mNotificationPanel.resetViews();
} }
@@ -3523,10 +3530,18 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
mQSPanel.refreshAllTiles(); mQSPanel.refreshAllTiles();
} }
mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT);
releaseGestureWakeLock();
mNotificationPanel.onAffordanceLaunchEnded();
mNotificationPanel.setAlpha(1f); mNotificationPanel.setAlpha(1f);
return staying; return staying;
} }
private void releaseGestureWakeLock() {
if (mGestureWakeLock.isHeld()) {
mGestureWakeLock.release();
}
}
public long calculateGoingToFullShadeDelay() { public long calculateGoingToFullShadeDelay() {
return mKeyguardFadingAwayDelay + mKeyguardFadingAwayDuration; return mKeyguardFadingAwayDelay + mKeyguardFadingAwayDuration;
} }
@@ -3651,6 +3666,11 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
return mState == StatusBarState.KEYGUARD && mStatusBarKeyguardViewManager.onMenuPressed(); return mState == StatusBarState.KEYGUARD && mStatusBarKeyguardViewManager.onMenuPressed();
} }
public void endAffordanceLaunch() {
releaseGestureWakeLock();
mNotificationPanel.onAffordanceLaunchEnded();
}
public boolean onBackPressed() { public boolean onBackPressed() {
if (mStatusBarKeyguardViewManager.onBackPressed()) { if (mStatusBarKeyguardViewManager.onBackPressed()) {
return true; return true;
@@ -3882,6 +3902,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
} }
public void onFinishedGoingToSleep() { public void onFinishedGoingToSleep() {
mNotificationPanel.onAffordanceLaunchEnded();
releaseGestureWakeLock();
mLaunchCameraOnScreenTurningOn = false;
mDeviceInteractive = false; mDeviceInteractive = false;
mWakeUpComingFromTouch = false; mWakeUpComingFromTouch = false;
mWakeUpTouchLocation = null; mWakeUpTouchLocation = null;
@@ -3898,6 +3921,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
public void onScreenTurningOn() { public void onScreenTurningOn() {
mNotificationPanel.onScreenTurningOn(); mNotificationPanel.onScreenTurningOn();
if (mLaunchCameraOnScreenTurningOn) {
mNotificationPanel.launchCamera(false);
mLaunchCameraOnScreenTurningOn = false;
}
} }
public void onScreenTurnedOn() { public void onScreenTurnedOn() {
@@ -4054,6 +4081,38 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
} }
} }
@Override
public void onCameraLaunchGestureDetected() {
if (!mNotificationPanel.canCameraGestureBeLaunched()) {
return;
}
if (!mDeviceInteractive) {
PowerManager pm = mContext.getSystemService(PowerManager.class);
pm.wakeUp(SystemClock.uptimeMillis(), "com.android.systemui:CAMERA_GESTURE");
mStatusBarKeyguardViewManager.notifyDeviceWakeUpRequested();
}
if (!mStatusBarKeyguardViewManager.isShowing()) {
startActivity(KeyguardBottomAreaView.INSECURE_CAMERA_INTENT,
true /* dismissShade */);
} else {
if (!mDeviceInteractive) {
// Avoid flickering of the scrim when we instant launch the camera and the bouncer
// comes on.
mScrimController.dontAnimateBouncerChangesUntilNextFrame();
mGestureWakeLock.acquire(LAUNCH_TRANSITION_TIMEOUT_MS + 1000L);
}
if (mStatusBarKeyguardViewManager.isScreenTurnedOn()) {
mNotificationPanel.launchCamera(mDeviceInteractive /* animate */);
} else {
// We need to defer the camera launch until the screen comes on, since otherwise
// we will dismiss us too early since we are waiting on an activity to be drawn and
// incorrectly get notified because of the screen on event (which resumes and pauses
// some activities)
mLaunchCameraOnScreenTurningOn = true;
}
}
}
public void notifyFpAuthModeChanged() { public void notifyFpAuthModeChanged() {
updateDozing(); updateDozing();
} }

View File

@@ -87,6 +87,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
private View mDraggedHeadsUpView; private View mDraggedHeadsUpView;
private boolean mForceHideScrims; private boolean mForceHideScrims;
private boolean mSkipFirstFrame; private boolean mSkipFirstFrame;
private boolean mDontAnimateBouncerChanges;
public ScrimController(ScrimView scrimBehind, ScrimView scrimInFront, View headsUpScrim, public ScrimController(ScrimView scrimBehind, ScrimView scrimInFront, View headsUpScrim,
boolean scrimSrcEnabled) { boolean scrimSrcEnabled) {
@@ -125,7 +126,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
public void setBouncerShowing(boolean showing) { public void setBouncerShowing(boolean showing) {
mBouncerShowing = showing; mBouncerShowing = showing;
mAnimateChange = !mExpanding; mAnimateChange = !mExpanding && !mDontAnimateBouncerChanges;
scheduleUpdate(); scheduleUpdate();
} }
@@ -360,6 +361,9 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
public boolean onPreDraw() { public boolean onPreDraw() {
mScrimBehind.getViewTreeObserver().removeOnPreDrawListener(this); mScrimBehind.getViewTreeObserver().removeOnPreDrawListener(this);
mUpdatePending = false; mUpdatePending = false;
if (mDontAnimateBouncerChanges) {
mDontAnimateBouncerChanges = false;
}
updateScrims(); updateScrims();
mDurationOverride = -1; mDurationOverride = -1;
mAnimationDelay = 0; mAnimationDelay = 0;
@@ -496,4 +500,8 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
mAnimateChange = false; mAnimateChange = false;
scheduleUpdate(); scheduleUpdate();
} }
public void dontAnimateBouncerChangesUntilNextFrame() {
mDontAnimateBouncerChanges = true;
}
} }

View File

@@ -179,6 +179,10 @@ public class StatusBarKeyguardViewManager {
mPhoneStatusBar.onScreenTurningOn(); mPhoneStatusBar.onScreenTurningOn();
} }
public boolean isScreenTurnedOn() {
return mScreenTurnedOn;
}
public void onScreenTurnedOn() { public void onScreenTurnedOn() {
mScreenTurnedOn = true; mScreenTurnedOn = true;
if (mDeferScrimFadeOut) { if (mDeferScrimFadeOut) {
@@ -385,6 +389,7 @@ public class StatusBarKeyguardViewManager {
*/ */
public boolean onBackPressed() { public boolean onBackPressed() {
if (mBouncer.isShowing()) { if (mBouncer.isShowing()) {
mPhoneStatusBar.endAffordanceLaunch();
reset(); reset();
return true; return true;
} }

View File

@@ -170,6 +170,10 @@ public class TvStatusBar extends BaseStatusBar {
public void appTransitionStarting(long startTime, long duration) { public void appTransitionStarting(long startTime, long duration) {
} }
@Override
public void onCameraLaunchGestureDetected() {
}
@Override @Override
protected void updateHeadsUp(String key, NotificationData.Entry entry, boolean shouldInterrupt, protected void updateHeadsUp(String key, NotificationData.Entry entry, boolean shouldInterrupt,
boolean alertAgain) { boolean alertAgain) {

View File

@@ -19,12 +19,9 @@ package com.android.server;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.app.KeyguardManager; import android.app.KeyguardManager;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources; import android.content.res.Resources;
import android.database.ContentObserver; import android.database.ContentObserver;
import android.hardware.Sensor; import android.hardware.Sensor;
@@ -35,12 +32,12 @@ import android.os.Handler;
import android.os.PowerManager; import android.os.PowerManager;
import android.os.PowerManager.WakeLock; import android.os.PowerManager.WakeLock;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.Vibrator; import android.os.Vibrator;
import android.provider.MediaStore;
import android.provider.Settings; import android.provider.Settings;
import android.util.Slog; import android.util.Slog;
import com.android.server.statusbar.StatusBarManagerInternal;
/** /**
* The service that listens for gestures detected in sensor firmware and starts the intent * The service that listens for gestures detected in sensor firmware and starts the intent
* accordingly. * accordingly.
@@ -57,7 +54,6 @@ class GestureLauncherService extends SystemService {
private Sensor mCameraLaunchSensor; private Sensor mCameraLaunchSensor;
private Vibrator mVibrator; private Vibrator mVibrator;
private KeyguardManager mKeyGuard;
private Context mContext; private Context mContext;
/** The wake lock held when a gesture is detected. */ /** The wake lock held when a gesture is detected. */
@@ -83,11 +79,9 @@ class GestureLauncherService extends SystemService {
} }
mVibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); mVibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
mKeyGuard = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
PowerManager powerManager = (PowerManager) mContext.getSystemService( PowerManager powerManager = (PowerManager) mContext.getSystemService(
Context.POWER_SERVICE); Context.POWER_SERVICE);
mWakeLock = powerManager.newWakeLock( mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP,
"GestureLauncherService"); "GestureLauncherService");
updateCameraRegistered(); updateCameraRegistered();
@@ -227,29 +221,17 @@ class GestureLauncherService extends SystemService {
if (DBG) Slog.d(TAG, String.format( if (DBG) Slog.d(TAG, String.format(
"userSetupComplete = %s, performing camera launch gesture.", "userSetupComplete = %s, performing camera launch gesture.",
userSetupComplete)); userSetupComplete));
boolean locked = mKeyGuard != null && mKeyGuard.inKeyguardRestrictedInputMode();
String action = locked
? MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE
: MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA;
Intent intent = new Intent(action);
PackageManager pm = mContext.getPackageManager();
ResolveInfo componentInfo = pm.resolveActivity(intent,
PackageManager.MATCH_DEFAULT_ONLY);
if (componentInfo == null) {
if (DBG) Slog.d(TAG, "Couldn't find an app to process the camera intent.");
return;
}
if (mVibrator != null && mVibrator.hasVibrator()) { if (mVibrator != null && mVibrator.hasVibrator()) {
mVibrator.vibrate(1000L); mVibrator.vibrate(1000L);
} }
// Turn on the screen before the camera launches. // Make sure we don't sleep too early
mWakeLock.acquire(500L); mWakeLock.acquire(500L);
intent.setComponent(new ComponentName(componentInfo.activityInfo.packageName, StatusBarManagerInternal service = LocalServices.getService(
componentInfo.activityInfo.name)); StatusBarManagerInternal.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); service.onCameraLaunchGestureDetected();
mContext.startActivityAsUser(intent, UserHandle.CURRENT);
mWakeLock.release(); mWakeLock.release();
} }
@Override @Override

View File

@@ -4410,7 +4410,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (mAppsToBeHidden.isEmpty()) { if (mAppsToBeHidden.isEmpty()) {
if (dismissKeyguard && !mKeyguardSecure) { if (dismissKeyguard && !mKeyguardSecure) {
mAppsThatDismissKeyguard.add(appToken); mAppsThatDismissKeyguard.add(appToken);
} else { } else if (win.isDrawnLw()) {
mWinShowWhenLocked = win; mWinShowWhenLocked = win;
mHideLockScreen = true; mHideLockScreen = true;
mForceStatusBarFromKeyguard = false; mForceStatusBarFromKeyguard = false;
@@ -4444,7 +4444,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mWinDismissingKeyguard = win; mWinDismissingKeyguard = win;
mSecureDismissingKeyguard = mKeyguardSecure; mSecureDismissingKeyguard = mKeyguardSecure;
mForceStatusBarFromKeyguard = mShowingLockscreen && mKeyguardSecure; mForceStatusBarFromKeyguard = mShowingLockscreen && mKeyguardSecure;
} else if (mAppsToBeHidden.isEmpty() && showWhenLocked) { } else if (mAppsToBeHidden.isEmpty() && showWhenLocked && win.isDrawnLw()) {
if (DEBUG_LAYOUT) Slog.v(TAG, if (DEBUG_LAYOUT) Slog.v(TAG,
"Setting mHideLockScreen to true by win " + win); "Setting mHideLockScreen to true by win " + win);
mHideLockScreen = true; mHideLockScreen = true;

View File

@@ -28,4 +28,5 @@ public interface StatusBarManagerInternal {
void showScreenPinningRequest(); void showScreenPinningRequest();
void showAssistDisclosure(); void showAssistDisclosure();
void startAssist(Bundle args); void startAssist(Bundle args);
void onCameraLaunchGestureDetected();
} }

View File

@@ -176,6 +176,16 @@ public class StatusBarManagerService extends IStatusBarService.Stub {
} }
} }
} }
@Override
public void onCameraLaunchGestureDetected() {
if (mBar != null) {
try {
mBar.onCameraLaunchGestureDetected();
} catch (RemoteException e) {
}
}
}
}; };
// ================================================================================ // ================================================================================