summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 b60639f..c3fb90a 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;
@@ -127,6 +128,7 @@ public class Camera extends NoSearchActivity 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;
@@ -241,6 +243,16 @@ public class Camera extends NoSearchActivity 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.
@@ -269,6 +281,7 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
readPreference();
if (mRecordLocation) startReceivingLocationUpdates();
+ keepMediaProviderInstance();
checkStorage();
// Initialize last picture button.
@@ -330,6 +343,7 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
initializeFocusTone();
+ keepMediaProviderInstance();
checkStorage();
if (mZoomButtons != null) {
@@ -992,6 +1006,15 @@ public class Camera extends NoSearchActivity 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;