mViewMediatorCallback.keyguardDoneDrawing();
}
+ @Override
+ public void setOnDismissRunnable(Runnable runnable) {
+ KeyguardHostView.this.setOnDismissRunnable(runnable);
+ }
+
};
public void takeEmergencyCallAction() {
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?
"unknown exception: ", e);
}
}
- };
+ });
mCallback.dismiss(false);
return true;
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++) {
((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");
}
break;
case com.android.internal.R.drawable.ic_lockscreen_camera:
- launchActivity(new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA));
+ launchCamera();
mCallback.userActivity(0);
break;
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());
/**
* 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);
}
}