lineage-next / android_packages_apps_Twelve

🎵
8 stars 1 forks source link

Database #30

Closed luca020400 closed 1 month ago

luca020400 commented 1 month ago

We're going to need a database.

The usecases are as follows:

Play count for each audio entry -> Can/will be used in the activity main page

Playlist -> media provider dropped playlist support so we're on our own

More -> TBD

Problems:

We need to ensure our local db and media provider are in sync.

We have to assume the media provider sets some guarantees such as stable Uri per media.

We have to implement garbage collection in our local db to ensure we remove non existing entries in the media provider.

We need to have well defined on cascades behaviour in case we remove entries (or GC removes them)

luca020400 commented 1 month ago

We need to decide the lifecycle of Item. Currently in the PR I try to remove them as soon as they go out of scope.

But with play count we could use the same row to store the count, meaning we don't want to ever remove the entry (unless the backing media is removed as well)

We need to decide if we want to have a mirror of the media provider with default play count = 0 or add it on demand with count = 1.

SebaUbuntu commented 1 month ago

Can't we just store the audio URI as string w/o any kind of new entity? For both the play count and the playlists that would be perfect:

Playlists: Playlist ID (unique autoincrement) Playlist name
0 Foo
1 Bar
Playlist songs: Playlist ID (int) Audio URI (string, not unique)
0 content://...
0 https://...
1 https://...
Play count: Audio URI (string, unique) Count
content://... 2
https://... 6
content://... 3