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
7239c2e3
Commit
7239c2e3
authored
Feb 04, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update to the latest settings
parent
43b7ef81
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
116 additions
and
73 deletions
+116
-73
Global.java
app/src/main/java/com/topjohnwu/magisk/Global.java
+7
-23
MainActivity.java
app/src/main/java/com/topjohnwu/magisk/MainActivity.java
+0
-2
SettingsActivity.java
app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java
+35
-23
SplashActivity.java
app/src/main/java/com/topjohnwu/magisk/SplashActivity.java
+9
-14
StatusFragment.java
app/src/main/java/com/topjohnwu/magisk/StatusFragment.java
+7
-1
BootReceiver.java
...ain/java/com/topjohnwu/magisk/receivers/BootReceiver.java
+17
-6
Async.java
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
+36
-0
Shell.java
app/src/main/java/com/topjohnwu/magisk/utils/Shell.java
+1
-1
strings.xml
app/src/main/res/values/strings.xml
+3
-2
app_settings.xml
app/src/main/res/xml/app_settings.xml
+1
-1
No files found.
app/src/main/java/com/topjohnwu/magisk/Global.java
View file @
7239c2e3
...
...
@@ -17,6 +17,8 @@ import java.util.List;
public
class
Global
{
public
static
final
String
MAGISK_DISABLE_FILE
=
"/cache/.disable_magisk"
;
public
static
class
Info
{
public
static
double
magiskVersion
;
public
static
String
magiskVersionString
=
"(none)"
;
...
...
@@ -27,6 +29,7 @@ public class Global {
public
static
String
bootBlock
=
null
;
public
static
boolean
isSuClient
=
false
;
public
static
String
suVersion
=
null
;
public
static
boolean
disabled
=
false
;
}
public
static
class
Data
{
public
static
ValueSortedMap
<
String
,
Repo
>
repoMap
;
...
...
@@ -64,28 +67,6 @@ public class Global {
public
static
int
suNotificationType
;
}
public
static
void
init
(
Context
context
)
{
SharedPreferences
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
context
);
Configs
.
isDarkTheme
=
prefs
.
getBoolean
(
"dark_theme"
,
false
);
Configs
.
devLogging
=
prefs
.
getBoolean
(
"developer_logging"
,
false
);
Configs
.
shellLogging
=
prefs
.
getBoolean
(
"shell_logging"
,
false
);
Configs
.
magiskHide
=
prefs
.
getBoolean
(
"magiskhide"
,
false
);
updateMagiskInfo
();
initSuAccess
();
initSuConfigs
(
context
);
// Initialize prefs
prefs
.
edit
()
.
putBoolean
(
"dark_theme"
,
Configs
.
isDarkTheme
)
.
putBoolean
(
"magiskhide"
,
Configs
.
magiskHide
)
.
putBoolean
(
"busybox"
,
Utils
.
commandExists
(
"busybox"
))
.
putBoolean
(
"hosts"
,
Utils
.
itemExist
(
false
,
"/magisk/.core/hosts"
))
.
putString
(
"su_request_timeout"
,
String
.
valueOf
(
Configs
.
suRequestTimeout
))
.
putString
(
"su_auto_response"
,
String
.
valueOf
(
Configs
.
suResponseType
))
.
putString
(
"su_notification"
,
String
.
valueOf
(
Configs
.
suNotificationType
))
.
putString
(
"su_access"
,
String
.
valueOf
(
Configs
.
suAccessState
))
.
apply
();
}
public
static
void
initSuConfigs
(
Context
context
)
{
SharedPreferences
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
context
);
Configs
.
suRequestTimeout
=
Utils
.
getPrefsInt
(
prefs
,
"su_request_timeout"
,
10
);
...
...
@@ -110,7 +91,7 @@ public class Global {
}
}
static
void
updateMagiskInfo
()
{
public
static
void
updateMagiskInfo
()
{
List
<
String
>
ret
=
Shell
.
sh
(
"getprop magisk.version"
);
if
(!
Utils
.
isValidShellResponse
(
ret
))
{
Info
.
magiskVersion
=
-
1
;
...
...
@@ -123,6 +104,9 @@ public class Global {
Info
.
magiskVersion
=
Double
.
POSITIVE_INFINITY
;
}
}
ret
=
Shell
.
sh
(
"getprop ro.magisk.disable"
);
if
(
Utils
.
isValidShellResponse
(
ret
))
Info
.
disabled
=
Integer
.
parseInt
(
ret
.
get
(
0
))
!=
0
;
}
}
app/src/main/java/com/topjohnwu/magisk/MainActivity.java
View file @
7239c2e3
...
...
@@ -101,8 +101,6 @@ public class MainActivity extends AppCompatActivity
@Override
protected
void
onDestroy
()
{
CallbackHandler
.
unRegister
(
Global
.
Events
.
reloadMainActivity
,
this
);
// Let garbage collector remove them
Global
.
Data
.
clear
();
super
.
onDestroy
();
}
...
...
app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java
View file @
7239c2e3
...
...
@@ -2,7 +2,6 @@ package com.topjohnwu.magisk;
import
android.content.SharedPreferences
;
import
android.os.Bundle
;
import
android.preference.CheckBoxPreference
;
import
android.preference.ListPreference
;
import
android.preference.PreferenceCategory
;
import
android.preference.PreferenceFragment
;
...
...
@@ -21,9 +20,6 @@ import com.topjohnwu.magisk.utils.Logger;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Utils
;
import
java.io.File
;
import
java.io.IOException
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
...
...
@@ -88,6 +84,10 @@ public class SettingsActivity extends AppCompatActivity {
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
getActivity
());
prefScreen
=
getPreferenceScreen
();
SwitchPreference
busybox
=
(
SwitchPreference
)
findPreference
(
"busybox"
);
SwitchPreference
magiskHide
=
(
SwitchPreference
)
findPreference
(
"magiskhide"
);
SwitchPreference
hosts
=
(
SwitchPreference
)
findPreference
(
"hosts"
);
PreferenceCategory
magiskCategory
=
(
PreferenceCategory
)
findPreference
(
"magisk"
);
PreferenceCategory
suCategory
=
(
PreferenceCategory
)
findPreference
(
"superuser"
);
...
...
@@ -111,6 +111,11 @@ public class SettingsActivity extends AppCompatActivity {
prefScreen
.
removePreference
(
suCategory
);
if
(
Global
.
Info
.
magiskVersion
<
11
)
prefScreen
.
removePreference
(
magiskCategory
);
if
(
Global
.
Info
.
disabled
)
{
busybox
.
setEnabled
(
false
);
magiskHide
.
setEnabled
(
false
);
hosts
.
setEnabled
(
false
);
}
}
}
...
...
@@ -142,31 +147,38 @@ public class SettingsActivity extends AppCompatActivity {
break
;
case
"disable"
:
enabled
=
prefs
.
getBoolean
(
"disable"
,
false
);
File
disable
=
new
File
(
getActivity
().
getFilesDir
()
+
"/disable"
);
if
(
enabled
)
try
{
disable
.
createNewFile
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
prefs
.
edit
().
putBoolean
(
"disable"
,
false
).
apply
();
new
Async
.
RootTask
<
Void
,
Void
,
Void
>()
{
private
boolean
enable
=
enabled
;
@Override
protected
Void
doInBackground
(
Void
...
voids
)
{
if
(
enable
)
{
Utils
.
createFile
(
Global
.
MAGISK_DISABLE_FILE
);
}
else
{
Utils
.
removeItem
(
Global
.
MAGISK_DISABLE_FILE
);
}
return
null
;
}
else
disable
.
delete
();
}.
exec
();
Toast
.
makeText
(
getActivity
(),
R
.
string
.
settings_reboot_toast
,
Toast
.
LENGTH_LONG
).
show
();
break
;
case
"busybox"
:
enabled
=
prefs
.
getBoolean
(
"busybox"
,
false
);
File
busybox
=
new
File
(
getActivity
().
getFilesDir
()
+
"/busybox"
);
if
(
enabled
)
try
{
busybox
.
createNewFile
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
prefs
.
edit
().
putBoolean
(
"busybox"
,
false
).
apply
();
new
Async
.
RootTask
<
Void
,
Void
,
Void
>()
{
private
boolean
enable
=
enabled
;
@Override
protected
Void
doInBackground
(
Void
...
voids
)
{
if
(
enable
)
{
Shell
.
su
(
"setprop persist.magisk.busybox 1"
,
"sh /sbin/magic_mask.sh mount_busybox"
);
}
else
{
Shell
.
su
(
"setprop persist.magisk.busybox 0"
,
"umount /system/xbin"
);
}
return
null
;
}
else
busybox
.
delete
();
Toast
.
makeText
(
getActivity
(),
R
.
string
.
settings_reboot_toast
,
Toast
.
LENGTH_LONG
).
show
();
}.
exec
();
break
;
case
"magiskhide"
:
enabled
=
prefs
.
getBoolean
(
"magiskhide"
,
false
);
...
...
app/src/main/java/com/topjohnwu/magisk/SplashActivity.java
View file @
7239c2e3
package
com
.
topjohnwu
.
magisk
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.os.Bundle
;
import
android.preference.PreferenceManager
;
import
android.support.v7.app.AppCompatActivity
;
import
com.topjohnwu.magisk.utils.Async
;
...
...
@@ -14,15 +12,17 @@ public class SplashActivity extends AppCompatActivity {
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
SharedPreferences
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
getApplicationContext
());
Global
.
init
(
getApplicationContext
());
if
(
Global
.
Configs
.
isDarkTheme
)
{
setTheme
(
R
.
style
.
AppTheme_dh
);
}
// Start all async tasks
new
Async
.
InitConfigs
(
getApplicationContext
()){
@Override
protected
void
onPostExecute
(
Void
v
)
{
// Start main activity only after configs are loaded
Intent
intent
=
new
Intent
(
getApplicationContext
(),
MainActivity
.
class
);
startActivity
(
intent
);
finish
();
}
}.
exec
();
new
Async
.
GetBootBlocks
().
exec
();
new
Async
.
CheckUpdates
().
exec
();
new
Async
.
LoadModules
()
{
...
...
@@ -33,10 +33,5 @@ public class SplashActivity extends AppCompatActivity {
}
}.
exec
();
new
Async
.
LoadApps
(
getPackageManager
()).
exec
();
// Start main activity
Intent
intent
=
new
Intent
(
getApplicationContext
(),
MainActivity
.
class
);
startActivity
(
intent
);
finish
();
}
}
app/src/main/java/com/topjohnwu/magisk/StatusFragment.java
View file @
7239c2e3
...
...
@@ -163,6 +163,8 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
if
(
Global
.
Info
.
magiskVersion
<
0
)
{
magiskVersionText
.
setText
(
R
.
string
.
magisk_version_error
);
}
else
if
(
Global
.
Info
.
disabled
)
{
magiskVersionText
.
setText
(
getString
(
R
.
string
.
magisk_version_disable
,
Global
.
Info
.
magiskVersionString
));
}
else
{
magiskVersionText
.
setText
(
getString
(
R
.
string
.
magisk_version
,
Global
.
Info
.
magiskVersionString
));
}
...
...
@@ -215,7 +217,11 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
if
(
Global
.
Info
.
magiskVersion
<
0
)
{
color
=
colorBad
;
image
=
R
.
drawable
.
ic_cancel
;
}
else
if
(
Global
.
Info
.
disabled
)
{
color
=
colorNeutral
;
image
=
R
.
drawable
.
ic_cancel
;
}
magiskStatusContainer
.
setBackgroundColor
(
color
);
magiskVersionText
.
setTextColor
(
color
);
magiskUpdateText
.
setTextColor
(
color
);
...
...
@@ -231,7 +237,7 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
.
setPositiveButton
(
R
.
string
.
goto_install
,
(
dialogInterface
,
i
)
->
{
((
MainActivity
)
getActivity
()).
navigationView
.
setCheckedItem
(
R
.
id
.
install
);
FragmentTransaction
transaction
=
getFragmentManager
().
beginTransaction
();
transaction
.
setCustomAnimations
(
android
.
R
.
anim
ator
.
fade_in
,
android
.
R
.
animator
.
fade_out
);
transaction
.
setCustomAnimations
(
android
.
R
.
anim
.
fade_in
,
android
.
R
.
anim
.
fade_out
);
try
{
transaction
.
replace
(
R
.
id
.
content_frame
,
new
InstallFragment
(),
"install"
).
commit
();
}
catch
(
IllegalStateException
ignored
)
{}
...
...
app/src/main/java/com/topjohnwu/magisk/receivers/BootReceiver.java
View file @
7239c2e3
...
...
@@ -14,11 +14,22 @@ import com.topjohnwu.magisk.utils.Async;
public
class
BootReceiver
extends
BroadcastReceiver
{
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
SharedPreferences
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
context
);
Global
.
initSuAccess
();
if
(
prefs
.
getBoolean
(
"magiskhide"
,
false
))
{
Toast
.
makeText
(
context
,
R
.
string
.
start_magiskhide
,
Toast
.
LENGTH_SHORT
).
show
();
new
Async
.
MagiskHide
().
enable
();
}
new
Async
.
RootTask
<
Void
,
Void
,
Void
>()
{
@Override
protected
Void
doInBackground
(
Void
...
params
)
{
Global
.
initSuAccess
();
Global
.
updateMagiskInfo
();
return
null
;
}
@Override
protected
void
onPostExecute
(
Void
v
)
{
SharedPreferences
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
context
);
if
(
prefs
.
getBoolean
(
"magiskhide"
,
false
)
&&
!
Global
.
Info
.
disabled
&&
Global
.
Info
.
magiskVersion
>=
11
)
{
Toast
.
makeText
(
context
,
R
.
string
.
start_magiskhide
,
Toast
.
LENGTH_SHORT
).
show
();
new
Async
.
MagiskHide
().
enable
();
}
}
}.
exec
();
}
}
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
View file @
7239c2e3
...
...
@@ -2,11 +2,13 @@ package com.topjohnwu.magisk.utils;
import
android.app.ProgressDialog
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.content.pm.ApplicationInfo
;
import
android.content.pm.PackageManager
;
import
android.database.Cursor
;
import
android.net.Uri
;
import
android.os.AsyncTask
;
import
android.preference.PreferenceManager
;
import
android.provider.OpenableColumns
;
import
android.widget.Toast
;
...
...
@@ -49,6 +51,40 @@ public class Async {
public
static
final
String
MAGISK_HIDE_PATH
=
"/magisk/.core/magiskhide/"
;
public
static
final
String
TMP_FOLDER_PATH
=
"/dev/tmp"
;
public
static
class
InitConfigs
extends
RootTask
<
Void
,
Void
,
Void
>
{
Context
mContext
;
public
InitConfigs
(
Context
context
)
{
mContext
=
context
;
}
@Override
protected
Void
doInBackground
(
Void
...
params
)
{
SharedPreferences
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
mContext
);
Global
.
Configs
.
isDarkTheme
=
prefs
.
getBoolean
(
"dark_theme"
,
false
);
Global
.
Configs
.
devLogging
=
prefs
.
getBoolean
(
"developer_logging"
,
false
);
Global
.
Configs
.
shellLogging
=
prefs
.
getBoolean
(
"shell_logging"
,
false
);
Global
.
Configs
.
magiskHide
=
prefs
.
getBoolean
(
"magiskhide"
,
false
);
Global
.
updateMagiskInfo
();
Global
.
initSuAccess
();
Global
.
initSuConfigs
(
mContext
);
// Initialize prefs
prefs
.
edit
()
.
putBoolean
(
"dark_theme"
,
Global
.
Configs
.
isDarkTheme
)
.
putBoolean
(
"magiskhide"
,
Global
.
Configs
.
magiskHide
)
.
putBoolean
(
"busybox"
,
Utils
.
commandExists
(
"busybox"
))
.
putBoolean
(
"hosts"
,
Utils
.
itemExist
(
false
,
"/magisk/.core/hosts"
))
.
putBoolean
(
"disable"
,
Utils
.
itemExist
(
Global
.
MAGISK_DISABLE_FILE
))
.
putString
(
"su_request_timeout"
,
String
.
valueOf
(
Global
.
Configs
.
suRequestTimeout
))
.
putString
(
"su_auto_response"
,
String
.
valueOf
(
Global
.
Configs
.
suResponseType
))
.
putString
(
"su_notification"
,
String
.
valueOf
(
Global
.
Configs
.
suNotificationType
))
.
putString
(
"su_access"
,
String
.
valueOf
(
Global
.
Configs
.
suAccessState
))
.
apply
();
return
null
;
}
}
public
static
class
CheckUpdates
extends
NormalTask
<
Void
,
Void
,
Void
>
{
@Override
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Shell.java
View file @
7239c2e3
...
...
@@ -41,7 +41,7 @@ public class Shell {
// Setup umask and PATH
su
(
"umask 022"
);
su
(
"PATH=
/data/busybox
:$PATH"
);
su
(
"PATH=
`[ -e /dev/busybox ] && echo /dev/busybox || echo /data/busybox`
:$PATH"
);
List
<
String
>
ret
=
su
(
"echo -BOC-"
,
"id"
);
...
...
app/src/main/res/values/strings.xml
View file @
7239c2e3
...
...
@@ -17,6 +17,7 @@
<!--Status Fragment-->
<string
name=
"magisk_version"
>
Installed Magisk v%1$s
</string>
<string
name=
"magisk_version_disable"
>
Magisk v%1$s disabled
</string>
<string
name=
"magisk_version_error"
>
Magisk not installed
</string>
<string
name=
"checking_for_updates"
>
Checking for updates…
</string>
...
...
@@ -127,6 +128,8 @@
<string
name=
"settings_clear_cache_title"
>
Clear Repo Cache
</string>
<string
name=
"settings_clear_cache_summary"
>
Clear the cached information for online repos, forces the app to refresh online
</string>
<string
name=
"settings_disable_title"
>
Disable Magisk
</string>
<string
name=
"settings_disable_summary"
>
Everything will be disabled except root (MagiskSU)
</string>
<string
name=
"settings_magiskhide_summary"
>
Hide Magisk from various detections
</string>
<string
name=
"settings_busybox_title"
>
Enable BusyBox
</string>
<string
name=
"settings_busybox_summary"
>
Bind mount Magisk\'s built-in busybox to xbin\nRequires reboot
</string>
...
...
@@ -185,7 +188,5 @@
<string
name=
"pid"
>
PID:\u0020
</string>
<string
name=
"target_uid"
>
Target UID:\u0020
</string>
<string
name=
"command"
>
Command:\u0020
</string>
<string
name=
"settings_disable_title"
>
Disable Magic Mount
</string>
<string
name=
"settings_disable_summary"
>
Disable Magic Mount, which will prevent all modules to work
</string>
</resources>
app/src/main/res/xml/app_settings.xml
View file @
7239c2e3
...
...
@@ -26,7 +26,7 @@
android:title=
"@string/settings_disable_title"
android:summary=
"@string/settings_disable_summary"
/>
<
CheckBox
Preference
<
Switch
Preference
android:key=
"busybox"
android:defaultValue=
"false"
android:title=
"@string/settings_busybox_title"
...
...
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