summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera
diff options
context:
space:
mode:
authorRay Chen <raychen@google.com>2009-11-16 14:43:29 -0800
committerRay Chen <raychen@google.com>2009-11-16 23:21:02 -0800
commit6d68a36b5da24f70e1a8d5e9529720eeb8ce6d86 (patch)
treebd720453b1f8dab44720754a2d18d1a6363acc6b /src/com/android/camera
parent4d55cb369de5933025af40bece5e08830aae935e (diff)
downloadLegacyCamera-6d68a36b5da24f70e1a8d5e9529720eeb8ce6d86.zip
LegacyCamera-6d68a36b5da24f70e1a8d5e9529720eeb8ce6d86.tar.gz
LegacyCamera-6d68a36b5da24f70e1a8d5e9529720eeb8ce6d86.tar.bz2
Fix issue 2259506 and 2262817 by keeping a reference to MediaProvider when camera is active.
Diffstat (limited to 'src/com/android/camera')
-rw-r--r--src/com/android/camera/Camera.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 22612ce..6fc0992 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -19,6 +19,7 @@ package com.android.camera;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
+import android.content.ContentProviderClient;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
@@ -126,6 +127,7 @@ public class Camera extends Activity implements View.OnClickListener,
private static final String sTempCropFilename = "crop-temp";
private android.hardware.Camera mCameraDevice;
+ private ContentProviderClient mMediaProviderClient;
private SurfaceView mSurfaceView;
private SurfaceHolder mSurfaceHolder = null;
private ShutterButton mShutterButton;
@@ -239,6 +241,16 @@ public class Camera extends Activity implements View.OnClickListener,
}
}
+ private void keepMediaProviderInstance() {
+ // We want to keep a reference to MediaProvider in camera's lifecycle.
+ // TODO: Utilize mMediaProviderClient instance to replace
+ // ContentResolver calls.
+ if (mMediaProviderClient == null) {
+ mMediaProviderClient = getContentResolver()
+ .acquireContentProviderClient(MediaStore.AUTHORITY);
+ }
+ }
+
// Snapshots can only be taken after this is called. It should be called
// once only. We could have done these things in onCreate() but we want to
// make preview screen appear as soon as possible.
@@ -267,6 +279,7 @@ public class Camera extends Activity implements View.OnClickListener,
readPreference();
if (mRecordLocation) startReceivingLocationUpdates();
+ keepMediaProviderInstance();
checkStorage();
// Initialize last picture button.
@@ -328,6 +341,7 @@ public class Camera extends Activity implements View.OnClickListener,
initializeFocusTone();
+ keepMediaProviderInstance();
checkStorage();
if (mZoomButtons != null) {
@@ -990,6 +1004,15 @@ public class Camera extends Activity implements View.OnClickListener,
}
}
+ @Override
+ public void onStop() {
+ super.onStop();
+ if (mMediaProviderClient != null) {
+ mMediaProviderClient.release();
+ mMediaProviderClient = null;
+ }
+ }
+
private void checkStorage() {
if (ImageManager.isMediaScannerScanning(getContentResolver())) {
mPicturesRemaining = MenuHelper.NO_STORAGE_ERROR;