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
0aebc0a8
Commit
0aebc0a8
authored
Jul 25, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use new service to download uninstall.zip
parent
c3a89f58
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
36 deletions
+21
-36
DownloadService.kt
...va/com/topjohnwu/magisk/model/download/DownloadService.kt
+0
-3
DownloadSubject.kt
...topjohnwu/magisk/model/entity/internal/DownloadSubject.kt
+12
-0
InstallMethodDialog.kt
.../com/topjohnwu/magisk/view/dialogs/InstallMethodDialog.kt
+2
-11
UninstallDialog.kt
...java/com/topjohnwu/magisk/view/dialogs/UninstallDialog.kt
+7
-22
No files found.
app/src/main/java/com/topjohnwu/magisk/model/download/DownloadService.kt
View file @
0aebc0a8
package
com.topjohnwu.magisk.model.download
package
com.topjohnwu.magisk.model.download
import
android.Manifest
import
android.annotation.SuppressLint
import
android.annotation.SuppressLint
import
android.app.PendingIntent
import
android.app.PendingIntent
import
android.content.Context
import
android.content.Context
import
android.content.Intent
import
android.content.Intent
import
android.os.Build
import
android.os.Build
import
android.webkit.MimeTypeMap
import
android.webkit.MimeTypeMap
import
androidx.annotation.RequiresPermission
import
androidx.core.app.NotificationCompat
import
androidx.core.app.NotificationCompat
import
com.topjohnwu.magisk.ClassMap
import
com.topjohnwu.magisk.ClassMap
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.R
...
@@ -115,7 +113,6 @@ open class DownloadService : RemoteFileService() {
...
@@ -115,7 +113,6 @@ open class DownloadService : RemoteFileService() {
companion
object
{
companion
object
{
@RequiresPermission
(
allOf
=
[
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
])
inline
operator
fun
invoke
(
context
:
Context
,
argBuilder
:
Builder
.()
->
Unit
)
{
inline
operator
fun
invoke
(
context
:
Context
,
argBuilder
:
Builder
.()
->
Unit
)
{
val
builder
=
Builder
().
apply
(
argBuilder
)
val
builder
=
Builder
().
apply
(
argBuilder
)
val
intent
=
Intent
(
context
,
ClassMap
[
DownloadService
::
class
.
java
])
val
intent
=
Intent
(
context
,
ClassMap
[
DownloadService
::
class
.
java
])
...
...
app/src/main/java/com/topjohnwu/magisk/model/entity/internal/DownloadSubject.kt
View file @
0aebc0a8
...
@@ -49,6 +49,17 @@ sealed class DownloadSubject : Parcelable {
...
@@ -49,6 +49,17 @@ sealed class DownloadSubject : Parcelable {
}
}
}
}
@Parcelize
protected
class
Uninstall
:
Magisk
()
{
override
val
configuration
:
Configuration
get
()
=
Configuration
.
Uninstall
override
val
url
:
String
get
()
=
Info
.
remote
.
uninstaller
.
link
@IgnoredOnParcel
override
val
file
by
lazy
{
get
<
Context
>().
cachedFile
(
"uninstall.zip"
)
}
}
@Parcelize
@Parcelize
protected
class
Download
:
Magisk
()
{
protected
class
Download
:
Magisk
()
{
override
val
configuration
:
Configuration
get
()
=
Configuration
.
Download
override
val
configuration
:
Configuration
get
()
=
Configuration
.
Download
...
@@ -63,6 +74,7 @@ sealed class DownloadSubject : Parcelable {
...
@@ -63,6 +74,7 @@ sealed class DownloadSubject : Parcelable {
companion
object
{
companion
object
{
operator
fun
invoke
(
configuration
:
Configuration
)
=
when
(
configuration
)
{
operator
fun
invoke
(
configuration
:
Configuration
)
=
when
(
configuration
)
{
Configuration
.
Download
->
Download
()
Configuration
.
Download
->
Download
()
Configuration
.
Uninstall
->
Uninstall
()
else
->
Flash
(
configuration
)
else
->
Flash
(
configuration
)
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/view/dialogs/InstallMethodDialog.kt
View file @
0aebc0a8
package
com.topjohnwu.magisk.view.dialogs
package
com.topjohnwu.magisk.view.dialogs
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.app.Activity
import
android.content.Intent
import
android.content.Intent
import
android.net.Uri
import
android.net.Uri
...
@@ -29,16 +28,10 @@ internal class InstallMethodDialog(activity: MagiskActivity<*, *>, options: List
...
@@ -29,16 +28,10 @@ internal class InstallMethodDialog(activity: MagiskActivity<*, *>, options: List
}
}
}
}
@SuppressLint
(
"MissingPermission"
)
private
fun
flash
(
activity
:
MagiskActivity
<
*
,
*
>)
=
DownloadService
(
activity
)
{
private
fun
flash
(
activity
:
MagiskActivity
<
*
,
*
>)
=
activity
.
withExternalRW
{
onSuccess
{
DownloadService
(
context
)
{
subject
=
DownloadSubject
.
Magisk
(
Configuration
.
Flash
.
Primary
)
subject
=
DownloadSubject
.
Magisk
(
Configuration
.
Flash
.
Primary
)
}
}
}
}
@SuppressLint
(
"MissingPermission"
)
private
fun
patchBoot
(
activity
:
MagiskActivity
<
*
,
*
>)
=
activity
.
withExternalRW
{
private
fun
patchBoot
(
activity
:
MagiskActivity
<
*
,
*
>)
=
activity
.
withExternalRW
{
onSuccess
{
onSuccess
{
Utils
.
toast
(
R
.
string
.
patch_file_msg
,
Toast
.
LENGTH_LONG
)
Utils
.
toast
(
R
.
string
.
patch_file_msg
,
Toast
.
LENGTH_LONG
)
...
@@ -56,7 +49,6 @@ internal class InstallMethodDialog(activity: MagiskActivity<*, *>, options: List
...
@@ -56,7 +49,6 @@ internal class InstallMethodDialog(activity: MagiskActivity<*, *>, options: List
}
}
}
}
@SuppressLint
(
"MissingPermission"
)
private
fun
downloadOnly
(
activity
:
MagiskActivity
<
*
,
*
>)
=
activity
.
withExternalRW
{
private
fun
downloadOnly
(
activity
:
MagiskActivity
<
*
,
*
>)
=
activity
.
withExternalRW
{
onSuccess
{
onSuccess
{
DownloadService
(
activity
)
{
DownloadService
(
activity
)
{
...
@@ -65,7 +57,6 @@ internal class InstallMethodDialog(activity: MagiskActivity<*, *>, options: List
...
@@ -65,7 +57,6 @@ internal class InstallMethodDialog(activity: MagiskActivity<*, *>, options: List
}
}
}
}
@SuppressLint
(
"MissingPermission"
)
private
fun
installInactiveSlot
(
activity
:
MagiskActivity
<
*
,
*
>)
{
private
fun
installInactiveSlot
(
activity
:
MagiskActivity
<
*
,
*
>)
{
CustomAlertDialog
(
activity
)
CustomAlertDialog
(
activity
)
.
setTitle
(
R
.
string
.
warning
)
.
setTitle
(
R
.
string
.
warning
)
...
...
app/src/main/java/com/topjohnwu/magisk/view/dialogs/UninstallDialog.kt
View file @
0aebc0a8
...
@@ -2,19 +2,14 @@ package com.topjohnwu.magisk.view.dialogs
...
@@ -2,19 +2,14 @@ package com.topjohnwu.magisk.view.dialogs
import
android.app.Activity
import
android.app.Activity
import
android.app.ProgressDialog
import
android.app.ProgressDialog
import
android.content.Intent
import
android.net.Uri
import
android.widget.Toast
import
android.widget.Toast
import
com.topjohnwu.magisk.ClassMap
import
com.topjohnwu.magisk.Const
import
com.topjohnwu.magisk.Info
import
com.topjohnwu.magisk.Info
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.ui.flash.FlashActivity
import
com.topjohnwu.magisk.model.download.DownloadService
import
com.topjohnwu.magisk.model.entity.internal.Configuration
import
com.topjohnwu.magisk.model.entity.internal.DownloadSubject
import
com.topjohnwu.magisk.utils.Utils
import
com.topjohnwu.magisk.utils.Utils
import
com.topjohnwu.magisk.view.ProgressNotification
import
com.topjohnwu.net.Networking
import
com.topjohnwu.superuser.Shell
import
com.topjohnwu.superuser.Shell
import
java.io.File
class
UninstallDialog
(
activity
:
Activity
)
:
CustomAlertDialog
(
activity
)
{
class
UninstallDialog
(
activity
:
Activity
)
:
CustomAlertDialog
(
activity
)
{
...
@@ -35,19 +30,9 @@ class UninstallDialog(activity: Activity) : CustomAlertDialog(activity) {
...
@@ -35,19 +30,9 @@ class UninstallDialog(activity: Activity) : CustomAlertDialog(activity) {
}
}
}
}
if
(
Info
.
remote
.
uninstaller
.
link
.
isNotEmpty
())
{
if
(
Info
.
remote
.
uninstaller
.
link
.
isNotEmpty
())
{
setPositiveButton
(
R
.
string
.
complete_uninstall
)
{
d
,
i
->
setPositiveButton
(
R
.
string
.
complete_uninstall
)
{
_
,
_
->
val
zip
=
File
(
activity
.
filesDir
,
"uninstaller.zip"
)
DownloadService
(
activity
)
{
val
progress
=
ProgressNotification
(
zip
.
name
)
subject
=
DownloadSubject
.
Magisk
(
Configuration
.
Uninstall
)
Networking
.
get
(
Info
.
remote
.
uninstaller
.
link
)
.
setDownloadProgressListener
(
progress
)
.
setErrorHandler
{
_
,
_
->
progress
.
dlFail
()
}
.
getAsFile
(
zip
)
{
f
->
progress
.
dismiss
()
val
intent
=
Intent
(
activity
,
ClassMap
[
FlashActivity
::
class
.
java
])
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
.
setData
(
Uri
.
fromFile
(
f
))
.
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
Const
.
Value
.
UNINSTALL
)
activity
.
startActivity
(
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