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

Commit 835758cc authored by George Lin's avatar George Lin
Browse files

Fix exception when getting grid title

Test: Tested no exception throws when no title key
Bug: 413320613
Flag: com.android.systemui.shared.new_customization_picker_ui
Change-Id: I875e230e02103868c10ab8debbe4bbc789b8c9aa
parent a6bb420b
Loading
Loading
Loading
Loading
+44 −25
Original line number Diff line number Diff line
@@ -53,15 +53,27 @@ constructor(
                    ?.use { cursor ->
                        buildList {
                                while (cursor.moveToNext()) {
                                    try {
                                        val rows = cursor.getInt(cursor.getColumnIndex(COL_ROWS))
                                        val cols = cursor.getInt(cursor.getColumnIndex(COL_COLS))
                                    val title =
                                        cursor.getString(cursor.getColumnIndex(COL_GRID_TITLE))
                                            ?: context.getString(
                                        val backUpTitle =
                                            context.getString(
                                                com.android.themepicker.R.string.grid_title_pattern,
                                                cols,
                                                rows,
                                            )
                                        val title =
                                            cursor.getColumnIndex(COL_GRID_TITLE).let { titleIndex
                                                ->
                                                if (titleIndex != -1) {
                                                    // Note that title can be null, even when the
                                                    // column field exists.
                                                    cursor.getString(titleIndex)
                                                } else {
                                                    null
                                                }
                                            } ?: backUpTitle

                                        add(
                                            GridOptionModel(
                                                key =
@@ -83,6 +95,13 @@ constructor(
                                                    ),
                                            )
                                        )
                                    } catch (e: IllegalStateException) {
                                        Log.e(
                                            TAG,
                                            "Fail to read from the cursor to build GridOptionModel",
                                            e,
                                        )
                                    }
                                }
                            }
                            .let { list ->