Always use low-res tasksnapshots for low ram devices

All snapshots are now stored using only the low resolution bitmaps
where all full size bitmaps are disabled to be written or loaded.

Bug: 62251652
Fixes: 63940837
Test: manual - open recents on low ram device to see if thumbnail is
there
Change-Id: I2128f0348cf71415721e73c730d3ed92e95d8144
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotController.java b/services/core/java/com/android/server/wm/TaskSnapshotController.java
index bc7f330..ecf9067 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotController.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotController.java
@@ -18,6 +18,8 @@
 
 import static android.app.ActivityManager.ENABLE_TASK_SNAPSHOTS;
 
+import static com.android.server.wm.TaskSnapshotPersister.DISABLE_FULL_SIZED_BITMAPS;
+import static com.android.server.wm.TaskSnapshotPersister.REDUCED_SCALE;
 import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
 import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
 
@@ -188,7 +190,8 @@
      */
     @Nullable TaskSnapshot getSnapshot(int taskId, int userId, boolean restoreFromDisk,
             boolean reducedResolution) {
-        return mCache.getSnapshot(taskId, userId, restoreFromDisk, reducedResolution);
+        return mCache.getSnapshot(taskId, userId, restoreFromDisk, reducedResolution
+                || DISABLE_FULL_SIZED_BITMAPS);
     }
 
     /**
@@ -209,14 +212,16 @@
         if (mainWindow == null) {
             return null;
         }
+        final boolean isLowRamDevice = ActivityManager.isLowRamDeviceStatic();
+        final float scaleFraction = isLowRamDevice ? REDUCED_SCALE : 1f;
         final GraphicBuffer buffer = top.mDisplayContent.screenshotApplicationsToBuffer(top.token,
-                -1, -1, false, 1.0f, false, true);
+                -1, -1, false, scaleFraction, false, true);
         if (buffer == null || buffer.getWidth() <= 1 || buffer.getHeight() <= 1) {
             return null;
         }
         return new TaskSnapshot(buffer, top.getConfiguration().orientation,
-                minRect(mainWindow.mContentInsets, mainWindow.mStableInsets), false /* reduced */,
-                1f /* scale */);
+                minRect(mainWindow.mContentInsets, mainWindow.mStableInsets),
+                isLowRamDevice /* reduced */, scaleFraction /* scale */);
     }
 
     private boolean shouldDisableSnapshots() {