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
4ff39f88
Commit
4ff39f88
authored
Jun 19, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update to libsu 1.2.0
parent
1df41003
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
72 additions
and
77 deletions
+72
-77
build.gradle
build.gradle
+2
-2
MagiskFragment.java
src/full/java/com/topjohnwu/magisk/MagiskFragment.java
+2
-2
MagiskManager.java
src/full/java/com/topjohnwu/magisk/MagiskManager.java
+11
-31
SettingsActivity.java
src/full/java/com/topjohnwu/magisk/SettingsActivity.java
+2
-1
FlashZip.java
src/full/java/com/topjohnwu/magisk/asyncs/FlashZip.java
+1
-2
HideManager.java
src/full/java/com/topjohnwu/magisk/asyncs/HideManager.java
+1
-1
InstallMagisk.java
src/full/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java
+4
-5
RestoreImages.java
src/full/java/com/topjohnwu/magisk/asyncs/RestoreImages.java
+3
-5
Module.java
src/full/java/com/topjohnwu/magisk/container/Module.java
+5
-11
MagiskDatabaseHelper.java
...a/com/topjohnwu/magisk/database/MagiskDatabaseHelper.java
+1
-1
RootUtils.java
src/full/java/com/topjohnwu/magisk/utils/RootUtils.java
+4
-12
ShellInitializer.java
...ull/java/com/topjohnwu/magisk/utils/ShellInitializer.java
+32
-0
ShowUI.java
src/full/java/com/topjohnwu/magisk/utils/ShowUI.java
+4
-4
No files found.
build.gradle
View file @
4ff39f88
...
@@ -27,7 +27,7 @@ android {
...
@@ -27,7 +27,7 @@ android {
productFlavors
{
productFlavors
{
full
{
full
{
versionCode
1
18
versionCode
1
20
versionName
"5.7.0"
versionName
"5.7.0"
}
}
stub
{
stub
{
...
@@ -57,7 +57,7 @@ dependencies {
...
@@ -57,7 +57,7 @@ dependencies {
fullImplementation
"com.android.support:recyclerview-v7:${rootProject.ext.supportLibVersion}"
fullImplementation
"com.android.support:recyclerview-v7:${rootProject.ext.supportLibVersion}"
fullImplementation
"com.android.support:cardview-v7:${rootProject.ext.supportLibVersion}"
fullImplementation
"com.android.support:cardview-v7:${rootProject.ext.supportLibVersion}"
fullImplementation
"com.android.support:design:${rootProject.ext.supportLibVersion}"
fullImplementation
"com.android.support:design:${rootProject.ext.supportLibVersion}"
fullImplementation
'com.github.topjohnwu:libsu:1.
1.1
'
fullImplementation
'com.github.topjohnwu:libsu:1.
2.0
'
fullImplementation
'com.atlassian.commonmark:commonmark:0.11.0'
fullImplementation
'com.atlassian.commonmark:commonmark:0.11.0'
fullImplementation
'org.kamranzafar:jtar:2.3'
fullImplementation
'org.kamranzafar:jtar:2.3'
fullImplementation
'com.jakewharton:butterknife:8.8.1'
fullImplementation
'com.jakewharton:butterknife:8.8.1'
...
...
src/full/java/com/topjohnwu/magisk/MagiskFragment.java
View file @
4ff39f88
...
@@ -25,11 +25,11 @@ import com.topjohnwu.magisk.components.ExpandableView;
...
@@ -25,11 +25,11 @@ import com.topjohnwu.magisk.components.ExpandableView;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.ISafetyNetHelper
;
import
com.topjohnwu.magisk.utils.ISafetyNetHelper
;
import
com.topjohnwu.magisk.utils.RootUtils
;
import
com.topjohnwu.magisk.utils.ShowUI
;
import
com.topjohnwu.magisk.utils.ShowUI
;
import
com.topjohnwu.magisk.utils.Topic
;
import
com.topjohnwu.magisk.utils.Topic
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.ShellUtils
;
import
butterknife.BindColor
;
import
butterknife.BindColor
;
import
butterknife.BindView
;
import
butterknife.BindView
;
...
@@ -265,7 +265,7 @@ public class MagiskFragment extends Fragment
...
@@ -265,7 +265,7 @@ public class MagiskFragment extends Fragment
||
mm
.
remoteManagerVersionCode
>
BuildConfig
.
VERSION_CODE
)
{
||
mm
.
remoteManagerVersionCode
>
BuildConfig
.
VERSION_CODE
)
{
install
();
install
();
}
else
if
(
mm
.
remoteMagiskVersionCode
>=
Const
.
MAGISK_VER
.
FIX_ENV
&&
}
else
if
(
mm
.
remoteMagiskVersionCode
>=
Const
.
MAGISK_VER
.
FIX_ENV
&&
!
RootUtils
.
c
mdResult
(
"env_check"
))
{
!
ShellUtils
.
fastC
mdResult
(
"env_check"
))
{
ShowUI
.
envFixDialog
(
getActivity
());
ShowUI
.
envFixDialog
(
getActivity
());
}
}
}
}
...
...
src/full/java/com/topjohnwu/magisk/MagiskManager.java
View file @
4ff39f88
...
@@ -8,7 +8,6 @@ import android.content.pm.PackageManager;
...
@@ -8,7 +8,6 @@ import android.content.pm.PackageManager;
import
android.content.res.Configuration
;
import
android.content.res.Configuration
;
import
android.content.res.Resources
;
import
android.content.res.Resources
;
import
android.preference.PreferenceManager
;
import
android.preference.PreferenceManager
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.util.Xml
;
import
android.util.Xml
;
...
@@ -20,10 +19,11 @@ import com.topjohnwu.magisk.database.RepoDatabaseHelper;
...
@@ -20,10 +19,11 @@ import com.topjohnwu.magisk.database.RepoDatabaseHelper;
import
com.topjohnwu.magisk.services.UpdateCheckService
;
import
com.topjohnwu.magisk.services.UpdateCheckService
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.RootUtils
;
import
com.topjohnwu.magisk.utils.RootUtils
;
import
com.topjohnwu.magisk.utils.ShellInitializer
;
import
com.topjohnwu.magisk.utils.Topic
;
import
com.topjohnwu.magisk.utils.Topic
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.superuser.BusyBox
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.ShellUtils
;
import
com.topjohnwu.superuser.io.SuFile
;
import
com.topjohnwu.superuser.io.SuFile
;
import
com.topjohnwu.superuser.io.SuFileInputStream
;
import
com.topjohnwu.superuser.io.SuFileInputStream
;
...
@@ -32,7 +32,6 @@ import org.xmlpull.v1.XmlPullParserException;
...
@@ -32,7 +32,6 @@ import org.xmlpull.v1.XmlPullParserException;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.lang.ref.WeakReference
;
import
java.lang.ref.WeakReference
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Locale
;
...
@@ -111,26 +110,7 @@ public class MagiskManager extends Application implements Shell.Container {
...
@@ -111,26 +110,7 @@ public class MagiskManager extends Application implements Shell.Container {
Shell
.
setFlags
(
Shell
.
FLAG_MOUNT_MASTER
);
Shell
.
setFlags
(
Shell
.
FLAG_MOUNT_MASTER
);
Shell
.
verboseLogging
(
BuildConfig
.
DEBUG
);
Shell
.
verboseLogging
(
BuildConfig
.
DEBUG
);
BusyBox
.
BB_PATH
=
new
File
(
Const
.
BUSYBOX_PATH
);
Shell
.
setInitializer
(
ShellInitializer
.
class
);
Shell
.
setInitializer
(
new
Shell
.
Initializer
()
{
@Override
public
void
onRootShellInit
(
@NonNull
Shell
shell
)
{
try
(
InputStream
magiskUtils
=
getAssets
().
open
(
Const
.
UTIL_FUNCTIONS
);
InputStream
managerUtils
=
getResources
().
openRawResource
(
R
.
raw
.
utils
)
)
{
shell
.
loadInputStream
(
null
,
null
,
magiskUtils
);
shell
.
loadInputStream
(
null
,
null
,
managerUtils
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
shell
.
run
(
null
,
null
,
"mount_partitions"
,
"find_boot_image"
,
"find_dtbo_image"
,
"get_flags"
,
"run_migrations"
);
}
});
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
this
);
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
this
);
mDB
=
MagiskDatabaseHelper
.
getInstance
(
this
);
mDB
=
MagiskDatabaseHelper
.
getInstance
(
this
);
...
@@ -207,19 +187,19 @@ public class MagiskManager extends Application implements Shell.Container {
...
@@ -207,19 +187,19 @@ public class MagiskManager extends Application implements Shell.Container {
public
void
loadMagiskInfo
()
{
public
void
loadMagiskInfo
()
{
try
{
try
{
magiskVersionString
=
RootUtils
.
c
md
(
"magisk -v"
).
split
(
":"
)[
0
];
magiskVersionString
=
ShellUtils
.
fastC
md
(
"magisk -v"
).
split
(
":"
)[
0
];
magiskVersionCode
=
Integer
.
parseInt
(
RootUtils
.
c
md
(
"magisk -V"
));
magiskVersionCode
=
Integer
.
parseInt
(
ShellUtils
.
fastC
md
(
"magisk -V"
));
String
s
=
RootUtils
.
cmd
((
magiskVersionCode
>=
Const
.
MAGISK_VER
.
RESETPROP_PERSIST
?
"resetprop -p "
:
"getprop "
)
String
s
=
ShellUtils
.
fastCmd
((
magiskVersionCode
>=
Const
.
MAGISK_VER
.
RESETPROP_PERSIST
?
+
Const
.
MAGISKHIDE_PROP
);
"resetprop -p "
:
"getprop "
)
+
Const
.
MAGISKHIDE_PROP
);
magiskHide
=
s
==
null
||
Integer
.
parseInt
(
s
)
!=
0
;
magiskHide
=
s
==
null
||
Integer
.
parseInt
(
s
)
!=
0
;
}
catch
(
Exception
ignored
)
{}
}
catch
(
Exception
ignored
)
{}
bootBlock
=
RootUtils
.
c
md
(
"echo \"$BOOTIMAGE\""
);
bootBlock
=
ShellUtils
.
fastC
md
(
"echo \"$BOOTIMAGE\""
);
}
}
public
void
getDefaultInstallFlags
()
{
public
void
getDefaultInstallFlags
()
{
keepVerity
=
Boolean
.
parseBoolean
(
RootUtils
.
c
md
(
"echo $KEEPVERITY"
));
keepVerity
=
Boolean
.
parseBoolean
(
ShellUtils
.
fastC
md
(
"echo $KEEPVERITY"
));
keepEnc
=
Boolean
.
parseBoolean
(
RootUtils
.
c
md
(
"echo $KEEPFORCEENCRYPT"
));
keepEnc
=
Boolean
.
parseBoolean
(
ShellUtils
.
fastC
md
(
"echo $KEEPFORCEENCRYPT"
));
}
}
public
void
setupUpdateCheck
()
{
public
void
setupUpdateCheck
()
{
...
@@ -250,7 +230,7 @@ public class MagiskManager extends Application implements Shell.Container {
...
@@ -250,7 +230,7 @@ public class MagiskManager extends Application implements Shell.Container {
}
}
public
void
loadPrefs
()
{
public
void
loadPrefs
()
{
SuFile
config
=
new
SuFile
(
Utils
.
fmt
(
"/data/user/%d/%s"
,
Const
.
USER_ID
,
Const
.
MANAGER_CONFIGS
)
,
true
);
SuFile
config
=
new
SuFile
(
Utils
.
fmt
(
"/data/user/%d/%s"
,
Const
.
USER_ID
,
Const
.
MANAGER_CONFIGS
));
if
(
config
.
exists
())
{
if
(
config
.
exists
())
{
SharedPreferences
.
Editor
editor
=
prefs
.
edit
();
SharedPreferences
.
Editor
editor
=
prefs
.
edit
();
try
{
try
{
...
...
src/full/java/com/topjohnwu/magisk/SettingsActivity.java
View file @
4ff39f88
...
@@ -30,6 +30,7 @@ import com.topjohnwu.magisk.utils.RootUtils;
...
@@ -30,6 +30,7 @@ import com.topjohnwu.magisk.utils.RootUtils;
import
com.topjohnwu.magisk.utils.Topic
;
import
com.topjohnwu.magisk.utils.Topic
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.ShellUtils
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Locale
;
import
java.util.Locale
;
...
@@ -172,7 +173,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
...
@@ -172,7 +173,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
@Override
@Override
public
void
onDownloadDone
(
Context
context
,
Uri
uri
)
{
public
void
onDownloadDone
(
Context
context
,
Uri
uri
)
{
mm
.
dumpPrefs
();
mm
.
dumpPrefs
();
if
(
RootUtils
.
c
mdResult
(
"pm install "
+
uri
.
getPath
()))
if
(
ShellUtils
.
fastC
mdResult
(
"pm install "
+
uri
.
getPath
()))
RootUtils
.
uninstallPkg
(
context
.
getPackageName
());
RootUtils
.
uninstallPkg
(
context
.
getPackageName
());
}
}
},
},
...
...
src/full/java/com/topjohnwu/magisk/asyncs/FlashZip.java
View file @
4ff39f88
...
@@ -9,7 +9,6 @@ import com.topjohnwu.magisk.FlashActivity;
...
@@ -9,7 +9,6 @@ import com.topjohnwu.magisk.FlashActivity;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.components.SnackbarMaker
;
import
com.topjohnwu.magisk.components.SnackbarMaker
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.RootUtils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.ZipUtils
;
import
com.topjohnwu.magisk.utils.ZipUtils
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.Shell
;
...
@@ -41,7 +40,7 @@ public class FlashZip extends ParallelTask<Void, Void, Integer> {
...
@@ -41,7 +40,7 @@ public class FlashZip extends ParallelTask<Void, Void, Integer> {
private
boolean
unzipAndCheck
()
throws
Exception
{
private
boolean
unzipAndCheck
()
throws
Exception
{
ZipUtils
.
unzip
(
mCachedFile
,
mCachedFile
.
getParentFile
(),
"META-INF/com/google/android"
,
true
);
ZipUtils
.
unzip
(
mCachedFile
,
mCachedFile
.
getParentFile
(),
"META-INF/com/google/android"
,
true
);
String
s
=
RootUtils
.
c
md
(
"head -n 1 "
+
new
File
(
mCachedFile
.
getParentFile
(),
"updater-script"
));
String
s
=
ShellUtils
.
fastC
md
(
"head -n 1 "
+
new
File
(
mCachedFile
.
getParentFile
(),
"updater-script"
));
return
s
!=
null
&&
s
.
contains
(
"#MAGISK"
);
return
s
!=
null
&&
s
.
contains
(
"#MAGISK"
);
}
}
...
...
src/full/java/com/topjohnwu/magisk/asyncs/HideManager.java
View file @
4ff39f88
...
@@ -58,7 +58,7 @@ public class HideManager extends ParallelTask<Void, Void, Boolean> {
...
@@ -58,7 +58,7 @@ public class HideManager extends ParallelTask<Void, Void, Boolean> {
MagiskManager
mm
=
MagiskManager
.
get
();
MagiskManager
mm
=
MagiskManager
.
get
();
// Generate a new app with random package name
// Generate a new app with random package name
SuFile
repack
=
new
SuFile
(
"/data/local/tmp/repack.apk"
,
true
);
SuFile
repack
=
new
SuFile
(
"/data/local/tmp/repack.apk"
);
String
pkg
=
genPackageName
(
"com."
,
Const
.
ORIG_PKG_NAME
.
length
());
String
pkg
=
genPackageName
(
"com."
,
Const
.
ORIG_PKG_NAME
.
length
());
try
{
try
{
...
...
src/full/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java
View file @
4ff39f88
...
@@ -13,7 +13,6 @@ import com.topjohnwu.magisk.MagiskManager;
...
@@ -13,7 +13,6 @@ import com.topjohnwu.magisk.MagiskManager;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.container.TarEntry
;
import
com.topjohnwu.magisk.container.TarEntry
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.RootUtils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.ZipUtils
;
import
com.topjohnwu.magisk.utils.ZipUtils
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.Shell
;
...
@@ -148,9 +147,8 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
...
@@ -148,9 +147,8 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
case
DIRECT_MODE:
case
DIRECT_MODE:
console
.
add
(
"- Patch boot/ramdisk image: "
+
mBootLocation
);
console
.
add
(
"- Patch boot/ramdisk image: "
+
mBootLocation
);
if
(
mm
.
remoteMagiskVersionCode
>=
1463
)
{
if
(
mm
.
remoteMagiskVersionCode
>=
1463
)
{
highCompression
=
Integer
.
parseInt
(
RootUtils
.
cmd
(
Utils
.
fmt
(
highCompression
=
Integer
.
parseInt
(
ShellUtils
.
fastCmd
(
Utils
.
fmt
(
"%s/magiskboot --parse %s; echo $?"
,
"%s/magiskboot --parse %s; echo $?"
,
install
,
mBootLocation
)))
==
2
;
install
,
mBootLocation
)))
==
2
;
if
(
highCompression
)
if
(
highCompression
)
console
.
add
(
"! Insufficient boot partition size detected"
);
console
.
add
(
"! Insufficient boot partition size detected"
);
}
}
...
@@ -263,6 +261,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
...
@@ -263,6 +261,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
.
getFilesDir
().
getParent
()
.
getFilesDir
().
getParent
()
,
"install"
);
,
"install"
);
Shell
.
Sync
.
sh
(
"rm -rf "
+
install
);
Shell
.
Sync
.
sh
(
"rm -rf "
+
install
);
install
.
mkdirs
();
}
}
List
<
String
>
abis
=
Arrays
.
asList
(
Build
.
SUPPORTED_ABIS
);
List
<
String
>
abis
=
Arrays
.
asList
(
Build
.
SUPPORTED_ABIS
);
...
@@ -294,7 +293,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
...
@@ -294,7 +293,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
);
);
}
else
{
}
else
{
File
boot
=
new
File
(
install
,
"boot.img"
);
File
boot
=
new
File
(
install
,
"boot.img"
);
SuFile
patched_boot
=
new
SuFile
(
install
.
getParent
()
+
"/new-boot.img"
,
true
);
SuFile
patched_boot
=
new
SuFile
(
install
.
getParent
()
,
"new-boot.img"
);
if
(!
dumpBoot
(
boot
)
||
!
patchBoot
(
boot
,
patched_boot
))
if
(!
dumpBoot
(
boot
)
||
!
patchBoot
(
boot
,
patched_boot
))
return
false
;
return
false
;
...
...
src/full/java/com/topjohnwu/magisk/asyncs/RestoreImages.java
View file @
4ff39f88
...
@@ -4,8 +4,6 @@ import android.widget.Toast;
...
@@ -4,8 +4,6 @@ import android.widget.Toast;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.utils.RootUtils
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.ShellUtils
;
import
com.topjohnwu.superuser.ShellUtils
;
public
class
RestoreImages
extends
ParallelTask
<
Void
,
Void
,
Boolean
>
{
public
class
RestoreImages
extends
ParallelTask
<
Void
,
Void
,
Boolean
>
{
...
@@ -13,15 +11,15 @@ public class RestoreImages extends ParallelTask<Void, Void, Boolean> {
...
@@ -13,15 +11,15 @@ public class RestoreImages extends ParallelTask<Void, Void, Boolean> {
@Override
@Override
protected
Boolean
doInBackground
(
Void
...
voids
)
{
protected
Boolean
doInBackground
(
Void
...
voids
)
{
String
sha1
;
String
sha1
;
sha1
=
RootUtils
.
c
md
(
"cat /.backup/.sha1"
);
sha1
=
ShellUtils
.
fastC
md
(
"cat /.backup/.sha1"
);
if
(
sha1
==
null
)
{
if
(
sha1
==
null
)
{
sha1
=
RootUtils
.
c
md
(
"cat /init.magisk.rc | grep STOCKSHA1"
);
sha1
=
ShellUtils
.
fastC
md
(
"cat /init.magisk.rc | grep STOCKSHA1"
);
if
(
sha1
==
null
)
if
(
sha1
==
null
)
return
false
;
return
false
;
sha1
=
sha1
.
substring
(
sha1
.
indexOf
(
'='
)
+
1
);
sha1
=
sha1
.
substring
(
sha1
.
indexOf
(
'='
)
+
1
);
}
}
return
ShellUtils
.
fastCmdResult
(
Shell
.
getShell
(),
"restore_imgs "
+
sha1
);
return
ShellUtils
.
fastCmdResult
(
"restore_imgs "
+
sha1
);
}
}
@Override
@Override
...
...
src/full/java/com/topjohnwu/magisk/container/Module.java
View file @
4ff39f88
...
@@ -3,8 +3,6 @@ package com.topjohnwu.magisk.container;
...
@@ -3,8 +3,6 @@ package com.topjohnwu.magisk.container;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.io.SuFile
;
import
com.topjohnwu.superuser.io.SuFile
;
import
java.io.IOException
;
public
class
Module
extends
BaseModule
{
public
class
Module
extends
BaseModule
{
private
SuFile
mRemoveFile
,
mDisableFile
,
mUpdateFile
;
private
SuFile
mRemoveFile
,
mDisableFile
,
mUpdateFile
;
...
@@ -16,9 +14,9 @@ public class Module extends BaseModule {
...
@@ -16,9 +14,9 @@ public class Module extends BaseModule {
parseProps
(
Shell
.
Sync
.
su
(
"dos2unix < "
+
path
+
"/module.prop"
));
parseProps
(
Shell
.
Sync
.
su
(
"dos2unix < "
+
path
+
"/module.prop"
));
}
catch
(
NumberFormatException
ignored
)
{}
}
catch
(
NumberFormatException
ignored
)
{}
mRemoveFile
=
new
SuFile
(
path
+
"/remove"
,
true
);
mRemoveFile
=
new
SuFile
(
path
+
"/remove"
);
mDisableFile
=
new
SuFile
(
path
+
"/disable"
,
true
);
mDisableFile
=
new
SuFile
(
path
+
"/disable"
);
mUpdateFile
=
new
SuFile
(
path
+
"/update"
,
true
);
mUpdateFile
=
new
SuFile
(
path
+
"/update"
);
if
(
getId
()
==
null
)
{
if
(
getId
()
==
null
)
{
int
sep
=
path
.
lastIndexOf
(
'/'
);
int
sep
=
path
.
lastIndexOf
(
'/'
);
...
@@ -36,9 +34,7 @@ public class Module extends BaseModule {
...
@@ -36,9 +34,7 @@ public class Module extends BaseModule {
public
void
createDisableFile
()
{
public
void
createDisableFile
()
{
mEnable
=
false
;
mEnable
=
false
;
try
{
mDisableFile
.
createNewFile
();
mDisableFile
.
createNewFile
();
}
catch
(
IOException
ignored
)
{}
}
}
public
void
removeDisableFile
()
{
public
void
removeDisableFile
()
{
...
@@ -52,9 +48,7 @@ public class Module extends BaseModule {
...
@@ -52,9 +48,7 @@ public class Module extends BaseModule {
public
void
createRemoveFile
()
{
public
void
createRemoveFile
()
{
mRemove
=
true
;
mRemove
=
true
;
try
{
mRemoveFile
.
createNewFile
();
mRemoveFile
.
createNewFile
();
}
catch
(
IOException
ignored
)
{}
}
}
public
void
deleteRemoveFile
()
{
public
void
deleteRemoveFile
()
{
...
...
src/full/java/com/topjohnwu/magisk/database/MagiskDatabaseHelper.java
View file @
4ff39f88
...
@@ -86,7 +86,7 @@ public class MagiskDatabaseHelper {
...
@@ -86,7 +86,7 @@ public class MagiskDatabaseHelper {
return
de
.
openOrCreateDatabase
(
"su.db"
,
Context
.
MODE_PRIVATE
,
null
);
return
de
.
openOrCreateDatabase
(
"su.db"
,
Context
.
MODE_PRIVATE
,
null
);
}
else
{
}
else
{
// Global database
// Global database
final
SuFile
GLOBAL_DB
=
new
SuFile
(
"/data/adb/magisk.db"
,
true
);
final
SuFile
GLOBAL_DB
=
new
SuFile
(
"/data/adb/magisk.db"
);
mm
.
deleteDatabase
(
"su.db"
);
mm
.
deleteDatabase
(
"su.db"
);
de
.
deleteDatabase
(
"su.db"
);
de
.
deleteDatabase
(
"su.db"
);
if
(
mm
.
magiskVersionCode
<
Const
.
MAGISK_VER
.
SEPOL_REFACTOR
)
{
if
(
mm
.
magiskVersionCode
<
Const
.
MAGISK_VER
.
SEPOL_REFACTOR
)
{
...
...
src/full/java/com/topjohnwu/magisk/utils/RootUtils.java
View file @
4ff39f88
...
@@ -8,26 +8,18 @@ import com.topjohnwu.superuser.io.SuFile;
...
@@ -8,26 +8,18 @@ import com.topjohnwu.superuser.io.SuFile;
public
class
RootUtils
{
public
class
RootUtils
{
public
static
void
init
()
{
public
static
void
init
()
{
Const
.
MAGISK_DISABLE_FILE
=
new
SuFile
(
"/cache/.disable_magisk"
,
true
);
Const
.
MAGISK_DISABLE_FILE
=
new
SuFile
(
"/cache/.disable_magisk"
);
SuFile
file
=
new
SuFile
(
"/sbin/.core/img"
,
true
);
SuFile
file
=
new
SuFile
(
"/sbin/.core/img"
);
if
(
file
.
exists
())
{
if
(
file
.
exists
())
{
Const
.
MAGISK_PATH
=
file
;
Const
.
MAGISK_PATH
=
file
;
}
else
if
((
file
=
new
SuFile
(
"/dev/magisk/img"
,
true
)).
exists
())
{
}
else
if
((
file
=
new
SuFile
(
"/dev/magisk/img"
)).
exists
())
{
Const
.
MAGISK_PATH
=
file
;
Const
.
MAGISK_PATH
=
file
;
}
else
{
}
else
{
Const
.
MAGISK_PATH
=
new
SuFile
(
"/magisk"
,
true
);
Const
.
MAGISK_PATH
=
new
SuFile
(
"/magisk"
);
}
}
Const
.
MAGISK_HOST_FILE
=
new
SuFile
(
Const
.
MAGISK_PATH
+
"/.core/hosts"
);
Const
.
MAGISK_HOST_FILE
=
new
SuFile
(
Const
.
MAGISK_PATH
+
"/.core/hosts"
);
}
}
public
static
String
cmd
(
String
cmd
)
{
return
ShellUtils
.
fastCmd
(
Shell
.
getShell
(),
cmd
);
}
public
static
boolean
cmdResult
(
String
cmd
)
{
return
ShellUtils
.
fastCmdResult
(
Shell
.
getShell
(),
cmd
);
}
public
static
void
uninstallPkg
(
String
pkg
)
{
public
static
void
uninstallPkg
(
String
pkg
)
{
Shell
.
Sync
.
su
(
"db_clean "
+
Const
.
USER_ID
,
"pm uninstall "
+
pkg
);
Shell
.
Sync
.
su
(
"db_clean "
+
Const
.
USER_ID
,
"pm uninstall "
+
pkg
);
}
}
...
...
src/full/java/com/topjohnwu/magisk/utils/ShellInitializer.java
0 → 100644
View file @
4ff39f88
package
com
.
topjohnwu
.
magisk
.
utils
;
import
android.content.Context
;
import
android.support.annotation.NonNull
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.superuser.BusyBox
;
import
com.topjohnwu.superuser.Shell
;
import
java.io.File
;
import
java.io.InputStream
;
public
class
ShellInitializer
extends
Shell
.
Initializer
{
@Override
public
boolean
onRootShellInit
(
Context
context
,
@NonNull
Shell
shell
)
throws
Exception
{
BusyBox
.
BB_PATH
=
new
File
(
Const
.
BUSYBOX_PATH
);
try
(
InputStream
magiskUtils
=
context
.
getAssets
().
open
(
Const
.
UTIL_FUNCTIONS
);
InputStream
managerUtils
=
context
.
getResources
().
openRawResource
(
R
.
raw
.
utils
)
)
{
shell
.
loadInputStream
(
null
,
null
,
magiskUtils
);
shell
.
loadInputStream
(
null
,
null
,
managerUtils
);
}
shell
.
run
(
null
,
null
,
"mount_partitions"
,
"find_boot_image"
,
"find_dtbo_image"
,
"get_flags"
,
"run_migrations"
);
return
true
;
}
}
src/full/java/com/topjohnwu/magisk/utils/ShowUI.java
View file @
4ff39f88
...
@@ -137,7 +137,7 @@ public class ShowUI {
...
@@ -137,7 +137,7 @@ public class ShowUI {
if
(
Shell
.
rootAccess
())
{
if
(
Shell
.
rootAccess
())
{
options
.
add
(
mm
.
getString
(
R
.
string
.
direct_install
));
options
.
add
(
mm
.
getString
(
R
.
string
.
direct_install
));
}
}
String
s
=
RootUtils
.
c
md
(
"echo $SLOT"
);
String
s
=
ShellUtils
.
fastC
md
(
"echo $SLOT"
);
if
(
s
!=
null
)
{
if
(
s
!=
null
)
{
options
.
add
(
mm
.
getString
(
R
.
string
.
install_second_slot
));
options
.
add
(
mm
.
getString
(
R
.
string
.
install_second_slot
));
}
}
...
@@ -211,9 +211,9 @@ public class ShowUI {
...
@@ -211,9 +211,9 @@ public class ShowUI {
if
(
slot
[
1
]
==
'a'
)
slot
[
1
]
=
'b'
;
if
(
slot
[
1
]
==
'a'
)
slot
[
1
]
=
'b'
;
else
slot
[
1
]
=
'a'
;
else
slot
[
1
]
=
'a'
;
// Then find the boot image again
// Then find the boot image again
boot
=
RootUtils
.
c
md
(
boot
=
ShellUtils
.
fastC
md
(
"SLOT="
+
String
.
valueOf
(
slot
)
+
"SLOT="
+
String
.
valueOf
(
slot
)
,
"
; find_boot_image;"
+
"
find_boot_image"
,
"echo \"$BOOTIMAGE\""
"echo \"$BOOTIMAGE\""
);
);
Shell
.
Async
.
su
(
"mount_partitions"
);
Shell
.
Async
.
su
(
"mount_partitions"
);
...
...
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