DO NOT MERGE Prevent ImageWallpaper from keeping crashing

GLUtil.texImage2D may throw exception that indicates bad image format.
We should catch this exception, otherwise, systemui may keep crashing.

Bug: 156087409
Test: Set a 16-bit rgb image as wallpaper
Test: Systemui shouldn't keep crashing
Change-Id: I6c9715c049b7848ecd5559ab76612a98dcd4ee6f
This commit is contained in:
Ahan Wu
2020-06-03 04:21:45 +08:00
committed by Wu Ahan
parent 6255311d39
commit a3bff94e18

View File

@@ -603,7 +603,16 @@ public class ImageWallpaper extends WallpaperService {
final FloatBuffer triangleVertices = createMesh(left, top, right, bottom);
final int texture = loadTexture(mBackground);
int texture = 0;
try {
texture = loadTexture(mBackground);
} catch (IllegalArgumentException e) {
mEgl.eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
mEgl.eglDestroySurface(mEglDisplay, mEglSurface);
mEgl.eglDestroyContext(mEglDisplay, mEglContext);
mEgl.eglTerminate(mEglDisplay);
return false;
}
final int program = buildProgram(sSimpleVS, sSimpleFS);
final int attribPosition = glGetAttribLocation(program, "position");