Improve the wallpaper crop & rescale logic

The current crop/rescale logic is... weird. See the associated bug for
moe details.

Instead, let's do the following:
   - if all crops for all orientations have more height in px than their
     associated screen, downsample the image
   - if the "total crop" width or height is more than twice the screen
     largest dimension or the max openGL texture size, downsample
     (note: "twice" is to let room for parallax, or to let have a too
     high res image (to some extent) as long as the crops are low res.
     This is more a security check and should not be used in practice.)

Also, move from using ImageDecoder.decodeBitmap() with sampleSize then
Bitmap.createScaledBitmap, to using ImageDecoder.decodeBitmap() with
targetSize, which should reduce the amount of IO.

Test: manual
Test: atest WallpaperManagerTest, WallpaperCropperTest
Bug: 332695334
Flag: aconfig com.android.window.flags.multi_crop
Change-Id: I68f1b48d136c4942880fc55e79cbbf7a16763b66
1 file changed