Remove core only mode

Replaced by native safe mode
This commit is contained in:
topjohnwu 2020-06-21 15:59:06 -07:00
parent e02386a6ac
commit 23a33b4351
11 changed files with 6 additions and 87 deletions

View File

@ -60,7 +60,6 @@ object Config : PreferenceModel, DBConfig {
// system state
const val MAGISKHIDE = "magiskhide"
const val COREONLY = "disable"
}
object Value {
@ -129,8 +128,6 @@ object Config : PreferenceModel, DBConfig {
var suReAuth by preference(Key.SU_REAUTH, false)
var checkUpdate by preference(Key.CHECK_UPDATES, 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)
@JvmStatic
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())
}
// Get actual state
putBoolean(Key.COREONLY, Const.MAGISK_DISABLE_FILE.exists())
// Write database configs
putString(Key.ROOT_ACCESS, rootMode.toString())
putString(Key.SU_MNT_NS, suMntNamespaceMode.toString())

View File

@ -1,14 +1,12 @@
package com.topjohnwu.magisk.core
import android.os.Process
import java.io.File
object Const {
// Paths
lateinit var MAGISKTMP: String
val MAGISK_PATH get() = "$MAGISKTMP/modules"
var MAGISK_DISABLE_FILE = File("xxx")
const val TMP_FOLDER_PATH = "/dev/tmp"
const val MAGISK_LOG = "/cache/magisk.log"

View File

@ -8,7 +8,6 @@ import com.topjohnwu.magisk.core.wrap
import com.topjohnwu.magisk.extensions.rawResource
import com.topjohnwu.superuser.Shell
import com.topjohnwu.superuser.ShellUtils
import com.topjohnwu.superuser.io.SuFile
class RootInit : Shell.Initializer() {
@ -29,7 +28,6 @@ class RootInit : Shell.Initializer() {
job.add(context.rawResource(R.raw.manager))
if (shell.isRoot) {
job.add(context.rawResource(R.raw.util_functions))
Const.MAGISK_DISABLE_FILE = SuFile("/cache/.disable_magisk")
}
job.add("mm_init").exec()

View File

@ -67,7 +67,7 @@ object Shortcuts {
.build()
)
}
if (!Config.coreOnly && Info.env.isActive) {
if (Info.env.isActive) {
shortCuts.add(
ShortcutInfo.Builder(context, "modules")
.setShortLabel(context.getString(R.string.modules))

View File

@ -13,19 +13,6 @@ import com.topjohnwu.magisk.databinding.ComparableRvItem
import com.topjohnwu.magisk.ui.module.ModuleViewModel
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>() {
override val layoutRes = R.layout.item_module_download

View File

@ -45,7 +45,7 @@ class HomeViewModel(
val stateMagiskRemoteVersion = KObservableField(R.string.loading.res())
val stateMagiskInstalledVersion get() =
"${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 stateManagerInstalledVersion = Info.stub?.let {

View File

@ -80,7 +80,6 @@ class ModuleViewModel(
private val itemsInstalledHelpers = ObservableArrayList<TextItem>()
private val itemsUpdatableHelpers = ObservableArrayList<TextItem>()
private val itemsCoreOnly = ObservableArrayList<SafeModeNotice>()
private val itemsInstalled = diffListOf<ModuleItem>()
private val itemsUpdatable = diffListOf<RepoItem.Update>()
private val itemsRemote = diffListOf<RepoItem.Remote>()
@ -94,7 +93,6 @@ class ModuleViewModel(
val adapter = adapterOf<ComparableRvItem<*>>()
val items = MergeObservableList<ComparableRvItem<*>>()
.insertList(itemsCoreOnly)
.insertItem(InstallModule)
.insertItem(sectionUpdate)
.insertList(itemsUpdatableHelpers)
@ -176,7 +174,6 @@ class ModuleViewModel(
// ---
override fun refresh(): Disposable {
updateCoreOnlyWarning()
if (itemsRemote.isEmpty())
loadRemote()
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

View File

@ -4,7 +4,6 @@ import android.content.Context
import android.os.Build
import android.os.Environment
import android.view.LayoutInflater
import android.widget.Toast
import androidx.databinding.Bindable
import com.topjohnwu.magisk.BR
import com.topjohnwu.magisk.BuildConfig
@ -210,21 +209,6 @@ object Magisk : SettingsItem.Section() {
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() {
override val title = R.string.magiskhide.asTransitive()
override val description = R.string.settings_magiskhide_summary.asTransitive()

View File

@ -63,7 +63,7 @@ class SettingsViewModel(
if (Info.env.isActive) {
list.addAll(listOf(
Magisk,
MagiskHide, SystemlessHosts, SafeMode
MagiskHide, SystemlessHosts
))
}

View File

@ -21,10 +21,10 @@
<com.google.android.material.card.MaterialCardView
style="@style/WidgetFoundation.Card.Variant"
isEnabled="@{!Config.coreOnly &amp;&amp; !item.removed}"
isEnabled="@{!item.removed}"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="@{item.enabled &amp;&amp; !Config.coreOnly ? 1f : .5f}"
android:alpha="@{item.enabled ? 1f : .5f}"
android:onClick="@{() -> item.toggle()}"
tools:layout_gravity="center"
tools:layout_marginBottom="@dimen/l1"
@ -82,7 +82,7 @@
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/module_indicator"
style="@style/WidgetFoundation.Switch"
isSelected="@{item.enabled &amp;&amp; !Config.coreOnly}"
isSelected="@{item.enabled}"
android:layout_marginEnd="@dimen/l_50"
app:layout_constraintBottom_toBottomOf="@+id/module_version_author"
app:layout_constraintEnd_toEndOf="parent"

View File

@ -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>