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
c5d67ebf
Commit
c5d67ebf
authored
Jul 26, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update libsu to 2.0.0
parent
91818cfa
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
132 additions
and
192 deletions
+132
-192
build.gradle
app/build.gradle
+2
-2
FlashActivity.java
app/src/full/java/com/topjohnwu/magisk/FlashActivity.java
+1
-1
MagiskLogFragment.java
...src/full/java/com/topjohnwu/magisk/MagiskLogFragment.java
+12
-30
MagiskManager.java
app/src/full/java/com/topjohnwu/magisk/MagiskManager.java
+8
-21
ModulesFragment.java
app/src/full/java/com/topjohnwu/magisk/ModulesFragment.java
+4
-4
SettingsActivity.java
app/src/full/java/com/topjohnwu/magisk/SettingsActivity.java
+8
-8
SplashActivity.java
app/src/full/java/com/topjohnwu/magisk/SplashActivity.java
+0
-2
ApplicationAdapter.java
...ava/com/topjohnwu/magisk/adapters/ApplicationAdapter.java
+3
-3
CheckSafetyNet.java
...full/java/com/topjohnwu/magisk/asyncs/CheckSafetyNet.java
+1
-1
FlashZip.java
app/src/full/java/com/topjohnwu/magisk/asyncs/FlashZip.java
+5
-11
InstallMagisk.java
.../full/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java
+22
-38
LoadModules.java
...rc/full/java/com/topjohnwu/magisk/asyncs/LoadModules.java
+6
-8
Module.java
app/src/full/java/com/topjohnwu/magisk/container/Module.java
+3
-3
MagiskDatabaseHelper.java
...a/com/topjohnwu/magisk/database/MagiskDatabaseHelper.java
+6
-6
PackageReceiver.java
.../java/com/topjohnwu/magisk/receivers/PackageReceiver.java
+1
-1
RebootReceiver.java
...l/java/com/topjohnwu/magisk/receivers/RebootReceiver.java
+1
-1
RootUtils.java
app/src/full/java/com/topjohnwu/magisk/utils/RootUtils.java
+49
-16
ShellInitializer.java
...ull/java/com/topjohnwu/magisk/utils/ShellInitializer.java
+0
-36
No files found.
app/build.gradle
View file @
c5d67ebf
...
@@ -27,7 +27,7 @@ android {
...
@@ -27,7 +27,7 @@ android {
productFlavors
{
productFlavors
{
full
{
full
{
versionCode
1
29
versionCode
1
30
versionName
"5.8.3"
versionName
"5.8.3"
}
}
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.3
.0'
fullImplementation
'com.github.topjohnwu:libsu:
2.0
.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'
...
...
app/src/full/java/com/topjohnwu/magisk/FlashActivity.java
View file @
c5d67ebf
...
@@ -51,7 +51,7 @@ public class FlashActivity extends Activity {
...
@@ -51,7 +51,7 @@ public class FlashActivity extends Activity {
@OnClick
(
R
.
id
.
reboot
)
@OnClick
(
R
.
id
.
reboot
)
void
reboot
()
{
void
reboot
()
{
Shell
.
Async
.
su
(
"/system/bin/reboot"
);
Shell
.
su
(
"/system/bin/reboot"
).
submit
(
);
}
}
@OnClick
(
R
.
id
.
save_logs
)
@OnClick
(
R
.
id
.
save_logs
)
...
...
app/src/full/java/com/topjohnwu/magisk/MagiskLogFragment.java
View file @
c5d67ebf
...
@@ -2,7 +2,6 @@ package com.topjohnwu.magisk;
...
@@ -2,7 +2,6 @@ package com.topjohnwu.magisk;
import
android.Manifest
;
import
android.Manifest
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.support.design.widget.Snackbar
;
import
android.support.design.widget.Snackbar
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
...
@@ -22,12 +21,10 @@ import com.topjohnwu.magisk.components.SnackbarMaker;
...
@@ -22,12 +21,10 @@ import com.topjohnwu.magisk.components.SnackbarMaker;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Const
;
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.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.List
;
import
butterknife.BindView
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
butterknife.ButterKnife
;
...
@@ -93,24 +90,15 @@ public class MagiskLogFragment extends Fragment {
...
@@ -93,24 +90,15 @@ public class MagiskLogFragment extends Fragment {
}
}
public
void
readLogs
()
{
public
void
readLogs
()
{
Shell
.
Async
.
su
(
new
Shell
.
Async
.
Callback
()
{
Shell
.
su
(
"cat "
+
Const
.
MAGISK_LOG
+
" | tail -n 5000"
).
submit
(
result
->
{
@Override
public
void
onTaskResult
(
@Nullable
List
<
String
>
out
,
@Nullable
List
<
String
>
err
)
{
progressBar
.
setVisibility
(
View
.
GONE
);
progressBar
.
setVisibility
(
View
.
GONE
);
if
(
ShellUtils
.
isValidOutput
(
out
))
{
if
(
result
.
getOut
().
isEmpty
())
txtLog
.
setText
(
TextUtils
.
join
(
"\n"
,
out
));
}
else
{
txtLog
.
setText
(
R
.
string
.
log_is_empty
);
txtLog
.
setText
(
R
.
string
.
log_is_empty
);
}
else
txtLog
.
setText
(
TextUtils
.
join
(
"\n"
,
result
.
getOut
()));
svLog
.
postDelayed
(()
->
svLog
.
fullScroll
(
ScrollView
.
FOCUS_DOWN
),
100
);
svLog
.
postDelayed
(()
->
svLog
.
fullScroll
(
ScrollView
.
FOCUS_DOWN
),
100
);
hsvLog
.
postDelayed
(()
->
hsvLog
.
fullScroll
(
ScrollView
.
FOCUS_LEFT
),
100
);
hsvLog
.
postDelayed
(()
->
hsvLog
.
fullScroll
(
ScrollView
.
FOCUS_LEFT
),
100
);
}
});
@Override
public
void
onTaskError
(
@NonNull
Throwable
throwable
)
{
txtLog
.
setText
(
R
.
string
.
log_is_empty
);
}
},
"cat "
+
Const
.
MAGISK_LOG
+
" | tail -n 5000"
);
}
}
public
void
saveLogs
()
{
public
void
saveLogs
()
{
...
@@ -127,19 +115,13 @@ public class MagiskLogFragment extends Fragment {
...
@@ -127,19 +115,13 @@ public class MagiskLogFragment extends Fragment {
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
return
;
return
;
}
}
Shell
.
Async
.
su
(
new
Shell
.
Async
.
Callback
()
{
Shell
.
su
(
"cat "
+
Const
.
MAGISK_LOG
+
" > "
+
targetFile
)
@Override
.
submit
(
result
->
public
void
onTaskResult
(
@Nullable
List
<
String
>
out
,
@Nullable
List
<
String
>
err
)
{
SnackbarMaker
.
make
(
txtLog
,
targetFile
.
getPath
(),
Snackbar
.
LENGTH_SHORT
).
show
());
SnackbarMaker
.
make
(
txtLog
,
targetFile
.
getPath
(),
Snackbar
.
LENGTH_SHORT
).
show
();
}
@Override
public
void
onTaskError
(
@NonNull
Throwable
throwable
)
{}
},
"cat "
+
Const
.
MAGISK_LOG
+
" > "
+
targetFile
);
}
}
public
void
clearLogs
()
{
public
void
clearLogs
()
{
Shell
.
Async
.
su
(
"echo -n > "
+
Const
.
MAGISK_LOG
);
Shell
.
su
(
"echo -n > "
+
Const
.
MAGISK_LOG
).
submit
(
);
SnackbarMaker
.
make
(
txtLog
,
R
.
string
.
logs_cleared
,
Snackbar
.
LENGTH_SHORT
).
show
();
SnackbarMaker
.
make
(
txtLog
,
R
.
string
.
logs_cleared
,
Snackbar
.
LENGTH_SHORT
).
show
();
}
}
}
}
app/src/full/java/com/topjohnwu/magisk/MagiskManager.java
View file @
c5d67ebf
...
@@ -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.Nullable
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.util.Xml
;
import
android.util.Xml
;
...
@@ -19,7 +18,6 @@ import com.topjohnwu.magisk.database.RepoDatabaseHelper;
...
@@ -19,7 +18,6 @@ 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.Shell
;
import
com.topjohnwu.superuser.Shell
;
...
@@ -37,7 +35,7 @@ import java.util.List;
...
@@ -37,7 +35,7 @@ import java.util.List;
import
java.util.Locale
;
import
java.util.Locale
;
import
java.util.Map
;
import
java.util.Map
;
public
class
MagiskManager
extends
Application
implements
Shell
.
Container
{
public
class
MagiskManager
extends
Application
{
// Topics
// Topics
public
final
Topic
magiskHideDone
=
new
Topic
();
public
final
Topic
magiskHideDone
=
new
Topic
();
...
@@ -89,31 +87,20 @@ public class MagiskManager extends Application implements Shell.Container {
...
@@ -89,31 +87,20 @@ public class MagiskManager extends Application implements Shell.Container {
public
MagiskDatabaseHelper
mDB
;
public
MagiskDatabaseHelper
mDB
;
public
RepoDatabaseHelper
repoDB
;
public
RepoDatabaseHelper
repoDB
;
private
volatile
Shell
mShell
;
private
Shell
.
Container
container
;
public
MagiskManager
()
{
public
MagiskManager
()
{
weakSelf
=
new
WeakReference
<>(
this
);
weakSelf
=
new
WeakReference
<>(
this
);
Shell
.
setContainer
(
this
);
container
=
Shell
.
Config
.
newContainer
();
}
@Nullable
@Override
public
Shell
getShell
()
{
return
mShell
;
}
@Override
public
void
setShell
(
@Nullable
Shell
shell
)
{
mShell
=
shell
;
}
}
@Override
@Override
public
void
onCreate
()
{
public
void
onCreate
()
{
super
.
onCreate
();
super
.
onCreate
();
Shell
.
setFlags
(
Shell
.
FLAG_MOUNT_MASTER
);
Shell
.
Config
.
setFlags
(
Shell
.
FLAG_MOUNT_MASTER
);
Shell
.
verboseLogging
(
BuildConfig
.
DEBUG
);
Shell
.
Config
.
verboseLogging
(
BuildConfig
.
DEBUG
);
Shell
.
setInitializer
(
ShellInitializer
.
class
);
Shell
.
Config
.
setInitializer
(
RootUtils
.
class
);
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
this
);
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
this
);
mDB
=
MagiskDatabaseHelper
.
getInstance
(
this
);
mDB
=
MagiskDatabaseHelper
.
getInstance
(
this
);
...
@@ -194,7 +181,7 @@ public class MagiskManager extends Application implements Shell.Container {
...
@@ -194,7 +181,7 @@ public class MagiskManager extends Application implements Shell.Container {
magiskVersionCode
=
Integer
.
parseInt
(
ShellUtils
.
fastCmd
(
"magisk -V"
));
magiskVersionCode
=
Integer
.
parseInt
(
ShellUtils
.
fastCmd
(
"magisk -V"
));
String
s
=
ShellUtils
.
fastCmd
((
magiskVersionCode
>=
Const
.
MAGISK_VER
.
RESETPROP_PERSIST
?
String
s
=
ShellUtils
.
fastCmd
((
magiskVersionCode
>=
Const
.
MAGISK_VER
.
RESETPROP_PERSIST
?
"resetprop -p "
:
"getprop "
)
+
Const
.
MAGISKHIDE_PROP
);
"resetprop -p "
:
"getprop "
)
+
Const
.
MAGISKHIDE_PROP
);
magiskHide
=
s
==
null
||
Integer
.
parseInt
(
s
)
!=
0
;
magiskHide
=
Integer
.
parseInt
(
s
)
!=
0
;
}
catch
(
Exception
ignored
)
{}
}
catch
(
Exception
ignored
)
{}
}
}
...
@@ -227,7 +214,7 @@ public class MagiskManager extends Application implements Shell.Container {
...
@@ -227,7 +214,7 @@ public class MagiskManager extends Application implements Shell.Container {
prefs
.
edit
().
commit
();
prefs
.
edit
().
commit
();
File
xml
=
new
File
(
getFilesDir
().
getParent
()
+
"/shared_prefs"
,
File
xml
=
new
File
(
getFilesDir
().
getParent
()
+
"/shared_prefs"
,
getPackageName
()
+
"_preferences.xml"
);
getPackageName
()
+
"_preferences.xml"
);
Shell
.
Sync
.
su
(
Utils
.
fmt
(
"for usr in /data/user/*; do cat %s > ${usr}/%s; done"
,
xml
,
Const
.
MANAGER_CONFIGS
)
);
Shell
.
su
(
Utils
.
fmt
(
"for usr in /data/user/*; do cat %s > ${usr}/%s; done"
,
xml
,
Const
.
MANAGER_CONFIGS
)).
exec
(
);
}
}
public
void
loadPrefs
()
{
public
void
loadPrefs
()
{
...
...
app/src/full/java/com/topjohnwu/magisk/ModulesFragment.java
View file @
c5d67ebf
...
@@ -112,16 +112,16 @@ public class ModulesFragment extends Fragment implements Topic.Subscriber {
...
@@ -112,16 +112,16 @@ public class ModulesFragment extends Fragment implements Topic.Subscriber {
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
switch
(
item
.
getItemId
())
{
switch
(
item
.
getItemId
())
{
case
R
.
id
.
reboot
:
case
R
.
id
.
reboot
:
Shell
.
Async
.
su
(
"/system/bin/reboot"
);
Shell
.
su
(
"/system/bin/reboot"
).
submit
(
);
return
true
;
return
true
;
case
R
.
id
.
reboot_recovery
:
case
R
.
id
.
reboot_recovery
:
Shell
.
Async
.
su
(
"/system/bin/reboot recovery"
);
Shell
.
su
(
"/system/bin/reboot recovery"
).
submit
(
);
return
true
;
return
true
;
case
R
.
id
.
reboot_bootloader
:
case
R
.
id
.
reboot_bootloader
:
Shell
.
Async
.
su
(
"/system/bin/reboot bootloader"
);
Shell
.
su
(
"/system/bin/reboot bootloader"
).
submit
(
);
return
true
;
return
true
;
case
R
.
id
.
reboot_download
:
case
R
.
id
.
reboot_download
:
Shell
.
Async
.
su
(
"/system/bin/reboot download"
);
Shell
.
su
(
"/system/bin/reboot download"
).
submit
(
);
return
true
;
return
true
;
default
:
default
:
return
false
;
return
false
;
...
...
app/src/full/java/com/topjohnwu/magisk/SettingsActivity.java
View file @
c5d67ebf
...
@@ -254,20 +254,20 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
...
@@ -254,20 +254,20 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
break
;
break
;
case
Const
.
Key
.
MAGISKHIDE
:
case
Const
.
Key
.
MAGISKHIDE
:
if
(
prefs
.
getBoolean
(
key
,
false
))
{
if
(
prefs
.
getBoolean
(
key
,
false
))
{
Shell
.
Async
.
su
(
"magiskhide --enable"
);
Shell
.
su
(
"magiskhide --enable"
).
submit
(
);
}
else
{
}
else
{
Shell
.
Async
.
su
(
"magiskhide --disable"
);
Shell
.
su
(
"magiskhide --disable"
).
submit
(
);
}
}
break
;
break
;
case
Const
.
Key
.
HOSTS
:
case
Const
.
Key
.
HOSTS
:
if
(
prefs
.
getBoolean
(
key
,
false
))
{
if
(
prefs
.
getBoolean
(
key
,
false
))
{
Shell
.
Async
.
su
(
Shell
.
su
(
"cp -af /system/etc/hosts "
+
Const
.
MAGISK_HOST_FILE
,
"
cp -af /system/etc/hosts "
+
Const
.
MAGISK_HOST_FILE
,
"
mount -o bind "
+
Const
.
MAGISK_HOST_FILE
+
" /system/etc/hosts"
)
"mount -o bind "
+
Const
.
MAGISK_HOST_FILE
+
" /system/etc/hosts"
);
.
submit
(
);
}
else
{
}
else
{
Shell
.
Async
.
su
(
Shell
.
su
(
"umount -l /system/etc/hosts"
,
"
umount -l /system/etc/hosts"
,
"
rm -f "
+
Const
.
MAGISK_HOST_FILE
)
"rm -f "
+
Const
.
MAGISK_HOST_FILE
);
.
submit
(
);
}
}
break
;
break
;
case
Const
.
Key
.
ROOT_ACCESS
:
case
Const
.
Key
.
ROOT_ACCESS
:
...
...
app/src/full/java/com/topjohnwu/magisk/SplashActivity.java
View file @
c5d67ebf
...
@@ -14,7 +14,6 @@ import com.topjohnwu.magisk.components.Activity;
...
@@ -14,7 +14,6 @@ import com.topjohnwu.magisk.components.Activity;
import
com.topjohnwu.magisk.database.RepoDatabaseHelper
;
import
com.topjohnwu.magisk.database.RepoDatabaseHelper
;
import
com.topjohnwu.magisk.receivers.ShortcutReceiver
;
import
com.topjohnwu.magisk.receivers.ShortcutReceiver
;
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.superuser.Shell
;
import
com.topjohnwu.superuser.Shell
;
...
@@ -24,7 +23,6 @@ public class SplashActivity extends Activity {
...
@@ -24,7 +23,6 @@ public class SplashActivity extends Activity {
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
RootUtils
.
init
();
MagiskManager
mm
=
getMagiskManager
();
MagiskManager
mm
=
getMagiskManager
();
mm
.
repoDB
=
new
RepoDatabaseHelper
(
this
);
mm
.
repoDB
=
new
RepoDatabaseHelper
(
this
);
...
...
app/src/full/java/com/topjohnwu/magisk/adapters/ApplicationAdapter.java
View file @
c5d67ebf
...
@@ -59,10 +59,10 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
...
@@ -59,10 +59,10 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
holder
.
checkBox
.
setChecked
(
hideList
.
contains
(
info
.
packageName
));
holder
.
checkBox
.
setChecked
(
hideList
.
contains
(
info
.
packageName
));
holder
.
checkBox
.
setOnCheckedChangeListener
((
v
,
isChecked
)
->
{
holder
.
checkBox
.
setOnCheckedChangeListener
((
v
,
isChecked
)
->
{
if
(
isChecked
)
{
if
(
isChecked
)
{
Shell
.
Async
.
su
(
"magiskhide --add "
+
info
.
packageName
);
Shell
.
su
(
"magiskhide --add "
+
info
.
packageName
).
submit
(
);
hideList
.
add
(
info
.
packageName
);
hideList
.
add
(
info
.
packageName
);
}
else
{
}
else
{
Shell
.
Async
.
su
(
"magiskhide --rm "
+
info
.
packageName
);
Shell
.
su
(
"magiskhide --rm "
+
info
.
packageName
).
submit
(
);
hideList
.
remove
(
info
.
packageName
);
hideList
.
remove
(
info
.
packageName
);
}
}
});
});
...
@@ -128,7 +128,7 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
...
@@ -128,7 +128,7 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
@Override
@Override
protected
Void
doInBackground
(
Void
...
voids
)
{
protected
Void
doInBackground
(
Void
...
voids
)
{
fullList
=
pm
.
getInstalledApplications
(
0
);
fullList
=
pm
.
getInstalledApplications
(
0
);
hideList
=
Shell
.
Sync
.
su
(
"magiskhide --ls"
);
hideList
=
Shell
.
su
(
"magiskhide --ls"
).
exec
().
getOut
(
);
for
(
Iterator
<
ApplicationInfo
>
i
=
fullList
.
iterator
();
i
.
hasNext
();
)
{
for
(
Iterator
<
ApplicationInfo
>
i
=
fullList
.
iterator
();
i
.
hasNext
();
)
{
ApplicationInfo
info
=
i
.
next
();
ApplicationInfo
info
=
i
.
next
();
if
(
Const
.
HIDE_BLACKLIST
.
contains
(
info
.
packageName
)
||
!
info
.
enabled
)
{
if
(
Const
.
HIDE_BLACKLIST
.
contains
(
info
.
packageName
)
||
!
info
.
enabled
)
{
...
...
app/src/full/java/com/topjohnwu/magisk/asyncs/CheckSafetyNet.java
View file @
c5d67ebf
...
@@ -30,7 +30,7 @@ public class CheckSafetyNet extends ParallelTask<Void, Void, Exception> {
...
@@ -30,7 +30,7 @@ public class CheckSafetyNet extends ParallelTask<Void, Void, Exception> {
}
}
private
void
dlSnet
()
throws
Exception
{
private
void
dlSnet
()
throws
Exception
{
Shell
.
Sync
.
sh
(
"rm -rf "
+
dexPath
.
getParent
()
);
Shell
.
sh
(
"rm -rf "
+
dexPath
.
getParent
()).
exec
(
);
dexPath
.
getParentFile
().
mkdir
();
dexPath
.
getParentFile
().
mkdir
();
HttpURLConnection
conn
=
WebService
.
request
(
Const
.
Url
.
SNET_URL
,
null
);
HttpURLConnection
conn
=
WebService
.
request
(
Const
.
Url
.
SNET_URL
,
null
);
try
(
try
(
...
...
app/src/full/java/com/topjohnwu/magisk/asyncs/FlashZip.java
View file @
c5d67ebf
...
@@ -2,7 +2,6 @@ package com.topjohnwu.magisk.asyncs;
...
@@ -2,7 +2,6 @@ package com.topjohnwu.magisk.asyncs;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.text.TextUtils
;
import
android.view.View
;
import
android.view.View
;
import
com.topjohnwu.magisk.FlashActivity
;
import
com.topjohnwu.magisk.FlashActivity
;
...
@@ -66,12 +65,10 @@ public class FlashZip extends ParallelTask<Void, Void, Integer> {
...
@@ -66,12 +65,10 @@ public class FlashZip extends ParallelTask<Void, Void, Integer> {
}
}
if
(!
unzipAndCheck
())
return
0
;
if
(!
unzipAndCheck
())
return
0
;
console
.
add
(
"- Installing "
+
Utils
.
getNameFromUri
(
mm
,
mUri
));
console
.
add
(
"- Installing "
+
Utils
.
getNameFromUri
(
mm
,
mUri
));
Shell
.
Sync
.
su
(
console
,
logs
,
if
(!
Shell
.
su
(
"cd "
+
mCachedFile
.
getParent
(),
"cd "
+
mCachedFile
.
getParent
(),
"BOOTMODE=true sh update-binary dummy 1 "
+
mCachedFile
)
"BOOTMODE=true sh update-binary dummy 1 "
+
mCachedFile
+
" || echo 'Failed!'"
.
to
(
console
,
logs
)
);
.
exec
().
isSuccess
())
if
(
TextUtils
.
equals
(
console
.
get
(
console
.
size
()
-
1
),
"Failed!"
))
return
-
1
;
return
-
1
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -86,10 +83,7 @@ public class FlashZip extends ParallelTask<Void, Void, Integer> {
...
@@ -86,10 +83,7 @@ public class FlashZip extends ParallelTask<Void, Void, Integer> {
@Override
@Override
protected
void
onPostExecute
(
Integer
result
)
{
protected
void
onPostExecute
(
Integer
result
)
{
FlashActivity
activity
=
(
FlashActivity
)
getActivity
();
FlashActivity
activity
=
(
FlashActivity
)
getActivity
();
Shell
.
Async
.
su
(
Shell
.
su
(
"rm -rf "
+
mCachedFile
.
getParent
(),
"rm -rf "
+
Const
.
TMP_FOLDER_PATH
).
submit
();
"rm -rf "
+
mCachedFile
.
getParent
(),
"rm -rf "
+
Const
.
TMP_FOLDER_PATH
);
switch
(
result
)
{
switch
(
result
)
{
case
-
1
:
case
-
1
:
console
.
add
(
"! Installation failed"
);
console
.
add
(
"! Installation failed"
);
...
...
app/src/full/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java
View file @
c5d67ebf
...
@@ -17,6 +17,7 @@ import com.topjohnwu.magisk.utils.Utils;
...
@@ -17,6 +17,7 @@ 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
;
import
com.topjohnwu.superuser.ShellUtils
;
import
com.topjohnwu.superuser.ShellUtils
;
import
com.topjohnwu.superuser.internal.NOPList
;
import
com.topjohnwu.superuser.io.SuFile
;
import
com.topjohnwu.superuser.io.SuFile
;
import
com.topjohnwu.superuser.io.SuFileInputStream
;
import
com.topjohnwu.superuser.io.SuFileInputStream
;
import
com.topjohnwu.superuser.io.SuFileOutputStream
;
import
com.topjohnwu.superuser.io.SuFileOutputStream
;
...
@@ -33,7 +34,6 @@ import java.io.FileOutputStream;
...
@@ -33,7 +34,6 @@ import java.io.FileOutputStream;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.util.AbstractList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
...
@@ -76,7 +76,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
...
@@ -76,7 +76,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
if
(
mode
==
FIX_ENV_MODE
)
{
if
(
mode
==
FIX_ENV_MODE
)
{
Activity
a
=
getActivity
();
Activity
a
=
getActivity
();
dialog
=
ProgressDialog
.
show
(
a
,
a
.
getString
(
R
.
string
.
setup_title
),
a
.
getString
(
R
.
string
.
setup_msg
));
dialog
=
ProgressDialog
.
show
(
a
,
a
.
getString
(
R
.
string
.
setup_title
),
a
.
getString
(
R
.
string
.
setup_msg
));
console
=
new
NOPList
<>
();
console
=
NOPList
.
getInstance
();
}
}
}
}
...
@@ -101,12 +101,12 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
...
@@ -101,12 +101,12 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
console
.
add
(
"! Cannot unzip zip"
);
console
.
add
(
"! Cannot unzip zip"
);
throw
e
;
throw
e
;
}
}
Shell
.
Sync
.
sh
(
Utils
.
fmt
(
"chmod -R 755 %s/*; %s/magiskinit -x magisk %s/magisk"
,
Shell
.
sh
(
Utils
.
fmt
(
"chmod -R 755 %s/*; %s/magiskinit -x magisk %s/magisk"
,
installDir
,
installDir
,
installDir
));
installDir
,
installDir
,
installDir
))
.
exec
()
;
}
}
private
boolean
dumpBoot
()
{
private
boolean
dumpBoot
()
{
console
.
add
(
"- Copying image
locally
"
);
console
.
add
(
"- Copying image
to cache
"
);
// Copy boot image to local
// Copy boot image to local
try
(
InputStream
in
=
mm
.
getContentResolver
().
openInputStream
(
bootUri
);
try
(
InputStream
in
=
mm
.
getContentResolver
().
openInputStream
(
bootUri
);
OutputStream
out
=
new
FileOutputStream
(
mBoot
)
OutputStream
out
=
new
FileOutputStream
(
mBoot
)
...
@@ -152,16 +152,13 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
...
@@ -152,16 +152,13 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
}
}
// Patch boot image
// Patch boot image
Shell
.
Sync
.
sh
(
console
,
logs
,
if
(!
Shell
.
sh
(
"cd "
+
installDir
,
Utils
.
fmt
(
"cd "
+
installDir
,
"KEEPFORCEENCRYPT=%b KEEPVERITY=%b sh update-binary indep boot_patch.sh %s"
,
Utils
.
fmt
(
"KEEPFORCEENCRYPT=%b KEEPVERITY=%b sh update-binary indep "
+
mm
.
keepEnc
,
mm
.
keepVerity
,
mBoot
))
"boot_patch.sh %s || echo 'Failed!'"
,
.
to
(
console
,
logs
).
exec
().
isSuccess
())
mm
.
keepEnc
,
mm
.
keepVerity
,
mBoot
));
if
(
TextUtils
.
equals
(
console
.
get
(
console
.
size
()
-
1
),
"Failed!"
))
return
null
;
return
null
;
Shell
.
Sync
.
sh
(
"mv bin/busybox busybox"
,
Shell
.
Job
job
=
Shell
.
sh
(
"mv bin/busybox busybox"
,
"rm -rf magisk.apk bin boot.img update-binary"
,
"rm -rf magisk.apk bin boot.img update-binary"
,
"cd /"
);
"cd /"
);
...
@@ -174,8 +171,9 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
...
@@ -174,8 +171,9 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
)
{
)
{
SignBoot
.
doSignature
(
"/boot"
,
in
,
out
,
null
,
null
);
SignBoot
.
doSignature
(
"/boot"
,
in
,
out
,
null
,
null
);
}
}
Shell
.
Sync
.
su
(
"mv -f "
+
signed
+
" "
+
patched
);
job
.
add
(
"mv -f "
+
signed
+
" "
+
patched
);
}
}
job
.
exec
();
return
patched
;
return
patched
;
}
}
...
@@ -199,7 +197,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
...
@@ -199,7 +197,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
ShellUtils
.
pump
(
in
,
out
);
ShellUtils
.
pump
(
in
,
out
);
out
.
close
();
out
.
close
();
}
}
Shell
.
Sync
.
su
(
"rm -f "
+
patched
);
Shell
.
sh
(
"rm -f "
+
patched
).
exec
(
);
console
.
add
(
""
);
console
.
add
(
""
);
console
.
add
(
"****************************"
);
console
.
add
(
"****************************"
);
console
.
add
(
" Patched image is placed in "
);
console
.
add
(
" Patched image is placed in "
);
...
@@ -208,10 +206,11 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
...
@@ -208,10 +206,11 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
break
;
break
;
case
SECOND_SLOT_MODE:
case
SECOND_SLOT_MODE:
case
DIRECT_MODE:
case
DIRECT_MODE:
Shell
.
Sync
.
sh
(
console
,
logs
,
Shell
.
Job
job
=
Shell
.
su
(
Utils
.
fmt
(
"direct_install %s %s %s"
,
patched
,
mBoot
,
installDir
))
Utils
.
fmt
(
"direct_install %s %s %s"
,
patched
,
mBoot
,
installDir
)
);
.
to
(
console
,
logs
);
if
(!
mm
.
keepVerity
)
if
(!
mm
.
keepVerity
)
Shell
.
Sync
.
sh
(
console
,
logs
,
"find_dtbo_image"
,
"patch_dtbo_image"
);
job
.
add
(
"find_dtbo_image"
,
"patch_dtbo_image"
);
job
.
exec
();
break
;
break
;
}
}
}
}
...
@@ -221,7 +220,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
...
@@ -221,7 +220,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
try
(
InputStream
in
=
mm
.
getResources
().
openRawResource
(
R
.
raw
.
bootctl
);
try
(
InputStream
in
=
mm
.
getResources
().
openRawResource
(
R
.
raw
.
bootctl
);
OutputStream
out
=
new
SuFileOutputStream
(
bootctl
))
{
OutputStream
out
=
new
SuFileOutputStream
(
bootctl
))
{
ShellUtils
.
pump
(
in
,
out
);
ShellUtils
.
pump
(
in
,
out
);
Shell
.
Sync
.
su
(
"post_ota "
+
bootctl
.
getParent
()
);
Shell
.
su
(
"post_ota "
+
bootctl
.
getParent
()).
exec
(
);
console
.
add
(
"***************************************"
);
console
.
add
(
"***************************************"
);
console
.
add
(
" Next reboot will boot to second slot!"
);
console
.
add
(
" Next reboot will boot to second slot!"
);
console
.
add
(
"***************************************"
);
console
.
add
(
"***************************************"
);
...
@@ -234,14 +233,14 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
...
@@ -234,14 +233,14 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
protected
Boolean
doInBackground
(
Void
...
voids
)
{
protected
Boolean
doInBackground
(
Void
...
voids
)
{
if
(
mode
==
FIX_ENV_MODE
)
{
if
(
mode
==
FIX_ENV_MODE
)
{
installDir
=
new
File
(
"/data/adb/magisk"
);
installDir
=
new
File
(
"/data/adb/magisk"
);
Shell
.
Sync
.
sh
(
"rm -rf /data/adb/magisk/*"
);
Shell
.
su
(
"rm -rf /data/adb/magisk/*"
).
exec
(
);
}
else
{
}
else
{
installDir
=
new
File
(
installDir
=
new
File
(
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
?
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
?
mm
.
createDeviceProtectedStorageContext
()
:
mm
)
mm
.
createDeviceProtectedStorageContext
()
:
mm
)
.
getFilesDir
().
getParent
()
.
getFilesDir
().
getParent
()
,
"install"
);
,
"install"
);
Shell
.
Sync
.
sh
(
"rm -rf "
+
installDir
);
Shell
.
sh
(
"rm -rf "
+
installDir
).
exec
(
);
installDir
.
mkdirs
();
installDir
.
mkdirs
();
}
}
...
@@ -298,7 +297,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
...
@@ -298,7 +297,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
try
{
try
{
extractFiles
(
arch
);
extractFiles
(
arch
);
if
(
mode
==
FIX_ENV_MODE
)
{
if
(
mode
==
FIX_ENV_MODE
)
{
Shell
.
Sync
.
sh
(
"fix_env"
);
Shell
.
su
(
"fix_env"
).
exec
(
);
}
else
{
}
else
{
File
patched
=
patchBoot
();
File
patched
=
patchBoot
();
if
(
patched
==
null
)
if
(
patched
==
null
)
...
@@ -324,26 +323,11 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
...
@@ -324,26 +323,11 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
// Running in FlashActivity
// Running in FlashActivity
FlashActivity
activity
=
(
FlashActivity
)
getActivity
();
FlashActivity
activity
=
(
FlashActivity
)
getActivity
();
if
(!
result
)
{
if
(!
result
)
{
Shell
.
Async
.
sh
(
"rm -rf "
+
installDir
);
Shell
.
sh
(
"rm -rf "
+
installDir
).
submit
(
);
console
.
add
(
"! Installation failed"
);
console
.
add
(
"! Installation failed"
);
activity
.
reboot
.
setVisibility
(
View
.
GONE
);
activity
.
reboot
.
setVisibility
(
View
.
GONE
);
}
}
activity
.
buttonPanel
.
setVisibility
(
View
.
VISIBLE
);
activity
.
buttonPanel
.
setVisibility
(
View
.
VISIBLE
);
}
}
}
}
private
static
class
NOPList
<
E
>
extends
AbstractList
<
E
>
{
@Override
public
E
get
(
int
index
)
{
return
null
;
}
@Override
public
int
size
()
{
return
0
;
}
@Override
public
void
add
(
int
index
,
E
element
)
{}
}
}
}
app/src/full/java/com/topjohnwu/magisk/asyncs/LoadModules.java
View file @
c5d67ebf
...
@@ -4,15 +4,13 @@ import com.topjohnwu.magisk.MagiskManager;
...
@@ -4,15 +4,13 @@ import com.topjohnwu.magisk.MagiskManager;
import
com.topjohnwu.magisk.container.Module
;
import
com.topjohnwu.magisk.container.Module
;
import
com.topjohnwu.magisk.container.ValueSortedMap
;
import
com.topjohnwu.magisk.container.ValueSortedMap
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.io.SuFile
;
import
java.util.List
;
public
class
LoadModules
extends
ParallelTask
<
Void
,
Void
,
Void
>
{
public
class
LoadModules
extends
ParallelTask
<
Void
,
Void
,
Void
>
{
private
List
<
String
>
getModList
()
{
private
String
[]
getModList
()
{
S
tring
command
=
"ls -d "
+
Const
.
MAGISK_PATH
+
"/* | grep -v lost+found"
;
S
uFile
path
=
new
SuFile
(
Const
.
MAGISK_PATH
)
;
return
Shell
.
Sync
.
su
(
command
);
return
path
.
list
((
file
,
name
)
->
!
name
.
equals
(
"lost+found"
)
&&
!
name
.
equals
(
".core"
)
);
}
}
@Override
@Override
...
@@ -20,8 +18,8 @@ public class LoadModules extends ParallelTask<Void, Void, Void> {
...
@@ -20,8 +18,8 @@ public class LoadModules extends ParallelTask<Void, Void, Void> {
MagiskManager
mm
=
MagiskManager
.
get
();
MagiskManager
mm
=
MagiskManager
.
get
();
mm
.
moduleMap
=
new
ValueSortedMap
<>();
mm
.
moduleMap
=
new
ValueSortedMap
<>();
for
(
String
path
:
getModList
())
{
for
(
String
name
:
getModList
())
{
Module
module
=
new
Module
(
path
);
Module
module
=
new
Module
(
Const
.
MAGISK_PATH
+
"/"
+
name
);
mm
.
moduleMap
.
put
(
module
.
getId
(),
module
);
mm
.
moduleMap
.
put
(
module
.
getId
(),
module
);
}
}
...
...
app/src/full/java/com/topjohnwu/magisk/container/Module.java
View file @
c5d67ebf
...
@@ -14,9 +14,9 @@ public class Module extends BaseModule {
...
@@ -14,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"
);
mRemoveFile
=
new
SuFile
(
path
,
"
remove"
);
mDisableFile
=
new
SuFile
(
path
+
"/
disable"
);
mDisableFile
=
new
SuFile
(
path
,
"
disable"
);
mUpdateFile
=
new
SuFile
(
path
+
"/
update"
);
mUpdateFile
=
new
SuFile
(
path
,
"
update"
);
if
(
getId
()
==
null
)
{
if
(
getId
()
==
null
)
{
int
sep
=
path
.
lastIndexOf
(
'/'
);
int
sep
=
path
.
lastIndexOf
(
'/'
);
...
...
app/src/full/java/com/topjohnwu/magisk/database/MagiskDatabaseHelper.java
View file @
c5d67ebf
...
@@ -44,7 +44,7 @@ public class MagiskDatabaseHelper {
...
@@ -44,7 +44,7 @@ public class MagiskDatabaseHelper {
return
new
MagiskDatabaseHelper
(
mm
);
return
new
MagiskDatabaseHelper
(
mm
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
// Let's cleanup everything and try again
// Let's cleanup everything and try again
Shell
.
Sync
.
su
(
"db_clean '*'"
);
Shell
.
su
(
"db_clean '*'"
).
exec
(
);
return
new
MagiskDatabaseHelper
(
mm
);
return
new
MagiskDatabaseHelper
(
mm
);
}
}
}
}
...
@@ -74,7 +74,7 @@ public class MagiskDatabaseHelper {
...
@@ -74,7 +74,7 @@ public class MagiskDatabaseHelper {
}
}
mm
.
loadMagiskInfo
();
mm
.
loadMagiskInfo
();
// Cleanup
// Cleanup
Shell
.
Sync
.
su
(
"db_clean "
+
Const
.
USER_ID
);
Shell
.
su
(
"db_clean "
+
Const
.
USER_ID
).
exec
(
);
if
(
mm
.
magiskVersionCode
<
Const
.
MAGISK_VER
.
FBE_AWARE
)
{
if
(
mm
.
magiskVersionCode
<
Const
.
MAGISK_VER
.
FBE_AWARE
)
{
// Super old legacy mode
// Super old legacy mode
return
mm
.
openOrCreateDatabase
(
"su.db"
,
Context
.
MODE_PRIVATE
,
null
);
return
mm
.
openOrCreateDatabase
(
"su.db"
,
Context
.
MODE_PRIVATE
,
null
);
...
@@ -91,15 +91,15 @@ public class MagiskDatabaseHelper {
...
@@ -91,15 +91,15 @@ public class MagiskDatabaseHelper {
de
.
deleteDatabase
(
"su.db"
);
de
.
deleteDatabase
(
"su.db"
);
if
(
mm
.
magiskVersionCode
<
Const
.
MAGISK_VER
.
SEPOL_REFACTOR
)
{
if
(
mm
.
magiskVersionCode
<
Const
.
MAGISK_VER
.
SEPOL_REFACTOR
)
{
// We need some additional policies on old versions
// We need some additional policies on old versions
Shell
.
Sync
.
su
(
"db_sepatch"
);
Shell
.
su
(
"db_sepatch"
).
exec
(
);
}
}
if
(!
GLOBAL_DB
.
exists
())
{
if
(!
GLOBAL_DB
.
exists
())
{
Shell
.
Sync
.
su
(
"db_init"
);
Shell
.
su
(
"db_init"
).
exec
(
);
SQLiteDatabase
.
openOrCreateDatabase
(
GLOBAL_DB
,
null
).
close
();
SQLiteDatabase
.
openOrCreateDatabase
(
GLOBAL_DB
,
null
).
close
();
Shell
.
Sync
.
su
(
"db_restore"
);
Shell
.
su
(
"db_restore"
).
exec
(
);
}
}
}
}
Shell
.
Sync
.
su
(
"db_setup "
+
Process
.
myUid
()
);
Shell
.
su
(
"db_setup "
+
Process
.
myUid
()).
exec
(
);
}
}
// Not using legacy mode, open the mounted global DB
// Not using legacy mode, open the mounted global DB
return
SQLiteDatabase
.
openOrCreateDatabase
(
DB_FILE
,
null
);
return
SQLiteDatabase
.
openOrCreateDatabase
(
DB_FILE
,
null
);
...
...
app/src/full/java/com/topjohnwu/magisk/receivers/PackageReceiver.java
View file @
c5d67ebf
...
@@ -25,7 +25,7 @@ public class PackageReceiver extends BroadcastReceiver {
...
@@ -25,7 +25,7 @@ public class PackageReceiver extends BroadcastReceiver {
break
;
break
;
case
Intent
.
ACTION_PACKAGE_FULLY_REMOVED
:
case
Intent
.
ACTION_PACKAGE_FULLY_REMOVED
:
mm
.
mDB
.
deletePolicy
(
pkg
);
mm
.
mDB
.
deletePolicy
(
pkg
);
Shell
.
Async
.
su
(
"magiskhide --rm "
+
pkg
);
Shell
.
su
(
"magiskhide --rm "
+
pkg
).
submit
(
);
break
;
break
;
}
}
}
}
...
...
app/src/full/java/com/topjohnwu/magisk/receivers/RebootReceiver.java
View file @
c5d67ebf
...
@@ -9,6 +9,6 @@ import com.topjohnwu.superuser.Shell;
...
@@ -9,6 +9,6 @@ import com.topjohnwu.superuser.Shell;
public
class
RebootReceiver
extends
BroadcastReceiver
{
public
class
RebootReceiver
extends
BroadcastReceiver
{
@Override
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
Shell
.
Async
.
su
(
"/system/bin/reboot"
);
Shell
.
su
(
"/system/bin/reboot"
).
submit
(
);
}
}
}
}
app/src/full/java/com/topjohnwu/magisk/utils/RootUtils.java
View file @
c5d67ebf
package
com
.
topjohnwu
.
magisk
.
utils
;
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
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.io.SuFile
;
import
com.topjohnwu.superuser.io.SuFile
;
public
class
RootUtils
{
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
public
class
RootUtils
extends
Shell
.
Initializer
{
static
{
BusyBox
.
BB_PATH
=
new
File
(
Const
.
BUSYBOX_PATH
);
}
private
static
boolean
fileInit
=
false
;
public
static
void
uninstallPkg
(
String
pkg
)
{
Shell
.
su
(
"db_clean "
+
Const
.
USER_ID
,
"pm uninstall "
+
pkg
).
exec
();
}
public
static
void
init
()
{
private
void
initConsts
()
{
if
(
Shell
.
rootAccess
())
{
Const
.
MAGISK_DISABLE_FILE
=
new
SuFile
(
"/cache/.disable_magisk"
);
Const
.
MAGISK_DISABLE_FILE
=
new
SuFile
(
"/cache/.disable_magisk"
);
SuFile
file
=
new
SuFile
(
"/sbin/.core/img"
);
SuFile
file
=
new
SuFile
(
"/sbin/.core/img"
);
if
(
file
.
exists
())
{
if
(
file
.
exists
())
{
...
@@ -17,10 +35,25 @@ public class RootUtils {
...
@@ -17,10 +35,25 @@ public class RootUtils {
Const
.
MAGISK_PATH
=
new
SuFile
(
"/magisk"
);
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"
);
}
fileInit
=
true
;
}
}
public
static
void
uninstallPkg
(
String
pkg
)
{
@Override
Shell
.
Sync
.
su
(
"db_clean "
+
Const
.
USER_ID
,
"pm uninstall "
+
pkg
);
public
boolean
onInit
(
Context
context
,
@NonNull
Shell
shell
)
{
if
(
shell
.
isRoot
())
{
try
(
InputStream
magiskUtils
=
context
.
getResources
().
openRawResource
(
R
.
raw
.
util_functions
);
InputStream
managerUtils
=
context
.
getResources
().
openRawResource
(
R
.
raw
.
utils
)
)
{
shell
.
newJob
()
.
add
(
magiskUtils
).
add
(
managerUtils
)
.
add
(
"mount_partitions"
,
"get_flags"
,
"run_migrations"
)
.
exec
();
}
catch
(
IOException
e
)
{
return
false
;
}
if
(!
fileInit
)
initConsts
();
}
return
true
;
}
}
}
}
app/src/full/java/com/topjohnwu/magisk/utils/ShellInitializer.java
deleted
100644 → 0
View file @
91818cfa
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
com.topjohnwu.superuser.ShellUtils
;
import
java.io.File
;
import
java.io.InputStream
;
public
class
ShellInitializer
extends
Shell
.
Initializer
{
static
{
BusyBox
.
BB_PATH
=
new
File
(
Const
.
BUSYBOX_PATH
);
}
@Override
public
boolean
onRootShellInit
(
Context
context
,
@NonNull
Shell
shell
)
throws
Exception
{
try
(
InputStream
magiskUtils
=
context
.
getResources
().
openRawResource
(
R
.
raw
.
util_functions
);
InputStream
managerUtils
=
context
.
getResources
().
openRawResource
(
R
.
raw
.
utils
)
)
{
shell
.
execTask
((
in
,
err
,
out
)
->
{
ShellUtils
.
pump
(
magiskUtils
,
in
);
ShellUtils
.
pump
(
managerUtils
,
in
);
});
}
shell
.
run
(
null
,
null
,
"mount_partitions"
,
"get_flags"
,
"run_migrations"
);
return
true
;
}
}
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