Merge "Kicking the trim memory callback off the main thread" into ub-launcher3-master
diff --git a/quickstep/src/com/android/quickstep/RecentsModel.java b/quickstep/src/com/android/quickstep/RecentsModel.java
index 196f0cc..517f759 100644
--- a/quickstep/src/com/android/quickstep/RecentsModel.java
+++ b/quickstep/src/com/android/quickstep/RecentsModel.java
@@ -27,6 +27,7 @@
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
+import android.os.Handler;
import android.os.RemoteException;
import android.os.UserHandle;
import android.util.Log;
@@ -38,6 +39,7 @@
import com.android.launcher3.R;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.Preconditions;
+import com.android.launcher3.util.UiThreadHelper;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.recents.model.IconLoader;
import com.android.systemui.shared.recents.model.RecentsTaskLoadPlan;
@@ -68,6 +70,7 @@
private final Context mContext;
private final RecentsTaskLoader mRecentsTaskLoader;
private final MainThreadExecutor mMainThreadExecutor;
+ private final Handler mBgHandler;
private RecentsTaskLoadPlan mLastLoadPlan;
private int mLastLoadPlanId;
@@ -85,6 +88,7 @@
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
mIsLowRamDevice = activityManager.isLowRamDevice();
mMainThreadExecutor = new MainThreadExecutor();
+ mBgHandler = new Handler(UiThreadHelper.getBackgroundLooper());
Resources res = context.getResources();
mRecentsTaskLoader = new RecentsTaskLoader(mContext,
@@ -226,7 +230,7 @@
// We already stop the loader in UI_HIDDEN, so stop the high res loader as well
mRecentsTaskLoader.getHighResThumbnailLoader().setVisible(false);
}
- mRecentsTaskLoader.onTrimMemory(level);
+ mBgHandler.post(() -> mRecentsTaskLoader.onTrimMemory(level));
}
public void onOverviewShown(boolean fromHome, String tag) {