diff options
author | Ahan Wu <ahanwu@google.com> | 2020-06-03 04:21:45 +0800 |
---|---|---|
committer | Anis Assi <anisassi@google.com> | 2020-06-04 11:25:48 -0700 |
commit | 71be05dc5d419aacd0d42484f7b6d2f44907e818 (patch) | |
tree | 5e2381fbc13a7c2f06f50d351cef00e7bfb7132c | |
parent | d53922f21328e1ab0d1def4f9bffad26b9cb6980 (diff) | |
download | base-71be05dc5d419aacd0d42484f7b6d2f44907e818.tar.gz |
DO NOT MERGE Prevent ImageWallpaper from keeping crashingandroid-8.1.0_r79
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
(cherry picked from commit a3bff94e184590351fd95f630e8b8313d1d2053b)
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/ImageWallpaper.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java index 907a79e723ac..db994d087d81 100644 --- a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java +++ b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java @@ -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"); |