summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/camera/ActivityBase.java50
-rw-r--r--src/com/android/camera/Camera.java29
-rwxr-xr-xsrc/com/android/camera/VideoCamera.java2
3 files changed, 78 insertions, 3 deletions
diff --git a/src/com/android/camera/ActivityBase.java b/src/com/android/camera/ActivityBase.java
index e399421..4a29469 100644
--- a/src/com/android/camera/ActivityBase.java
+++ b/src/com/android/camera/ActivityBase.java
@@ -20,13 +20,16 @@ import com.android.camera.ui.PopupManager;
import android.app.Activity;
import android.app.KeyguardManager;
+import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.hardware.Camera;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
+import android.view.WindowManager;
/**
* Superclass of Camera and VideoCamera activities.
@@ -38,6 +41,11 @@ abstract public class ActivityBase extends Activity {
private boolean mOnResumePending;
private Intent mResultDataForTesting;
protected Camera mCameraDevice;
+ // settings for lock screen camera
+ protected static final String INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE =
+ "android.media.action.STILL_IMAGE_CAMERA_SECURE";
+ protected static final String ACTION_IMAGE_CAPTURE_SECURE =
+ "android.media.action.IMAGE_CAPTURE_SECURE";
@Override
public void onCreate(Bundle icicle) {
@@ -47,6 +55,18 @@ abstract public class ActivityBase extends Activity {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
super.onCreate(icicle);
+
+ if(isCameraSecure()){
+ Log.v(TAG, "Starting in secure camera mode.");
+
+ // show on lock screen
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
+
+ // Filter for screen off so that we can finish secure camera activity
+ // when screen is off.
+ IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
+ registerReceiver(mScreenOffReceiver, filter);
+ }
}
@Override
@@ -62,6 +82,7 @@ abstract public class ActivityBase extends Activity {
@Override
protected void onResume() {
super.onResume();
+ onResumeAfterSuper();
// Don't grab the camera if in use by lockscreen. For example, face
// unlock may be using the camera. Camera may be already opened in
// onCreate. doOnResume should continue if mCameraDevice != null.
@@ -127,11 +148,14 @@ abstract public class ActivityBase extends Activity {
@Override
protected void onDestroy() {
+ if (isCameraSecure()) {
+ unregisterReceiver(mScreenOffReceiver);
+ }
PopupManager.removeInstance(this);
super.onDestroy();
}
- private boolean isKeyguardLocked() {
+ protected boolean isKeyguardLocked() {
KeyguardManager kgm = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
if (LOGV) {
if (kgm != null) {
@@ -142,4 +166,28 @@ abstract public class ActivityBase extends Activity {
// isKeyguardSecure excludes the slide lock case.
return (kgm != null) && kgm.isKeyguardLocked() && kgm.isKeyguardSecure();
}
+
+ protected boolean isCameraSecure() {
+ // Check if this is in the secure camera mode.
+ String action = getIntent().getAction();
+ if (INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE.equals(action)
+ || ACTION_IMAGE_CAPTURE_SECURE.equals(action)){
+ return true;
+ }
+ else{
+ return isKeyguardLocked();
+ }
+ }
+
+ // close activity when screen turns off
+ protected BroadcastReceiver mScreenOffReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.v(TAG, "Finishing because screen turned off.");
+ finish();
+ }
+ };
+
+ // implemented in class Camera, class Video needs empty one
+ public void onResumeAfterSuper() {};
}
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 2ca7944..f7de7f6 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -100,6 +100,10 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
private static final int SHOW_TAP_TO_FOCUS_TOAST = 6;
private static final int UPDATE_THUMBNAIL = 7;
+ // This is the delay before we execute onResume tasks when coming
+ // from the lock screen, to allow time for onPause to execute.
+ private static final int ON_RESUME_TASKS_DELAY_MSEC = 20;
+
// The subset of parameters we need to update in setCameraParameters().
private static final int UPDATE_PARAM_INITIALIZE = 1;
private static final int UPDATE_PARAM_ZOOM = 2;
@@ -1345,7 +1349,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
@OnClickAttr
public void onThumbnailClicked(View v) {
- if (isCameraIdle() && mThumbnail != null) {
+ if (isCameraIdle() && mThumbnail != null && !isCameraSecure()) {
showSharePopup();
}
}
@@ -2318,4 +2322,27 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
mAeLockSupported = mInitialParams.isAutoExposureLockSupported();
mAwbLockSupported = mInitialParams.isAutoWhiteBalanceLockSupported();
}
+
+ @Override
+ public void onResumeAfterSuper() {
+ // Add delay on resume from lock screen only, in order to to speed up
+ // the onResume --> onPause --> onResume cycle from lock screen.
+ // Don't do always because letting go of thread can cause delay.
+ String action = getIntent().getAction();
+ if (isCameraSecure()) {
+ Log.v(TAG, "On resume, from lock screen.");
+ // Note: onPauseAfterSuper() will delete this runnable, so we will
+ // at most have 1 copy queued up.
+ mHandler.postDelayed(new Runnable() {
+ public void run() {
+ doOnResume();
+ }
+ }, ON_RESUME_TASKS_DELAY_MSEC);
+ // show on lock screen
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
+ } else {
+ Log.v(TAG, "On resume.");
+ doOnResume();
+ }
+ }
}
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index b2626ed..2190c48 100755
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -608,7 +608,7 @@ public class VideoCamera extends ActivityBase
@OnClickAttr
public void onThumbnailClicked(View v) {
- if (!mMediaRecorderRecording && mThumbnail != null) {
+ if (!mMediaRecorderRecording && mThumbnail != null && !isCameraSecure()) {
showSharePopup();
}
}