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
13512b41
Commit
13512b41
authored
Jan 29, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add BootReceiver
parent
49e54691
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
32 deletions
+38
-32
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+6
-0
Global.java
app/src/main/java/com/topjohnwu/magisk/Global.java
+18
-16
MagiskLogFragment.java
...src/main/java/com/topjohnwu/magisk/MagiskLogFragment.java
+0
-16
BootReceiver.java
...ain/java/com/topjohnwu/magisk/receivers/BootReceiver.java
+14
-0
No files found.
app/src/main/AndroidManifest.xml
View file @
13512b41
...
...
@@ -53,6 +53,12 @@
<receiver
android:name=
".superuser.SuReceiver"
/>
<receiver
android:name=
".receivers.BootReceiver"
>
<intent-filter>
<action
android:name=
"android.intent.action.BOOT_COMPLETED"
/>
</intent-filter>
</receiver>
<provider
android:name=
"android.support.v4.content.FileProvider"
android:authorities=
"com.topjohnwu.magisk.provider"
...
...
app/src/main/java/com/topjohnwu/magisk/Global.java
View file @
13512b41
...
...
@@ -28,7 +28,6 @@ public class Global {
public
static
String
bootBlock
=
null
;
public
static
boolean
isSuClient
=
false
;
public
static
String
suVersion
=
null
;
public
static
int
shellUid
;
}
public
static
class
Data
{
public
static
ValueSortedMap
<
String
,
Repo
>
repoMap
=
new
ValueSortedMap
<>();
...
...
@@ -60,12 +59,8 @@ public class Global {
Configs
.
isDarkTheme
=
prefs
.
getBoolean
(
"dark_theme"
,
false
);
Configs
.
devLogging
=
prefs
.
getBoolean
(
"developer_logging"
,
false
);
Configs
.
shellLogging
=
prefs
.
getBoolean
(
"shell_logging"
,
false
);
List
<
String
>
ret
=
Shell
.
sh
(
"su -v"
);
if
(
Utils
.
isValidShellResponse
(
ret
))
{
Info
.
suVersion
=
ret
.
get
(
0
);
Info
.
isSuClient
=
Info
.
suVersion
.
toUpperCase
().
contains
(
"MAGISK"
);
}
updateMagiskInfo
();
initSuAccess
();
initSuConfigs
(
context
);
// Initialize prefs
prefs
.
edit
()
...
...
@@ -82,19 +77,26 @@ public class Global {
public
static
void
initSuConfigs
(
Context
context
)
{
SharedPreferences
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
context
);
List
<
String
>
ret
=
Shell
.
sh
(
"getprop persist.sys.root_access"
);
Configs
.
suRequestTimeout
=
Utils
.
getPrefsInt
(
prefs
,
"su_request_timeout"
,
10
);
Configs
.
suResponseType
=
Utils
.
getPrefsInt
(
prefs
,
"su_auto_response"
,
0
);
Configs
.
suNotificationType
=
Utils
.
getPrefsInt
(
prefs
,
"su_notification"
,
1
);
}
public
static
void
initSuAccess
()
{
List
<
String
>
ret
=
Shell
.
sh
(
"su -v"
);
if
(
Utils
.
isValidShellResponse
(
ret
))
{
Info
.
suVersion
=
ret
.
get
(
0
);
Info
.
isSuClient
=
Info
.
suVersion
.
toUpperCase
().
contains
(
"MAGISK"
);
}
if
(
Info
.
isSuClient
)
{
ret
=
Shell
.
sh
(
"getprop persist.sys.root_access"
);
if
(
Utils
.
isValidShellResponse
(
ret
))
Configs
.
suAccessState
=
Integer
.
parseInt
(
ret
.
get
(
0
));
else
{
Shell
.
su
(
"setprop persist.sys.root_access 3"
);
Configs
.
suAccessState
=
3
;
}
Configs
.
suRequestTimeout
=
Utils
.
getPrefsInt
(
prefs
,
"su_request_timeout"
,
10
);
Configs
.
suResponseType
=
Utils
.
getPrefsInt
(
prefs
,
"su_auto_response"
,
0
);
Configs
.
suNotificationType
=
Utils
.
getPrefsInt
(
prefs
,
"su_notification"
,
1
);
ret
=
Shell
.
sh
(
"id -u shell"
);
if
(
Utils
.
isValidShellResponse
(
ret
))
Info
.
shellUid
=
Integer
.
parseInt
(
ret
.
get
(
0
));
}
}
static
void
updateMagiskInfo
()
{
...
...
app/src/main/java/com/topjohnwu/magisk/MagiskLogFragment.java
View file @
13512b41
...
...
@@ -156,7 +156,6 @@ public class MagiskLogFragment extends Fragment {
return
""
;
case
2
:
case
3
:
if
(
ActivityCompat
.
checkSelfPermission
(
getActivity
(),
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
!=
PackageManager
.
PERMISSION_GRANTED
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
requestPermissions
(
new
String
[]{
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
},
0
);
...
...
@@ -221,17 +220,6 @@ public class MagiskLogFragment extends Fragment {
else
Toast
.
makeText
(
getActivity
(),
getString
(
R
.
string
.
logs_save_failed
),
Toast
.
LENGTH_LONG
).
show
();
break
;
case
3
:
bool
=
(
boolean
)
o
;
if
(
bool
)
{
Intent
sendIntent
=
new
Intent
();
sendIntent
.
setAction
(
Intent
.
ACTION_SEND
);
sendIntent
.
putExtra
(
Intent
.
EXTRA_STREAM
,
Uri
.
fromFile
(
targetFile
));
sendIntent
.
setType
(
"application/html"
);
startActivity
(
Intent
.
createChooser
(
sendIntent
,
getResources
().
getString
(
R
.
string
.
menuSend
)));
}
else
{
Toast
.
makeText
(
getActivity
(),
getString
(
R
.
string
.
logs_save_failed
),
Toast
.
LENGTH_LONG
).
show
();
}
}
}
...
...
@@ -246,10 +234,6 @@ public class MagiskLogFragment extends Fragment {
public
void
save
()
{
exec
(
2
);
}
public
void
send
()
{
exec
(
3
);
}
}
}
app/src/main/java/com/topjohnwu/magisk/receivers/BootReceiver.java
0 → 100644
View file @
13512b41
package
com
.
topjohnwu
.
magisk
.
receivers
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Intent
;
import
com.topjohnwu.magisk.Global
;
public
class
BootReceiver
extends
BroadcastReceiver
{
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
Global
.
initSuAccess
();
}
}
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