summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormingwax <mingwax@codeaurora.org>2016-11-30 14:42:27 +0800
committerGerrit - the friendly Code Review server <code-review@localhost>2016-11-30 01:24:53 -0800
commit9a351414d4e634f09313ca27c286d919b1b43636 (patch)
treea784e698ec37f373ba61e5d2971216aaff1e9f7c
parent2f936e251c8e76d89b908041d0d1366e3bac576a (diff)
downloadandroid_packages_apps_Snap-9a351414d4e634f09313ca27c286d919b1b43636.tar.gz
android_packages_apps_Snap-9a351414d4e634f09313ca27c286d919b1b43636.tar.bz2
android_packages_apps_Snap-9a351414d4e634f09313ca27c286d919b1b43636.zip
SnapdragonCamera: Keep screen on when recording the video
Add the actions to keep the screen on or off. (1) We always keep the screen on when click video button for recording video. (2) We keep the screen on for 2 mins when click video button for stop recording video. (3) We clear the flag(FLAG_KEEP_SCREEN_ON) when exit the camera. CRs-Fixed: 1095512 change-Id: I283c29882f0654315536afbafc5072491343a38f
-rw-r--r--src/com/android/camera/CaptureModule.java32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index c45496c1f..ebc1060b9 100644
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -72,6 +72,7 @@ import android.view.OrientationEventListener;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.View;
+import android.view.WindowManager;
import android.widget.Toast;
import com.android.camera.exif.ExifInterface;
@@ -168,6 +169,8 @@ public class CaptureModule implements CameraModule, PhotoController,
private static final int NORMAL_SESSION_MAX_FPS = 60;
+ private static final int SCREEN_DELAY = 2 * 60 * 1000;
+
MeteringRectangle[][] mAFRegions = new MeteringRectangle[MAX_NUM_CAM][];
MeteringRectangle[][] mAERegions = new MeteringRectangle[MAX_NUM_CAM][];
CaptureRequest.Key<Byte> BayerMonoLinkEnableKey =
@@ -289,6 +292,7 @@ public class CaptureModule implements CameraModule, PhotoController,
private int mTimeBetweenTimeLapseFrameCaptureMs = 0;
private boolean mCaptureTimeLapse = false;
private CamcorderProfile mProfile;
+ private static final int CLEAR_SCREEN_DELAY = 4;
private static final int UPDATE_RECORD_TIME = 5;
private ContentValues mCurrentVideoValues;
private String mVideoFilename;
@@ -1893,6 +1897,7 @@ public class CaptureModule implements CameraModule, PhotoController,
if (selfieThread != null) {
selfieThread.interrupt();
}
+ resetScreenOn();
mUI.stopSelfieFlash();
}
@@ -2675,6 +2680,7 @@ public class CaptureModule implements CameraModule, PhotoController,
mUI.enableShutter(false);
mUI.showRecordingUI(true, true);
updateRecordingTime();
+ keepScreenOn();
}
@Override
@@ -2706,6 +2712,7 @@ public class CaptureModule implements CameraModule, PhotoController,
mRecordingStartTime = SystemClock.uptimeMillis();
mUI.showRecordingUI(true, false);
updateRecordingTime();
+ keepScreenOn();
}
@Override
@@ -2911,7 +2918,7 @@ public class CaptureModule implements CameraModule, PhotoController,
if (shouldAddToMediaStoreNow) {
saveVideo();
}
-
+ keepScreenOnAwhile();
// release media recorder
releaseMediaRecorder();
releaseAudioFocus();
@@ -3928,6 +3935,11 @@ public class CaptureModule implements CameraModule, PhotoController,
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
+ case CLEAR_SCREEN_DELAY: {
+ mActivity.getWindow().clearFlags(
+ WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+ break;
+ }
case UPDATE_RECORD_TIME: {
updateRecordingTime();
break;
@@ -4026,4 +4038,20 @@ public class CaptureModule implements CameraModule, PhotoController,
mToast.setText(tips);
mToast.show();
}
-}
+
+ private void resetScreenOn() {
+ mHandler.removeMessages(CLEAR_SCREEN_DELAY);
+ mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+ }
+
+ private void keepScreenOnAwhile() {
+ mHandler.removeMessages(CLEAR_SCREEN_DELAY);
+ mActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+ mHandler.sendEmptyMessageDelayed(CLEAR_SCREEN_DELAY, SCREEN_DELAY);
+ }
+
+ private void keepScreenOn() {
+ mHandler.removeMessages(CLEAR_SCREEN_DELAY);
+ mActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+ }
+} \ No newline at end of file