Remove core only mode
Replaced by native safe mode
This commit is contained in:
parent
e02386a6ac
commit
23a33b4351
@ -60,7 +60,6 @@ object Config : PreferenceModel, DBConfig {
|
|||||||
|
|
||||||
// system state
|
// system state
|
||||||
const val MAGISKHIDE = "magiskhide"
|
const val MAGISKHIDE = "magiskhide"
|
||||||
const val COREONLY = "disable"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object Value {
|
object Value {
|
||||||
@ -129,8 +128,6 @@ object Config : PreferenceModel, DBConfig {
|
|||||||
var suReAuth by preference(Key.SU_REAUTH, false)
|
var suReAuth by preference(Key.SU_REAUTH, false)
|
||||||
var checkUpdate by preference(Key.CHECK_UPDATES, true)
|
var checkUpdate by preference(Key.CHECK_UPDATES, true)
|
||||||
var magiskHide by preference(Key.MAGISKHIDE, true)
|
var magiskHide by preference(Key.MAGISKHIDE, true)
|
||||||
@JvmStatic
|
|
||||||
var coreOnly by preference(Key.COREONLY, false)
|
|
||||||
var showSystemApp by preference(Key.SHOW_SYSTEM_APP, false)
|
var showSystemApp by preference(Key.SHOW_SYSTEM_APP, false)
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
var listSpanCount by preference(Key.LIST_SPAN_COUNT, 1)
|
var listSpanCount by preference(Key.LIST_SPAN_COUNT, 1)
|
||||||
@ -166,9 +163,6 @@ object Config : PreferenceModel, DBConfig {
|
|||||||
putString(Key.UPDATE_CHANNEL, Value.CANARY_CHANNEL.toString())
|
putString(Key.UPDATE_CHANNEL, Value.CANARY_CHANNEL.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get actual state
|
|
||||||
putBoolean(Key.COREONLY, Const.MAGISK_DISABLE_FILE.exists())
|
|
||||||
|
|
||||||
// Write database configs
|
// Write database configs
|
||||||
putString(Key.ROOT_ACCESS, rootMode.toString())
|
putString(Key.ROOT_ACCESS, rootMode.toString())
|
||||||
putString(Key.SU_MNT_NS, suMntNamespaceMode.toString())
|
putString(Key.SU_MNT_NS, suMntNamespaceMode.toString())
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package com.topjohnwu.magisk.core
|
package com.topjohnwu.magisk.core
|
||||||
|
|
||||||
import android.os.Process
|
import android.os.Process
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
object Const {
|
object Const {
|
||||||
|
|
||||||
// Paths
|
// Paths
|
||||||
lateinit var MAGISKTMP: String
|
lateinit var MAGISKTMP: String
|
||||||
val MAGISK_PATH get() = "$MAGISKTMP/modules"
|
val MAGISK_PATH get() = "$MAGISKTMP/modules"
|
||||||
var MAGISK_DISABLE_FILE = File("xxx")
|
|
||||||
const val TMP_FOLDER_PATH = "/dev/tmp"
|
const val TMP_FOLDER_PATH = "/dev/tmp"
|
||||||
const val MAGISK_LOG = "/cache/magisk.log"
|
const val MAGISK_LOG = "/cache/magisk.log"
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import com.topjohnwu.magisk.core.wrap
|
|||||||
import com.topjohnwu.magisk.extensions.rawResource
|
import com.topjohnwu.magisk.extensions.rawResource
|
||||||
import com.topjohnwu.superuser.Shell
|
import com.topjohnwu.superuser.Shell
|
||||||
import com.topjohnwu.superuser.ShellUtils
|
import com.topjohnwu.superuser.ShellUtils
|
||||||
import com.topjohnwu.superuser.io.SuFile
|
|
||||||
|
|
||||||
class RootInit : Shell.Initializer() {
|
class RootInit : Shell.Initializer() {
|
||||||
|
|
||||||
@ -29,7 +28,6 @@ class RootInit : Shell.Initializer() {
|
|||||||
job.add(context.rawResource(R.raw.manager))
|
job.add(context.rawResource(R.raw.manager))
|
||||||
if (shell.isRoot) {
|
if (shell.isRoot) {
|
||||||
job.add(context.rawResource(R.raw.util_functions))
|
job.add(context.rawResource(R.raw.util_functions))
|
||||||
Const.MAGISK_DISABLE_FILE = SuFile("/cache/.disable_magisk")
|
|
||||||
}
|
}
|
||||||
job.add("mm_init").exec()
|
job.add("mm_init").exec()
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ object Shortcuts {
|
|||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (!Config.coreOnly && Info.env.isActive) {
|
if (Info.env.isActive) {
|
||||||
shortCuts.add(
|
shortCuts.add(
|
||||||
ShortcutInfo.Builder(context, "modules")
|
ShortcutInfo.Builder(context, "modules")
|
||||||
.setShortLabel(context.getString(R.string.modules))
|
.setShortLabel(context.getString(R.string.modules))
|
||||||
|
@ -13,19 +13,6 @@ import com.topjohnwu.magisk.databinding.ComparableRvItem
|
|||||||
import com.topjohnwu.magisk.ui.module.ModuleViewModel
|
import com.topjohnwu.magisk.ui.module.ModuleViewModel
|
||||||
import com.topjohnwu.magisk.utils.KObservableField
|
import com.topjohnwu.magisk.utils.KObservableField
|
||||||
|
|
||||||
object SafeModeNotice : ComparableRvItem<SafeModeNotice>() {
|
|
||||||
override val layoutRes = R.layout.item_safe_mode_notice
|
|
||||||
|
|
||||||
override fun onBindingBound(binding: ViewDataBinding) {
|
|
||||||
super.onBindingBound(binding)
|
|
||||||
val params = binding.root.layoutParams as? StaggeredGridLayoutManager.LayoutParams
|
|
||||||
params?.isFullSpan = true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun contentSameAs(other: SafeModeNotice) = this == other
|
|
||||||
override fun itemSameAs(other: SafeModeNotice) = this === other
|
|
||||||
}
|
|
||||||
|
|
||||||
object InstallModule : ComparableRvItem<InstallModule>() {
|
object InstallModule : ComparableRvItem<InstallModule>() {
|
||||||
override val layoutRes = R.layout.item_module_download
|
override val layoutRes = R.layout.item_module_download
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class HomeViewModel(
|
|||||||
val stateMagiskRemoteVersion = KObservableField(R.string.loading.res())
|
val stateMagiskRemoteVersion = KObservableField(R.string.loading.res())
|
||||||
val stateMagiskInstalledVersion get() =
|
val stateMagiskInstalledVersion get() =
|
||||||
"${Info.env.magiskVersionString} (${Info.env.magiskVersionCode})"
|
"${Info.env.magiskVersionString} (${Info.env.magiskVersionCode})"
|
||||||
val stateMagiskMode get() = (if (Config.coreOnly) R.string.home_status_safe else R.string.home_status_normal).res()
|
val stateMagiskMode get() = R.string.home_status_normal.res()
|
||||||
|
|
||||||
val stateManagerRemoteVersion = KObservableField(R.string.loading.res())
|
val stateManagerRemoteVersion = KObservableField(R.string.loading.res())
|
||||||
val stateManagerInstalledVersion = Info.stub?.let {
|
val stateManagerInstalledVersion = Info.stub?.let {
|
||||||
|
@ -80,7 +80,6 @@ class ModuleViewModel(
|
|||||||
private val itemsInstalledHelpers = ObservableArrayList<TextItem>()
|
private val itemsInstalledHelpers = ObservableArrayList<TextItem>()
|
||||||
private val itemsUpdatableHelpers = ObservableArrayList<TextItem>()
|
private val itemsUpdatableHelpers = ObservableArrayList<TextItem>()
|
||||||
|
|
||||||
private val itemsCoreOnly = ObservableArrayList<SafeModeNotice>()
|
|
||||||
private val itemsInstalled = diffListOf<ModuleItem>()
|
private val itemsInstalled = diffListOf<ModuleItem>()
|
||||||
private val itemsUpdatable = diffListOf<RepoItem.Update>()
|
private val itemsUpdatable = diffListOf<RepoItem.Update>()
|
||||||
private val itemsRemote = diffListOf<RepoItem.Remote>()
|
private val itemsRemote = diffListOf<RepoItem.Remote>()
|
||||||
@ -94,7 +93,6 @@ class ModuleViewModel(
|
|||||||
|
|
||||||
val adapter = adapterOf<ComparableRvItem<*>>()
|
val adapter = adapterOf<ComparableRvItem<*>>()
|
||||||
val items = MergeObservableList<ComparableRvItem<*>>()
|
val items = MergeObservableList<ComparableRvItem<*>>()
|
||||||
.insertList(itemsCoreOnly)
|
|
||||||
.insertItem(InstallModule)
|
.insertItem(InstallModule)
|
||||||
.insertItem(sectionUpdate)
|
.insertItem(sectionUpdate)
|
||||||
.insertList(itemsUpdatableHelpers)
|
.insertList(itemsUpdatableHelpers)
|
||||||
@ -176,7 +174,6 @@ class ModuleViewModel(
|
|||||||
// ---
|
// ---
|
||||||
|
|
||||||
override fun refresh(): Disposable {
|
override fun refresh(): Disposable {
|
||||||
updateCoreOnlyWarning()
|
|
||||||
if (itemsRemote.isEmpty())
|
if (itemsRemote.isEmpty())
|
||||||
loadRemote()
|
loadRemote()
|
||||||
return loadInstalled().subscribeK()
|
return loadInstalled().subscribeK()
|
||||||
@ -303,15 +300,6 @@ class ModuleViewModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateCoreOnlyWarning() {
|
|
||||||
if (Config.coreOnly) {
|
|
||||||
if (itemsCoreOnly.isNotEmpty()) return
|
|
||||||
itemsCoreOnly.add(SafeModeNotice)
|
|
||||||
} else {
|
|
||||||
itemsCoreOnly.clear()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
|
@ -4,7 +4,6 @@ import android.content.Context
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.databinding.Bindable
|
import androidx.databinding.Bindable
|
||||||
import com.topjohnwu.magisk.BR
|
import com.topjohnwu.magisk.BR
|
||||||
import com.topjohnwu.magisk.BuildConfig
|
import com.topjohnwu.magisk.BuildConfig
|
||||||
@ -210,21 +209,6 @@ object Magisk : SettingsItem.Section() {
|
|||||||
override val title = R.string.magisk.asTransitive()
|
override val title = R.string.magisk.asTransitive()
|
||||||
}
|
}
|
||||||
|
|
||||||
object SafeMode : SettingsItem.Toggle() {
|
|
||||||
override val title = R.string.settings_safe_mode_title.asTransitive()
|
|
||||||
// Use old placeholder for now, will update text once native implementation is changed
|
|
||||||
override val description = R.string.settings_core_only_summary.asTransitive()
|
|
||||||
override var value by bindableValue(Config.coreOnly) {
|
|
||||||
if (Config.coreOnly == it) return@bindableValue
|
|
||||||
Config.coreOnly = it
|
|
||||||
when {
|
|
||||||
it -> runCatching { Const.MAGISK_DISABLE_FILE.createNewFile() }
|
|
||||||
else -> Const.MAGISK_DISABLE_FILE.delete()
|
|
||||||
}
|
|
||||||
Utils.toast(R.string.settings_reboot_toast, Toast.LENGTH_LONG)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
object MagiskHide : SettingsItem.Toggle() {
|
object MagiskHide : SettingsItem.Toggle() {
|
||||||
override val title = R.string.magiskhide.asTransitive()
|
override val title = R.string.magiskhide.asTransitive()
|
||||||
override val description = R.string.settings_magiskhide_summary.asTransitive()
|
override val description = R.string.settings_magiskhide_summary.asTransitive()
|
||||||
|
@ -63,7 +63,7 @@ class SettingsViewModel(
|
|||||||
if (Info.env.isActive) {
|
if (Info.env.isActive) {
|
||||||
list.addAll(listOf(
|
list.addAll(listOf(
|
||||||
Magisk,
|
Magisk,
|
||||||
MagiskHide, SystemlessHosts, SafeMode
|
MagiskHide, SystemlessHosts
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,10 +21,10 @@
|
|||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.card.MaterialCardView
|
||||||
style="@style/WidgetFoundation.Card.Variant"
|
style="@style/WidgetFoundation.Card.Variant"
|
||||||
isEnabled="@{!Config.coreOnly && !item.removed}"
|
isEnabled="@{!item.removed}"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:alpha="@{item.enabled && !Config.coreOnly ? 1f : .5f}"
|
android:alpha="@{item.enabled ? 1f : .5f}"
|
||||||
android:onClick="@{() -> item.toggle()}"
|
android:onClick="@{() -> item.toggle()}"
|
||||||
tools:layout_gravity="center"
|
tools:layout_gravity="center"
|
||||||
tools:layout_marginBottom="@dimen/l1"
|
tools:layout_marginBottom="@dimen/l1"
|
||||||
@ -82,7 +82,7 @@
|
|||||||
<androidx.appcompat.widget.AppCompatImageView
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
android:id="@+id/module_indicator"
|
android:id="@+id/module_indicator"
|
||||||
style="@style/WidgetFoundation.Switch"
|
style="@style/WidgetFoundation.Switch"
|
||||||
isSelected="@{item.enabled && !Config.coreOnly}"
|
isSelected="@{item.enabled}"
|
||||||
android:layout_marginEnd="@dimen/l_50"
|
android:layout_marginEnd="@dimen/l_50"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/module_version_author"
|
app:layout_constraintBottom_toBottomOf="@+id/module_version_author"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
|
||||||
|
|
||||||
<data>
|
|
||||||
|
|
||||||
<variable
|
|
||||||
name="item"
|
|
||||||
type="com.topjohnwu.magisk.model.entity.recycler.SafeModeNotice" />
|
|
||||||
|
|
||||||
</data>
|
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
style="@style/WidgetFoundation.Card"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:cardBackgroundColor="?colorError">
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center"
|
|
||||||
android:padding="@dimen/l1"
|
|
||||||
android:text="@string/module_safe_mode_message"
|
|
||||||
android:textAppearance="@style/AppearanceFoundation.Caption.OnPrimary"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
</layout>
|
|
Loading…
Reference in New Issue
Block a user