summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/screenshot
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2015-05-29 13:36:56 -0700
committerWinson Chung <winsonc@google.com>2015-06-01 11:15:45 -0700
commitebd77b550be51ccb535b76ac5ba04d37658d2a45 (patch)
tree7e6476f2a2515fe3ba617813c9d49b2540614a97 /packages/SystemUI/src/com/android/systemui/screenshot
parentf042cd841fcc6607bb84f8ddb25db3f4b6ddb3e0 (diff)
downloadframeworks_base-ebd77b550be51ccb535b76ac5ba04d37658d2a45.zip
frameworks_base-ebd77b550be51ccb535b76ac5ba04d37658d2a45.tar.gz
frameworks_base-ebd77b550be51ccb535b76ac5ba04d37658d2a45.tar.bz2
Ensuring that we write to disk first.
Change-Id: I2c55db77ab6feef1b405858aac53fb0ed3370dc2
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/screenshot')
-rw-r--r--packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java19
1 files changed, 9 insertions, 10 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
index 7e32c3a..6d02365 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
@@ -60,6 +60,7 @@ import android.widget.ImageView;
import com.android.systemui.R;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.OutputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
@@ -232,6 +233,12 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
// for DATE_TAKEN
long dateSeconds = mImageTime / 1000;
+ // Save
+ OutputStream out = new FileOutputStream(mImageFilePath);
+ image.compress(Bitmap.CompressFormat.PNG, 100, out);
+ out.flush();
+ out.close();
+
// Save the screenshot to the MediaStore
ContentValues values = new ContentValues();
ContentResolver resolver = context.getContentResolver();
@@ -244,8 +251,10 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
values.put(MediaStore.Images.ImageColumns.MIME_TYPE, "image/png");
values.put(MediaStore.Images.ImageColumns.WIDTH, mImageWidth);
values.put(MediaStore.Images.ImageColumns.HEIGHT, mImageHeight);
+ values.put(MediaStore.Images.ImageColumns.SIZE, new File(mImageFilePath).length());
Uri uri = resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
+ // Create a share intent
String subjectDate = DateFormat.getDateTimeInstance().format(new Date(mImageTime));
String subject = String.format(SCREENSHOT_SHARE_SUBJECT_TEMPLATE, subjectDate);
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
@@ -253,16 +262,6 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
sharingIntent.putExtra(Intent.EXTRA_STREAM, uri);
sharingIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
- OutputStream out = resolver.openOutputStream(uri);
- image.compress(Bitmap.CompressFormat.PNG, 100, out);
- out.flush();
- out.close();
-
- // Update file size in the database
- values.clear();
- values.put(MediaStore.Images.ImageColumns.SIZE, new File(mImageFilePath).length());
- resolver.update(uri, values, null, null);
-
// Create a share action for the notification
final PendingIntent callback = PendingIntent.getBroadcast(context, 0,
new Intent(context, GlobalScreenshot.TargetChosenReceiver.class)