From 23a33b43513734888ca2391849751f8c6153b9d5 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sun, 21 Jun 2020 15:59:06 -0700 Subject: [PATCH] Remove core only mode Replaced by native safe mode --- .../java/com/topjohnwu/magisk/core/Config.kt | 6 ---- .../java/com/topjohnwu/magisk/core/Const.kt | 2 -- .../topjohnwu/magisk/core/utils/RootInit.kt | 2 -- .../topjohnwu/magisk/core/view/Shortcuts.kt | 2 +- .../model/entity/recycler/ModuleRvItem.kt | 13 -------- .../topjohnwu/magisk/ui/home/HomeViewModel.kt | 2 +- .../magisk/ui/module/ModuleViewModel.kt | 12 -------- .../magisk/ui/settings/SettingsItems.kt | 16 ---------- .../magisk/ui/settings/SettingsViewModel.kt | 2 +- app/src/main/res/layout/item_module_md2.xml | 6 ++-- .../main/res/layout/item_safe_mode_notice.xml | 30 ------------------- 11 files changed, 6 insertions(+), 87 deletions(-) delete mode 100644 app/src/main/res/layout/item_safe_mode_notice.xml diff --git a/app/src/main/java/com/topjohnwu/magisk/core/Config.kt b/app/src/main/java/com/topjohnwu/magisk/core/Config.kt index e8f425026..32378f3e6 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/Config.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/Config.kt @@ -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()) diff --git a/app/src/main/java/com/topjohnwu/magisk/core/Const.kt b/app/src/main/java/com/topjohnwu/magisk/core/Const.kt index bcd96628e..62d700969 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/Const.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/Const.kt @@ -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" diff --git a/app/src/main/java/com/topjohnwu/magisk/core/utils/RootInit.kt b/app/src/main/java/com/topjohnwu/magisk/core/utils/RootInit.kt index 21b30b218..dca3d8a45 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/utils/RootInit.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/utils/RootInit.kt @@ -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() diff --git a/app/src/main/java/com/topjohnwu/magisk/core/view/Shortcuts.kt b/app/src/main/java/com/topjohnwu/magisk/core/view/Shortcuts.kt index f4d0a3c78..a86e4d267 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/view/Shortcuts.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/view/Shortcuts.kt @@ -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)) diff --git a/app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/ModuleRvItem.kt b/app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/ModuleRvItem.kt index 111154846..b9108f528 100644 --- a/app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/ModuleRvItem.kt +++ b/app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/ModuleRvItem.kt @@ -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() { - 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() { override val layoutRes = R.layout.item_module_download diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt index 7435116fa..fd49bfb29 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt @@ -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 { diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt index 5a8f38edf..2b11492c0 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt @@ -80,7 +80,6 @@ class ModuleViewModel( private val itemsInstalledHelpers = ObservableArrayList() private val itemsUpdatableHelpers = ObservableArrayList() - private val itemsCoreOnly = ObservableArrayList() private val itemsInstalled = diffListOf() private val itemsUpdatable = diffListOf() private val itemsRemote = diffListOf() @@ -94,7 +93,6 @@ class ModuleViewModel( val adapter = adapterOf>() val items = MergeObservableList>() - .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 diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt index 6b44c5998..43536debe 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt @@ -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() diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt index 991c58866..6b2f0ec4f 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt @@ -63,7 +63,7 @@ class SettingsViewModel( if (Info.env.isActive) { list.addAll(listOf( Magisk, - MagiskHide, SystemlessHosts, SafeMode + MagiskHide, SystemlessHosts )) } diff --git a/app/src/main/res/layout/item_module_md2.xml b/app/src/main/res/layout/item_module_md2.xml index bbc4a7792..13fda3ff6 100644 --- a/app/src/main/res/layout/item_module_md2.xml +++ b/app/src/main/res/layout/item_module_md2.xml @@ -21,10 +21,10 @@ - - - - - - - - - - - - - - - \ No newline at end of file