Only preload tasks in background when service is connected
Bug: 76162466 Test: Disable the component, ensure no task snapshots are preloaded Change-Id: I86b66c79eb2c33796fef09d4466bc313f1c6af69
This commit is contained in:
parent
d39b8755b5
commit
b882b171e0
|
@ -87,7 +87,8 @@ public class RecentsModel extends TaskStackChangeListener {
|
||||||
private int mTaskChangeId;
|
private int mTaskChangeId;
|
||||||
private ISystemUiProxy mSystemUiProxy;
|
private ISystemUiProxy mSystemUiProxy;
|
||||||
private boolean mClearAssistCacheOnStackChange = true;
|
private boolean mClearAssistCacheOnStackChange = true;
|
||||||
private final boolean mPreloadTasksInBackground;
|
private final boolean mIsLowRamDevice;
|
||||||
|
private boolean mPreloadTasksInBackground;
|
||||||
private final AccessibilityManager mAccessibilityManager;
|
private final AccessibilityManager mAccessibilityManager;
|
||||||
|
|
||||||
private RecentsModel(Context context) {
|
private RecentsModel(Context context) {
|
||||||
|
@ -95,7 +96,7 @@ public class RecentsModel extends TaskStackChangeListener {
|
||||||
|
|
||||||
ActivityManager activityManager =
|
ActivityManager activityManager =
|
||||||
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||||
mPreloadTasksInBackground = !activityManager.isLowRamDevice();
|
mIsLowRamDevice = activityManager.isLowRamDevice();
|
||||||
mMainThreadExecutor = new MainThreadExecutor();
|
mMainThreadExecutor = new MainThreadExecutor();
|
||||||
|
|
||||||
Resources res = context.getResources();
|
Resources res = context.getResources();
|
||||||
|
@ -160,6 +161,10 @@ public class RecentsModel extends TaskStackChangeListener {
|
||||||
return requestId;
|
return requestId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPreloadTasksInBackground(boolean preloadTasksInBackground) {
|
||||||
|
mPreloadTasksInBackground = preloadTasksInBackground && !mIsLowRamDevice;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityPinned(String packageName, int userId, int taskId, int stackId) {
|
public void onActivityPinned(String packageName, int userId, int taskId, int stackId) {
|
||||||
mTaskChangeId++;
|
mTaskChangeId++;
|
||||||
|
|
|
@ -173,6 +173,7 @@ public class TouchInteractionService extends Service {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
mAM = ActivityManagerWrapper.getInstance();
|
mAM = ActivityManagerWrapper.getInstance();
|
||||||
mRecentsModel = RecentsModel.getInstance(this);
|
mRecentsModel = RecentsModel.getInstance(this);
|
||||||
|
mRecentsModel.setPreloadTasksInBackground(true);
|
||||||
mMainThreadExecutor = new MainThreadExecutor();
|
mMainThreadExecutor = new MainThreadExecutor();
|
||||||
mOverviewCommandHelper = new OverviewCommandHelper(this);
|
mOverviewCommandHelper = new OverviewCommandHelper(this);
|
||||||
mMainThreadChoreographer = Choreographer.getInstance();
|
mMainThreadChoreographer = Choreographer.getInstance();
|
||||||
|
|
Loading…
Reference in New Issue