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

Commit 06cab606 authored by Nishith  Khanna's avatar Nishith Khanna
Browse files

Merge remote-tracking branch 'origin/lineage-22.1' into a15

parents 891736a7 1d3e3124
Loading
Loading
Loading
Loading
Loading
+441 −0
Original line number Diff line number Diff line
{
  "formatVersion": 1,
  "database": {
    "version": 7,
    "identityHash": "778031ff65e0381410ea48280a59b511",
    "entities": [
      {
        "tableName": "Favorite",
        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`item_id` INTEGER NOT NULL, `added_at` TEXT NOT NULL, PRIMARY KEY(`item_id`), FOREIGN KEY(`item_id`) REFERENCES `Item`(`item_id`) ON UPDATE CASCADE ON DELETE CASCADE )",
        "fields": [
          {
            "fieldPath": "itemId",
            "columnName": "item_id",
            "affinity": "INTEGER",
            "notNull": true
          },
          {
            "fieldPath": "addedAt",
            "columnName": "added_at",
            "affinity": "TEXT",
            "notNull": true
          }
        ],
        "primaryKey": {
          "autoGenerate": false,
          "columnNames": [
            "item_id"
          ]
        },
        "indices": [
          {
            "name": "index_Favorite_item_id",
            "unique": true,
            "columnNames": [
              "item_id"
            ],
            "orders": [],
            "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_Favorite_item_id` ON `${TABLE_NAME}` (`item_id`)"
          }
        ],
        "foreignKeys": [
          {
            "table": "Item",
            "onDelete": "CASCADE",
            "onUpdate": "CASCADE",
            "columns": [
              "item_id"
            ],
            "referencedColumns": [
              "item_id"
            ]
          }
        ]
      },
      {
        "tableName": "Playlist",
        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`playlist_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `created_at` INTEGER NOT NULL)",
        "fields": [
          {
            "fieldPath": "id",
            "columnName": "playlist_id",
            "affinity": "INTEGER",
            "notNull": true
          },
          {
            "fieldPath": "name",
            "columnName": "name",
            "affinity": "TEXT",
            "notNull": true
          },
          {
            "fieldPath": "createdAt",
            "columnName": "created_at",
            "affinity": "INTEGER",
            "notNull": true
          }
        ],
        "primaryKey": {
          "autoGenerate": true,
          "columnNames": [
            "playlist_id"
          ]
        },
        "indices": [],
        "foreignKeys": []
      },
      {
        "tableName": "Item",
        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`item_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `audio_uri` TEXT NOT NULL, `count` INTEGER NOT NULL DEFAULT 0)",
        "fields": [
          {
            "fieldPath": "id",
            "columnName": "item_id",
            "affinity": "INTEGER",
            "notNull": true
          },
          {
            "fieldPath": "audioUri",
            "columnName": "audio_uri",
            "affinity": "TEXT",
            "notNull": true
          },
          {
            "fieldPath": "count",
            "columnName": "count",
            "affinity": "INTEGER",
            "notNull": true,
            "defaultValue": "0"
          }
        ],
        "primaryKey": {
          "autoGenerate": true,
          "columnNames": [
            "item_id"
          ]
        },
        "indices": [
          {
            "name": "index_Item_audio_uri",
            "unique": true,
            "columnNames": [
              "audio_uri"
            ],
            "orders": [],
            "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_Item_audio_uri` ON `${TABLE_NAME}` (`audio_uri`)"
          }
        ],
        "foreignKeys": []
      },
      {
        "tableName": "PlaylistItemCrossRef",
        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`playlist_id` INTEGER NOT NULL, `item_id` INTEGER NOT NULL, `last_modified` INTEGER NOT NULL, PRIMARY KEY(`playlist_id`, `item_id`), FOREIGN KEY(`playlist_id`) REFERENCES `Playlist`(`playlist_id`) ON UPDATE CASCADE ON DELETE CASCADE , FOREIGN KEY(`item_id`) REFERENCES `Item`(`item_id`) ON UPDATE CASCADE ON DELETE CASCADE )",
        "fields": [
          {
            "fieldPath": "playlistId",
            "columnName": "playlist_id",
            "affinity": "INTEGER",
            "notNull": true
          },
          {
            "fieldPath": "itemId",
            "columnName": "item_id",
            "affinity": "INTEGER",
            "notNull": true
          },
          {
            "fieldPath": "lastModified",
            "columnName": "last_modified",
            "affinity": "INTEGER",
            "notNull": true
          }
        ],
        "primaryKey": {
          "autoGenerate": false,
          "columnNames": [
            "playlist_id",
            "item_id"
          ]
        },
        "indices": [
          {
            "name": "index_PlaylistItemCrossRef_item_id",
            "unique": false,
            "columnNames": [
              "item_id"
            ],
            "orders": [],
            "createSql": "CREATE INDEX IF NOT EXISTS `index_PlaylistItemCrossRef_item_id` ON `${TABLE_NAME}` (`item_id`)"
          }
        ],
        "foreignKeys": [
          {
            "table": "Playlist",
            "onDelete": "CASCADE",
            "onUpdate": "CASCADE",
            "columns": [
              "playlist_id"
            ],
            "referencedColumns": [
              "playlist_id"
            ]
          },
          {
            "table": "Item",
            "onDelete": "CASCADE",
            "onUpdate": "CASCADE",
            "columns": [
              "item_id"
            ],
            "referencedColumns": [
              "item_id"
            ]
          }
        ]
      },
      {
        "tableName": "ResumptionItem",
        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`playlist_index` INTEGER NOT NULL, `resumption_playlist_id` INTEGER NOT NULL, `media_id` TEXT NOT NULL, PRIMARY KEY(`playlist_index`), FOREIGN KEY(`resumption_playlist_id`) REFERENCES `ResumptionPlaylist`(`resumption_id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
        "fields": [
          {
            "fieldPath": "playlistIndex",
            "columnName": "playlist_index",
            "affinity": "INTEGER",
            "notNull": true
          },
          {
            "fieldPath": "resumptionPlaylistId",
            "columnName": "resumption_playlist_id",
            "affinity": "INTEGER",
            "notNull": true
          },
          {
            "fieldPath": "mediaId",
            "columnName": "media_id",
            "affinity": "TEXT",
            "notNull": true
          }
        ],
        "primaryKey": {
          "autoGenerate": false,
          "columnNames": [
            "playlist_index"
          ]
        },
        "indices": [
          {
            "name": "index_ResumptionItem_playlist_index",
            "unique": true,
            "columnNames": [
              "playlist_index"
            ],
            "orders": [],
            "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_ResumptionItem_playlist_index` ON `${TABLE_NAME}` (`playlist_index`)"
          },
          {
            "name": "index_ResumptionItem_resumption_playlist_id",
            "unique": false,
            "columnNames": [
              "resumption_playlist_id"
            ],
            "orders": [],
            "createSql": "CREATE INDEX IF NOT EXISTS `index_ResumptionItem_resumption_playlist_id` ON `${TABLE_NAME}` (`resumption_playlist_id`)"
          }
        ],
        "foreignKeys": [
          {
            "table": "ResumptionPlaylist",
            "onDelete": "CASCADE",
            "onUpdate": "NO ACTION",
            "columns": [
              "resumption_playlist_id"
            ],
            "referencedColumns": [
              "resumption_id"
            ]
          }
        ]
      },
      {
        "tableName": "ResumptionPlaylist",
        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`resumption_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `start_index` INTEGER NOT NULL, `start_position_ms` INTEGER NOT NULL)",
        "fields": [
          {
            "fieldPath": "id",
            "columnName": "resumption_id",
            "affinity": "INTEGER",
            "notNull": true
          },
          {
            "fieldPath": "startIndex",
            "columnName": "start_index",
            "affinity": "INTEGER",
            "notNull": true
          },
          {
            "fieldPath": "startPositionMs",
            "columnName": "start_position_ms",
            "affinity": "INTEGER",
            "notNull": true
          }
        ],
        "primaryKey": {
          "autoGenerate": true,
          "columnNames": [
            "resumption_id"
          ]
        },
        "indices": [],
        "foreignKeys": []
      },
      {
        "tableName": "JellyfinProvider",
        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`jellyfin_provider_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `url` TEXT NOT NULL, `username` TEXT NOT NULL, `password` TEXT NOT NULL, `device_identifier` TEXT NOT NULL, `token` TEXT)",
        "fields": [
          {
            "fieldPath": "id",
            "columnName": "jellyfin_provider_id",
            "affinity": "INTEGER",
            "notNull": true
          },
          {
            "fieldPath": "name",
            "columnName": "name",
            "affinity": "TEXT",
            "notNull": true
          },
          {
            "fieldPath": "url",
            "columnName": "url",
            "affinity": "TEXT",
            "notNull": true
          },
          {
            "fieldPath": "username",
            "columnName": "username",
            "affinity": "TEXT",
            "notNull": true
          },
          {
            "fieldPath": "password",
            "columnName": "password",
            "affinity": "TEXT",
            "notNull": true
          },
          {
            "fieldPath": "deviceIdentifier",
            "columnName": "device_identifier",
            "affinity": "TEXT",
            "notNull": true
          },
          {
            "fieldPath": "token",
            "columnName": "token",
            "affinity": "TEXT",
            "notNull": false
          }
        ],
        "primaryKey": {
          "autoGenerate": true,
          "columnNames": [
            "jellyfin_provider_id"
          ]
        },
        "indices": [],
        "foreignKeys": []
      },
      {
        "tableName": "SubsonicProvider",
        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`subsonic_provider_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `url` TEXT NOT NULL, `username` TEXT NOT NULL, `password` TEXT NOT NULL, `use_legacy_authentication` INTEGER NOT NULL)",
        "fields": [
          {
            "fieldPath": "id",
            "columnName": "subsonic_provider_id",
            "affinity": "INTEGER",
            "notNull": true
          },
          {
            "fieldPath": "name",
            "columnName": "name",
            "affinity": "TEXT",
            "notNull": true
          },
          {
            "fieldPath": "url",
            "columnName": "url",
            "affinity": "TEXT",
            "notNull": true
          },
          {
            "fieldPath": "username",
            "columnName": "username",
            "affinity": "TEXT",
            "notNull": true
          },
          {
            "fieldPath": "password",
            "columnName": "password",
            "affinity": "TEXT",
            "notNull": true
          },
          {
            "fieldPath": "useLegacyAuthentication",
            "columnName": "use_legacy_authentication",
            "affinity": "INTEGER",
            "notNull": true
          }
        ],
        "primaryKey": {
          "autoGenerate": true,
          "columnNames": [
            "subsonic_provider_id"
          ]
        },
        "indices": [],
        "foreignKeys": []
      },
      {
        "tableName": "LocalMediaStats",
        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`audio_uri` TEXT NOT NULL, `play_count` INTEGER NOT NULL DEFAULT 1, PRIMARY KEY(`audio_uri`))",
        "fields": [
          {
            "fieldPath": "audioUri",
            "columnName": "audio_uri",
            "affinity": "TEXT",
            "notNull": true
          },
          {
            "fieldPath": "playCount",
            "columnName": "play_count",
            "affinity": "INTEGER",
            "notNull": true,
            "defaultValue": "1"
          }
        ],
        "primaryKey": {
          "autoGenerate": false,
          "columnNames": [
            "audio_uri"
          ]
        },
        "indices": [
          {
            "name": "index_LocalMediaStats_audio_uri",
            "unique": true,
            "columnNames": [
              "audio_uri"
            ],
            "orders": [],
            "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_LocalMediaStats_audio_uri` ON `${TABLE_NAME}` (`audio_uri`)"
          }
        ],
        "foreignKeys": []
      }
    ],
    "views": [],
    "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, '778031ff65e0381410ea48280a59b511')"
    ]
  }
}
 No newline at end of file
+386 −0

File added.

Preview size limit exceeded, changes collapsed.

+1 −4
Original line number Diff line number Diff line
@@ -111,14 +111,11 @@
                <action android:name="androidx.media3.session.MediaLibraryService" />
                <action android:name="android.media.browse.MediaBrowserService" />
                <action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
                <action android:name="org.lineageos.twelve.ACTION_TOGGLE_PLAY_PAUSE" />
            </intent-filter>

        </service>

        <receiver
            android:name=".services.PlaybackServiceActionsReceiver"
            android:exported="false" />

        <receiver
            android:name="androidx.media3.session.MediaButtonReceiver"
            android:exported="true">
+152 −12
Original line number Diff line number Diff line
@@ -8,15 +8,19 @@ package org.lineageos.twelve.database
import android.content.Context
import androidx.room.AutoMigration
import androidx.room.Database
import androidx.room.DeleteColumn
import androidx.room.DeleteTable
import androidx.room.RenameColumn
import androidx.room.Room
import androidx.room.RoomDatabase
import androidx.room.TypeConverters
import androidx.room.migration.AutoMigrationSpec
import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase
import org.lineageos.twelve.database.converters.InstantConverter
import org.lineageos.twelve.database.converters.UriConverter
import org.lineageos.twelve.database.dao.FavoriteDao
import org.lineageos.twelve.database.dao.ItemDao
import org.lineageos.twelve.database.dao.JellyfinProviderDao
import org.lineageos.twelve.database.dao.LastPlayedDao
import org.lineageos.twelve.database.dao.MediaStatsDao
import org.lineageos.twelve.database.dao.PlaylistDao
import org.lineageos.twelve.database.dao.PlaylistItemCrossRefDao
@@ -24,9 +28,7 @@ import org.lineageos.twelve.database.dao.PlaylistWithItemsDao
import org.lineageos.twelve.database.dao.ResumptionPlaylistDao
import org.lineageos.twelve.database.dao.SubsonicProviderDao
import org.lineageos.twelve.database.entities.Favorite
import org.lineageos.twelve.database.entities.Item
import org.lineageos.twelve.database.entities.JellyfinProvider
import org.lineageos.twelve.database.entities.LastPlayed
import org.lineageos.twelve.database.entities.LocalMediaStats
import org.lineageos.twelve.database.entities.Playlist
import org.lineageos.twelve.database.entities.PlaylistItemCrossRef
@@ -41,7 +43,6 @@ import org.lineageos.twelve.database.entities.SubsonicProvider

        /* Playlist */
        Playlist::class,
        Item::class,
        PlaylistItemCrossRef::class,

        /* Resumption */
@@ -52,19 +53,18 @@ import org.lineageos.twelve.database.entities.SubsonicProvider
        JellyfinProvider::class,
        SubsonicProvider::class,

        /* Last Played */
        LastPlayed::class,

        /* Local Media Stats */
        LocalMediaStats::class,
    ],
    version = 6,
    version = 8,
    autoMigrations = [
        AutoMigration(from = 1, to = 2),
        AutoMigration(from = 2, to = 3),
        AutoMigration(from = 3, to = 4),
        AutoMigration(from = 4, to = 5),
        AutoMigration(from = 5, to = 6),
        AutoMigration(from = 6, to = 7, spec = TwelveDatabase.Companion.MigrationSpec6To7::class),
        // 7 to 8 is done manually
    ],
)
@TypeConverters(
@@ -73,9 +73,7 @@ import org.lineageos.twelve.database.entities.SubsonicProvider
)
abstract class TwelveDatabase : RoomDatabase() {
    abstract fun getFavoriteDao(): FavoriteDao
    abstract fun getItemDao(): ItemDao
    abstract fun getJellyfinProviderDao(): JellyfinProviderDao
    abstract fun getLastPlayedDao(): LastPlayedDao
    abstract fun getLocalMediaStatsProviderDao(): MediaStatsDao
    abstract fun getPlaylistDao(): PlaylistDao
    abstract fun getPlaylistItemCrossRefDao(): PlaylistItemCrossRefDao
@@ -84,10 +82,152 @@ abstract class TwelveDatabase : RoomDatabase() {
    abstract fun getSubsonicProviderDao(): SubsonicProviderDao

    companion object {
        @DeleteColumn.Entries(
            DeleteColumn(
                tableName = "Item",
                columnName = "count"
            ),
            DeleteColumn(
                tableName = "LocalMediaStats",
                columnName = "favorite"
            ),
            DeleteColumn(
                tableName = "Playlist",
                columnName = "track_count"
            ),
        )
        @DeleteTable.Entries(
            DeleteTable(
                tableName = "LastPlayed"
            ),
        )
        @RenameColumn.Entries(
            RenameColumn(
                tableName = "LocalMediaStats",
                fromColumnName = "media_uri",
                toColumnName = "audio_uri"
            ),
            RenameColumn(
                tableName = "Playlist",
                fromColumnName = "last_modified",
                toColumnName = "created_at"
            ),
        )
        class MigrationSpec6To7 : AutoMigrationSpec

        object Migration7To8 : Migration(7, 8) {
            override fun migrate(db: SupportSQLiteDatabase) {
                // Favorite: Start
                // Create temp table (copy paste query from JSON, reorder entries to match
                // auto-generated migration)
                db.execSQL(
                    """
                        CREATE TABLE IF NOT EXISTS `Favorite_temp`
                        (
                            `added_at` TEXT NOT NULL,
                            `audio_uri` TEXT NOT NULL DEFAULT '',
                            PRIMARY KEY(`audio_uri`)
                        )
                    """.trimIndent()
                )
                // Migrate data
                db.execSQL(
                    """
                        INSERT INTO Favorite_temp (audio_uri, added_at)
                        SELECT audio_uri, added_at FROM Favorite
                            INNER JOIN Item ON Item.item_id = Favorite.item_id
                    """.trimIndent()
                )
                // Delete old table and rename new table
                db.execSQL(
                    """
                        DROP TABLE IF EXISTS `Favorite`
                    """.trimIndent()
                )
                db.execSQL(
                    """
                        ALTER TABLE `Favorite_temp`
                        RENAME TO `Favorite`
                    """.trimIndent()
                )
                // Create indexes
                db.execSQL(
                    """
                        CREATE UNIQUE INDEX IF NOT EXISTS `index_Favorite_audio_uri`
                        ON `Favorite` (`audio_uri`)
                    """.trimIndent()
                )
                // Favorite: End

                // PlaylistItemCrossRef: Start
                // Create temp table (copy paste query from JSON, reorder entries to match
                // auto-generated migration)
                db.execSQL(
                    """
                        CREATE TABLE IF NOT EXISTS `PlaylistItemCrossRef_temp`
                        (
                            `last_modified` INTEGER NOT NULL,
                            `playlist_id` INTEGER NOT NULL,
                            `audio_uri` TEXT NOT NULL DEFAULT '',
                            PRIMARY KEY(`playlist_id`, `audio_uri`),
                            FOREIGN KEY(`playlist_id`) REFERENCES `Playlist`(`playlist_id`)
                                ON UPDATE CASCADE
                                ON DELETE CASCADE
                        )
                    """.trimIndent()
                )
                // Migrate data
                db.execSQL(
                    """
                        INSERT INTO PlaylistItemCrossRef_temp (playlist_id, audio_uri, last_modified)
                        SELECT playlist_id, audio_uri, last_modified FROM PlaylistItemCrossRef
                            INNER JOIN Item ON Item.item_id = PlaylistItemCrossRef.item_id
                    """.trimIndent()
                )
                // Delete old table and rename new table
                db.execSQL(
                    """
                        DROP TABLE IF EXISTS `PlaylistItemCrossRef`
                    """.trimIndent()
                )
                db.execSQL(
                    """
                        ALTER TABLE `PlaylistItemCrossRef_temp`
                        RENAME TO `PlaylistItemCrossRef`
                    """.trimIndent()
                )
                // Create indexes
                db.execSQL(
                    """
                        CREATE INDEX IF NOT EXISTS `index_PlaylistItemCrossRef_playlist_id`
                        ON `PlaylistItemCrossRef` (`playlist_id`)
                    """.trimIndent()
                )
                db.execSQL(
                    """
                        CREATE INDEX IF NOT EXISTS `index_PlaylistItemCrossRef_audio_uri`
                        ON `PlaylistItemCrossRef` (`audio_uri`)
                    """.trimIndent()
                )
                // PlaylistItemCrossRef: End

                // Item: Start
                // Delete the table
                db.execSQL(
                    """
                        DROP TABLE IF EXISTS `Item`
                    """.trimIndent()
                )
                // Item: End
            }
        }

        fun get(context: Context) = Room.databaseBuilder(
            context.applicationContext,
            TwelveDatabase::class.java,
            "twelve_database",
        ).build()
        )
            .addMigrations(Migration7To8)
            .build()
    }
}
+16 −35

File changed.

Preview size limit exceeded, changes collapsed.

Loading