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
dbe6e5b3
Commit
dbe6e5b3
authored
Aug 29, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify app startup
parent
cc81cd44
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
65 deletions
+38
-65
MagiskFragment.java
app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java
+5
-11
MagiskManager.java
app/src/main/java/com/topjohnwu/magisk/MagiskManager.java
+29
-2
MainActivity.java
app/src/main/java/com/topjohnwu/magisk/MainActivity.java
+1
-10
SplashActivity.java
app/src/main/java/com/topjohnwu/magisk/SplashActivity.java
+2
-39
Utils.java
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
+1
-3
No files found.
app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java
View file @
dbe6e5b3
...
...
@@ -122,6 +122,7 @@ public class MagiskFragment extends Fragment
}
}
}
((
NotificationManager
)
getActivity
().
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)).
cancelAll
();
final
String
finalBootImage
=
bootImage
;
String
filename
=
"Magisk-v"
+
magiskManager
.
remoteMagiskVersionString
+
".zip"
;
new
AlertDialogBuilder
(
getActivity
())
...
...
@@ -129,9 +130,7 @@ public class MagiskFragment extends Fragment
.
setMessage
(
getString
(
R
.
string
.
repo_install_msg
,
filename
))
.
setCancelable
(
true
)
.
setPositiveButton
(
Shell
.
rootAccess
()
?
R
.
string
.
install
:
R
.
string
.
download
,
(
d
,
i
)
->
{
((
NotificationManager
)
getActivity
()
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)).
cancelAll
();
(
d
,
i
)
->
Utils
.
dlAndReceive
(
getActivity
(),
new
DownloadReceiver
()
{
...
...
@@ -155,8 +154,7 @@ public class MagiskFragment extends Fragment
}
},
magiskManager
.
magiskLink
,
Utils
.
getLegalFilename
(
filename
));
}
Utils
.
getLegalFilename
(
filename
))
)
.
setNeutralButton
(
R
.
string
.
release_notes
,
(
d
,
i
)
->
{
if
(
magiskManager
.
releaseNoteLink
!=
null
)
{
...
...
@@ -226,20 +224,16 @@ public class MagiskFragment extends Fragment
public
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
View
v
=
inflater
.
inflate
(
R
.
layout
.
fragment_magisk
,
container
,
false
);
unbinder
=
ButterKnife
.
bind
(
this
,
v
);
getActivity
().
setTitle
(
R
.
string
.
magisk
);
magiskManager
=
getApplication
();
expandableContainer
.
expandLayout
=
expandLayout
;
setupExpandable
();
mSwipeRefreshLayout
.
setOnRefreshListener
(
this
);
updateUI
();
if
(
getArguments
()
!=
null
&&
getArguments
().
getBoolean
(
SHOW_DIALOG
))
install
();
getActivity
().
setTitle
(
R
.
string
.
magisk
);
return
v
;
}
...
...
app/src/main/java/com/topjohnwu/magisk/MagiskManager.java
View file @
dbe6e5b3
...
...
@@ -3,6 +3,9 @@ package com.topjohnwu.magisk;
import
android.app.Application
;
import
android.app.NotificationChannel
;
import
android.app.NotificationManager
;
import
android.app.job.JobInfo
;
import
android.app.job.JobScheduler
;
import
android.content.ComponentName
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.content.res.Configuration
;
...
...
@@ -14,10 +17,13 @@ import android.widget.Toast;
import
com.topjohnwu.magisk.asyncs.CheckUpdates
;
import
com.topjohnwu.magisk.asyncs.DownloadBusybox
;
import
com.topjohnwu.magisk.asyncs.LoadModules
;
import
com.topjohnwu.magisk.asyncs.ParallelTask
;
import
com.topjohnwu.magisk.asyncs.UpdateRepos
;
import
com.topjohnwu.magisk.database.RepoDatabaseHelper
;
import
com.topjohnwu.magisk.database.SuDatabaseHelper
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.services.UpdateCheckService
;
import
com.topjohnwu.magisk.superuser.SuReceiver
;
import
com.topjohnwu.magisk.superuser.SuRequestActivity
;
import
com.topjohnwu.magisk.utils.SafetyNetHelper
;
...
...
@@ -42,6 +48,7 @@ public class MagiskManager extends Application {
public
static
final
String
DISABLE_INDICATION_PROP
=
"ro.magisk.disable"
;
public
static
final
String
NOTIFICATION_CHANNEL
=
"magisk_update_notice"
;
public
static
final
String
BUSYBOX_VERSION
=
"1.27.1"
;
public
static
final
int
UPDATE_SERVICE_ID
=
1
;
// Topics
public
final
Topic
magiskHideDone
=
new
Topic
();
...
...
@@ -100,6 +107,7 @@ public class MagiskManager extends Application {
public
Shell
shell
;
private
static
Handler
mHandler
=
new
Handler
();
private
boolean
startup
=
false
;
private
static
class
LoadLocale
extends
ParallelTask
<
Void
,
Void
,
Void
>
{
...
...
@@ -177,7 +185,12 @@ public class MagiskManager extends Application {
mHandler
.
post
(()
->
Toast
.
makeText
(
this
,
resId
,
duration
).
show
());
}
public
void
init
()
{
public
void
startup
()
{
if
(
startup
)
return
;
startup
=
true
;
shell
=
Shell
.
getShell
();
new
LoadLocale
(
this
).
exec
();
new
DownloadBusybox
(
this
).
exec
();
getMagiskInfo
();
...
...
@@ -212,10 +225,24 @@ public class MagiskManager extends Application {
((
NotificationManager
)
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)).
createNotificationChannel
(
channel
);
}
LoadModules
loadModuleTask
=
new
LoadModules
(
this
);
// Start update check job
if
(
Utils
.
checkNetworkStatus
(
this
))
{
ComponentName
service
=
new
ComponentName
(
this
,
UpdateCheckService
.
class
);
JobInfo
jobInfo
=
new
JobInfo
.
Builder
(
UPDATE_SERVICE_ID
,
service
)
.
setRequiredNetworkType
(
JobInfo
.
NETWORK_TYPE_ANY
)
.
setPersisted
(
true
)
.
setPeriodic
(
8
*
60
*
60
*
1000
)
.
build
();
((
JobScheduler
)
getSystemService
(
Context
.
JOB_SCHEDULER_SERVICE
)).
schedule
(
jobInfo
);
loadModuleTask
.
setCallBack
(()
->
new
UpdateRepos
(
this
).
exec
());
}
// Fire asynctasks
loadModuleTask
.
exec
();
}
public
void
getMagiskInfo
()
{
Shell
.
getShell
(
this
);
List
<
String
>
ret
;
ret
=
shell
.
sh
(
"su -v"
);
if
(
Utils
.
isValidShellResponse
(
ret
))
{
...
...
app/src/main/java/com/topjohnwu/magisk/MainActivity.java
View file @
dbe6e5b3
...
...
@@ -38,6 +38,7 @@ public class MainActivity extends Activity
@Override
protected
void
onCreate
(
final
Bundle
savedInstanceState
)
{
getApplicationContext
().
startup
();
prefs
=
getApplicationContext
().
prefs
;
...
...
@@ -131,9 +132,6 @@ public class MainActivity extends Activity
case
"magisk"
:
itemId
=
R
.
id
.
magisk
;
break
;
case
"install"
:
itemId
=
-
1
;
break
;
case
"superuser"
:
itemId
=
R
.
id
.
superuser
;
break
;
...
...
@@ -165,13 +163,6 @@ public class MainActivity extends Activity
mDrawerItem
=
itemId
;
navigationView
.
setCheckedItem
(
itemId
);
switch
(
itemId
)
{
case
-
1
:
Bundle
args
=
new
Bundle
();
args
.
putBoolean
(
MagiskFragment
.
SHOW_DIALOG
,
true
);
Fragment
frag
=
new
MagiskFragment
();
frag
.
setArguments
(
args
);
displayFragment
(
frag
,
"magisk"
,
true
);
break
;
case
R
.
id
.
magisk
:
displayFragment
(
new
MagiskFragment
(),
"magisk"
,
true
);
break
;
...
...
app/src/main/java/com/topjohnwu/magisk/SplashActivity.java
View file @
dbe6e5b3
package
com
.
topjohnwu
.
magisk
;
import
android.app.job.JobInfo
;
import
android.app.job.JobScheduler
;
import
android.content.ComponentName
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
com.topjohnwu.magisk.asyncs.LoadModules
;
import
com.topjohnwu.magisk.asyncs.UpdateRepos
;
import
com.topjohnwu.magisk.components.Activity
;
import
com.topjohnwu.magisk.services.UpdateCheckService
;
import
com.topjohnwu.magisk.utils.Utils
;
public
class
SplashActivity
extends
Activity
{
private
static
final
int
UPDATE_SERVICE_ID
=
1
;
public
class
SplashActivity
extends
Activity
{
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
MagiskManager
magiskManager
=
getApplicationContext
();
// Init the info and configs and root sh
magiskManager
.
init
();
// Get possible additional info from intent
magiskManager
.
remoteMagiskVersionString
=
getIntent
().
getStringExtra
(
MagiskManager
.
INTENT_VERSION
);
magiskManager
.
magiskLink
=
getIntent
().
getStringExtra
(
MagiskManager
.
INTENT_LINK
);
LoadModules
loadModuleTask
=
new
LoadModules
(
this
);
if
(
Utils
.
checkNetworkStatus
(
this
))
{
// Initialize the update check service, notify every 8 hours
if
(!
TextUtils
.
equals
(
"install"
,
getIntent
().
getStringExtra
(
MagiskManager
.
INTENT_SECTION
)))
{
ComponentName
service
=
new
ComponentName
(
this
,
UpdateCheckService
.
class
);
JobInfo
jobInfo
=
new
JobInfo
.
Builder
(
UPDATE_SERVICE_ID
,
service
)
.
setRequiredNetworkType
(
JobInfo
.
NETWORK_TYPE_ANY
)
.
setPersisted
(
true
)
.
setPeriodic
(
8
*
60
*
60
*
1000
)
.
build
();
((
JobScheduler
)
getSystemService
(
Context
.
JOB_SCHEDULER_SERVICE
)).
schedule
(
jobInfo
);
}
loadModuleTask
.
setCallBack
(()
->
new
UpdateRepos
(
getApplication
()).
exec
());
}
loadModuleTask
.
exec
();
getApplicationContext
().
startup
();
Intent
intent
=
new
Intent
(
this
,
MainActivity
.
class
);
String
section
=
getIntent
().
getStringExtra
(
MagiskManager
.
INTENT_SECTION
);
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
View file @
dbe6e5b3
...
...
@@ -201,9 +201,7 @@ public class Utils {
.
setVibrate
(
new
long
[]{
0
,
100
,
100
,
100
})
.
setAutoCancel
(
true
);
Intent
intent
=
new
Intent
(
magiskManager
,
SplashActivity
.
class
);
intent
.
putExtra
(
MagiskManager
.
INTENT_SECTION
,
"install"
);
intent
.
putExtra
(
MagiskManager
.
INTENT_VERSION
,
magiskManager
.
remoteMagiskVersionString
);
intent
.
putExtra
(
MagiskManager
.
INTENT_LINK
,
magiskManager
.
magiskLink
);
intent
.
putExtra
(
MagiskManager
.
INTENT_SECTION
,
"magisk"
);
TaskStackBuilder
stackBuilder
=
TaskStackBuilder
.
create
(
magiskManager
);
stackBuilder
.
addParentStack
(
SplashActivity
.
class
);
stackBuilder
.
addNextIntent
(
intent
);
...
...
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