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
a7ed6c15
Commit
a7ed6c15
authored
Dec 20, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More precise sudb management
parent
5ee49ba0
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
33 additions
and
31 deletions
+33
-31
build.gradle
build.gradle
+1
-1
changelog.md
src/main/assets/changelog.md
+2
-1
MagiskManager.java
src/main/java/com/topjohnwu/magisk/MagiskManager.java
+2
-11
SplashActivity.java
src/main/java/com/topjohnwu/magisk/SplashActivity.java
+3
-3
SuDatabaseHelper.java
.../java/com/topjohnwu/magisk/database/SuDatabaseHelper.java
+22
-10
ShowUI.java
src/main/java/com/topjohnwu/magisk/utils/ShowUI.java
+0
-1
Utils.java
src/main/java/com/topjohnwu/magisk/utils/Utils.java
+3
-3
strings.xml
src/main/res/values-el/strings.xml
+0
-1
No files found.
build.gradle
View file @
a7ed6c15
...
...
@@ -8,7 +8,7 @@ android {
applicationId
"com.topjohnwu.magisk"
minSdkVersion
21
targetSdkVersion
27
versionCode
7
4
versionCode
7
5
versionName
"5.4.3"
ndk
{
moduleName
'zipadjust'
...
...
src/main/assets/changelog.md
View file @
a7ed6c15
### v5.4.3 (7
4
)
### v5.4.3 (7
5
)
-
Fix dynamic resource loading, should prevent crashing when checking SafetyNet
-
Update SignAPK to use very little RAM, should expand old device support
-
Support settings migration after hiding Magisk Manager
...
...
@@ -7,3 +7,4 @@
-
Add dark theme to superuser requests
-
Properly handle new
`KEEPVERITY`
and
`HIGHCOMP`
flags for installation
-
Adapt su database to
`/data/adb/magisk.adb`
and installation paths to
`/data/adb`
-
Massive improvements for repackaging Magisk Manager
src/main/java/com/topjohnwu/magisk/MagiskManager.java
View file @
a7ed6c15
...
...
@@ -106,16 +106,7 @@ public class MagiskManager extends Application {
}
catch
(
PackageManager
.
NameNotFoundException
ignored
)
{
/* Expected */
}
}
suDB
=
new
SuDatabaseHelper
(
true
);
if
(
getPackageName
().
equals
(
Const
.
ORIG_PKG_NAME
))
{
String
pkg
=
suDB
.
getStrings
(
Const
.
Key
.
SU_REQUESTER
,
null
);
if
(
pkg
!=
null
)
{
Utils
.
uninstallPkg
(
pkg
);
suDB
.
setStrings
(
Const
.
Key
.
SU_REQUESTER
,
null
);
}
}
suDB
=
new
SuDatabaseHelper
(
false
);
repoDB
=
new
RepoDatabaseHelper
(
this
);
defaultLocale
=
Locale
.
getDefault
();
setLocale
();
...
...
@@ -212,7 +203,7 @@ public class MagiskManager extends Application {
keepEnc
=
false
;
}
if
(
suDB
!=
null
)
{
if
(
suDB
!=
null
&&
!
SuDatabaseHelper
.
verified
)
{
suDB
.
close
();
suDB
=
new
SuDatabaseHelper
();
}
...
...
src/main/java/com/topjohnwu/magisk/SplashActivity.java
View file @
a7ed6c15
...
...
@@ -35,6 +35,9 @@ public class SplashActivity extends Activity {
MagiskManager
mm
=
getMagiskManager
();
mm
.
loadMagiskInfo
();
Utils
.
loadPrefs
();
// Dynamic detect all locales
new
LoadLocale
().
exec
();
...
...
@@ -45,9 +48,6 @@ public class SplashActivity extends Activity {
getSystemService
(
NotificationManager
.
class
).
createNotificationChannel
(
channel
);
}
mm
.
loadMagiskInfo
();
Utils
.
loadPrefs
();
LoadModules
loadModuleTask
=
new
LoadModules
();
if
(
Utils
.
checkNetworkStatus
())
{
...
...
src/main/java/com/topjohnwu/magisk/database/SuDatabaseHelper.java
View file @
a7ed6c15
...
...
@@ -29,6 +29,7 @@ import java.util.List;
public
class
SuDatabaseHelper
extends
SQLiteOpenHelper
{
public
static
final
String
DB_NAME
=
"su.db"
;
public
static
boolean
verified
=
false
;
private
static
final
int
DATABASE_VER
=
5
;
private
static
final
String
POLICY_TABLE
=
"policies"
;
...
...
@@ -41,7 +42,7 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
private
PackageManager
pm
;
private
SQLiteDatabase
mDb
;
private
static
Context
initDB
(
boolean
local
)
{
private
static
Context
initDB
(
boolean
verify
)
{
Context
context
;
MagiskManager
ce
=
MagiskManager
.
get
();
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
...
...
@@ -61,46 +62,49 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
}
File
db
=
Utils
.
getDatabasePath
(
context
,
DB_NAME
);
if
(
local
&&
db
.
length
()
==
0
)
{
if
(
!
verify
&&
db
.
length
()
==
0
)
{
ce
.
loadMagiskInfo
();
return
initDB
(
fals
e
);
return
initDB
(
tru
e
);
}
// Only care about local db (no shell involved)
if
(
local
)
if
(
!
verify
)
return
context
;
// We need to make sure the global db is setup properly
if
(
ce
.
magiskVersionCode
>=
1464
&&
Shell
.
rootAccess
())
{
Shell
.
su
_raw
(
Utils
.
fmt
(
"mkdir %s
; chmod 700 %s"
,
GLOBAL_DB
.
getParent
(),
GLOBAL_DB
.
getParent
()));
Shell
.
su
(
Utils
.
fmt
(
"mkdir %s 2>/dev/null
; chmod 700 %s"
,
GLOBAL_DB
.
getParent
(),
GLOBAL_DB
.
getParent
()));
if
(!
Utils
.
itemExist
(
GLOBAL_DB
))
{
db
=
context
.
getDatabasePath
(
DB_NAME
);
Shell
.
su
(
Utils
.
fmt
(
"cp -af %s %s; rm -f %s*"
,
db
,
GLOBAL_DB
,
db
));
}
try
{
db
.
getParentFile
().
mkdirs
();
db
.
createNewFile
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
// Make sure the global and local db matches
if
(!
TextUtils
.
equals
(
Utils
.
checkMD5
(
GLOBAL_DB
),
Utils
.
checkMD5
(
db
)))
{
// Make sure the global and local db is the same inode
verified
=
TextUtils
.
equals
(
Utils
.
checkInode
(
GLOBAL_DB
),
Utils
.
checkInode
(
db
));
if
(!
verified
)
{
Shell
.
su
(
Utils
.
fmt
(
"chown 0.0 %s; chmod 666 %s; chcon u:object_r:su_file:s0 %s;"
+
"mount -o bind %s %s"
,
GLOBAL_DB
,
GLOBAL_DB
,
GLOBAL_DB
,
GLOBAL_DB
,
db
));
verified
=
TextUtils
.
equals
(
Utils
.
checkInode
(
GLOBAL_DB
),
Utils
.
checkInode
(
db
));
}
}
return
context
;
}
public
SuDatabaseHelper
()
{
this
(
fals
e
);
this
(
tru
e
);
}
public
SuDatabaseHelper
(
boolean
local
)
{
this
(
initDB
(
local
));
public
SuDatabaseHelper
(
boolean
verify
)
{
this
(
initDB
(
verify
));
}
private
SuDatabaseHelper
(
Context
context
)
{
...
...
@@ -109,6 +113,14 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
pm
=
context
.
getPackageManager
();
mDb
=
getWritableDatabase
();
cleanup
();
if
(
context
.
getPackageName
().
equals
(
Const
.
ORIG_PKG_NAME
))
{
String
pkg
=
getStrings
(
Const
.
Key
.
SU_REQUESTER
,
null
);
if
(
pkg
!=
null
)
{
Utils
.
uninstallPkg
(
pkg
);
setStrings
(
Const
.
Key
.
SU_REQUESTER
,
null
);
}
}
}
@Override
...
...
src/main/java/com/topjohnwu/magisk/utils/ShowUI.java
View file @
a7ed6c15
...
...
@@ -239,7 +239,6 @@ public class ShowUI {
Utils
.
fmt
(
"MagiskManager-v%s.apk"
,
mm
.
remoteManagerVersionString
)))
.
setCancelable
(
true
)
.
setPositiveButton
(
R
.
string
.
install
,
(
d
,
i
)
->
{
Utils
.
dumpPrefs
();
Utils
.
runWithPermission
(
activity
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
()
->
{
Intent
intent
=
new
Intent
(
mm
,
ManagerUpdate
.
class
);
intent
.
putExtra
(
Const
.
Key
.
INTENT_SET_LINK
,
mm
.
managerLink
);
...
...
src/main/java/com/topjohnwu/magisk/utils/Utils.java
View file @
a7ed6c15
...
...
@@ -62,9 +62,9 @@ public class Utils {
return
Shell
.
su
(
fmt
(
"cat %s | sed '$a\\ ' | sed '$d'"
,
path
));
}
public
static
String
check
MD5
(
Object
path
)
{
List
<
String
>
ret
=
Shell
.
su
(
fmt
(
"
md5sum
%s"
,
path
));
return
isValidShellResponse
(
ret
)
?
ret
.
get
(
0
).
split
(
"\\s+"
)[
0
]
:
null
;
public
static
String
check
Inode
(
Object
path
)
{
List
<
String
>
ret
=
Shell
.
su
(
fmt
(
"
ls -i
%s"
,
path
));
return
isValidShellResponse
(
ret
)
?
ret
.
get
(
0
).
trim
().
split
(
"\\s+"
)[
0
]
:
null
;
}
public
static
void
uninstallPkg
(
String
pkg
)
{
...
...
src/main/res/values-el/strings.xml
View file @
a7ed6c15
<resources>
<!--Welcome Activity-->
<string
name=
"magiskhide"
translatable=
"false"
>
Απόκρυψη του Magisk
</string>
<string
name=
"modules"
>
Modules
</string>
<string
name=
"downloads"
>
Λήψεις
</string>
...
...
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