diff options
4 files changed, 14 insertions, 6 deletions
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl index caf9c8b810ca..fd458663a13a 100644 --- a/core/java/android/view/IWindowManager.aidl +++ b/core/java/android/view/IWindowManager.aidl @@ -205,7 +205,8 @@ interface IWindowManager /** * Create a screenshot of the applications currently displayed. */ - Bitmap screenshotApplications(IBinder appToken, int displayId, int maxWidth, int maxHeight); + Bitmap screenshotApplications(IBinder appToken, int displayId, int maxWidth, + int maxHeight, boolean force565); /** * Called by the status bar to notify Views of changes to System UI visiblity. diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index f2ff9ca646c1..f23bcba6f04a 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -254,7 +254,7 @@ public final class ActivityManagerService extends ActivityManagerNative static final boolean IS_USER_BUILD = "user".equals(Build.TYPE); // Maximum number of recent tasks that we can remember. - static final int MAX_RECENT_TASKS = 20; + static final int MAX_RECENT_TASKS = ActivityManager.isLowRamDeviceStatic() ? 10 : 20; // Amount of time after a call to stopAppSwitches() during which we will // prevent further untrusted switches from happening. diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java index 28c87d1e5ea6..45b30f1cf60a 100644 --- a/services/java/com/android/server/am/ActivityStack.java +++ b/services/java/com/android/server/am/ActivityStack.java @@ -121,6 +121,9 @@ final class ActivityStack { // convertToTranslucent(). static final long TRANSLUCENT_CONVERSION_TIMEOUT = 2000; + static final boolean SCREENSHOT_FORCE_565 = ActivityManager + .isLowRamDeviceStatic() ? true : false; + enum ActivityState { INITIALIZING, RESUMED, @@ -691,10 +694,10 @@ final class ActivityStack { || mLastScreenshotBitmap.getHeight() != h) { mLastScreenshotActivity = who; mLastScreenshotBitmap = mWindowManager.screenshotApplications( - who.appToken, Display.DEFAULT_DISPLAY, w, h); + who.appToken, Display.DEFAULT_DISPLAY, w, h, SCREENSHOT_FORCE_565); } if (mLastScreenshotBitmap != null) { - return mLastScreenshotBitmap.copy(Config.ARGB_8888, true); + return mLastScreenshotBitmap.copy(mLastScreenshotBitmap.getConfig(), true); } } return null; diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index e625caea25e5..3b572e453e4d 100644 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -60,6 +60,7 @@ import android.content.pm.PackageManager; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.graphics.Bitmap; +import android.graphics.Bitmap.Config; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.PixelFormat; @@ -5513,9 +5514,12 @@ public class WindowManagerService extends IWindowManager.Stub * @param displayId the Display to take a screenshot of. * @param width the width of the target bitmap * @param height the height of the target bitmap + * @param force565 if true the returned bitmap will be RGB_565, otherwise it + * will be the same config as the surface */ @Override - public Bitmap screenshotApplications(IBinder appToken, int displayId, int width, int height) { + public Bitmap screenshotApplications(IBinder appToken, int displayId, int width, + int height, boolean force565) { if (!checkCallingPermission(android.Manifest.permission.READ_FRAME_BUFFER, "screenshotApplications()")) { throw new SecurityException("Requires READ_FRAME_BUFFER permission"); @@ -5718,7 +5722,7 @@ public class WindowManagerService extends IWindowManager.Stub return null; } - Bitmap bm = Bitmap.createBitmap(width, height, rawss.getConfig()); + Bitmap bm = Bitmap.createBitmap(width, height, force565 ? Config.RGB_565 : rawss.getConfig()); frame.scale(scale); Matrix matrix = new Matrix(); ScreenRotationAnimation.createRotationMatrix(rot, dw, dh, matrix); |