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
15e27e54
Commit
15e27e54
authored
Mar 05, 2021
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate to new endpoints
parent
85140420
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
84 deletions
+44
-84
Const.kt
app/src/main/java/com/topjohnwu/magisk/core/Const.kt
+3
-3
UpdateInfo.kt
...c/main/java/com/topjohnwu/magisk/core/model/UpdateInfo.kt
+1
-2
NetworkServices.kt
...java/com/topjohnwu/magisk/data/network/NetworkServices.kt
+4
-9
NetworkService.kt
...va/com/topjohnwu/magisk/data/repository/NetworkService.kt
+3
-19
build.gradle.kts
stub/build.gradle.kts
+5
-2
DelegateApplication.java
...c/main/java/com/topjohnwu/magisk/DelegateApplication.java
+2
-4
DownloadActivity.java
.../src/main/java/com/topjohnwu/magisk/DownloadActivity.java
+26
-45
No files found.
app/src/main/java/com/topjohnwu/magisk/core/Const.kt
View file @
15e27e54
...
@@ -30,8 +30,8 @@ object Const {
...
@@ -30,8 +30,8 @@ object Const {
// Versions
// Versions
const
val
SNET_EXT_VER
=
15
const
val
SNET_EXT_VER
=
15
const
val
SNET_REVISION
=
"
18ab78817087c337ae0edd1ecac38aec4921788
0"
const
val
SNET_REVISION
=
"
22.
0"
const
val
BOOTCTL_REVISION
=
"
18ab78817087c337ae0edd1ecac38aec4921788
0"
const
val
BOOTCTL_REVISION
=
"
22.
0"
// Misc
// Misc
val
USER_ID
=
Process
.
myUid
()
/
100000
val
USER_ID
=
Process
.
myUid
()
/
100000
...
@@ -62,7 +62,7 @@ object Const {
...
@@ -62,7 +62,7 @@ object Const {
const
val
GITHUB_RAW_URL
=
"https://raw.githubusercontent.com/"
const
val
GITHUB_RAW_URL
=
"https://raw.githubusercontent.com/"
const
val
GITHUB_API_URL
=
"https://api.github.com/"
const
val
GITHUB_API_URL
=
"https://api.github.com/"
const
val
GITHUB_PAGE_URL
=
"https://topjohnwu.github.io/magisk
_
files/"
const
val
GITHUB_PAGE_URL
=
"https://topjohnwu.github.io/magisk
-
files/"
const
val
JS_DELIVR_URL
=
"https://cdn.jsdelivr.net/gh/"
const
val
JS_DELIVR_URL
=
"https://cdn.jsdelivr.net/gh/"
const
val
OFFICIAL_REPO
=
"https://magisk-modules-repo.github.io/submission/modules.json"
const
val
OFFICIAL_REPO
=
"https://magisk-modules-repo.github.io/submission/modules.json"
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/core/model/UpdateInfo.kt
View file @
15e27e54
...
@@ -16,8 +16,7 @@ data class MagiskJson(
...
@@ -16,8 +16,7 @@ data class MagiskJson(
val
version
:
String
=
""
,
val
version
:
String
=
""
,
val
versionCode
:
Int
=
-
1
,
val
versionCode
:
Int
=
-
1
,
val
link
:
String
=
""
,
val
link
:
String
=
""
,
val
note
:
String
=
""
,
val
note
:
String
=
""
val
md5
:
String
=
""
)
:
Parcelable
)
:
Parcelable
@Parcelize
@Parcelize
...
...
app/src/main/java/com/topjohnwu/magisk/data/network/NetworkServices.kt
View file @
15e27e54
...
@@ -10,17 +10,15 @@ import retrofit2.http.*
...
@@ -10,17 +10,15 @@ import retrofit2.http.*
private
const
val
REVISION
=
"revision"
private
const
val
REVISION
=
"revision"
private
const
val
BRANCH
=
"branch"
private
const
val
BRANCH
=
"branch"
private
const
val
REPO
=
"repo"
private
const
val
REPO
=
"repo"
private
const
val
FILE
=
"file"
const
val
MAGISK_FILES
=
"topjohnwu/magisk
_
files"
const
val
MAGISK_FILES
=
"topjohnwu/magisk
-
files"
const
val
MAGISK_MAIN
=
"topjohnwu/Magisk"
const
val
MAGISK_MAIN
=
"topjohnwu/Magisk"
interface
GithubPageServices
{
interface
GithubPageServices
{
@GET
(
"stable.json"
)
@GET
(
"{$FILE}"
)
suspend
fun
fetchStableUpdate
():
UpdateInfo
suspend
fun
fetchUpdateJSON
(
@Path
(
FILE
)
file
:
String
):
UpdateInfo
@GET
(
"beta.json"
)
suspend
fun
fetchBetaUpdate
():
UpdateInfo
}
}
interface
JSDelivrServices
{
interface
JSDelivrServices
{
...
@@ -33,9 +31,6 @@ interface JSDelivrServices {
...
@@ -33,9 +31,6 @@ interface JSDelivrServices {
@Streaming
@Streaming
suspend
fun
fetchBootctl
(
@Path
(
REVISION
)
revision
:
String
=
Const
.
BOOTCTL_REVISION
):
ResponseBody
suspend
fun
fetchBootctl
(
@Path
(
REVISION
)
revision
:
String
=
Const
.
BOOTCTL_REVISION
):
ResponseBody
@GET
(
"$MAGISK_FILES@{$REVISION}/canary.json"
)
suspend
fun
fetchCanaryUpdate
(
@Path
(
REVISION
)
revision
:
String
):
UpdateInfo
@GET
(
"$MAGISK_MAIN@{$REVISION}/scripts/module_installer.sh"
)
@GET
(
"$MAGISK_MAIN@{$REVISION}/scripts/module_installer.sh"
)
@Streaming
@Streaming
suspend
fun
fetchInstaller
(
@Path
(
REVISION
)
revision
:
String
):
ResponseBody
suspend
fun
fetchInstaller
(
@Path
(
REVISION
)
revision
:
String
):
ResponseBody
...
...
app/src/main/java/com/topjohnwu/magisk/data/repository/NetworkService.kt
View file @
15e27e54
...
@@ -8,9 +8,6 @@ import com.topjohnwu.magisk.core.Config.Value.DEFAULT_CHANNEL
...
@@ -8,9 +8,6 @@ import com.topjohnwu.magisk.core.Config.Value.DEFAULT_CHANNEL
import
com.topjohnwu.magisk.core.Config.Value.STABLE_CHANNEL
import
com.topjohnwu.magisk.core.Config.Value.STABLE_CHANNEL
import
com.topjohnwu.magisk.core.Const
import
com.topjohnwu.magisk.core.Const
import
com.topjohnwu.magisk.core.Info
import
com.topjohnwu.magisk.core.Info
import
com.topjohnwu.magisk.core.model.MagiskJson
import
com.topjohnwu.magisk.core.model.StubJson
import
com.topjohnwu.magisk.core.model.UpdateInfo
import
com.topjohnwu.magisk.data.network.*
import
com.topjohnwu.magisk.data.network.*
import
retrofit2.HttpException
import
retrofit2.HttpException
import
timber.log.Timber
import
timber.log.Timber
...
@@ -40,22 +37,10 @@ class NetworkService(
...
@@ -40,22 +37,10 @@ class NetworkService(
}
}
// UpdateInfo
// UpdateInfo
private
suspend
fun
fetchStableUpdate
()
=
pages
.
fetchStableUpdate
()
private
suspend
fun
fetchStableUpdate
()
=
pages
.
fetchUpdateJSON
(
"stable.json"
)
private
suspend
fun
fetchBetaUpdate
()
=
pages
.
fetchBetaUpdate
()
private
suspend
fun
fetchBetaUpdate
()
=
pages
.
fetchUpdateJSON
(
"beta.json"
)
private
suspend
fun
fetchCanaryUpdate
()
=
pages
.
fetchUpdateJSON
(
"canary.json"
)
private
suspend
fun
fetchCustomUpdate
(
url
:
String
)
=
raw
.
fetchCustomUpdate
(
url
)
private
suspend
fun
fetchCustomUpdate
(
url
:
String
)
=
raw
.
fetchCustomUpdate
(
url
)
private
suspend
fun
fetchCanaryUpdate
():
UpdateInfo
{
val
sha
=
fetchCanaryVersion
()
val
info
=
jsd
.
fetchCanaryUpdate
(
sha
)
fun
genCDNUrl
(
name
:
String
)
=
"${Const.Url.JS_DELIVR_URL}${MAGISK_FILES}@${sha}/${name}"
fun
MagiskJson
.
updateCopy
()
=
copy
(
link
=
genCDNUrl
(
link
),
note
=
genCDNUrl
(
note
))
fun
StubJson
.
updateCopy
()
=
copy
(
link
=
genCDNUrl
(
link
))
return
info
.
copy
(
magisk
=
info
.
magisk
.
updateCopy
(),
stub
=
info
.
stub
.
updateCopy
()
)
}
private
inline
fun
<
T
>
safe
(
factory
:
()
->
T
):
T
?
{
private
inline
fun
<
T
>
safe
(
factory
:
()
->
T
):
T
?
{
return
try
{
return
try
{
...
@@ -89,6 +74,5 @@ class NetworkService(
...
@@ -89,6 +74,5 @@ class NetworkService(
suspend
fun
fetchFile
(
url
:
String
)
=
wrap
{
raw
.
fetchFile
(
url
)
}
suspend
fun
fetchFile
(
url
:
String
)
=
wrap
{
raw
.
fetchFile
(
url
)
}
suspend
fun
fetchString
(
url
:
String
)
=
wrap
{
raw
.
fetchString
(
url
)
}
suspend
fun
fetchString
(
url
:
String
)
=
wrap
{
raw
.
fetchString
(
url
)
}
private
suspend
fun
fetchCanaryVersion
()
=
api
.
fetchBranch
(
MAGISK_FILES
,
"canary"
).
commit
.
sha
private
suspend
fun
fetchMainVersion
()
=
api
.
fetchBranch
(
MAGISK_MAIN
,
"master"
).
commit
.
sha
private
suspend
fun
fetchMainVersion
()
=
api
.
fetchBranch
(
MAGISK_MAIN
,
"master"
).
commit
.
sha
}
}
stub/build.gradle.kts
View file @
15e27e54
...
@@ -5,13 +5,16 @@ plugins {
...
@@ -5,13 +5,16 @@ plugins {
android
{
android
{
val
canary
=
!
Config
.
version
.
contains
(
"."
)
val
canary
=
!
Config
.
version
.
contains
(
"."
)
val
url
=
Config
[
"DEV_CHANNEL"
]
?:
if
(
canary
)
null
else
"https://cdn.jsdelivr.net/gh/topjohnwu/magisk-files@${Config.version}/app-release.apk"
defaultConfig
{
defaultConfig
{
applicationId
=
"com.topjohnwu.magisk"
applicationId
=
"com.topjohnwu.magisk"
minSdkVersion
(
21
)
versionCode
=
1
versionCode
=
1
versionName
=
Config
.
version
versionName
=
Config
.
version
buildConfigField
(
"int"
,
"STUB_VERSION"
,
Config
.
stubVersion
)
buildConfigField
(
"int"
,
"STUB_VERSION"
,
Config
.
stubVersion
)
buildConfigField
(
"String"
,
"DEV_CHANNEL"
,
Config
[
"DEV_CHANNEL"
]
?:
"null"
)
buildConfigField
(
"String"
,
"APK_URL"
,
url
?.
let
{
"\"$it\""
}
?:
"null"
)
buildConfigField
(
"boolean"
,
"CANARY"
,
if
(
canary
)
"true"
else
"false"
)
}
}
buildTypes
{
buildTypes
{
...
...
stub/src/main/java/com/topjohnwu/magisk/DelegateApplication.java
View file @
15e27e54
...
@@ -4,7 +4,6 @@ import android.app.Application;
...
@@ -4,7 +4,6 @@ import android.app.Application;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.ContextWrapper
;
import
android.content.ContextWrapper
;
import
android.content.res.Configuration
;
import
android.content.res.Configuration
;
import
android.os.Build
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
...
@@ -18,9 +17,8 @@ public class DelegateApplication extends Application {
...
@@ -18,9 +17,8 @@ public class DelegateApplication extends Application {
protected
void
attachBaseContext
(
Context
base
)
{
protected
void
attachBaseContext
(
Context
base
)
{
super
.
attachBaseContext
(
base
);
super
.
attachBaseContext
(
base
);
// Only dynamic load full APK if hidden and supported
// Only dynamic load full APK if hidden
dynLoad
=
Build
.
VERSION
.
SDK_INT
>=
21
&&
dynLoad
=
!
base
.
getPackageName
().
equals
(
BuildConfig
.
APPLICATION_ID
);
!
base
.
getPackageName
().
equals
(
BuildConfig
.
APPLICATION_ID
);
receiver
=
InjectAPK
.
setup
(
this
);
receiver
=
InjectAPK
.
setup
(
this
);
if
(
receiver
!=
null
)
try
{
if
(
receiver
!=
null
)
try
{
...
...
stub/src/main/java/com/topjohnwu/magisk/DownloadActivity.java
View file @
15e27e54
...
@@ -15,7 +15,6 @@ import com.topjohnwu.magisk.net.Request;
...
@@ -15,7 +15,6 @@ import com.topjohnwu.magisk.net.Request;
import
com.topjohnwu.magisk.utils.APKInstall
;
import
com.topjohnwu.magisk.utils.APKInstall
;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.io.File
;
import
java.io.File
;
...
@@ -31,21 +30,23 @@ import static com.topjohnwu.magisk.R.string.upgrade_msg;
...
@@ -31,21 +30,23 @@ import static com.topjohnwu.magisk.R.string.upgrade_msg;
public
class
DownloadActivity
extends
Activity
{
public
class
DownloadActivity
extends
Activity
{
private
static
final
String
APP_NAME
=
"Magisk"
;
private
static
final
String
APP_NAME
=
"Magisk"
;
private
static
final
String
C
DN_URL
=
"https://cdn.jsdelivr.net/gh/topjohnwu/magisk_files@%s/%s
"
;
private
static
final
String
C
ANARY_URL
=
"https://topjohnwu.github.io/magisk-files/canary.json
"
;
private
String
apkLink
;
private
String
apkLink
=
BuildConfig
.
APK_URL
;
private
String
sha
;
private
Context
themed
;
private
Context
themed
;
private
ProgressDialog
dialog
;
private
ProgressDialog
dialog
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
Networking
.
init
(
this
);
themed
=
new
ContextThemeWrapper
(
this
,
android
.
R
.
style
.
Theme_DeviceDefault
);
themed
=
new
ContextThemeWrapper
(
this
,
android
.
R
.
style
.
Theme_DeviceDefault
);
if
(
Networking
.
checkNetworkStatus
(
this
))
{
if
(
Networking
.
checkNetworkStatus
(
this
))
{
fetchAPKURL
();
if
(
apkLink
==
null
)
{
fetchCanary
();
}
else
{
showDialog
();
}
}
else
{
}
else
{
new
AlertDialog
.
Builder
(
themed
)
new
AlertDialog
.
Builder
(
themed
)
.
setCancelable
(
false
)
.
setCancelable
(
false
)
...
@@ -56,21 +57,6 @@ public class DownloadActivity extends Activity {
...
@@ -56,21 +57,6 @@ public class DownloadActivity extends Activity {
}
}
}
}
private
void
fetchAPKURL
()
{
dialog
=
ProgressDialog
.
show
(
themed
,
""
,
""
,
true
);
String
url
;
if
(
BuildConfig
.
DEV_CHANNEL
!=
null
)
{
url
=
BuildConfig
.
DEV_CHANNEL
;
}
else
if
(!
BuildConfig
.
CANARY
)
{
url
=
"https://topjohnwu.github.io/magisk_files/stable.json"
;
}
else
{
url
=
"https://api.github.com/repos/topjohnwu/magisk_files/branches/canary"
;
request
(
url
).
getAsJSONObject
(
this
::
handleCanary
);
return
;
}
request
(
url
).
getAsJSONObject
(
this
::
handleJSON
);
}
private
void
error
(
Throwable
e
)
{
private
void
error
(
Throwable
e
)
{
Log
.
e
(
getClass
().
getSimpleName
(),
""
,
e
);
Log
.
e
(
getClass
().
getSimpleName
(),
""
,
e
);
finish
();
finish
();
...
@@ -80,32 +66,27 @@ public class DownloadActivity extends Activity {
...
@@ -80,32 +66,27 @@ public class DownloadActivity extends Activity {
return
Networking
.
get
(
url
).
setErrorHandler
((
conn
,
e
)
->
error
(
e
));
return
Networking
.
get
(
url
).
setErrorHandler
((
conn
,
e
)
->
error
(
e
));
}
}
private
void
handleCanary
(
JSONObject
json
)
{
private
void
showDialog
(
)
{
try
{
new
AlertDialog
.
Builder
(
themed
)
sha
=
json
.
getJSONObject
(
"commit"
).
getString
(
"sha"
);
.
setCancelable
(
false
)
String
url
=
String
.
format
(
CDN_URL
,
sha
,
"canary.json"
);
.
setTitle
(
APP_NAME
)
request
(
url
).
getAsJSONObject
(
this
::
handleJSON
);
.
setMessage
(
getString
(
upgrade_msg
))
}
catch
(
JSONException
e
)
{
.
setPositiveButton
(
yes
,
(
d
,
w
)
->
dlAPK
())
error
(
e
);
.
setNegativeButton
(
no
,
(
d
,
w
)
->
finish
())
}
.
show
();
}
}
private
void
handleJSON
(
JSONObject
json
)
{
private
void
fetchCanary
()
{
dialog
.
dismiss
();
dialog
=
ProgressDialog
.
show
(
themed
,
""
,
""
,
true
);
try
{
request
(
CANARY_URL
).
getAsJSONObject
(
json
->
{
apkLink
=
json
.
getJSONObject
(
"app"
).
getString
(
"link"
);
dialog
.
dismiss
();
if
(!
apkLink
.
startsWith
(
"http"
))
try
{
apkLink
=
String
.
format
(
CDN_URL
,
sha
,
apkLink
);
apkLink
=
json
.
getJSONObject
(
"magisk"
).
getString
(
"link"
);
new
AlertDialog
.
Builder
(
themed
)
showDialog
();
.
setCancelable
(
false
)
}
catch
(
JSONException
e
)
{
.
setTitle
(
APP_NAME
)
error
(
e
);
.
setMessage
(
getString
(
upgrade_msg
))
}
.
setPositiveButton
(
yes
,
(
d
,
w
)
->
dlAPK
())
});
.
setNegativeButton
(
no
,
(
d
,
w
)
->
finish
())
.
show
();
}
catch
(
JSONException
e
)
{
error
(
e
);
}
}
}
private
void
dlAPK
()
{
private
void
dlAPK
()
{
...
...
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