mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-02-22 06:28:31 +00:00
Fixed issues after merge
This commit is contained in:
parent
4f0e1c6c61
commit
e82bc1b7bc
@ -8,6 +8,8 @@ import com.topjohnwu.magisk.model.entity.module.Repo
|
|||||||
abstract class RepoDatabase : RoomDatabase() {
|
abstract class RepoDatabase : RoomDatabase() {
|
||||||
|
|
||||||
abstract fun repoDao() : RepoDao
|
abstract fun repoDao() : RepoDao
|
||||||
|
abstract fun repoByUpdatedDao(): RepoByUpdatedDao
|
||||||
|
abstract fun repoByNameDao(): RepoByNameDao
|
||||||
}
|
}
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
package com.topjohnwu.magisk.data.database
|
|
||||||
|
|
||||||
import androidx.room.Database
|
|
||||||
import androidx.room.RoomDatabase
|
|
||||||
import com.topjohnwu.magisk.model.entity.module.Repo
|
|
||||||
|
|
||||||
@Database(version = 6, entities = [Repo::class, RepoEtag::class])
|
|
||||||
abstract class RepoDatabase : RoomDatabase() {
|
|
||||||
|
|
||||||
abstract fun repoDao(): RepoDao
|
|
||||||
abstract fun repoByUpdatedDao(): RepoByUpdatedDao
|
|
||||||
abstract fun repoByNameDao(): RepoByNameDao
|
|
||||||
|
|
||||||
}
|
|
@ -54,7 +54,7 @@ fun <T> Single<T>.subscribeK(
|
|||||||
onError: OnErrorListener = { it.printStackTrace() },
|
onError: OnErrorListener = { it.printStackTrace() },
|
||||||
onNext: OnSuccessListener<T> = {}
|
onNext: OnSuccessListener<T> = {}
|
||||||
) = applySchedulers()
|
) = applySchedulers()
|
||||||
.subscribe(onSuccess, onError)
|
.subscribe(onNext, onError)
|
||||||
|
|
||||||
fun <T> Maybe<T>.subscribeK(
|
fun <T> Maybe<T>.subscribeK(
|
||||||
onError: OnErrorListener = { it.printStackTrace() },
|
onError: OnErrorListener = { it.printStackTrace() },
|
||||||
|
@ -81,7 +81,7 @@ class LogItem(val item: MagiskLog) : ObservableItem<LogItem>() {
|
|||||||
|
|
||||||
override val layoutRes = R.layout.item_log_access_md2
|
override val layoutRes = R.layout.item_log_access_md2
|
||||||
|
|
||||||
val date = item.date.time.toTime(timeDateFormat)
|
val date = item.time.toTime(timeDateFormat)
|
||||||
var isTop = false
|
var isTop = false
|
||||||
@Bindable get
|
@Bindable get
|
||||||
set(value) {
|
set(value) {
|
||||||
@ -103,7 +103,7 @@ class LogItem(val item: MagiskLog) : ObservableItem<LogItem>() {
|
|||||||
item.packageName == other.item.packageName &&
|
item.packageName == other.item.packageName &&
|
||||||
item.command == other.item.command &&
|
item.command == other.item.command &&
|
||||||
item.action == other.item.action &&
|
item.action == other.item.action &&
|
||||||
item.date == other.item.date &&
|
item.time == other.item.time &&
|
||||||
isTop == other.isTop &&
|
isTop == other.isTop &&
|
||||||
isBottom == other.isBottom
|
isBottom == other.isBottom
|
||||||
}
|
}
|
@ -27,7 +27,7 @@ class InstallExternalModuleEvent : ViewEvent(), ActivityExecutor {
|
|||||||
fun onActivityResult(context: Context, requestCode: Int, resultCode: Int, data: Intent?) {
|
fun onActivityResult(context: Context, requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
if (requestCode == Const.ID.FETCH_ZIP && resultCode == Activity.RESULT_OK && data != null) {
|
if (requestCode == Const.ID.FETCH_ZIP && resultCode == Activity.RESULT_OK && data != null) {
|
||||||
// Get the URI of the selected file
|
// Get the URI of the selected file
|
||||||
val intent = context.intent(FlashActivity::class.java)
|
val intent = context.intent<FlashActivity>()
|
||||||
intent.setData(data.data).putExtra(Const.Key.FLASH_ACTION, Const.Value.FLASH_ZIP)
|
intent.setData(data.data).putExtra(Const.Key.FLASH_ACTION, Const.Value.FLASH_ZIP)
|
||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.topjohnwu.magisk.model.events
|
package com.topjohnwu.magisk.model.events
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
@ -10,11 +11,11 @@ import com.karumi.dexter.listener.PermissionRequest
|
|||||||
import com.karumi.dexter.listener.multi.MultiplePermissionsListener
|
import com.karumi.dexter.listener.multi.MultiplePermissionsListener
|
||||||
import com.topjohnwu.magisk.Const
|
import com.topjohnwu.magisk.Const
|
||||||
import com.topjohnwu.magisk.R
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.base.BaseActivity
|
||||||
import com.topjohnwu.magisk.data.repository.MagiskRepository
|
import com.topjohnwu.magisk.data.repository.MagiskRepository
|
||||||
import com.topjohnwu.magisk.extensions.DynamicClassLoader
|
import com.topjohnwu.magisk.extensions.DynamicClassLoader
|
||||||
import com.topjohnwu.magisk.extensions.subscribeK
|
import com.topjohnwu.magisk.extensions.subscribeK
|
||||||
import com.topjohnwu.magisk.extensions.writeTo
|
import com.topjohnwu.magisk.extensions.writeTo
|
||||||
import com.topjohnwu.magisk.base.BaseActivity
|
|
||||||
import com.topjohnwu.magisk.model.entity.module.Repo
|
import com.topjohnwu.magisk.model.entity.module.Repo
|
||||||
import com.topjohnwu.magisk.model.permissions.PermissionRequestBuilder
|
import com.topjohnwu.magisk.model.permissions.PermissionRequestBuilder
|
||||||
import com.topjohnwu.magisk.utils.RxBus
|
import com.topjohnwu.magisk.utils.RxBus
|
||||||
@ -136,7 +137,7 @@ class UpdateSafetyNetEvent : ViewEvent(), ContextExecutor, KoinComponent, Safety
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ViewActionEvent(val action: BaseActivity<*, *>.() -> Unit) : ViewEvent(), ActivityExecutor {
|
class ViewActionEvent(val action: BaseActivity<*, *>.() -> Unit) : ViewEvent(), ActivityExecutor {
|
||||||
override fun invoke(activity: AppCompatActivity) = activity.run(action)
|
override fun invoke(activity: AppCompatActivity) = (activity as BaseActivity<*, *>).run(action)
|
||||||
}
|
}
|
||||||
|
|
||||||
class OpenFilePickerEvent : ViewEvent()
|
class OpenFilePickerEvent : ViewEvent()
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package com.topjohnwu.magisk.model.events.dialog
|
package com.topjohnwu.magisk.model.events.dialog
|
||||||
|
|
||||||
import android.os.Handler
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.biometric.BiometricPrompt
|
|
||||||
import com.topjohnwu.magisk.model.events.ActivityExecutor
|
import com.topjohnwu.magisk.model.events.ActivityExecutor
|
||||||
import com.topjohnwu.magisk.model.events.ViewEvent
|
import com.topjohnwu.magisk.model.events.ViewEvent
|
||||||
|
import com.topjohnwu.magisk.utils.BiometricHelper
|
||||||
|
|
||||||
class BiometricDialog(
|
class BiometricDialog(
|
||||||
builder: Builder.() -> Unit
|
builder: Builder.() -> Unit
|
||||||
@ -18,26 +17,11 @@ class BiometricDialog(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun invoke(activity: AppCompatActivity) {
|
override fun invoke(activity: AppCompatActivity) {
|
||||||
val handler = Handler()
|
BiometricHelper.authenticate(
|
||||||
val prompt = BiometricPrompt.PromptInfo.Builder()
|
activity,
|
||||||
.setNegativeButtonText(activity.getString(android.R.string.cancel))
|
onError = listenerOnFailure,
|
||||||
.build()
|
onSuccess = listenerOnSuccess
|
||||||
|
)
|
||||||
val callback = object : BiometricPrompt.AuthenticationCallback() {
|
|
||||||
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
|
|
||||||
listenerOnFailure()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
|
|
||||||
listenerOnSuccess()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onAuthenticationFailed() {
|
|
||||||
listenerOnFailure()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BiometricPrompt(activity, { handler.post(it) }, callback)
|
|
||||||
.authenticate(prompt/*launch with no crypto for now*/)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class Builder internal constructor() {
|
inner class Builder internal constructor() {
|
||||||
|
@ -1,82 +0,0 @@
|
|||||||
package com.topjohnwu.magisk.model.events.dialog
|
|
||||||
|
|
||||||
import android.hardware.fingerprint.FingerprintManager
|
|
||||||
import android.widget.Toast
|
|
||||||
import com.topjohnwu.magisk.R
|
|
||||||
import com.topjohnwu.magisk.utils.FingerprintHelper
|
|
||||||
import com.topjohnwu.magisk.utils.Utils
|
|
||||||
import com.topjohnwu.magisk.view.MagiskDialog
|
|
||||||
import timber.log.Timber
|
|
||||||
|
|
||||||
@Deprecated(
|
|
||||||
"Use Biometrics instead",
|
|
||||||
ReplaceWith(
|
|
||||||
"BiometricDialog",
|
|
||||||
imports = ["com.topjohnwu.magisk.model.events.dialog.BiometricDialog"]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
class FingerprintDialog(
|
|
||||||
builder: Builder.() -> Unit
|
|
||||||
) : DialogEvent() {
|
|
||||||
|
|
||||||
private val callbacks = Builder().apply(builder)
|
|
||||||
private var helper: Helper? = null
|
|
||||||
get() {
|
|
||||||
if (field == null) {
|
|
||||||
runCatching { field = Helper() }.onFailure { Timber.e(it) }
|
|
||||||
}
|
|
||||||
return field
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun build(dialog: MagiskDialog) {
|
|
||||||
dialog.applyIcon(R.drawable.ic_fingerprint)
|
|
||||||
.applyTitle(R.string.auth_fingerprint)
|
|
||||||
.cancellable(false) //possible fix for devices that have flawed under-screen sensor implementation
|
|
||||||
.applyButton(MagiskDialog.ButtonType.POSITIVE) {
|
|
||||||
titleRes = android.R.string.cancel
|
|
||||||
onClick {
|
|
||||||
callbacks.listenerOnFailure()
|
|
||||||
helper?.cancel()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.onShow {
|
|
||||||
helper?.authenticate() ?: it.let {
|
|
||||||
callbacks.listenerOnFailure()
|
|
||||||
Utils.toast(R.string.auth_fail, Toast.LENGTH_SHORT)
|
|
||||||
it.dismiss()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inner class Builder internal constructor() {
|
|
||||||
internal var listenerOnFailure: GenericDialogListener = {}
|
|
||||||
internal var listenerOnSuccess: GenericDialogListener = {}
|
|
||||||
|
|
||||||
fun onFailure(listener: GenericDialogListener) {
|
|
||||||
listenerOnFailure = listener
|
|
||||||
}
|
|
||||||
|
|
||||||
fun onSuccess(listener: GenericDialogListener) {
|
|
||||||
listenerOnSuccess = listener
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private inner class Helper @Throws(Exception::class) constructor() : FingerprintHelper() {
|
|
||||||
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
|
|
||||||
dialog.applyMessage(errString)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onAuthenticationHelp(helpCode: Int, helpString: CharSequence) {
|
|
||||||
dialog.applyMessage(helpString)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onAuthenticationFailed() {
|
|
||||||
dialog.applyMessage(R.string.auth_fail)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onAuthenticationSucceeded(result: FingerprintManager.AuthenticationResult) {
|
|
||||||
callbacks.listenerOnSuccess()
|
|
||||||
dialog.dismiss()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -111,12 +111,10 @@ object Navigation {
|
|||||||
// redesign starts here
|
// redesign starts here
|
||||||
|
|
||||||
fun start(launchIntent: Intent, context: Context) {
|
fun start(launchIntent: Intent, context: Context) {
|
||||||
val destination = when {
|
when {
|
||||||
Config.redesign -> RedesignActivity::class.java
|
Config.redesign -> context.intent<RedesignActivity>()
|
||||||
else -> MainActivity::class.java
|
else -> context.intent<MainActivity>()
|
||||||
}
|
}.putExtra(Const.Key.OPEN_SECTION, launchIntent.getStringExtra(Const.Key.OPEN_SECTION))
|
||||||
context.intent(destination)
|
|
||||||
.putExtra(Const.Key.OPEN_SECTION, launchIntent.getStringExtra(Const.Key.OPEN_SECTION))
|
|
||||||
.putExtra(
|
.putExtra(
|
||||||
Const.Key.OPEN_SETTINGS,
|
Const.Key.OPEN_SETTINGS,
|
||||||
launchIntent.action == ACTION_APPLICATION_PREFERENCES
|
launchIntent.action == ACTION_APPLICATION_PREFERENCES
|
||||||
|
@ -114,9 +114,6 @@ class HideViewModel(
|
|||||||
|
|
||||||
fun toggleItem(item: HideProcessItem) = magiskRepo
|
fun toggleItem(item: HideProcessItem) = magiskRepo
|
||||||
.toggleHide(item.isHidden.value, item.item.packageName, item.item.name)
|
.toggleHide(item.isHidden.value, item.item.packageName, item.item.name)
|
||||||
// might wanna reorder the list to display the item at the top
|
|
||||||
.subscribeK()
|
|
||||||
.add()
|
|
||||||
|
|
||||||
fun toggle(item: KObservableField<Boolean>) = item.toggle()
|
fun toggle(item: KObservableField<Boolean>) = item.toggle()
|
||||||
|
|
||||||
|
@ -58,6 +58,7 @@ class LogViewModel(
|
|||||||
.ignoreElement()
|
.ignoreElement()
|
||||||
|
|
||||||
val console = repo.fetchMagiskLogs()
|
val console = repo.fetchMagiskLogs()
|
||||||
|
.toList()
|
||||||
.map { it.map { ConsoleRvItem(it) } }
|
.map { it.map { ConsoleRvItem(it) } }
|
||||||
.observeOn(Schedulers.computation())
|
.observeOn(Schedulers.computation())
|
||||||
.map { it to itemsConsole.calculateDiff(it) }
|
.map { it to itemsConsole.calculateDiff(it) }
|
||||||
@ -90,7 +91,6 @@ class LogViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun clearMagiskLog() = repo.clearMagiskLogs()
|
fun clearMagiskLog() = repo.clearMagiskLogs()
|
||||||
.ignoreElement()
|
|
||||||
.subscribeK {
|
.subscribeK {
|
||||||
SnackbarEvent(R.string.logs_cleared).publish()
|
SnackbarEvent(R.string.logs_cleared).publish()
|
||||||
requestRefresh()
|
requestRefresh()
|
||||||
|
@ -18,8 +18,8 @@ import com.topjohnwu.magisk.model.events.dialog.SuperuserRevokeDialog
|
|||||||
import com.topjohnwu.magisk.model.navigation.Navigation
|
import com.topjohnwu.magisk.model.navigation.Navigation
|
||||||
import com.topjohnwu.magisk.redesign.compat.CompatViewModel
|
import com.topjohnwu.magisk.redesign.compat.CompatViewModel
|
||||||
import com.topjohnwu.magisk.redesign.home.itemBindingOf
|
import com.topjohnwu.magisk.redesign.home.itemBindingOf
|
||||||
|
import com.topjohnwu.magisk.utils.BiometricHelper
|
||||||
import com.topjohnwu.magisk.utils.DiffObservableList
|
import com.topjohnwu.magisk.utils.DiffObservableList
|
||||||
import com.topjohnwu.magisk.utils.FingerprintHelper
|
|
||||||
import com.topjohnwu.magisk.utils.RxBus
|
import com.topjohnwu.magisk.utils.RxBus
|
||||||
import com.topjohnwu.magisk.utils.currentLocale
|
import com.topjohnwu.magisk.utils.currentLocale
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
@ -71,7 +71,7 @@ class SuperuserViewModel(
|
|||||||
.subscribeK { items.removeAll { it.itemSameAs(item) } }
|
.subscribeK { items.removeAll { it.itemSameAs(item) } }
|
||||||
.add()
|
.add()
|
||||||
|
|
||||||
if (FingerprintHelper.useFingerprint()) {
|
if (BiometricHelper.isEnabled) {
|
||||||
BiometricDialog {
|
BiometricDialog {
|
||||||
onSuccess { updateState() }
|
onSuccess { updateState() }
|
||||||
}.publish()
|
}.publish()
|
||||||
@ -115,7 +115,7 @@ class SuperuserViewModel(
|
|||||||
.add()
|
.add()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FingerprintHelper.useFingerprint()) {
|
if (BiometricHelper.isEnabled) {
|
||||||
BiometricDialog {
|
BiometricDialog {
|
||||||
onSuccess { updateState() }
|
onSuccess { updateState() }
|
||||||
onFailure { item.isEnabled.toggle() }
|
onFailure { item.isEnabled.toggle() }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user