-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
lucky
committed
Jul 21, 2022
1 parent
8ee1f31
commit 368ec9e
Showing
29 changed files
with
785 additions
and
158 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# Privacy Policy | ||
|
||
The app has nothing to store, but settings. | ||
The app may store package names of apps without internet permission in internal database if | ||
Monitor > Internet is checked. |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"formatVersion": 1, | ||
"database": { | ||
"version": 1, | ||
"identityHash": "70aadd9a8960bce26cb4a67e42c1d104", | ||
"entities": [ | ||
{ | ||
"tableName": "package", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`uid` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL)", | ||
"fields": [ | ||
{ | ||
"fieldPath": "uid", | ||
"columnName": "uid", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "name", | ||
"columnName": "name", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
} | ||
], | ||
"primaryKey": { | ||
"columnNames": [ | ||
"uid" | ||
], | ||
"autoGenerate": true | ||
}, | ||
"indices": [ | ||
{ | ||
"name": "index_package_name", | ||
"unique": true, | ||
"columnNames": [ | ||
"name" | ||
], | ||
"orders": [], | ||
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_package_name` ON `${TABLE_NAME}` (`name`)" | ||
} | ||
], | ||
"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, '70aadd9a8960bce26cb4a67e42c1d104')" | ||
] | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package me.lucky.sentry | ||
|
||
import android.content.Context | ||
import androidx.room.* | ||
|
||
@Database(entities = [Package::class], version = 1) | ||
abstract class AppDatabase : RoomDatabase() { | ||
abstract fun packageDao(): PackageDao | ||
|
||
companion object { | ||
@Volatile private var instance: AppDatabase? = null | ||
private const val DATABASE_NAME = "app.db" | ||
|
||
fun getInstance(context: Context) = | ||
instance ?: synchronized(this) { | ||
instance ?: buildDatabase(context).also { instance = it } | ||
} | ||
|
||
private fun buildDatabase(context: Context) = Room | ||
.databaseBuilder(context.applicationContext, AppDatabase::class.java, DATABASE_NAME) | ||
.allowMainThreadQueries() | ||
.build() | ||
} | ||
} | ||
|
||
@Dao | ||
interface PackageDao { | ||
@Insert | ||
fun insert(obj: Package) | ||
|
||
@Query("DELETE FROM package WHERE name = :name") | ||
fun delete(name: String) | ||
|
||
@Query("SELECT * FROM package WHERE name = :name") | ||
fun select(name: String): Package? | ||
|
||
@Query("DELETE FROM package") | ||
fun deleteAll() | ||
} | ||
|
||
@Entity( | ||
indices = [Index(value = ["name"], unique = true)], | ||
tableName = "package", | ||
) | ||
data class Package( | ||
@PrimaryKey(autoGenerate = true) val uid: Int, | ||
@ColumnInfo(name = "name") val name: String, | ||
) |
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
Oops, something went wrong.