feat: Add InstalledEntity and AntiFeatureAppRelation

This commit introduces two new entities to the local database:
- `InstalledEntity`: Stores information about installed applications including version code, version name, signature, and package name.
- `AntiFeatureAppRelation`: Represents the relationship between anti-features and applications, including the tag, reason, application ID, and version code.

It also adds `InstalledEntity` and `AntiFeatureAppRelation` to the list of entities in `DroidifyDatabase` and updates the database schema accordingly.
This commit is contained in:
LooKeR 2025-05-12 12:31:10 +05:30
parent dc9f7f9cce
commit e30bb19b10
No known key found for this signature in database
GPG Key ID: 6B59369FDB608FB9
5 changed files with 122 additions and 16 deletions

View File

@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 1,
"identityHash": "24eabf107191decae9c13f869c451673",
"identityHash": "099d07ab258fe12cb0a660545bd36e63",
"entities": [
{
"tableName": "anti_feature",
@ -49,6 +49,58 @@
"indices": [],
"foreignKeys": []
},
{
"tableName": "anti_features_app_relation",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`tag` TEXT NOT NULL, `reason` TEXT NOT NULL, `appId` INTEGER NOT NULL, `versionCode` INTEGER NOT NULL, PRIMARY KEY(`tag`, `appId`, `versionCode`), FOREIGN KEY(`appId`) REFERENCES `app`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "tag",
"columnName": "tag",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "reason",
"columnName": "reason",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "appId",
"columnName": "appId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "versionCode",
"columnName": "versionCode",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"tag",
"appId",
"versionCode"
]
},
"indices": [],
"foreignKeys": [
{
"table": "app",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"appId"
],
"referencedColumns": [
"id"
]
}
]
},
{
"tableName": "anti_feature_repo_relation",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `tag` TEXT NOT NULL, PRIMARY KEY(`id`, `tag`), FOREIGN KEY(`id`) REFERENCES `repository`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
@ -90,7 +142,7 @@
},
{
"tableName": "authentication",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`password` TEXT NOT NULL, `username` TEXT NOT NULL, `repoId` INTEGER NOT NULL, PRIMARY KEY(`repoId`), FOREIGN KEY(`repoId`) REFERENCES `repository`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`password` TEXT NOT NULL, `username` TEXT NOT NULL, `initializationVector` TEXT NOT NULL, `repoId` INTEGER NOT NULL, PRIMARY KEY(`repoId`), FOREIGN KEY(`repoId`) REFERENCES `repository`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )",
"fields": [
{
"fieldPath": "password",
@ -104,6 +156,12 @@
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "initializationVector",
"columnName": "initializationVector",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "repoId",
"columnName": "repoId",
@ -580,6 +638,44 @@
}
]
},
{
"tableName": "installed",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`versionCode` TEXT NOT NULL, `versionName` TEXT NOT NULL, `signature` TEXT NOT NULL, `packageName` TEXT NOT NULL, PRIMARY KEY(`packageName`))",
"fields": [
{
"fieldPath": "versionCode",
"columnName": "versionCode",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "versionName",
"columnName": "versionName",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "signature",
"columnName": "signature",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "packageName",
"columnName": "packageName",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"packageName"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "link",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`changelog` TEXT, `issueTracker` TEXT, `translation` TEXT, `sourceCode` TEXT, `webSite` TEXT, `appId` INTEGER NOT NULL, PRIMARY KEY(`appId`), FOREIGN KEY(`appId`) REFERENCES `app`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
@ -830,7 +926,7 @@
},
{
"tableName": "version",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`added` INTEGER NOT NULL, `whatsNew` TEXT NOT NULL, `versionName` TEXT NOT NULL, `versionCode` INTEGER NOT NULL, `maxSdkVersion` INTEGER, `minSdkVersion` INTEGER NOT NULL, `targetSdkVersion` INTEGER NOT NULL, `features` TEXT NOT NULL, `nativeCode` TEXT NOT NULL, `permissions` TEXT NOT NULL, `permissionsSdk23` TEXT NOT NULL, `antiFeature` TEXT NOT NULL, `appId` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `apk_name` TEXT NOT NULL, `apk_sha256` TEXT NOT NULL, `apk_size` INTEGER NOT NULL, `src_name` TEXT, `src_sha256` TEXT, `src_size` INTEGER, FOREIGN KEY(`appId`) REFERENCES `app`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`added` INTEGER NOT NULL, `whatsNew` TEXT NOT NULL, `versionName` TEXT NOT NULL, `versionCode` INTEGER NOT NULL, `maxSdkVersion` INTEGER, `minSdkVersion` INTEGER NOT NULL, `targetSdkVersion` INTEGER NOT NULL, `features` TEXT NOT NULL, `nativeCode` TEXT NOT NULL, `permissions` TEXT NOT NULL, `permissionsSdk23` TEXT NOT NULL, `appId` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `apk_name` TEXT NOT NULL, `apk_sha256` TEXT NOT NULL, `apk_size` INTEGER NOT NULL, `src_name` TEXT, `src_sha256` TEXT, `src_size` INTEGER, FOREIGN KEY(`appId`) REFERENCES `app`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "added",
@ -898,12 +994,6 @@
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "antiFeature",
"columnName": "antiFeature",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "appId",
"columnName": "appId",
@ -988,7 +1078,7 @@
"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, '24eabf107191decae9c13f869c451673')"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '099d07ab258fe12cb0a660545bd36e63')"
]
}
}

View File

@ -13,6 +13,7 @@ import com.looker.droidify.data.local.dao.AppDao
import com.looker.droidify.data.local.dao.AuthDao
import com.looker.droidify.data.local.dao.IndexDao
import com.looker.droidify.data.local.dao.RepoDao
import com.looker.droidify.data.local.model.AntiFeatureAppRelation
import com.looker.droidify.data.local.model.AntiFeatureEntity
import com.looker.droidify.data.local.model.AntiFeatureRepoRelation
import com.looker.droidify.data.local.model.AppEntity
@ -23,6 +24,7 @@ import com.looker.droidify.data.local.model.CategoryEntity
import com.looker.droidify.data.local.model.CategoryRepoRelation
import com.looker.droidify.data.local.model.DonateEntity
import com.looker.droidify.data.local.model.GraphicEntity
import com.looker.droidify.data.local.model.InstalledEntity
import com.looker.droidify.data.local.model.LinksEntity
import com.looker.droidify.data.local.model.MirrorEntity
import com.looker.droidify.data.local.model.RepoEntity
@ -32,6 +34,7 @@ import com.looker.droidify.data.local.model.VersionEntity
@Database(
entities = [
AntiFeatureEntity::class,
AntiFeatureAppRelation::class,
AntiFeatureRepoRelation::class,
AuthenticationEntity::class,
AuthorEntity::class,
@ -41,6 +44,7 @@ import com.looker.droidify.data.local.model.VersionEntity
CategoryRepoRelation::class,
DonateEntity::class,
GraphicEntity::class,
InstalledEntity::class,
LinksEntity::class,
MirrorEntity::class,
RepoEntity::class,

View File

@ -47,12 +47,6 @@ data class AntiFeatureRepoRelation(
parentColumns = ["id"],
onDelete = ForeignKey.CASCADE,
),
ForeignKey(
entity = AntiFeatureEntity::class,
childColumns = ["tag"],
parentColumns = ["tag"],
onDelete = ForeignKey.CASCADE,
)
],
)
data class AntiFeatureAppRelation(

View File

@ -84,6 +84,11 @@ data class AppEntityRelations(
entityColumn = "appId",
)
val versions: List<VersionEntity>?,
@Relation(
parentColumn = "packageName",
entityColumn = "packageName",
)
val installed: InstalledEntity?,
)
fun MetadataV2.appEntity(

View File

@ -0,0 +1,13 @@
package com.looker.droidify.data.local.model
import androidx.room.Entity
import androidx.room.PrimaryKey
@Entity("installed")
data class InstalledEntity(
val versionCode: String,
val versionName: String,
val signature: String,
@PrimaryKey
val packageName: String,
)