summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/CameraActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/camera/CameraActivity.java')
-rw-r--r--src/com/android/camera/CameraActivity.java41
1 files changed, 36 insertions, 5 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 91cd742e7..e7c55dfab 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -210,6 +210,7 @@ public class CameraActivity extends Activity
private int mResultCodeForTesting;
private Intent mResultDataForTesting;
private OnScreenHint mStorageHint;
+ private final Object mStorageSpaceLock = new Object();
private long mStorageSpaceBytes = Storage.LOW_STORAGE_THRESHOLD_BYTES;
private boolean mSecureCamera;
private int mLastRawOrientation;
@@ -1862,16 +1863,21 @@ public class CameraActivity extends Activity
mFilmStripView.setPreviewGestures(previewGestures);
}
- protected void updateStorageSpace() {
- mStorageSpaceBytes = Storage.getAvailableSpace();
- if (Storage.switchSavePath()) {
+ protected long updateStorageSpace() {
+ synchronized (mStorageSpaceLock) {
mStorageSpaceBytes = Storage.getAvailableSpace();
- mCurrentModule.onSwitchSavePath();
+ if (Storage.switchSavePath()) {
+ mStorageSpaceBytes = Storage.getAvailableSpace();
+ mCurrentModule.onSwitchSavePath();
+ }
+ return mStorageSpaceBytes;
}
}
protected long getStorageSpaceBytes() {
- return mStorageSpaceBytes;
+ synchronized (mStorageSpaceLock) {
+ return mStorageSpaceBytes;
+ }
}
protected void updateStorageSpaceAndHint() {
@@ -1879,6 +1885,31 @@ public class CameraActivity extends Activity
updateStorageHint(mStorageSpaceBytes);
}
+ protected interface OnStorageUpdateDoneListener {
+ void onStorageUpdateDone(long storageSpace);
+ }
+
+ protected void updateStorageSpaceAndHint(final OnStorageUpdateDoneListener callback) {
+ (new AsyncTask<Void, Void, Long>() {
+ @Override
+ protected Long doInBackground(Void ... arg) {
+ return updateStorageSpace();
+ }
+
+ @Override
+ protected void onPostExecute(Long storageSpace) {
+ updateStorageHint(storageSpace);
+ // This callback returns after I/O to check disk, so we could be
+ // pausing and shutting down. If so, don't bother invoking.
+ if (callback != null && !mPaused) {
+ callback.onStorageUpdateDone(storageSpace);
+ } else {
+ Log.v(TAG, "ignoring storage callback after activity pause");
+ }
+ }
+ }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ }
+
protected void updateStorageHint(long storageSpace) {
String message = null;
if (storageSpace == Storage.UNAVAILABLE) {