Remove 0-length bitmap checks

It is not possible to have a wallpaper bitmap of width or height zero. Remove the unnecessary checks.

Bug: 243402530
Test: manual
Test: atest ImageWallpaperTest
Change-Id: I7279c169798ed11441c935192234884c48eaf614
This commit is contained in:
Aurélien Pomini
2022-10-28 17:10:59 +00:00
parent e0b68d396e
commit 0580dc49b1
2 changed files with 0 additions and 29 deletions

View File

@@ -764,9 +764,6 @@ public class ImageWallpaper extends WallpaperService {
Log.e(TAG, "Attempt to load a recycled bitmap");
} else if (mBitmap == bitmap) {
Log.e(TAG, "Loaded a bitmap that was already loaded");
} else if (bitmap.getWidth() < 1 || bitmap.getHeight() < 1) {
Log.e(TAG, "Attempt to load an invalid wallpaper of length "
+ bitmap.getWidth() + "x" + bitmap.getHeight());
} else {
// at this point, loading is done correctly.
loadSuccess = true;

View File

@@ -28,7 +28,6 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -289,9 +288,6 @@ public class ImageWallpaperTest extends SysuiTestCase {
testMinSurfaceHelper(8, 8);
testMinSurfaceHelper(100, 2000);
testMinSurfaceHelper(200, 1);
testMinSurfaceHelper(0, 1);
testMinSurfaceHelper(1, 0);
testMinSurfaceHelper(0, 0);
}
private void testMinSurfaceHelper(int bitmapWidth, int bitmapHeight) {
@@ -309,28 +305,6 @@ public class ImageWallpaperTest extends SysuiTestCase {
intThat(greaterThanOrEqualTo(ImageWallpaper.CanvasEngine.MIN_SURFACE_HEIGHT)));
}
@Test
public void testZeroBitmap() {
// test that a frame is never drawn with a 0 bitmap
testZeroBitmapHelper(0, 1);
testZeroBitmapHelper(1, 0);
testZeroBitmapHelper(0, 0);
}
private void testZeroBitmapHelper(int bitmapWidth, int bitmapHeight) {
clearInvocations(mSurfaceHolder);
setBitmapDimensions(bitmapWidth, bitmapHeight);
ImageWallpaper imageWallpaper = createImageWallpaperCanvas();
ImageWallpaper.CanvasEngine engine =
(ImageWallpaper.CanvasEngine) imageWallpaper.onCreateEngine();
ImageWallpaper.CanvasEngine spyEngine = spy(engine);
spyEngine.onCreate(mSurfaceHolder);
spyEngine.onSurfaceRedrawNeeded(mSurfaceHolder);
verify(spyEngine, never()).drawFrameOnCanvas(any());
}
@Test
public void testLoadDrawAndUnloadBitmap() {
setBitmapDimensions(LOW_BMP_WIDTH, LOW_BMP_HEIGHT);