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

Commit 81b1558a authored by Lucas Silva's avatar Lucas Silva
Browse files

Update communal db for responsive grid

In the responsive grid, we are updating the grid cells such that a
widget occupies a single cell instead of the 3 cells they do today. We
therefore add a new spanY field in the database which stores the new
height in responsive grid units.

Also noticed that we were not properly backing up the spanY field
before, so fixed that in this change also.

Bug: 378171351
Flag: com.android.systemui.communal_responsive_grid
Test: atest SystemUITests
Change-Id: I147e1ba5f7fa1c0ad2eaffcd02b11bfd062ab55d
parent c9b66b17
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1203,6 +1203,13 @@ flag {
  }
}

flag {
  name: "communal_responsive_grid"
  namespace: "systemui"
  description: "Enables responsive grid on glanceable hub"
  bug: "378171351"
}

flag {
  name: "communal_standalone_support"
  namespace: "systemui"
+5 −4
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.data.db.DefaultWidgetPopulation.SkipReason.RESTORED_FROM_BACKUP
import com.android.systemui.communal.shared.model.SpanValue
import com.android.systemui.communal.widgets.CommunalWidgetHost
import com.android.systemui.kosmos.applicationCoroutineScope
import com.android.systemui.kosmos.testScope
@@ -117,7 +118,7 @@ class DefaultWidgetPopulationTest : SysuiTestCase() {
                    componentName = defaultWidgets[0],
                    rank = 0,
                    userSerialNumber = 0,
                    spanY = 3,
                    spanY = SpanValue.Fixed(3),
                )
            verify(communalWidgetDao)
                .addWidget(
@@ -125,7 +126,7 @@ class DefaultWidgetPopulationTest : SysuiTestCase() {
                    componentName = defaultWidgets[1],
                    rank = 1,
                    userSerialNumber = 0,
                    spanY = 3,
                    spanY = SpanValue.Fixed(3),
                )
            verify(communalWidgetDao)
                .addWidget(
@@ -133,7 +134,7 @@ class DefaultWidgetPopulationTest : SysuiTestCase() {
                    componentName = defaultWidgets[2],
                    rank = 2,
                    userSerialNumber = 0,
                    spanY = 3,
                    spanY = SpanValue.Fixed(3),
                )
        }

@@ -155,7 +156,7 @@ class DefaultWidgetPopulationTest : SysuiTestCase() {
                    componentName = any(),
                    rank = anyInt(),
                    userSerialNumber = anyInt(),
                    spanY = anyInt(),
                    spanY = any(),
                )
        }
}
+223 −104

File changed.

Preview size limit exceeded, changes collapsed.

+95 −0
Original line number Diff line number Diff line
{
  "formatVersion": 1,
  "database": {
    "version": 5,
    "identityHash": "a83f96ef4babe730b3a00e8acb777a25",
    "entities": [
      {
        "tableName": "communal_widget_table",
        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`uid` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `widget_id` INTEGER NOT NULL, `component_name` TEXT NOT NULL, `item_id` INTEGER NOT NULL, `user_serial_number` INTEGER NOT NULL DEFAULT -1, `span_y` INTEGER NOT NULL DEFAULT 3, `span_y_new` INTEGER NOT NULL DEFAULT 1)",
        "fields": [
          {
            "fieldPath": "uid",
            "columnName": "uid",
            "affinity": "INTEGER",
            "notNull": true
          },
          {
            "fieldPath": "widgetId",
            "columnName": "widget_id",
            "affinity": "INTEGER",
            "notNull": true
          },
          {
            "fieldPath": "componentName",
            "columnName": "component_name",
            "affinity": "TEXT",
            "notNull": true
          },
          {
            "fieldPath": "itemId",
            "columnName": "item_id",
            "affinity": "INTEGER",
            "notNull": true
          },
          {
            "fieldPath": "userSerialNumber",
            "columnName": "user_serial_number",
            "affinity": "INTEGER",
            "notNull": true,
            "defaultValue": "-1"
          },
          {
            "fieldPath": "spanY",
            "columnName": "span_y",
            "affinity": "INTEGER",
            "notNull": true,
            "defaultValue": "3"
          },
          {
            "fieldPath": "spanYNew",
            "columnName": "span_y_new",
            "affinity": "INTEGER",
            "notNull": true,
            "defaultValue": "1"
          }
        ],
        "primaryKey": {
          "autoGenerate": true,
          "columnNames": [
            "uid"
          ]
        }
      },
      {
        "tableName": "communal_item_rank_table",
        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`uid` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `rank` INTEGER NOT NULL DEFAULT 0)",
        "fields": [
          {
            "fieldPath": "uid",
            "columnName": "uid",
            "affinity": "INTEGER",
            "notNull": true
          },
          {
            "fieldPath": "rank",
            "columnName": "rank",
            "affinity": "INTEGER",
            "notNull": true,
            "defaultValue": "0"
          }
        ],
        "primaryKey": {
          "autoGenerate": true,
          "columnNames": [
            "uid"
          ]
        }
      }
    ],
    "setupQueries": [
      "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
      "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'a83f96ef4babe730b3a00e8acb777a25')"
    ]
  }
}
 No newline at end of file
+3 −3
Original line number Diff line number Diff line
@@ -29,9 +29,7 @@ import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking

/** Utilities for communal backup and restore. */
class CommunalBackupUtils(
    private val context: Context,
) {
class CommunalBackupUtils(private val context: Context) {

    /**
     * Retrieves a communal hub state protobuf that represents the current state of the communal
@@ -50,6 +48,8 @@ class CommunalBackupUtils(
                    widgetId = widget.widgetId
                    componentName = widget.componentName
                    userSerialNumber = widget.userSerialNumber
                    spanY = widget.spanY
                    spanYNew = widget.spanYNew
                }
            )
        }
Loading