Merge "Fixing issue where screenshot intent to file path did not show other screenshots. (Bug: 5333706)" into ics-mr0
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
index 181cc98..301ae73 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
@@ -38,6 +38,7 @@
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Environment;
+import android.os.Process;
import android.os.ServiceManager;
import android.provider.MediaStore;
import android.util.DisplayMetrics;
@@ -54,7 +55,6 @@
import android.widget.FrameLayout;
import android.widget.ImageView;
-import com.android.server.wm.WindowManagerService;
import com.android.systemui.R;
import java.io.File;
@@ -68,6 +68,7 @@
class SaveImageInBackgroundData {
Context context;
Bitmap image;
+ Uri imageUri;
Runnable finisher;
int iconSize;
int result;
@@ -128,9 +129,6 @@
(iconHeight - data.iconSize) / 2, data.iconSize, data.iconSize);
// Show the intermediate notification
- mLaunchIntent = new Intent(Intent.ACTION_VIEW);
- mLaunchIntent.setDataAndType(Uri.fromFile(new File(mImageFilePath)), "image/png");
- mLaunchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mTickerAddSpace = !mTickerAddSpace;
mNotificationId = nId;
mNotificationBuilder = new Notification.Builder(context)
@@ -152,6 +150,10 @@
protected SaveImageInBackgroundData doInBackground(SaveImageInBackgroundData... params) {
if (params.length != 1) return null;
+ // By default, AsyncTask sets the worker thread to have background thread priority, so bump
+ // it back up so that we save a little quicker.
+ Process.setThreadPriority(Process.THREAD_PRIORITY_FOREGROUND);
+
Context context = params[0].context;
Bitmap image = params[0].image;
@@ -178,6 +180,7 @@
values.put(MediaStore.Images.ImageColumns.SIZE, new File(mImageFilePath).length());
resolver.update(uri, values, null, null);
+ params[0].imageUri = uri;
params[0].result = 0;
} catch (Exception e) {
// IOException/UnsupportedOperationException may be thrown if external storage is not
@@ -197,6 +200,11 @@
// Show the final notification to indicate screenshot saved
Resources r = params.context.getResources();
+ // Create the intent to show the screenshot in gallery
+ mLaunchIntent = new Intent(Intent.ACTION_VIEW);
+ mLaunchIntent.setDataAndType(params.imageUri, "image/png");
+ mLaunchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
mNotificationBuilder
.setContentTitle(r.getString(R.string.screenshot_saved_title))
.setContentText(r.getString(R.string.screenshot_saved_text))