summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/camera/CameraActivity.java50
1 files changed, 31 insertions, 19 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 300975845..b3a7680a9 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -49,6 +49,8 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
+import android.os.PowerManager;
+import android.os.PowerManager.WakeLock;
import android.os.SystemProperties;
import android.preference.PreferenceManager;
import android.provider.MediaStore;
@@ -217,6 +219,7 @@ public class CameraActivity extends Activity
private AudioManager mAudioManager;
private int mShutterVol;
private int mOriginalMasterVol;
+ private WakeLock mWakeLock;
private class MyOrientationEventListener
extends OrientationEventListener {
@@ -1176,25 +1179,6 @@ public class CameraActivity extends Activity
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
- GcamHelper.init(getContentResolver());
-
- mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
- mOriginalMasterVol = mAudioManager.getMasterVolume();
- mShutterVol = SystemProperties.getInt("persist.camera.snapshot.volume", -1);
- if (mShutterVol >= 0 && mShutterVol <= 100 )
- mAudioManager.setMasterVolume(mShutterVol,0);
-
- getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
- setContentView(R.layout.camera_filmstrip);
-
- mActionBar = getActionBar();
- mActionBar.addOnMenuVisibilityListener(this);
-
- if (ApiHelper.HAS_ROTATION_ANIMATION) {
- setRotationAnimation();
- }
-
- mMainHandler = new MainHandler(getMainLooper());
// Check if this is in the secure camera mode.
Intent intent = getIntent();
String action = intent.getAction();
@@ -1213,6 +1197,10 @@ public class CameraActivity extends Activity
params.flags |= WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
if (intent.getComponent().getClassName().equals(GESTURE_CAMERA_NAME)) {
params.flags |= WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
+ PowerManager pm = ((PowerManager) getSystemService(POWER_SERVICE));
+ mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
+ mWakeLock.acquire();
+ Log.d(TAG, "acquire wake lock");
}
win.setAttributes(params);
@@ -1228,6 +1216,26 @@ public class CameraActivity extends Activity
registerReceiver(sScreenOffReceiver, filter);
}
}
+ GcamHelper.init(getContentResolver());
+
+ mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
+ mOriginalMasterVol = mAudioManager.getMasterVolume();
+ mShutterVol = SystemProperties.getInt("persist.camera.snapshot.volume", -1);
+ if (mShutterVol >= 0 && mShutterVol <= 100 )
+ mAudioManager.setMasterVolume(mShutterVol,0);
+
+ getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
+ setContentView(R.layout.camera_filmstrip);
+
+ mActionBar = getActionBar();
+ mActionBar.addOnMenuVisibilityListener(this);
+
+ if (ApiHelper.HAS_ROTATION_ANIMATION) {
+ setRotationAnimation();
+ }
+
+ mMainHandler = new MainHandler(getMainLooper());
+
mAboveFilmstripControlLayout =
(FrameLayout) findViewById(R.id.camera_above_filmstrip_layout);
mAboveFilmstripControlLayout.setFitsSystemWindows(true);
@@ -1478,6 +1486,10 @@ public class CameraActivity extends Activity
@Override
public void onDestroy() {
+ if (mWakeLock != null && mWakeLock.isHeld()) {
+ mWakeLock.release();
+ Log.d(TAG, "wake lock release");
+ }
if (mShutterVol >= 0 && mShutterVol <= 100)
mAudioManager.setMasterVolume(mOriginalMasterVol,0);
if (mSecureCamera) {