Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
efb3239c
Commit
efb3239c
authored
Mar 28, 2022
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Drop package_name column
parent
7e7ddeb9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
10 deletions
+29
-10
PolicyDao.kt
...main/java/com/topjohnwu/magisk/core/magiskdb/PolicyDao.kt
+4
-2
db.cpp
native/jni/core/db.cpp
+25
-8
No files found.
app/src/main/java/com/topjohnwu/magisk/core/magiskdb/PolicyDao.kt
View file @
efb3239c
...
@@ -26,8 +26,10 @@ class PolicyDao : MagiskDB() {
...
@@ -26,8 +26,10 @@ class PolicyDao : MagiskDB() {
suspend
fun
update
(
policy
:
SuPolicy
)
{
suspend
fun
update
(
policy
:
SuPolicy
)
{
val
map
=
policy
.
toMap
()
val
map
=
policy
.
toMap
()
// Put in package_name for old database
if
(!
Const
.
Version
.
isCanary
())
{
map
[
"package_name"
]
=
AppContext
.
packageManager
.
getNameForUid
(
policy
.
uid
)
!!
// Put in package_name for old database
map
[
"package_name"
]
=
AppContext
.
packageManager
.
getNameForUid
(
policy
.
uid
)
!!
}
val
query
=
"REPLACE INTO ${Table.POLICY} ${map.toQuery()}"
val
query
=
"REPLACE INTO ${Table.POLICY} ${map.toQuery()}"
exec
(
query
)
exec
(
query
)
}
}
...
...
native/jni/core/db.cpp
View file @
efb3239c
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
#include <socket.hpp>
#include <socket.hpp>
#include <utils.hpp>
#include <utils.hpp>
#define DB_VERSION 1
1
#define DB_VERSION 1
2
using
namespace
std
;
using
namespace
std
;
...
@@ -158,8 +158,8 @@ static char *open_and_init_db(sqlite3 *&db) {
...
@@ -158,8 +158,8 @@ static char *open_and_init_db(sqlite3 *&db) {
auto
create_policy
=
[
&
]
{
auto
create_policy
=
[
&
]
{
sqlite3_exec
(
db
,
sqlite3_exec
(
db
,
"CREATE TABLE IF NOT EXISTS policies "
"CREATE TABLE IF NOT EXISTS policies "
"(uid INT, p
ackage_name TEXT, policy INT, until
INT, "
"(uid INT, p
olicy INT, until INT, logging
INT, "
"
logging INT,
notification INT, PRIMARY KEY(uid))"
,
"notification INT, PRIMARY KEY(uid))"
,
nullptr
,
nullptr
,
&
err
);
nullptr
,
nullptr
,
&
err
);
};
};
auto
create_settings
=
[
&
]
{
auto
create_settings
=
[
&
]
{
...
@@ -185,11 +185,12 @@ static char *open_and_init_db(sqlite3 *&db) {
...
@@ -185,11 +185,12 @@ static char *open_and_init_db(sqlite3 *&db) {
//
//
// 0 - 6: DB stored in app private data. There are no longer any code in the project to
// 0 - 6: DB stored in app private data. There are no longer any code in the project to
// migrate these data, so no need to take any of these versions into consideration.
// migrate these data, so no need to take any of these versions into consideration.
// 7 : create table 'hidelist' (process TEXT, PRIMARY KEY(process))
// 7 : create table `hidelist` (process TEXT, PRIMARY KEY(process))
// 8 : add new column (package_name TEXT) to table 'hidelist'
// 8 : add new column (package_name TEXT) to table `hidelist`
// 9 : rebuild table 'hidelist' to update primary key (PRIMARY KEY(package_name, process))
// 9 : rebuild table `hidelist` to change primary key (PRIMARY KEY(package_name, process))
// 10: remove table 'logs'
// 10: remove table `logs`
// 11: remove table 'hidelist' and create table 'denylist' (same data structure)
// 11: remove table `hidelist` and create table `denylist` (same data structure)
// 12: rebuild table `policies` to drop column `package_name`
if
(
/* 0, 1, 2, 3, 4, 5, 6 */
ver
<=
6
)
{
if
(
/* 0, 1, 2, 3, 4, 5, 6 */
ver
<=
6
)
{
create_policy
();
create_policy
();
...
@@ -251,6 +252,22 @@ static char *open_and_init_db(sqlite3 *&db) {
...
@@ -251,6 +252,22 @@ static char *open_and_init_db(sqlite3 *&db) {
ver
=
11
;
ver
=
11
;
upgrade
=
true
;
upgrade
=
true
;
}
}
if
(
ver
==
11
)
{
sqlite3_exec
(
db
,
"BEGIN TRANSACTION;"
"ALTER TABLE policies RENAME TO policies_tmp;"
"CREATE TABLE IF NOT EXISTS policies "
"(uid INT, policy INT, until INT, logging INT, "
"notification INT, PRIMARY KEY(uid));"
"INSERT INTO policies "
"SELECT uid, policy, until, logging, notification FROM policies_tmp;"
"DROP TABLE policies_tmp;"
"COMMIT;"
,
nullptr
,
nullptr
,
&
err
);
err_ret
(
err
);
ver
=
12
;
upgrade
=
true
;
}
if
(
upgrade
)
{
if
(
upgrade
)
{
// Set version
// Set version
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment