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
1d16d980
Commit
1d16d980
authored
Jul 10, 2019
by
Viktor De Pasquale
Committed by
John Wu
Jul 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added second slot flashing capability
parent
501b18f9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
30 deletions
+45
-30
CompoundDownloadService.kt
...opjohnwu/magisk/model/download/CompoundDownloadService.kt
+24
-22
SubstrateDownloadService.kt
...pjohnwu/magisk/model/download/SubstrateDownloadService.kt
+5
-2
Configuration.kt
...m/topjohnwu/magisk/model/entity/internal/Configuration.kt
+9
-2
FlashActivity.kt
.../main/java/com/topjohnwu/magisk/ui/flash/FlashActivity.kt
+7
-4
No files found.
app/src/main/java/com/topjohnwu/magisk/model/download/CompoundDownloadService.kt
View file @
1d16d980
...
...
@@ -8,8 +8,11 @@ import android.content.Intent
import
androidx.annotation.RequiresPermission
import
androidx.core.app.NotificationCompat
import
com.topjohnwu.magisk.ClassMap
import
com.topjohnwu.magisk.model.entity.internal.Configuration
import
com.topjohnwu.magisk.model.entity.internal.Configuration.*
import
com.topjohnwu.magisk.model.entity.internal.Configuration.Flash.Secondary
import
com.topjohnwu.magisk.model.entity.internal.DownloadSubject
import
com.topjohnwu.magisk.model.entity.internal.DownloadSubject.Magisk
import
com.topjohnwu.magisk.model.entity.internal.DownloadSubject.Module
import
com.topjohnwu.magisk.ui.flash.FlashActivity
import
java.io.File
import
kotlin.random.Random.Default.nextInt
...
...
@@ -20,27 +23,27 @@ open class CompoundDownloadService : SubstrateDownloadService() {
private
val
context
get
()
=
this
override
fun
onFinished
(
file
:
File
,
subject
:
DownloadSubject
)
=
when
(
subject
)
{
is
DownloadSubject
.
Magisk
->
onFinishedInternal
(
file
,
subject
)
is
DownloadSubject
.
Module
->
onFinishedInternal
(
file
,
subject
)
is
Magisk
->
onFinishedInternal
(
file
,
subject
)
is
Module
->
onFinishedInternal
(
file
,
subject
)
}
private
fun
onFinishedInternal
(
file
:
File
,
subject
:
DownloadSubject
.
Magisk
subject
:
Magisk
)
=
when
(
val
conf
=
subject
.
configuration
)
{
Configuration
.
Download
->
moveToDownloads
(
file
)
Configuration
.
Flash
->
FlashActivity
.
flash
(
this
,
file
)
Configuration
.
Uninstall
->
FlashActivity
.
uninstall
(
this
,
file
)
is
Configuration
.
Patch
->
FlashActivity
.
patch
(
this
,
file
,
conf
.
fileUri
)
Download
->
moveToDownloads
(
file
)
Uninstall
->
FlashActivity
.
uninstall
(
this
,
file
)
is
Patch
->
FlashActivity
.
patch
(
this
,
file
,
conf
.
fileUri
)
is
Flash
->
FlashActivity
.
flash
(
this
,
file
,
conf
is
Secondary
)
else
->
Unit
}
private
fun
onFinishedInternal
(
file
:
File
,
subject
:
DownloadSubject
.
Module
subject
:
Module
)
=
when
(
subject
.
configuration
)
{
Configuration
.
Download
->
moveToDownloads
(
file
)
Configuration
.
Flash
->
FlashActivity
.
install
(
this
,
file
)
Download
->
moveToDownloads
(
file
)
is
Flash
->
FlashActivity
.
install
(
this
,
file
)
else
->
Unit
}
...
...
@@ -50,28 +53,27 @@ open class CompoundDownloadService : SubstrateDownloadService() {
file
:
File
,
subject
:
DownloadSubject
)
=
when
(
subject
)
{
is
DownloadSubject
.
Magisk
->
addActionsInternal
(
file
,
subject
)
is
DownloadSubject
.
Module
->
addActionsInternal
(
file
,
subject
)
is
Magisk
->
addActionsInternal
(
file
,
subject
)
is
Module
->
addActionsInternal
(
file
,
subject
)
}
private
fun
NotificationCompat
.
Builder
.
addActionsInternal
(
file
:
File
,
subject
:
DownloadSubject
.
Magisk
subject
:
Magisk
)
=
when
(
val
conf
=
subject
.
configuration
)
{
Configuration
.
Download
->
setContentIntent
(
fileIntent
(
subject
.
fileName
))
Configuration
.
Flash
->
setContentIntent
(
FlashActivity
.
flashIntent
(
context
,
file
))
Configuration
.
Uninstall
->
setContentIntent
(
FlashActivity
.
uninstallIntent
(
context
,
file
))
is
Configuration
.
Patch
->
setContentIntent
(
FlashActivity
.
patchIntent
(
context
,
file
,
conf
.
fileUri
))
Download
->
setContentIntent
(
fileIntent
(
subject
.
fileName
))
Uninstall
->
setContentIntent
(
FlashActivity
.
uninstallIntent
(
context
,
file
))
is
Flash
->
setContentIntent
(
FlashActivity
.
flashIntent
(
context
,
file
,
conf
is
Secondary
))
is
Patch
->
setContentIntent
(
FlashActivity
.
patchIntent
(
context
,
file
,
conf
.
fileUri
))
else
->
this
}
private
fun
NotificationCompat
.
Builder
.
addActionsInternal
(
file
:
File
,
subject
:
DownloadSubject
.
Module
subject
:
Module
)
=
when
(
subject
.
configuration
)
{
Configuration
.
Download
->
setContentIntent
(
fileIntent
(
subject
.
fileName
))
Configuration
.
Flash
->
setContentIntent
(
FlashActivity
.
installIntent
(
context
,
file
))
Download
->
setContentIntent
(
fileIntent
(
subject
.
fileName
))
is
Flash
->
setContentIntent
(
FlashActivity
.
installIntent
(
context
,
file
))
else
->
this
}
...
...
app/src/main/java/com/topjohnwu/magisk/model/download/SubstrateDownloadService.kt
View file @
1d16d980
...
...
@@ -14,8 +14,8 @@ import com.topjohnwu.magisk.Const
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.data.repository.FileRepository
import
com.topjohnwu.magisk.model.entity.internal.DownloadSubject
import
com.topjohnwu.magisk.utils.Utils
import
com.topjohnwu.magisk.utils.provide
import
com.topjohnwu.magisk.utils.toast
import
com.topjohnwu.magisk.utils.writeToCachedFile
import
com.topjohnwu.magisk.view.Notifications
import
com.topjohnwu.superuser.ShellUtils
...
...
@@ -98,7 +98,10 @@ abstract class SubstrateDownloadService : Service() {
destination
.
deleteRecursively
()
file
.
copyTo
(
destination
)
}
toast
(
getString
(
R
.
string
.
internal_storage
,
"/Download/${file.name}"
),
Toast
.
LENGTH_LONG
)
Utils
.
toast
(
getString
(
R
.
string
.
internal_storage
,
"/Download/${file.name}"
),
Toast
.
LENGTH_LONG
)
}
// ---
...
...
app/src/main/java/com/topjohnwu/magisk/model/entity/internal/Configuration.kt
View file @
1d16d980
...
...
@@ -6,8 +6,15 @@ import kotlinx.android.parcel.Parcelize
sealed
class
Configuration
:
Parcelable
{
@Parcelize
object
Flash
:
Configuration
()
sealed
class
Flash
:
Configuration
()
{
@Parcelize
object
Primary
:
Flash
()
@Parcelize
object
Secondary
:
Flash
()
}
@Parcelize
object
Download
:
Configuration
()
...
...
app/src/main/java/com/topjohnwu/magisk/ui/flash/FlashActivity.kt
View file @
1d16d980
...
...
@@ -33,13 +33,16 @@ open class FlashActivity : MagiskActivity<FlashViewModel, ActivityFlashBinding>(
private
fun
intent
(
context
:
Context
)
=
Intent
(
context
,
ClassMap
[
FlashActivity
::
class
.
java
])
private
fun
intent
(
context
:
Context
,
file
:
File
)
=
intent
(
context
).
setData
(
file
.
toUri
())
private
fun
flashType
(
isSecondSlot
:
Boolean
)
=
if
(
isSecondSlot
)
Const
.
Value
.
FLASH_INACTIVE_SLOT
else
Const
.
Value
.
FLASH_MAGISK
/* Flashing is understood as installing / flashing magisk itself */
fun
flashIntent
(
context
:
Context
,
file
:
File
)
=
intent
(
context
,
file
)
.
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
Const
.
Value
.
FLASH_MAGISK
)
fun
flashIntent
(
context
:
Context
,
file
:
File
,
isSecondSlot
:
Boolean
)
=
intent
(
context
,
file
)
.
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
flashType
(
isSecondSlot
)
)
fun
flash
(
context
:
Context
,
file
:
File
)
=
context
.
startActivity
(
flashIntent
(
context
,
file
))
fun
flash
(
context
:
Context
,
file
:
File
,
isSecondSlot
:
Boolean
)
=
context
.
startActivity
(
flashIntent
(
context
,
file
,
isSecondSlot
))
/* Patching is understood as injecting img files with magisk */
...
...
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