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
ea884e7f
Commit
ea884e7f
authored
Aug 11, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-organize application startup
parent
1b1394cf
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
47 additions
and
53 deletions
+47
-53
MagiskFragment.java
app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java
+1
-1
MagiskManager.java
app/src/main/java/com/topjohnwu/magisk/MagiskManager.java
+43
-44
BootReceiver.java
...ain/java/com/topjohnwu/magisk/receivers/BootReceiver.java
+0
-2
PackageReceiver.java
.../java/com/topjohnwu/magisk/receivers/PackageReceiver.java
+0
-1
UpdateCheckService.java
...ava/com/topjohnwu/magisk/services/UpdateCheckService.java
+1
-1
RequestActivity.java
.../java/com/topjohnwu/magisk/superuser/RequestActivity.java
+0
-1
SuReceiver.java
.../main/java/com/topjohnwu/magisk/superuser/SuReceiver.java
+0
-1
Shell.java
app/src/main/java/com/topjohnwu/magisk/utils/Shell.java
+1
-1
build.gradle
build.gradle
+1
-1
No files found.
app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java
View file @
ea884e7f
...
@@ -260,6 +260,7 @@ public class MagiskFragment extends Fragment
...
@@ -260,6 +260,7 @@ public class MagiskFragment extends Fragment
@Override
@Override
public
void
onRefresh
()
{
public
void
onRefresh
()
{
magiskManager
.
getMagiskInfo
();
updateUI
();
updateUI
();
magiskUpdateText
.
setText
(
R
.
string
.
checking_for_updates
);
magiskUpdateText
.
setText
(
R
.
string
.
checking_for_updates
);
...
@@ -304,7 +305,6 @@ public class MagiskFragment extends Fragment
...
@@ -304,7 +305,6 @@ public class MagiskFragment extends Fragment
private
void
updateUI
()
{
private
void
updateUI
()
{
((
MainActivity
)
getActivity
()).
checkHideSection
();
((
MainActivity
)
getActivity
()).
checkHideSection
();
magiskManager
.
updateMagiskInfo
();
final
int
ROOT
=
0x1
,
NETWORK
=
0x2
,
UPTODATE
=
0x4
;
final
int
ROOT
=
0x1
,
NETWORK
=
0x2
,
UPTODATE
=
0x4
;
int
status
=
0
;
int
status
=
0
;
...
...
app/src/main/java/com/topjohnwu/magisk/MagiskManager.java
View file @
ea884e7f
...
@@ -117,6 +117,16 @@ public class MagiskManager extends Application {
...
@@ -117,6 +117,16 @@ public class MagiskManager extends Application {
}
}
}
}
@Override
public
void
onCreate
()
{
super
.
onCreate
();
new
File
(
getApplicationInfo
().
dataDir
).
mkdirs
();
/* Create the app data directory */
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
this
);
suDB
=
new
SuDatabaseHelper
(
this
);
repoDB
=
new
RepoDatabaseHelper
(
this
);
loadConfig
();
}
public
void
setLocale
()
{
public
void
setLocale
()
{
String
localeTag
=
prefs
.
getString
(
"locale"
,
""
);
String
localeTag
=
prefs
.
getString
(
"locale"
,
""
);
if
(
localeTag
.
isEmpty
())
{
if
(
localeTag
.
isEmpty
())
{
...
@@ -130,17 +140,31 @@ public class MagiskManager extends Application {
...
@@ -130,17 +140,31 @@ public class MagiskManager extends Application {
res
.
updateConfiguration
(
config
,
res
.
getDisplayMetrics
());
res
.
updateConfiguration
(
config
,
res
.
getDisplayMetrics
());
}
}
@Override
private
void
loadConfig
()
{
public
void
onCreate
()
{
// Locale
super
.
onCreate
();
new
File
(
getApplicationInfo
().
dataDir
).
mkdirs
();
/* Create the app data directory */
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
this
);
shell
=
Shell
.
getShell
();
suDB
=
new
SuDatabaseHelper
(
this
);
repoDB
=
new
RepoDatabaseHelper
(
this
);
defaultLocale
=
Locale
.
getDefault
();
defaultLocale
=
Locale
.
getDefault
();
setLocale
();
setLocale
();
new
LoadLocale
(
this
).
exec
();
new
LoadLocale
(
this
).
exec
();
isDarkTheme
=
prefs
.
getBoolean
(
"dark_theme"
,
false
);
if
(
BuildConfig
.
DEBUG
)
{
devLogging
=
prefs
.
getBoolean
(
"developer_logging"
,
false
);
shellLogging
=
prefs
.
getBoolean
(
"shell_logging"
,
false
);
}
else
{
devLogging
=
false
;
shellLogging
=
false
;
}
// su
suRequestTimeout
=
Utils
.
getPrefsInt
(
prefs
,
"su_request_timeout"
,
10
);
suResponseType
=
Utils
.
getPrefsInt
(
prefs
,
"su_auto_response"
,
0
);
suNotificationType
=
Utils
.
getPrefsInt
(
prefs
,
"su_notification"
,
1
);
suReauth
=
prefs
.
getBoolean
(
"su_reauth"
,
false
);
suAccessState
=
suDB
.
getSettings
(
SuDatabaseHelper
.
ROOT_ACCESS
,
3
);
multiuserMode
=
suDB
.
getSettings
(
SuDatabaseHelper
.
MULTIUSER_MODE
,
0
);
suNamespaceMode
=
suDB
.
getSettings
(
SuDatabaseHelper
.
MNT_NS
,
1
);
updateNotification
=
prefs
.
getBoolean
(
"notification"
,
true
);
}
}
public
void
toast
(
String
msg
,
int
duration
)
{
public
void
toast
(
String
msg
,
int
duration
)
{
...
@@ -152,18 +176,10 @@ public class MagiskManager extends Application {
...
@@ -152,18 +176,10 @@ public class MagiskManager extends Application {
}
}
public
void
init
()
{
public
void
init
()
{
isDarkTheme
=
prefs
.
getBoolean
(
"dark_theme"
,
false
);
getMagiskInfo
();
if
(
BuildConfig
.
DEBUG
)
{
devLogging
=
prefs
.
getBoolean
(
"developer_logging"
,
false
);
shellLogging
=
prefs
.
getBoolean
(
"shell_logging"
,
false
);
}
else
{
devLogging
=
false
;
shellLogging
=
false
;
}
initSU
();
updateMagiskInfo
();
updateBlockInfo
();
updateBlockInfo
();
// Initialize prefs
// Write back default values
prefs
.
edit
()
prefs
.
edit
()
.
putBoolean
(
"dark_theme"
,
isDarkTheme
)
.
putBoolean
(
"dark_theme"
,
isDarkTheme
)
.
putBoolean
(
"magiskhide"
,
magiskHide
)
.
putBoolean
(
"magiskhide"
,
magiskHide
)
...
@@ -192,31 +208,14 @@ public class MagiskManager extends Application {
...
@@ -192,31 +208,14 @@ public class MagiskManager extends Application {
}
}
public
void
initSUConfig
()
{
public
void
getMagiskInfo
()
{
suRequestTimeout
=
Utils
.
getPrefsInt
(
prefs
,
"su_request_timeout"
,
10
);
Shell
.
getShell
(
this
);
suResponseType
=
Utils
.
getPrefsInt
(
prefs
,
"su_auto_response"
,
0
);
List
<
String
>
ret
;
suNotificationType
=
Utils
.
getPrefsInt
(
prefs
,
"su_notification"
,
1
);
ret
=
shell
.
sh
(
"su -v"
);
suReauth
=
prefs
.
getBoolean
(
"su_reauth"
,
false
);
}
public
void
initSU
()
{
initSUConfig
();
List
<
String
>
ret
=
shell
.
sh
(
"su -v"
);
if
(
Utils
.
isValidShellResponse
(
ret
))
{
if
(
Utils
.
isValidShellResponse
(
ret
))
{
suVersion
=
ret
.
get
(
0
);
suVersion
=
ret
.
get
(
0
);
isSuClient
=
suVersion
.
toUpperCase
().
contains
(
"MAGISK"
);
isSuClient
=
suVersion
.
toUpperCase
().
contains
(
"MAGISK"
);
}
}
if
(
isSuClient
)
{
suAccessState
=
suDB
.
getSettings
(
SuDatabaseHelper
.
ROOT_ACCESS
,
3
);
multiuserMode
=
suDB
.
getSettings
(
SuDatabaseHelper
.
MULTIUSER_MODE
,
0
);
suNamespaceMode
=
suDB
.
getSettings
(
SuDatabaseHelper
.
MNT_NS
,
1
);
}
}
public
void
updateMagiskInfo
()
{
updateNotification
=
prefs
.
getBoolean
(
"notification"
,
true
);
List
<
String
>
ret
;
ret
=
shell
.
sh
(
"magisk -v"
);
ret
=
shell
.
sh
(
"magisk -v"
);
if
(!
Utils
.
isValidShellResponse
(
ret
))
{
if
(!
Utils
.
isValidShellResponse
(
ret
))
{
ret
=
shell
.
sh
(
"getprop magisk.version"
);
ret
=
shell
.
sh
(
"getprop magisk.version"
);
...
@@ -247,11 +246,11 @@ public class MagiskManager extends Application {
...
@@ -247,11 +246,11 @@ public class MagiskManager extends Application {
}
}
}
}
p
ublic
void
updateBlockInfo
()
{
p
rivate
void
updateBlockInfo
()
{
List
<
String
>
res
=
shell
.
su
(
List
<
String
>
res
=
shell
.
su
(
"for BLOCK in boot_a
BOOT_A kern-a KERN-A android_boot ANDROID_BOOT kernel KERNEL boot BOOT lnx LNX
; do"
,
"for BLOCK in boot_a
kern-a android_boot kernel boot lnx
; do"
,
"
BOOTIMAGE=`ls /dev/block/by-name/$BLOCK || ls /dev/block/platform/*/by-name/$BLOCK || ls /dev/block/platform/*/*/by-name/$BLOCK
` 2>/dev/null"
,
"
BOOTIMAGE=`find /dev/block -iname $BLOCK | head -n 1
` 2>/dev/null"
,
"
[ ! -z \"$BOOTIMAGE\"
] && break"
,
"
[ ! -z $BOOTIMAGE
] && break"
,
"done"
,
"done"
,
"[ ! -z \"$BOOTIMAGE\" -a -L \"$BOOTIMAGE\" ] && BOOTIMAGE=`readlink $BOOTIMAGE`"
,
"[ ! -z \"$BOOTIMAGE\" -a -L \"$BOOTIMAGE\" ] && BOOTIMAGE=`readlink $BOOTIMAGE`"
,
"echo \"$BOOTIMAGE\""
"echo \"$BOOTIMAGE\""
...
...
app/src/main/java/com/topjohnwu/magisk/receivers/BootReceiver.java
View file @
ea884e7f
...
@@ -6,7 +6,6 @@ import android.content.Intent;
...
@@ -6,7 +6,6 @@ import android.content.Intent;
import
android.os.Build
;
import
android.os.Build
;
import
com.topjohnwu.magisk.services.OnBootIntentService
;
import
com.topjohnwu.magisk.services.OnBootIntentService
;
import
com.topjohnwu.magisk.utils.Utils
;
public
class
BootReceiver
extends
BroadcastReceiver
{
public
class
BootReceiver
extends
BroadcastReceiver
{
...
@@ -21,7 +20,6 @@ public class BootReceiver extends BroadcastReceiver {
...
@@ -21,7 +20,6 @@ public class BootReceiver extends BroadcastReceiver {
@Override
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
if
(
intent
.
getAction
().
equals
(
Intent
.
ACTION_BOOT_COMPLETED
))
{
if
(
intent
.
getAction
().
equals
(
Intent
.
ACTION_BOOT_COMPLETED
))
{
Utils
.
getMagiskManager
(
context
).
initSU
();
// There is currently no need to start an IntentService onBoot
// There is currently no need to start an IntentService onBoot
// startIntentService(context);
// startIntentService(context);
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/receivers/PackageReceiver.java
View file @
ea884e7f
...
@@ -12,7 +12,6 @@ public class PackageReceiver extends BroadcastReceiver {
...
@@ -12,7 +12,6 @@ public class PackageReceiver extends BroadcastReceiver {
@Override
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
MagiskManager
magiskManager
=
Utils
.
getMagiskManager
(
context
);
MagiskManager
magiskManager
=
Utils
.
getMagiskManager
(
context
);
magiskManager
.
initSUConfig
();
String
pkg
=
intent
.
getData
().
getEncodedSchemeSpecificPart
();
String
pkg
=
intent
.
getData
().
getEncodedSchemeSpecificPart
();
Policy
policy
=
magiskManager
.
suDB
.
getPolicy
(
pkg
);
Policy
policy
=
magiskManager
.
suDB
.
getPolicy
(
pkg
);
...
...
app/src/main/java/com/topjohnwu/magisk/services/UpdateCheckService.java
View file @
ea884e7f
...
@@ -10,7 +10,7 @@ public class UpdateCheckService extends JobService {
...
@@ -10,7 +10,7 @@ public class UpdateCheckService extends JobService {
@Override
@Override
public
boolean
onStartJob
(
JobParameters
params
)
{
public
boolean
onStartJob
(
JobParameters
params
)
{
Utils
.
getMagiskManager
(
this
).
update
MagiskInfo
();
Utils
.
getMagiskManager
(
this
).
get
MagiskInfo
();
new
CheckUpdates
(
this
,
true
)
new
CheckUpdates
(
this
,
true
)
.
setCallBack
(()
->
jobFinished
(
params
,
false
)).
exec
();
.
setCallBack
(()
->
jobFinished
(
params
,
false
)).
exec
();
return
true
;
return
true
;
...
...
app/src/main/java/com/topjohnwu/magisk/superuser/RequestActivity.java
View file @
ea884e7f
...
@@ -17,7 +17,6 @@ public class RequestActivity extends Activity {
...
@@ -17,7 +17,6 @@ public class RequestActivity extends Activity {
return
;
return
;
}
}
getApplicationContext
().
initSUConfig
();
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
).
setClass
(
this
,
SuRequestActivity
.
class
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
).
setClass
(
this
,
SuRequestActivity
.
class
);
startActivity
(
intent
);
startActivity
(
intent
);
finish
();
finish
();
...
...
app/src/main/java/com/topjohnwu/magisk/superuser/SuReceiver.java
View file @
ea884e7f
...
@@ -27,7 +27,6 @@ public class SuReceiver extends BroadcastReceiver {
...
@@ -27,7 +27,6 @@ public class SuReceiver extends BroadcastReceiver {
Policy
policy
;
Policy
policy
;
MagiskManager
magiskManager
=
(
MagiskManager
)
context
.
getApplicationContext
();
MagiskManager
magiskManager
=
(
MagiskManager
)
context
.
getApplicationContext
();
magiskManager
.
initSUConfig
();
if
(
intent
==
null
)
return
;
if
(
intent
==
null
)
return
;
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Shell.java
View file @
ea884e7f
...
@@ -91,7 +91,7 @@ public class Shell {
...
@@ -91,7 +91,7 @@ public class Shell {
public
static
Shell
getShell
(
Context
context
)
{
public
static
Shell
getShell
(
Context
context
)
{
MagiskManager
magiskManager
=
Utils
.
getMagiskManager
(
context
);
MagiskManager
magiskManager
=
Utils
.
getMagiskManager
(
context
);
if
(!
magiskManager
.
shell
.
isValid
)
{
if
(
magiskManager
.
shell
==
null
||
!
magiskManager
.
shell
.
isValid
)
{
// Get new shell if needed
// Get new shell if needed
magiskManager
.
shell
=
getShell
();
magiskManager
.
shell
=
getShell
();
}
}
...
...
build.gradle
View file @
ea884e7f
...
@@ -7,7 +7,7 @@ buildscript {
...
@@ -7,7 +7,7 @@ buildscript {
maven
{
url
"https://maven.google.com"
}
maven
{
url
"https://maven.google.com"
}
}
}
dependencies
{
dependencies
{
classpath
'com.android.tools.build:gradle:3.0.0-
alpha9
'
classpath
'com.android.tools.build:gradle:3.0.0-
beta1
'
// NOTE: Do not place your application dependencies here; they belong
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
// in the individual module build.gradle files
...
...
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