summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Wang <jaywang@codeaurora.org>2016-02-01 13:10:14 -0800
committerSteve Kondik <shade@chemlab.org>2016-09-30 14:41:02 -0700
commit597e7cc826eb65c0fcf2b600f4aef76a13e02a45 (patch)
treeec2db51fab38d2113b97f0c4ac76c2193eaed755
parent778dd70562d56bd10741fbe1eeadcad053ff3968 (diff)
downloadandroid_packages_apps_Snap-597e7cc826eb65c0fcf2b600f4aef76a13e02a45.zip
android_packages_apps_Snap-597e7cc826eb65c0fcf2b600f4aef76a13e02a45.tar.gz
android_packages_apps_Snap-597e7cc826eb65c0fcf2b600f4aef76a13e02a45.tar.bz2
SnapdragonCamera: Fix blank preview issue during pause & resume
Continuous pause & resume operation by pressing the power button can cause the blank preview. The application close the camera when there is onPause or screen off intent. Sometimes the resume comes after screen off intent when user resumes the device quickly after pausing the device. Because of this race-condition, the camera is closed unintentionally. To resolve the issue, re-structure the code to receive screen-off intent only during video recording and stop the recording when intent is received. Change-Id: Ic993b83527b41dbbf53f63ef8ca25fa3a12fb77e CRs-Fixed: 970172
-rw-r--r--src/com/android/camera/CameraActivity.java42
-rw-r--r--src/com/android/camera/PhotoModule.java2
-rwxr-xr-xsrc/com/android/camera/VideoModule.java4
3 files changed, 4 insertions, 44 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 3458e8c..234c6a6 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -218,8 +218,6 @@ public class CameraActivity extends Activity
public static boolean mPowerShutter = false;
// Keep track of max brightness state
public static boolean mMaxBrightness = false;
- // This is a hack to speed up the start of SecureCamera.
- private static boolean sFirstStartAfterScreenOn = true;
private int mLastRawOrientation;
private MyOrientationEventListener mOrientationListener;
private Handler mMainHandler;
@@ -360,23 +358,6 @@ public class CameraActivity extends Activity
registerReceiver(mSDcardMountedReceiver, filter);
}
- // close activity when screen turns off
- private BroadcastReceiver mScreenOffReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- finish();
- }
- };
-
- private static BroadcastReceiver sScreenOffReceiver;
-
- private static class ScreenOffReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- sFirstStartAfterScreenOn = true;
- }
- }
-
private class MainHandler extends Handler {
public MainHandler(Looper looper) {
super(looper);
@@ -399,10 +380,6 @@ public class CameraActivity extends Activity
mOnActionBarVisibilityListener = listener;
}
- public static boolean isFirstStartAfterScreenOn() {
- return sFirstStartAfterScreenOn;
- }
-
public static boolean isPieMenuEnabled() {
return PIE_MENU_ENABLED;
}
@@ -419,10 +396,6 @@ public class CameraActivity extends Activity
mDeveloperMenuEnabled = false;
}
- public static void resetFirstStartAfterScreenOn() {
- sFirstStartAfterScreenOn = false;
- }
-
private String fileNameFromDataID(int dataID) {
final LocalData localData = mDataAdapter.getLocalData(dataID);
@@ -1473,18 +1446,6 @@ public class CameraActivity extends Activity
Log.d(TAG, "acquire wake lock");
}
win.setAttributes(params);
-
- // 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);
- // TODO: This static screen off event receiver is a workaround to the
- // double onResume() invocation (onResume->onPause->onResume). We should
- // find a better solution to this.
- if (sScreenOffReceiver == null) {
- sScreenOffReceiver = new ScreenOffReceiver();
- registerReceiver(sScreenOffReceiver, filter);
- }
}
GcamHelper.init(getContentResolver());
@@ -1829,9 +1790,6 @@ public class CameraActivity extends Activity
settingsMngr.destroyInstance();
}
if (mCursor != null) {
- if (mSecureCamera) {
- unregisterReceiver(mScreenOffReceiver);
- }
getContentResolver().unregisterContentObserver(mLocalImagesObserver);
getContentResolver().unregisterContentObserver(mLocalVideosObserver);
unregisterReceiver(mSDcardMountedReceiver);
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 6ec88ff..26a3210 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -2794,7 +2794,7 @@ public class PhotoModule
mCameraDevice.setFaceDetectionCallback(null, null);
mCameraDevice.setErrorCallback(null);
- if (mActivity.isSecureCamera() && !CameraActivity.isFirstStartAfterScreenOn()) {
+ if (mActivity.isSecureCamera()) {
// Blocks until camera is actually released.
CameraHolder.instance().strongRelease();
} else {
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index 25a77ee..1117664 100755
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -422,7 +422,8 @@ public class VideoModule implements CameraModule,
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
- if (action.equals(Intent.ACTION_MEDIA_EJECT)) {
+ if (action.equals(Intent.ACTION_MEDIA_EJECT) ||
+ action.equals(Intent.ACTION_SCREEN_OFF)) {
stopVideoRecording();
RotateTextToast.makeText(mActivity,
mActivity.getResources().getString(R.string.video_recording_stopped),
@@ -1151,6 +1152,7 @@ public class VideoModule implements CameraModule,
// install an intent filter to receive SD card related events.
IntentFilter intentFilter =
new IntentFilter(Intent.ACTION_MEDIA_EJECT);
+ intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_STARTED);
intentFilter.addDataScheme("file");
mReceiver = new MyBroadcastReceiver();