-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to customize
Requester
and Executor
- Loading branch information
Showing
29 changed files
with
797 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"formatVersion": 1, | ||
"database": { | ||
"version": 2, | ||
"identityHash": "2f898d36eac649a9827b70b7bb6d234b", | ||
"entities": [ | ||
{ | ||
"tableName": "packages", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`packageName` TEXT NOT NULL, `authorized` INTEGER NOT NULL, PRIMARY KEY(`packageName`))", | ||
"fields": [ | ||
{ | ||
"fieldPath": "packageName", | ||
"columnName": "packageName", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "authorized", | ||
"columnName": "authorized", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
} | ||
], | ||
"primaryKey": { | ||
"autoGenerate": false, | ||
"columnNames": [ | ||
"packageName" | ||
] | ||
}, | ||
"indices": [], | ||
"foreignKeys": [] | ||
}, | ||
{ | ||
"tableName": "settings", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`key` TEXT NOT NULL, `value` TEXT NOT NULL, PRIMARY KEY(`key`))", | ||
"fields": [ | ||
{ | ||
"fieldPath": "key", | ||
"columnName": "key", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "value", | ||
"columnName": "value", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
} | ||
], | ||
"primaryKey": { | ||
"autoGenerate": false, | ||
"columnNames": [ | ||
"key" | ||
] | ||
}, | ||
"indices": [], | ||
"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, '2f898d36eac649a9827b70b7bb6d234b')" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
app/src/main/kotlin/dev/sanmer/pi/compat/PackageInfoCompat.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package dev.sanmer.pi.compat | ||
|
||
import android.content.pm.PackageInfo | ||
import android.content.pm.PackageInfoHidden | ||
import dev.rikka.tools.refine.Refine | ||
|
||
object PackageInfoCompat { | ||
val PackageInfo.isOverlayPackage get() = | ||
Refine.unsafeCast<PackageInfoHidden>(this) | ||
.isOverlayPackage | ||
|
||
val PackageInfo.isPreinstalled get() = | ||
lastUpdateTime <= 1230768000000 // 2009-01-01 08:00:00 GMT+8 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
app/src/main/kotlin/dev/sanmer/pi/database/dao/SettingDao.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package dev.sanmer.pi.database.dao | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Insert | ||
import androidx.room.OnConflictStrategy | ||
import androidx.room.Query | ||
import dev.sanmer.pi.database.entity.SettingEntity | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
@Dao | ||
interface SettingDao { | ||
@Query("SELECT value FROM settings WHERE `key` = :key") | ||
fun getByKeyAsFlow(key: String): Flow<String> | ||
|
||
@Query("SELECT value FROM settings WHERE `key` = :key") | ||
suspend fun getByKey(key: String): String? | ||
|
||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
suspend fun insert(value: SettingEntity) | ||
|
||
@Query("DELETE FROM settings") | ||
suspend fun deleteAll() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
app/src/main/kotlin/dev/sanmer/pi/database/entity/SettingEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package dev.sanmer.pi.database.entity | ||
|
||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
|
||
@Entity(tableName = "settings") | ||
data class SettingEntity( | ||
@PrimaryKey val key: String, | ||
val value: String | ||
) |
Oops, something went wrong.