summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2011-10-27 17:05:36 +0800
committerChih-Chung Chang <chihchung@google.com>2011-10-28 10:25:15 +0800
commitbc85294715ce88c8378af3b77f7a0d27d7ceeaba (patch)
tree17f0ced828e7dd56142ef70684c793236079cefc /src/com/android
parent15402eff4f819bd0984ca8f2f6ea76ea0b92b326 (diff)
downloadLegacyCamera-bc85294715ce88c8378af3b77f7a0d27d7ceeaba.zip
LegacyCamera-bc85294715ce88c8378af3b77f7a0d27d7ceeaba.tar.gz
LegacyCamera-bc85294715ce88c8378af3b77f7a0d27d7ceeaba.tar.bz2
Fix 5520611: Sleep after no interaction fow two minutes.
Change-Id: I33b38fa54302c0dbf98298e28c9457c9bf61bb7d
Diffstat (limited to 'src/com/android')
-rwxr-xr-xsrc/com/android/camera/panorama/PanoramaActivity.java36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/com/android/camera/panorama/PanoramaActivity.java b/src/com/android/camera/panorama/PanoramaActivity.java
index e63ef71..d95ac03 100755
--- a/src/com/android/camera/panorama/PanoramaActivity.java
+++ b/src/com/android/camera/panorama/PanoramaActivity.java
@@ -83,6 +83,9 @@ public class PanoramaActivity extends ActivityBase implements
private static final int MSG_RESET_TO_PREVIEW_WITH_THUMBNAIL = 2;
private static final int MSG_GENERATE_FINAL_MOSAIC_ERROR = 3;
private static final int MSG_RESET_TO_PREVIEW = 4;
+ private static final int MSG_CLEAR_SCREEN_DELAY = 5;
+
+ private static final int SCREEN_DELAY = 2 * 60 * 1000;
private static final String TAG = "PanoramaActivity";
private static final int PREVIEW_STOPPED = 0;
@@ -242,8 +245,6 @@ public class PanoramaActivity extends ActivityBase implements
super.onCreate(icicle);
Window window = getWindow();
- window.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
- WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Util.enterLightsOutMode(window);
Util.initializeScreenBrightness(window, getContentResolver());
@@ -294,6 +295,11 @@ public class PanoramaActivity extends ActivityBase implements
case MSG_RESET_TO_PREVIEW:
onBackgroundThreadFinished();
resetToPreview();
+ break;
+ case MSG_CLEAR_SCREEN_DELAY:
+ getWindow().clearFlags(WindowManager.LayoutParams.
+ FLAG_KEEP_SCREEN_ON);
+ break;
}
clearMosaicFrameProcessorIfNeeded();
}
@@ -562,6 +568,7 @@ public class PanoramaActivity extends ActivityBase implements
mPanoProgressBar.setIndicatorWidth(20);
mPanoProgressBar.setMaxProgress(DEFAULT_SWEEP_ANGLE);
mPanoProgressBar.setVisibility(View.VISIBLE);
+ keepScreenOn();
}
private void stopCapture(boolean aborted) {
@@ -597,6 +604,7 @@ public class PanoramaActivity extends ActivityBase implements
}
// do we have to wait for the thread to complete before enabling this?
if (mModePicker != null) mModePicker.setEnabled(true);
+ keepScreenOnAwhile();
}
private void showTooFastIndication() {
@@ -913,6 +921,7 @@ public class PanoramaActivity extends ActivityBase implements
mMosaicView.onPause();
clearMosaicFrameProcessorIfNeeded();
mOrientationEventListener.disable();
+ resetScreenOn();
System.gc();
}
@@ -930,6 +939,7 @@ public class PanoramaActivity extends ActivityBase implements
mMosaicView.onResume();
initThumbnailButton();
+ keepScreenOnAwhile();
}
public MosaicJpeg generateFinalMosaic(boolean highRes) {
@@ -1007,4 +1017,26 @@ public class PanoramaActivity extends ActivityBase implements
}
mCameraState = PREVIEW_STOPPED;
}
+
+ @Override
+ public void onUserInteraction() {
+ super.onUserInteraction();
+ if (mCaptureState != CAPTURE_STATE_MOSAIC) keepScreenOnAwhile();
+ }
+
+ private void resetScreenOn() {
+ mMainHandler.removeMessages(MSG_CLEAR_SCREEN_DELAY);
+ getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+ }
+
+ private void keepScreenOnAwhile() {
+ mMainHandler.removeMessages(MSG_CLEAR_SCREEN_DELAY);
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+ mMainHandler.sendEmptyMessageDelayed(MSG_CLEAR_SCREEN_DELAY, SCREEN_DELAY);
+ }
+
+ private void keepScreenOn() {
+ mMainHandler.removeMessages(MSG_CLEAR_SCREEN_DELAY);
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+ }
}