Loading services/core/java/com/android/server/wm/AppWindowToken.java +1 −1 Original line number Diff line number Diff line Loading @@ -1975,7 +1975,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree } else if (newTask || !processRunning || (taskSwitch && !activityCreated)) { return STARTING_WINDOW_TYPE_SPLASH_SCREEN; } else if (taskSwitch && allowTaskSnapshot) { if (mWmService.mLowRamTaskSnapshots) { if (mWmService.mLowRamTaskSnapshotsAndRecents) { // For low RAM devices, we use the splash screen starting window instead of the // task snapshot starting window. return STARTING_WINDOW_TYPE_SPLASH_SCREEN; Loading services/core/java/com/android/server/wm/TaskSnapshotController.java +5 −5 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.server.wm; 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.DEBUG_SCREENSHOT; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; Loading Loading @@ -90,9 +89,8 @@ class TaskSnapshotController { private final WindowManagerService mService; private final TaskSnapshotCache mCache; private final TaskSnapshotPersister mPersister = new TaskSnapshotPersister( Environment::getDataSystemCeDirectory); private final TaskSnapshotLoader mLoader = new TaskSnapshotLoader(mPersister); private final TaskSnapshotPersister mPersister; private final TaskSnapshotLoader mLoader; private final ArraySet<Task> mSkipClosingAppSnapshotTasks = new ArraySet<>(); private final ArraySet<Task> mTmpTasks = new ArraySet<>(); private final Handler mHandler = new Handler(); Loading @@ -116,6 +114,8 @@ class TaskSnapshotController { TaskSnapshotController(WindowManagerService service) { mService = service; mPersister = new TaskSnapshotPersister(mService, Environment::getDataSystemCeDirectory); mLoader = new TaskSnapshotLoader(mPersister); mCache = new TaskSnapshotCache(mService, mLoader); mIsRunningOnTv = mService.mContext.getPackageManager().hasSystemFeature( PackageManager.FEATURE_LEANBACK); Loading Loading @@ -270,7 +270,7 @@ class TaskSnapshotController { } final boolean isLowRamDevice = ActivityManager.isLowRamDeviceStatic(); final float scaleFraction = isLowRamDevice ? REDUCED_SCALE : 1f; final float scaleFraction = isLowRamDevice ? mPersister.getReducedScale() : 1f; task.getBounds(mTmpRect); mTmpRect.offsetTo(0, 0); Loading services/core/java/com/android/server/wm/TaskSnapshotLoader.java +1 −2 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.server.wm; import static com.android.server.wm.TaskSnapshotPersister.*; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; Loading Loading @@ -92,7 +91,7 @@ class TaskSnapshotLoader { proto.topActivityComponent); return new TaskSnapshot(topActivityComponent, buffer, proto.orientation, new Rect(proto.insetLeft, proto.insetTop, proto.insetRight, proto.insetBottom), reducedResolution, reducedResolution ? REDUCED_SCALE : 1f, reducedResolution, reducedResolution ? mPersister.getReducedScale() : 1f, proto.isRealSnapshot, proto.windowingMode, proto.systemUiVisibility, proto.isTranslucent); } catch (IOException e) { Loading services/core/java/com/android/server/wm/TaskSnapshotPersister.java +24 −4 Original line number Diff line number Diff line Loading @@ -52,7 +52,9 @@ class TaskSnapshotPersister { private static final String TAG = TAG_WITH_CLASS_NAME ? "TaskSnapshotPersister" : TAG_WM; private static final String SNAPSHOTS_DIRNAME = "snapshots"; private static final String REDUCED_POSTFIX = "_reduced"; static final float REDUCED_SCALE = ActivityManager.isLowRamDeviceStatic() ? 0.6f : 0.5f; private static final float REDUCED_SCALE = .5f; private static final float LOW_RAM_REDUCED_SCALE = .6f; private static final float LOW_RAM_RECENTS_REDUCED_SCALE = .1f; static final boolean DISABLE_FULL_SIZED_BITMAPS = ActivityManager.isLowRamDeviceStatic(); private static final long DELAY_MS = 100; private static final int QUALITY = 95; Loading @@ -71,6 +73,7 @@ class TaskSnapshotPersister { private boolean mStarted; private final Object mLock = new Object(); private final DirectoryResolver mDirectoryResolver; private final float mReducedScale; /** * The list of ids of the tasks that have been persisted since {@link #removeObsoleteFiles} was Loading @@ -79,8 +82,16 @@ class TaskSnapshotPersister { @GuardedBy("mLock") private final ArraySet<Integer> mPersistedTaskIdsSinceLastRemoveObsolete = new ArraySet<>(); TaskSnapshotPersister(DirectoryResolver resolver) { TaskSnapshotPersister(WindowManagerService service, DirectoryResolver resolver) { mDirectoryResolver = resolver; if (service.mLowRamTaskSnapshotsAndRecents) { // Use very low res snapshots if we are using Go version of recents. mReducedScale = LOW_RAM_RECENTS_REDUCED_SCALE; } else { // TODO(122671846) Replace the low RAM value scale with the above when it is fully built mReducedScale = ActivityManager.isLowRamDeviceStatic() ? LOW_RAM_REDUCED_SCALE : REDUCED_SCALE; } } /** Loading Loading @@ -144,6 +155,15 @@ class TaskSnapshotPersister { } } /** * Gets the scaling the persister uses for low resolution task snapshots. * * @return the reduced scale of task snapshots when they are set to be low res */ float getReducedScale() { return mReducedScale; } @TestApi void waitForQueueEmpty() { while (true) { Loading Loading @@ -350,8 +370,8 @@ class TaskSnapshotPersister { final Bitmap reduced = mSnapshot.isReducedResolution() ? swBitmap : Bitmap.createScaledBitmap(swBitmap, (int) (bitmap.getWidth() * REDUCED_SCALE), (int) (bitmap.getHeight() * REDUCED_SCALE), true /* filter */); (int) (bitmap.getWidth() * mReducedScale), (int) (bitmap.getHeight() * mReducedScale), true /* filter */); try { FileOutputStream reducedFos = new FileOutputStream(reducedFile); reduced.compress(JPEG, QUALITY, reducedFos); Loading services/core/java/com/android/server/wm/WindowManagerService.java +3 −2 Original line number Diff line number Diff line Loading @@ -433,11 +433,12 @@ public class WindowManagerService extends IWindowManager.Stub final long mDrawLockTimeoutMillis; final boolean mAllowAnimationsInLowPowerMode; // TODO(b/122671846) Remove the flag below in favor of isLowRam once feature is stable /** * Use very low resolution task snapshots. Replaces task snapshot starting windows with * splashscreen starting windows. Used on low RAM devices to save memory. */ final boolean mLowRamTaskSnapshots; final boolean mLowRamTaskSnapshotsAndRecents; final boolean mAllowBootMessages; Loading Loading @@ -955,7 +956,7 @@ public class WindowManagerService extends IWindowManager.Stub com.android.internal.R.bool.config_disableTransitionAnimation); mPerDisplayFocusEnabled = context.getResources().getBoolean( com.android.internal.R.bool.config_perDisplayFocusEnabled); mLowRamTaskSnapshots = context.getResources().getBoolean( mLowRamTaskSnapshotsAndRecents = context.getResources().getBoolean( com.android.internal.R.bool.config_lowRamTaskSnapshotsAndRecents); mInputManager = inputManager; // Must be before createDisplayContentLocked. mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class); Loading Loading
services/core/java/com/android/server/wm/AppWindowToken.java +1 −1 Original line number Diff line number Diff line Loading @@ -1975,7 +1975,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree } else if (newTask || !processRunning || (taskSwitch && !activityCreated)) { return STARTING_WINDOW_TYPE_SPLASH_SCREEN; } else if (taskSwitch && allowTaskSnapshot) { if (mWmService.mLowRamTaskSnapshots) { if (mWmService.mLowRamTaskSnapshotsAndRecents) { // For low RAM devices, we use the splash screen starting window instead of the // task snapshot starting window. return STARTING_WINDOW_TYPE_SPLASH_SCREEN; Loading
services/core/java/com/android/server/wm/TaskSnapshotController.java +5 −5 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.server.wm; 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.DEBUG_SCREENSHOT; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; Loading Loading @@ -90,9 +89,8 @@ class TaskSnapshotController { private final WindowManagerService mService; private final TaskSnapshotCache mCache; private final TaskSnapshotPersister mPersister = new TaskSnapshotPersister( Environment::getDataSystemCeDirectory); private final TaskSnapshotLoader mLoader = new TaskSnapshotLoader(mPersister); private final TaskSnapshotPersister mPersister; private final TaskSnapshotLoader mLoader; private final ArraySet<Task> mSkipClosingAppSnapshotTasks = new ArraySet<>(); private final ArraySet<Task> mTmpTasks = new ArraySet<>(); private final Handler mHandler = new Handler(); Loading @@ -116,6 +114,8 @@ class TaskSnapshotController { TaskSnapshotController(WindowManagerService service) { mService = service; mPersister = new TaskSnapshotPersister(mService, Environment::getDataSystemCeDirectory); mLoader = new TaskSnapshotLoader(mPersister); mCache = new TaskSnapshotCache(mService, mLoader); mIsRunningOnTv = mService.mContext.getPackageManager().hasSystemFeature( PackageManager.FEATURE_LEANBACK); Loading Loading @@ -270,7 +270,7 @@ class TaskSnapshotController { } final boolean isLowRamDevice = ActivityManager.isLowRamDeviceStatic(); final float scaleFraction = isLowRamDevice ? REDUCED_SCALE : 1f; final float scaleFraction = isLowRamDevice ? mPersister.getReducedScale() : 1f; task.getBounds(mTmpRect); mTmpRect.offsetTo(0, 0); Loading
services/core/java/com/android/server/wm/TaskSnapshotLoader.java +1 −2 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.server.wm; import static com.android.server.wm.TaskSnapshotPersister.*; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; Loading Loading @@ -92,7 +91,7 @@ class TaskSnapshotLoader { proto.topActivityComponent); return new TaskSnapshot(topActivityComponent, buffer, proto.orientation, new Rect(proto.insetLeft, proto.insetTop, proto.insetRight, proto.insetBottom), reducedResolution, reducedResolution ? REDUCED_SCALE : 1f, reducedResolution, reducedResolution ? mPersister.getReducedScale() : 1f, proto.isRealSnapshot, proto.windowingMode, proto.systemUiVisibility, proto.isTranslucent); } catch (IOException e) { Loading
services/core/java/com/android/server/wm/TaskSnapshotPersister.java +24 −4 Original line number Diff line number Diff line Loading @@ -52,7 +52,9 @@ class TaskSnapshotPersister { private static final String TAG = TAG_WITH_CLASS_NAME ? "TaskSnapshotPersister" : TAG_WM; private static final String SNAPSHOTS_DIRNAME = "snapshots"; private static final String REDUCED_POSTFIX = "_reduced"; static final float REDUCED_SCALE = ActivityManager.isLowRamDeviceStatic() ? 0.6f : 0.5f; private static final float REDUCED_SCALE = .5f; private static final float LOW_RAM_REDUCED_SCALE = .6f; private static final float LOW_RAM_RECENTS_REDUCED_SCALE = .1f; static final boolean DISABLE_FULL_SIZED_BITMAPS = ActivityManager.isLowRamDeviceStatic(); private static final long DELAY_MS = 100; private static final int QUALITY = 95; Loading @@ -71,6 +73,7 @@ class TaskSnapshotPersister { private boolean mStarted; private final Object mLock = new Object(); private final DirectoryResolver mDirectoryResolver; private final float mReducedScale; /** * The list of ids of the tasks that have been persisted since {@link #removeObsoleteFiles} was Loading @@ -79,8 +82,16 @@ class TaskSnapshotPersister { @GuardedBy("mLock") private final ArraySet<Integer> mPersistedTaskIdsSinceLastRemoveObsolete = new ArraySet<>(); TaskSnapshotPersister(DirectoryResolver resolver) { TaskSnapshotPersister(WindowManagerService service, DirectoryResolver resolver) { mDirectoryResolver = resolver; if (service.mLowRamTaskSnapshotsAndRecents) { // Use very low res snapshots if we are using Go version of recents. mReducedScale = LOW_RAM_RECENTS_REDUCED_SCALE; } else { // TODO(122671846) Replace the low RAM value scale with the above when it is fully built mReducedScale = ActivityManager.isLowRamDeviceStatic() ? LOW_RAM_REDUCED_SCALE : REDUCED_SCALE; } } /** Loading Loading @@ -144,6 +155,15 @@ class TaskSnapshotPersister { } } /** * Gets the scaling the persister uses for low resolution task snapshots. * * @return the reduced scale of task snapshots when they are set to be low res */ float getReducedScale() { return mReducedScale; } @TestApi void waitForQueueEmpty() { while (true) { Loading Loading @@ -350,8 +370,8 @@ class TaskSnapshotPersister { final Bitmap reduced = mSnapshot.isReducedResolution() ? swBitmap : Bitmap.createScaledBitmap(swBitmap, (int) (bitmap.getWidth() * REDUCED_SCALE), (int) (bitmap.getHeight() * REDUCED_SCALE), true /* filter */); (int) (bitmap.getWidth() * mReducedScale), (int) (bitmap.getHeight() * mReducedScale), true /* filter */); try { FileOutputStream reducedFos = new FileOutputStream(reducedFile); reduced.compress(JPEG, QUALITY, reducedFos); Loading
services/core/java/com/android/server/wm/WindowManagerService.java +3 −2 Original line number Diff line number Diff line Loading @@ -433,11 +433,12 @@ public class WindowManagerService extends IWindowManager.Stub final long mDrawLockTimeoutMillis; final boolean mAllowAnimationsInLowPowerMode; // TODO(b/122671846) Remove the flag below in favor of isLowRam once feature is stable /** * Use very low resolution task snapshots. Replaces task snapshot starting windows with * splashscreen starting windows. Used on low RAM devices to save memory. */ final boolean mLowRamTaskSnapshots; final boolean mLowRamTaskSnapshotsAndRecents; final boolean mAllowBootMessages; Loading Loading @@ -955,7 +956,7 @@ public class WindowManagerService extends IWindowManager.Stub com.android.internal.R.bool.config_disableTransitionAnimation); mPerDisplayFocusEnabled = context.getResources().getBoolean( com.android.internal.R.bool.config_perDisplayFocusEnabled); mLowRamTaskSnapshots = context.getResources().getBoolean( mLowRamTaskSnapshotsAndRecents = context.getResources().getBoolean( com.android.internal.R.bool.config_lowRamTaskSnapshotsAndRecents); mInputManager = inputManager; // Must be before createDisplayContentLocked. mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class); Loading