From 3f873303a847f112558f081f42720a284558cace Mon Sep 17 00:00:00 2001 From: kaiyiz Date: Fri, 9 Jan 2015 13:09:03 +0800 Subject: SnapdragonCamera: fix don't lock screen after press power key The window flag FLAG_SHOW_WHEN_LOCKED is workding even if press power key, so camera activity will not be close still run above locked screen UI. The CameraGestureActivity is start from screen off, so it will be a SecureCameraActivity. Finish activity as same as the secure camera activity. Change-Id: I76d8ff3d2f037b81140b35255b52b4c4f4de95d3 CRs-Fixed: 777770 --- AndroidManifest.xml | 2 +- src/com/android/camera/CameraActivity.java | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index bf13fac83..c827e6013 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -97,7 +97,7 @@ android:name="com.android.camera.CameraGestureActivity" android:icon="@mipmap/ic_launcher_camera" android:label="@string/camera_gesture_title" - android:targetActivity="com.android.camera.CameraActivity"> + android:targetActivity="com.android.camera.SecureCameraActivity"> diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java index 8fd8f9daa..d460867a6 100644 --- a/src/com/android/camera/CameraActivity.java +++ b/src/com/android/camera/CameraActivity.java @@ -122,6 +122,9 @@ public class CameraActivity extends Activity // panorama. If the extra is not set, it is in the normal camera mode. public static final String SECURE_CAMERA_EXTRA = "secure_camera"; + // This string is used for judge start activity from screenoff or not + public static final String GESTURE_CAMERA_NAME = "com.android.camera.CameraGestureActivity"; + /** * Request code from an activity we started that indicated that we do not * want to reset the view to the preview in onResume. @@ -1158,9 +1161,6 @@ public class CameraActivity extends Activity getWindow().requestFeature(Window.FEATURE_ACTION_BAR); setContentView(R.layout.camera_filmstrip); - int flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED - | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON; - getWindow().addFlags(flags); mActionBar = getActionBar(); mActionBar.addOnMenuVisibilityListener(this); @@ -1174,7 +1174,8 @@ public class CameraActivity extends Activity Intent intent = getIntent(); String action = intent.getAction(); if (INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE.equals(action) - || ACTION_IMAGE_CAPTURE_SECURE.equals(action)) { + || ACTION_IMAGE_CAPTURE_SECURE.equals(action) + || intent.getComponent().getClassName().equals(GESTURE_CAMERA_NAME)) { mSecureCamera = true; } else { mSecureCamera = intent.getBooleanExtra(SECURE_CAMERA_EXTRA, false); @@ -1185,6 +1186,9 @@ public class CameraActivity extends Activity Window win = getWindow(); WindowManager.LayoutParams params = win.getAttributes(); params.flags |= WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; + if (intent.getComponent().getClassName().equals(GESTURE_CAMERA_NAME)) { + params.flags |= WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON; + } win.setAttributes(params); // Filter for screen off so that we can finish secure camera activity -- cgit v1.2.3