summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jim Miller <jaggies@google.com> 2012-08-29 20:07:56 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2012-08-29 20:07:56 -0700
commit5b81de4de741f736889fd86e1dd324ad88136ebe (patch)
treeee8f77c8cea0d6a5a541515c4cc9d8747b563716
parentb07e89f6fdbf85d2f436dc67074793444462abf9 (diff)
parent5f75aa15d7c1c5ea1c1eecd95bf2bb0920173eb2 (diff)
Merge "Fix Camera and GoogleNow launching in keyguard" into jb-mr1-dev
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java17
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardSecurityCallback.java9
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java49
3 files changed, 61 insertions, 14 deletions
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
index e071f4cce01f..d74a5e7610d1 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
@@ -221,6 +221,11 @@ public class KeyguardHostView extends KeyguardViewBase {
mViewMediatorCallback.keyguardDoneDrawing();
}
+ @Override
+ public void setOnDismissRunnable(Runnable runnable) {
+ KeyguardHostView.this.setOnDismissRunnable(runnable);
+ }
+
};
public void takeEmergencyCallAction() {
@@ -273,7 +278,7 @@ public class KeyguardHostView extends KeyguardViewBase {
final android.app.PendingIntent pendingIntent,
final Intent fillInIntent) {
if (pendingIntent.isActivity()) {
- mLaunchRunnable = new Runnable() {
+ setOnDismissRunnable(new Runnable() {
public void run() {
try {
// TODO: Unregister this handler if PendingIntent.FLAG_ONE_SHOT?
@@ -292,7 +297,7 @@ public class KeyguardHostView extends KeyguardViewBase {
"unknown exception: ", e);
}
}
- };
+ });
mCallback.dismiss(false);
return true;
@@ -307,6 +312,14 @@ public class KeyguardHostView extends KeyguardViewBase {
requestFocus();
}
+ /**
+ * Sets a runnable to run when keyguard is dismissed
+ * @param runnable
+ */
+ protected void setOnDismissRunnable(Runnable runnable) {
+ mLaunchRunnable = runnable;
+ }
+
private KeyguardSecurityView getSecurityView(int securitySelectorId) {
final int children = mViewFlipper.getChildCount();
for (int child = 0; child < children; child++) {
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSecurityCallback.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSecurityCallback.java
index 1a4a40bff21b..36342a5772e6 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSecurityCallback.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSecurityCallback.java
@@ -57,6 +57,15 @@ public interface KeyguardSecurityCallback {
*/
void showBackupUnlock();
+ /**
+ * Used to inform keyguard when the current view is done drawing.
+ */
void keyguardDoneDrawing();
+ /**
+ * Sets a runnable to launch after the user enters their
+ * @param runnable
+ */
+ void setOnDismissRunnable(Runnable runnable);
+
}
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java
index b69697fc1c24..a38b2475508f 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java
@@ -61,7 +61,7 @@ public class KeyguardSelectorView extends LinearLayout implements KeyguardSecuri
((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE))
.getAssistIntent(mContext, UserHandle.USER_CURRENT);
if (assistIntent != null) {
- launchActivity(assistIntent);
+ launchActivity(assistIntent, false);
} else {
Log.w(TAG, "Failed to get intent for assist activity");
}
@@ -69,7 +69,7 @@ public class KeyguardSelectorView extends LinearLayout implements KeyguardSecuri
break;
case com.android.internal.R.drawable.ic_lockscreen_camera:
- launchActivity(new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA));
+ launchCamera();
mCallback.userActivity(0);
break;
@@ -128,6 +128,16 @@ public class KeyguardSelectorView extends LinearLayout implements KeyguardSecuri
this(context, null);
}
+ protected void launchCamera() {
+ if (mLockPatternUtils.isSecure()) {
+ // Launch the secure version of the camera
+ launchActivity(new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE), true);
+ } else {
+ // Launch the normal camera
+ launchActivity(new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA), false);
+ }
+ }
+
public KeyguardSelectorView(Context context, AttributeSet attrs) {
super(context, attrs);
mLockPatternUtils = new LockPatternUtils(getContext());
@@ -217,21 +227,36 @@ public class KeyguardSelectorView extends LinearLayout implements KeyguardSecuri
/**
* Launches the said intent for the current foreground user.
* @param intent
+ * @param showsWhileLocked true if the activity can be run on top of keyguard.
+ * See {@link WindowManager#FLAG_SHOW_WHEN_LOCKED}
*/
- private void launchActivity(Intent intent) {
+ private void launchActivity(final Intent intent, boolean showsWhileLocked) {
intent.setFlags(
Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_SINGLE_TOP
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
- try {
- ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity();
- } catch (RemoteException e) {
- Log.w(TAG, "can't dismiss keyguard on launch");
- }
- try {
- mContext.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
- } catch (ActivityNotFoundException e) {
- Log.w(TAG, "Activity not found for intent + " + intent.getAction());
+ boolean isSecure = mLockPatternUtils.isSecure();
+ if (!isSecure || showsWhileLocked) {
+ if (!isSecure) try {
+ ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity();
+ } catch (RemoteException e) {
+ Log.w(TAG, "can't dismiss keyguard on launch");
+ }
+ try {
+ mContext.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
+ } catch (ActivityNotFoundException e) {
+ Log.w(TAG, "Activity not found for intent + " + intent.getAction());
+ }
+ } else {
+ // Create a runnable to start the activity and ask the user to enter their
+ // credentials.
+ mCallback.setOnDismissRunnable(new Runnable() {
+ @Override
+ public void run() {
+ mContext.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
+ }
+ });
+ mCallback.dismiss(false);
}
}