Merge "Fixing potential ANR when fetching for wallpaper info" into tm-dev

This commit is contained in:
TreeHugger Robot
2022-04-11 22:43:43 +00:00
committed by Android (Google) Code Review
@@ -14,6 +14,8 @@ import android.os.SystemClock;
import android.util.Log;
import android.view.animation.Interpolator;
import androidx.annotation.AnyThread;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
import com.android.launcher3.anim.Interpolators;
@@ -182,6 +184,7 @@ public class WallpaperOffsetInterpolator extends BroadcastReceiver {
}
}
@AnyThread
private void updateOffset() {
Message.obtain(mHandler, MSG_SET_NUM_PARALLAX, getNumPagesForWallpaperParallax(), 0,
mWindowToken).sendToTarget();
@@ -206,9 +209,12 @@ public class WallpaperOffsetInterpolator extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
mWallpaperIsLiveWallpaper =
WallpaperManager.getInstance(mWorkspace.getContext()).getWallpaperInfo() != null;
updateOffset();
UI_HELPER_EXECUTOR.execute(() -> {
// Updating the boolean on a background thread is fine as the assignments are atomic
mWallpaperIsLiveWallpaper =
WallpaperManager.getInstance(context).getWallpaperInfo() != null;
updateOffset();
});
}
private static final int MSG_START_ANIMATION = 1;