1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.communal.data.db 18 19 import androidx.room.ColumnInfo 20 import androidx.room.Entity 21 import androidx.room.PrimaryKey 22 23 @Entity(tableName = "communal_widget_table") 24 data class CommunalWidgetItem( 25 @PrimaryKey(autoGenerate = true) val uid: Long, 26 /** Id of an app widget */ 27 @ColumnInfo(name = "widget_id") val widgetId: Int, 28 /** Component name of the app widget provider */ 29 @ColumnInfo(name = "component_name") val componentName: String, 30 /** Reference the id of an item persisted in the glanceable hub */ 31 @ColumnInfo(name = "item_id") val itemId: Long, 32 /** 33 * A serial number of the user that the widget provider is associated with. For example, a work 34 * profile widget. 35 * 36 * A serial number may be different from its user id in that user ids may be recycled but serial 37 * numbers are unique until the device is wiped. 38 * 39 * Most commonly, this value would be 0 for the primary user, and 10 for the work profile. 40 */ 41 @ColumnInfo(name = "user_serial_number", defaultValue = "$USER_SERIAL_NUMBER_UNDEFINED") 42 val userSerialNumber: Int, 43 44 /** 45 * The vertical span of the widget. Span_Y default value corresponds to 46 * CommunalContentSize.HALF.span 47 */ 48 @Deprecated("Use spanYNew instead") 49 @ColumnInfo(name = "span_y", defaultValue = "3") 50 val spanY: Int, 51 52 /** The vertical span of the widget in grid cell units. */ 53 @ColumnInfo(name = "span_y_new", defaultValue = "1") val spanYNew: Int, 54 ) { 55 companion object { 56 /** 57 * The user serial number associated with the widget is undefined. 58 * 59 * This should only happen for widgets migrated from V1 before user serial number was 60 * included in the schema. 61 */ 62 const val USER_SERIAL_NUMBER_UNDEFINED = -1 63 } 64 } 65 66 @Entity(tableName = "communal_item_rank_table") 67 data class CommunalItemRank( 68 /** Unique id of an item persisted in the glanceable hub */ 69 @PrimaryKey(autoGenerate = true) val uid: Long, 70 /** Order in which the item will be displayed */ 71 @ColumnInfo(name = "rank", defaultValue = "0") val rank: Int, 72 ) 73