Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 20d4a69a authored by Ahan Wu's avatar Ahan Wu
Browse files

Catch possible exception while uploading texture

The GLUtils#texImage2D may throw IllegalArgumentException, this might
cause SystemUI keeps crashing, let's catch it and print error log.

Bug: 156087409
Test: Manually
Change-Id: I03e1b2bde1db2d10f4bb61df335147b787c1957b
parent 61ac9f94
Loading
Loading
Loading
Loading
+15 −11
Original line number Diff line number Diff line
@@ -134,7 +134,7 @@ class ImageGLWallpaper {
    private void setupTexture(Bitmap bitmap) {
        final int[] tids = new int[1];

        if (bitmap == null) {
        if (bitmap == null || bitmap.isRecycled()) {
            Log.w(TAG, "setupTexture: invalid bitmap");
            return;
        }
@@ -146,16 +146,20 @@ class ImageGLWallpaper {
            return;
        }

        try {
            // Bind a named texture to a target.
            glBindTexture(GL_TEXTURE_2D, tids[0]);
        // Load the bitmap data and copy it over into the texture object that is currently bound.
            // Load the bitmap data and copy it over into the texture object
            // that is currently bound.
            GLUtils.texImage2D(GL_TEXTURE_2D, 0, bitmap, 0);
            // Use bilinear texture filtering when minification.
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
            // Use bilinear texture filtering when magnification.
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

            mTextureId = tids[0];
        } catch (IllegalArgumentException e) {
            Log.w(TAG, "Failed uploading texture: " + e.getLocalizedMessage());
        }
    }

    void useTexture() {