Skip to content

Commit 6588f3b

Browse files
authored
Merge branch 'master' into patch-boot
2 parents 004caf0 + e472db5 commit 6588f3b

186 files changed

Lines changed: 4668 additions & 4355 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/setup/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ runs:
4545
env:
4646
SCCACHE_DIRECT: false
4747
SCCACHE_DIR: ${{ github.workspace }}/.sccache
48-
SCCACHE_CACHE_SIZE: 2G
48+
SCCACHE_CACHE_SIZE: ${{ inputs.is-asset-build == 'true' && '2G' || '300M' }}
4949
SCCACHE_IDLE_TIMEOUT: 0
5050
run: |
5151
bash $GITHUB_ACTION_PATH/sccache.sh
@@ -70,7 +70,7 @@ runs:
7070
.gradle/caches
7171
.gradle/wrapper
7272
!.gradle/caches/build-cache-*
73-
key: gradle-cache-${{ hashFiles('gradle/**') }}
73+
key: gradle-cache-${{ hashFiles('app/gradle/**') }}
7474
restore-keys: gradle-cache-
7575

7676
- name: Restore Gradle dependencies

.github/workflows/build.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,10 @@ jobs:
8282
strategy:
8383
fail-fast: false
8484
matrix:
85-
version: [23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
85+
version: [23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, "36.0-CANARY"]
8686
type: [""]
8787
include:
88-
- version: 36
89-
type: "google_apis"
90-
- version: 36
88+
- version: "36.0-CANARY"
9189
type: "google_apis_ps16k"
9290

9391
steps:
@@ -110,7 +108,7 @@ jobs:
110108
timeout-minutes: 10
111109
env:
112110
AVD_TEST_LOG: 1
113-
run: scripts/avd_test.sh ${{ matrix.version }} ${{ matrix.type }}
111+
run: scripts/avd.sh test ${{ matrix.version }} ${{ matrix.type }}
114112

115113
- name: Upload logs on error
116114
if: ${{ failure() }}
@@ -152,7 +150,7 @@ jobs:
152150
env:
153151
FORCE_32_BIT: 1
154152
AVD_TEST_LOG: 1
155-
run: scripts/avd_test.sh ${{ matrix.version }}
153+
run: scripts/avd.sh test ${{ matrix.version }}
156154

157155
- name: Upload logs on error
158156
if: ${{ failure() }}

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
[submodule "libcxx"]
1111
path = native/src/external/libcxx
1212
url = https://github.com/topjohnwu/libcxx.git
13-
[submodule "zopfli"]
14-
path = native/src/external/zopfli
15-
url = https://github.com/google/zopfli.git
1613
[submodule "cxx-rs"]
1714
path = native/src/external/cxx-rs
1815
url = https://github.com/topjohnwu/cxx.git

README.MD

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,7 @@ Some highlight features:
1616

1717
## Downloads
1818

19-
[Github](https://github.com/topjohnwu/Magisk/) is the only source where you can get official Magisk information and downloads.
20-
21-
Click the icon below to download Magisk apk.
22-
23-
[![](https://img.shields.io/badge/Magisk-v28.1-blue)](https://github.com/topjohnwu/Magisk/releases/tag/v28.1)
24-
[![](https://img.shields.io/badge/Magisk%20Beta-v28.1-blue)](https://github.com/topjohnwu/Magisk/releases/tag/v28.1)
25-
[![](https://img.shields.io/badge/Magisk-Canary-red)](https://github.com/topjohnwu/Magisk/releases/tag/canary-28104)
19+
[Github](https://github.com/topjohnwu/Magisk/releases) is the only source where you can get official Magisk information and downloads.
2620

2721
## Useful Links
2822

app/apk/src/main/java/com/topjohnwu/magisk/databinding/DataBindingAdapters.kt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import androidx.core.widget.ImageViewCompat
2424
import androidx.databinding.BindingAdapter
2525
import androidx.databinding.InverseBindingAdapter
2626
import androidx.databinding.InverseBindingListener
27+
import androidx.databinding.InverseMethod
2728
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
2829
import androidx.recyclerview.widget.DividerItemDecoration
2930
import androidx.recyclerview.widget.GridLayoutManager
@@ -33,9 +34,11 @@ import androidx.recyclerview.widget.StaggeredGridLayoutManager
3334
import com.google.android.material.button.MaterialButton
3435
import com.google.android.material.card.MaterialCardView
3536
import com.google.android.material.chip.Chip
37+
import com.google.android.material.slider.Slider
3638
import com.google.android.material.textfield.TextInputLayout
3739
import com.topjohnwu.magisk.R
3840
import com.topjohnwu.magisk.core.di.ServiceLocator
41+
import com.topjohnwu.magisk.core.model.su.SuPolicy
3942
import com.topjohnwu.magisk.utils.TextHolder
4043
import com.topjohnwu.superuser.internal.UiThreadHandler
4144
import com.topjohnwu.widget.IndeterminateCheckBox
@@ -306,3 +309,38 @@ fun TextView.setText(text: TextHolder) {
306309
fun Spinner.setAdapter(items: Array<Any>, layoutRes: Int) {
307310
adapter = ArrayAdapter(context, layoutRes, items)
308311
}
312+
313+
@BindingAdapter("labelFormatter")
314+
fun Slider.setLabelFormatter(formatter: (Float) -> Int) {
315+
setLabelFormatter { value -> resources.getString(formatter(value)) }
316+
}
317+
318+
@InverseBindingAdapter(attribute = "android:value")
319+
fun Slider.getValueBinding() = value
320+
321+
@BindingAdapter("android:valueAttrChanged")
322+
fun Slider.setListener(attrChange: InverseBindingListener) {
323+
addOnSliderTouchListener(object : Slider.OnSliderTouchListener {
324+
override fun onStartTrackingTouch(slider: Slider) = Unit
325+
override fun onStopTrackingTouch(slider: Slider) = attrChange.onChange()
326+
})
327+
}
328+
329+
@InverseMethod("sliderValueToPolicy")
330+
fun policyToSliderValue(policy: Int): Float {
331+
return when (policy) {
332+
SuPolicy.DENY -> 1f
333+
SuPolicy.RESTRICT -> 2f
334+
SuPolicy.ALLOW -> 3f
335+
else -> 1f
336+
}
337+
}
338+
339+
fun sliderValueToPolicy(value: Float): Int {
340+
return when (value) {
341+
1f -> SuPolicy.DENY
342+
2f -> SuPolicy.RESTRICT
343+
3f -> SuPolicy.ALLOW
344+
else -> SuPolicy.DENY
345+
}
346+
}

app/apk/src/main/java/com/topjohnwu/magisk/dialog/ManagerInstallDialog.kt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,17 @@ package com.topjohnwu.magisk.dialog
33
import com.topjohnwu.magisk.core.AppContext
44
import com.topjohnwu.magisk.core.Info
55
import com.topjohnwu.magisk.core.R
6-
import com.topjohnwu.magisk.core.di.ServiceLocator
76
import com.topjohnwu.magisk.core.download.DownloadEngine
87
import com.topjohnwu.magisk.core.download.Subject
98
import com.topjohnwu.magisk.view.MagiskDialog
109
import java.io.File
1110

1211
class ManagerInstallDialog : MarkDownDialog() {
1312

14-
private val svc get() = ServiceLocator.networkService
15-
1613
override suspend fun getMarkdownText(): String {
17-
val text = svc.fetchString(Info.remote.magisk.note)
14+
val text = Info.update.note
1815
// Cache the changelog
19-
AppContext.cacheDir.listFiles { _, name -> name.endsWith(".md") }.orEmpty().forEach {
20-
it.delete()
21-
}
22-
File(AppContext.cacheDir, "${Info.remote.magisk.versionCode}.md").writeText(text)
16+
File(AppContext.cacheDir, "${Info.update.versionCode}.md").writeText(text)
2317
return text
2418
}
2519

app/apk/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,15 @@ class HomeViewModel(
9191

9292
override suspend fun doLoadWork() {
9393
appState = State.LOADING
94-
Info.getRemote(svc)?.apply {
94+
Info.fetchUpdate(svc)?.apply {
9595
appState = when {
96-
BuildConfig.APP_VERSION_CODE < magisk.versionCode -> State.OUTDATED
96+
BuildConfig.APP_VERSION_CODE < versionCode -> State.OUTDATED
9797
else -> State.UP_TO_DATE
9898
}
9999

100100
val isDebug = Config.updateChannel == Config.Value.DEBUG_CHANNEL
101101
managerRemoteVersion =
102-
("${magisk.version} (${magisk.versionCode})" +
103-
if (isDebug) " (D)" else "").asText()
102+
("$version (${versionCode})" + if (isDebug) " (D)" else "").asText()
104103
} ?: run {
105104
appState = State.INVALID
106105
managerRemoteVersion = CoreR.string.not_available.asText()

app/apk/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ import com.topjohnwu.magisk.BR
1414
import com.topjohnwu.magisk.R
1515
import com.topjohnwu.magisk.arch.BaseViewModel
1616
import com.topjohnwu.magisk.core.AppContext
17-
import com.topjohnwu.magisk.core.BuildConfig
17+
import com.topjohnwu.magisk.core.BuildConfig.APP_VERSION_CODE
1818
import com.topjohnwu.magisk.core.Config
19-
import com.topjohnwu.magisk.core.Const
2019
import com.topjohnwu.magisk.core.Info
2120
import com.topjohnwu.magisk.core.base.ContentResultCallback
2221
import com.topjohnwu.magisk.core.ktx.toast
@@ -70,17 +69,16 @@ class InstallViewModel(svc: NetworkService, markwon: Markwon) : BaseViewModel()
7069
init {
7170
viewModelScope.launch(Dispatchers.IO) {
7271
try {
73-
val file = File(AppContext.cacheDir, "${BuildConfig.APP_VERSION_CODE}.md")
74-
val text = when {
75-
file.exists() -> file.readText()
76-
Const.Url.CHANGELOG_URL.isEmpty() -> ""
72+
val noteFile = File(AppContext.cacheDir, "${APP_VERSION_CODE}.md")
73+
val noteText = when {
74+
noteFile.exists() -> noteFile.readText()
7775
else -> {
78-
val str = svc.fetchString(Const.Url.CHANGELOG_URL)
79-
file.writeText(str)
80-
str
76+
val note = svc.fetchUpdate(APP_VERSION_CODE).note
77+
noteFile.writeText(note)
78+
note
8179
}
8280
}
83-
val spanned = markwon.toMarkdown(text)
81+
val spanned = markwon.toMarkdown(noteText)
8482
withContext(Dispatchers.Main) {
8583
notes = spanned
8684
}
@@ -100,13 +98,15 @@ class InstallViewModel(svc: NetworkService, markwon: Markwon) : BaseViewModel()
10098
}
10199

102100
override fun onSaveState(state: Bundle) {
103-
state.putParcelable(INSTALL_STATE_KEY, InstallState(
104-
methodId,
105-
step,
106-
Config.keepVerity,
107-
Config.keepEnc,
108-
Config.recovery
109-
))
101+
state.putParcelable(
102+
INSTALL_STATE_KEY, InstallState(
103+
methodId,
104+
step,
105+
Config.keepVerity,
106+
Config.keepEnc,
107+
Config.recovery
108+
)
109+
)
110110
}
111111

112112
override fun onRestoreState(state: Bundle) {
@@ -124,6 +124,7 @@ class InstallViewModel(svc: NetworkService, markwon: Markwon) : BaseViewModel()
124124
override fun onActivityLaunch() {
125125
AppContext.toast(CoreR.string.patch_file_msg, Toast.LENGTH_LONG)
126126
}
127+
127128
override fun onActivityResult(result: Uri) {
128129
uri.value = result
129130
}

app/apk/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,19 +147,11 @@ object UpdateChannel : BaseSettingsItem.Selector() {
147147
get() = Config.updateChannel
148148
set(value) {
149149
Config.updateChannel = value
150-
Info.remote = Info.EMPTY_REMOTE
150+
Info.resetUpdate()
151151
}
152152

153153
override val title = CoreR.string.settings_update_channel_title.asText()
154-
155154
override val entryRes = CoreR.array.update_channel
156-
override fun entries(res: Resources): Array<String> {
157-
return super.entries(res).let {
158-
if (!Const.APP_IS_CANARY && !BuildConfig.DEBUG)
159-
it.copyOfRange(0, Config.Value.CANARY_CHANNEL)
160-
else it
161-
}
162-
}
163155
}
164156

165157
object UpdateChannelUrl : BaseSettingsItem.Input() {
@@ -169,7 +161,7 @@ object UpdateChannelUrl : BaseSettingsItem.Input() {
169161
get() = Config.customChannelUrl
170162
set(value) {
171163
Config.customChannelUrl = value
172-
Info.remote = Info.EMPTY_REMOTE
164+
Info.resetUpdate()
173165
notifyPropertyChanged(BR.description)
174166
}
175167

@@ -330,6 +322,12 @@ object Reauthenticate : BaseSettingsItem.Toggle() {
330322
override var value by Config::suReAuth
331323

332324
override fun refresh() {
333-
isEnabled = Build.VERSION.SDK_INT < Build.VERSION_CODES.O && Info.showSuperUser
325+
isEnabled = Build.VERSION.SDK_INT < Build.VERSION_CODES.O
334326
}
335327
}
328+
329+
object Restrict : BaseSettingsItem.Toggle() {
330+
override val title = CoreR.string.settings_su_restrict_title.asText()
331+
override val description = CoreR.string.settings_su_restrict_summary.asText()
332+
override var value by Config::suRestrict
333+
}

app/apk/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ class SettingsViewModel : BaseViewModel(), BaseSettingsItem.Handler {
8383
// Can hide overlay windows on 12.0+
8484
list.remove(Tapjack)
8585
}
86+
if (Const.Version.atLeast_30_1()) {
87+
list.add(Restrict)
88+
}
8689
}
8790

8891
return list

0 commit comments

Comments
 (0)