summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/statusbar
diff options
context:
space:
mode:
authorJorim Jaggi <jjaggi@google.com>2015-04-02 16:32:29 -0700
committerJorim Jaggi <jjaggi@google.com>2015-04-07 11:24:05 -0700
commita86790bf23a98ede5fc0c29b996a5229e08181cd (patch)
tree356a816c89f4dd08c1437221eb57aa168fe0a015 /packages/SystemUI/src/com/android/systemui/statusbar
parent6e9fa1a4b74dc4e35470739cfd64881cb9bcc7b1 (diff)
downloadframeworks_base-a86790bf23a98ede5fc0c29b996a5229e08181cd.zip
frameworks_base-a86790bf23a98ede5fc0c29b996a5229e08181cd.tar.gz
frameworks_base-a86790bf23a98ede5fc0c29b996a5229e08181cd.tar.bz2
Add Camera prewarm intent.
Also adds a test app for testing this intent. In addition, the secure camera gets launched in the background to fix jank while sending the intent. Bug: 20016619 Change-Id: I7bb7e22ddaf5dc67fc09b9e63e5f3d10fe8e3ee4
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/statusbar')
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java32
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java40
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java14
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/PreviewInflater.java18
4 files changed, 85 insertions, 19 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java
index 3b8fccc..cab152f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java
@@ -69,7 +69,7 @@ public class KeyguardAffordanceHelper {
@Override
public void onAnimationEnd(Animator animation) {
mSwipeAnimator = null;
- setSwipingInProgress(false);
+ mSwipingInProgress = false;
}
};
private Runnable mAnimationEndRunnable = new Runnable() {
@@ -117,14 +117,17 @@ public class KeyguardAffordanceHelper {
}
public boolean onTouchEvent(MotionEvent event) {
- if (mMotionCancelled && event.getActionMasked() != MotionEvent.ACTION_DOWN) {
+ int action = event.getActionMasked();
+ if (mMotionCancelled && action != MotionEvent.ACTION_DOWN
+ && action != MotionEvent.ACTION_UP
+ && action != MotionEvent.ACTION_CANCEL) {
return false;
}
final float y = event.getY();
final float x = event.getX();
boolean isUp = false;
- switch (event.getActionMasked()) {
+ switch (action) {
case MotionEvent.ACTION_DOWN:
if (mSwipingInProgress) {
cancelAnimation();
@@ -152,7 +155,8 @@ public class KeyguardAffordanceHelper {
mInitialTouchY = y;
mInitialTouchX = x;
mTranslationOnDown = mTranslation;
- setSwipingInProgress(true);
+ mSwipingInProgress = true;
+ mCallback.onSwipingStarted(w < -mTouchSlop);
}
if (mSwipingInProgress) {
setTranslation(mTranslationOnDown + x - mInitialTouchX, false, false);
@@ -179,13 +183,6 @@ public class KeyguardAffordanceHelper {
}
}
- private void setSwipingInProgress(boolean inProgress) {
- mSwipingInProgress = inProgress;
- if (inProgress) {
- mCallback.onSwipingStarted();
- }
- }
-
private boolean rightSwipePossible() {
return mRightIcon.getVisibility() == View.VISIBLE;
}
@@ -323,6 +320,9 @@ public class KeyguardAffordanceHelper {
}
animator.start();
mSwipeAnimator = animator;
+ if (snapBack) {
+ mCallback.onSwipingAborted();
+ }
}
private void startFinishingCircleAnimation(float velocity, Runnable mAnimationEndRunnable) {
@@ -451,7 +451,11 @@ public class KeyguardAffordanceHelper {
mSwipeAnimator.cancel();
}
setTranslation(0.0f, true, animate);
- setSwipingInProgress(false);
+ mMotionCancelled = true;
+ if (mSwipingInProgress) {
+ mCallback.onSwipingAborted();
+ }
+ mSwipingInProgress = false;
}
public interface Callback {
@@ -470,7 +474,9 @@ public class KeyguardAffordanceHelper {
float getPageWidth();
- void onSwipingStarted();
+ void onSwipingStarted(boolean isRightwardMotion);
+
+ void onSwipingAborted();
KeyguardAffordanceView getLeftIcon();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
index a247c8e..628ae84 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
@@ -100,6 +100,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
private final TrustDrawable mTrustDrawable;
private final Interpolator mLinearOutSlowInInterpolator;
private int mLastUnlockIconRes = 0;
+ private boolean mPrewarmSent;
public KeyguardBottomAreaView(Context context) {
this(context, null);
@@ -335,12 +336,47 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
mLockPatternUtils.requireCredentialEntry(mLockPatternUtils.getCurrentUser());
}
- public void launchCamera() {
+ public void prewarmCamera() {
+ Intent intent = getCameraIntent();
+ String targetPackage = PreviewInflater.getTargetPackage(mContext, intent,
+ mLockPatternUtils.getCurrentUser());
+ if (targetPackage != null) {
+ Intent prewarm = new Intent(MediaStore.ACTION_STILL_IMAGE_CAMERA_PREWARM);
+ prewarm.setPackage(targetPackage);
+ mPrewarmSent = true;
+ mContext.sendBroadcast(prewarm);
+ }
+ }
+
+ public void maybeCooldownCamera() {
+ if (!mPrewarmSent) {
+ return;
+ }
+ mPrewarmSent = false;
Intent intent = getCameraIntent();
+ String targetPackage = PreviewInflater.getTargetPackage(mContext, intent,
+ mLockPatternUtils.getCurrentUser());
+ if (targetPackage != null) {
+ Intent prewarm = new Intent(MediaStore.ACTION_STILL_IMAGE_CAMERA_COOLDOWN);
+ prewarm.setPackage(targetPackage);
+ mContext.sendBroadcast(prewarm);
+ }
+ }
+
+ public void launchCamera() {
+
+ // Reset prewarm state.
+ mPrewarmSent = false;
+ final Intent intent = getCameraIntent();
boolean wouldLaunchResolverActivity = PreviewInflater.wouldLaunchResolverActivity(
mContext, intent, mLockPatternUtils.getCurrentUser());
if (intent == SECURE_CAMERA_INTENT && !wouldLaunchResolverActivity) {
- mContext.startActivityAsUser(intent, UserHandle.CURRENT);
+ AsyncTask.execute(new Runnable() {
+ @Override
+ public void run() {
+ mContext.startActivityAsUser(intent, UserHandle.CURRENT);
+ }
+ });
} else {
// We need to delay starting the activity because ResolverActivity finishes itself if
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 195da46..216730b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -1809,14 +1809,24 @@ public class NotificationPanelView extends PanelView implements
}
@Override
- public void onSwipingStarted() {
- mSecureCameraLaunchManager.onSwipingStarted();
+ public void onSwipingStarted(boolean isRightwardMotion) {
+ boolean start = getLayoutDirection() == LAYOUT_DIRECTION_RTL ? isRightwardMotion
+ : !isRightwardMotion;
+ if (!start) {
+ mSecureCameraLaunchManager.onSwipingStarted();
+ mKeyguardBottomArea.prewarmCamera();
+ }
requestDisallowInterceptTouchEvent(true);
mOnlyAffordanceInThisMotion = true;
mQsTracking = false;
}
@Override
+ public void onSwipingAborted() {
+ mKeyguardBottomArea.maybeCooldownCamera();
+ }
+
+ @Override
public KeyguardAffordanceView getLeftIcon() {
return getLayoutDirection() == LAYOUT_DIRECTION_RTL
? mKeyguardBottomArea.getCameraView()
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/PreviewInflater.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/PreviewInflater.java
index 34068fd..0dce82f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/PreviewInflater.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/PreviewInflater.java
@@ -16,6 +16,7 @@
package com.android.systemui.statusbar.policy;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -106,15 +107,28 @@ public class PreviewInflater {
public static boolean wouldLaunchResolverActivity(Context ctx, Intent intent,
int currentUserId) {
+ return getTargetPackage(ctx, intent, currentUserId) == null;
+ }
+
+ /**
+ * @return the target package of the intent it resolves to a specific package or {@code null} if
+ * it resolved to the resolver activity
+ */
+ public static String getTargetPackage(Context ctx, Intent intent,
+ int currentUserId) {
PackageManager packageManager = ctx.getPackageManager();
final List<ResolveInfo> appList = packageManager.queryIntentActivitiesAsUser(
intent, PackageManager.MATCH_DEFAULT_ONLY, currentUserId);
if (appList.size() == 0) {
- return false;
+ return null;
}
ResolveInfo resolved = packageManager.resolveActivityAsUser(intent,
PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_META_DATA, currentUserId);
- return wouldLaunchResolverActivity(resolved, appList);
+ if (resolved == null || wouldLaunchResolverActivity(resolved, appList)) {
+ return null;
+ } else {
+ return resolved.activityInfo.packageName;
+ }
}
private static boolean wouldLaunchResolverActivity(