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
188ea264
Commit
188ea264
authored
Jun 24, 2019
by
Viktor De Pasquale
Committed by
John Wu
Jul 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated downloading magisk to pull the zip from cache if eligible
parent
4c8f3579
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
21 deletions
+37
-21
InstallMethodDialog.kt
.../com/topjohnwu/magisk/view/dialogs/InstallMethodDialog.kt
+37
-21
No files found.
app/src/main/java/com/topjohnwu/magisk/view/dialogs/InstallMethodDialog.kt
View file @
188ea264
...
...
@@ -15,9 +15,11 @@ import com.topjohnwu.magisk.utils.Utils
import
com.topjohnwu.magisk.view.ProgressNotification
import
com.topjohnwu.magisk.view.SnackbarMaker
import
com.topjohnwu.net.Networking
import
com.topjohnwu.superuser.ShellUtils
import
java.io.File
internal
class
InstallMethodDialog
(
activity
:
MagiskActivity
<
*
,
*
>,
options
:
List
<
String
>)
:
AlertDialog
.
Builder
(
activity
)
{
internal
class
InstallMethodDialog
(
activity
:
MagiskActivity
<
*
,
*
>,
options
:
List
<
String
>)
:
AlertDialog
.
Builder
(
activity
)
{
init
{
setTitle
(
R
.
string
.
select_method
)
...
...
@@ -27,7 +29,7 @@ internal class InstallMethodDialog(activity: MagiskActivity<*, *>, options: List
1
->
patchBoot
(
activity
)
2
->
{
val
intent
=
Intent
(
activity
,
ClassMap
[
FlashActivity
::
class
.
java
])
.
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
Const
.
Value
.
FLASH_MAGISK
)
.
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
Const
.
Value
.
FLASH_MAGISK
)
activity
.
startActivity
(
intent
)
}
3
->
installInactiveSlot
(
activity
)
...
...
@@ -40,13 +42,13 @@ internal class InstallMethodDialog(activity: MagiskActivity<*, *>, options: List
onSuccess
{
Utils
.
toast
(
R
.
string
.
patch_file_msg
,
Toast
.
LENGTH_LONG
)
val
intent
=
Intent
(
Intent
.
ACTION_GET_CONTENT
)
.
setType
(
"*/*"
)
.
addCategory
(
Intent
.
CATEGORY_OPENABLE
)
.
setType
(
"*/*"
)
.
addCategory
(
Intent
.
CATEGORY_OPENABLE
)
activity
.
startActivityForResult
(
intent
,
Const
.
ID
.
SELECT_BOOT
)
{
resultCode
,
data
->
if
(
resultCode
==
Activity
.
RESULT_OK
&&
data
!=
null
)
{
val
i
=
Intent
(
this
,
ClassMap
[
FlashActivity
::
class
.
java
])
.
setData
(
data
.
data
)
.
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
Const
.
Value
.
PATCH_FILE
)
.
setData
(
data
.
data
)
.
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
Const
.
Value
.
PATCH_FILE
)
startActivity
(
i
)
}
}
...
...
@@ -60,31 +62,45 @@ internal class InstallMethodDialog(activity: MagiskActivity<*, *>, options: List
val
filename
=
"Magisk-v${Info.remote.magisk.version}"
+
"(${Info.remote.magisk.versionCode}).zip"
val
zip
=
File
(
Const
.
EXTERNAL_PATH
,
filename
)
val
progress
=
ProgressNotification
(
filename
)
Networking
.
get
(
Info
.
remote
.
magisk
.
link
)
val
cachedZip
=
File
(
activity
.
cacheDir
,
"magisk.zip"
)
fun
onSuccess
()
{
SnackbarMaker
.
make
(
activity
,
activity
.
getString
(
R
.
string
.
internal_storage
,
"/Download/$filename"
),
Snackbar
.
LENGTH_LONG
).
show
()
}
if
(
ShellUtils
.
checkSum
(
"MD5"
,
cachedZip
,
Info
.
remote
.
magisk
.
hash
))
{
cachedZip
.
copyTo
(
zip
,
true
)
onSuccess
()
}
else
{
val
progress
=
ProgressNotification
(
filename
)
Networking
.
get
(
Info
.
remote
.
magisk
.
link
)
.
setDownloadProgressListener
(
progress
)
.
setErrorHandler
{
_
,
_
->
progress
.
dlFail
()
}
.
getAsFile
(
zip
)
{
progress
.
dlDone
()
SnackbarMaker
.
make
(
activity
,
activity
.
getString
(
R
.
string
.
internal_storage
,
"/Download/$filename"
),
Snackbar
.
LENGTH_LONG
).
show
()
onSuccess
()
}
}
}
}
}
private
fun
installInactiveSlot
(
activity
:
MagiskActivity
<
*
,
*
>)
{
CustomAlertDialog
(
activity
)
.
setTitle
(
R
.
string
.
warning
)
.
setMessage
(
R
.
string
.
install_inactive_slot_msg
)
.
setCancelable
(
true
)
.
setPositiveButton
(
R
.
string
.
yes
)
{
_
,
_
->
val
intent
=
Intent
(
activity
,
ClassMap
[
FlashActivity
::
class
.
java
])
.
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
Const
.
Value
.
FLASH_INACTIVE_SLOT
)
activity
.
startActivity
(
intent
)
}
.
setNegativeButton
(
R
.
string
.
no_thanks
,
null
)
.
show
()
.
setTitle
(
R
.
string
.
warning
)
.
setMessage
(
R
.
string
.
install_inactive_slot_msg
)
.
setCancelable
(
true
)
.
setPositiveButton
(
R
.
string
.
yes
)
{
_
,
_
->
val
intent
=
Intent
(
activity
,
ClassMap
[
FlashActivity
::
class
.
java
])
.
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
Const
.
Value
.
FLASH_INACTIVE_SLOT
)
activity
.
startActivity
(
intent
)
}
.
setNegativeButton
(
R
.
string
.
no_thanks
,
null
)
.
show
()
}
}
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