commit 882eabe25704d6541a0e905793b4262edd941b74
parent 79a53422c14ffdd13c3a72a7d74e2364086be9d6
Author: rhunk <101876869+rhunk@users.noreply.github.com>
Date: Mon, 29 May 2023 00:02:13 +0200
fix: passcode type password
Diffstat:
5 files changed, 130 insertions(+), 126 deletions(-)
diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/features/impl/MeoPasscodeBypass.kt b/app/src/main/kotlin/me/rhunk/snapenhance/features/impl/MeoPasscodeBypass.kt
@@ -1,21 +0,0 @@
-package me.rhunk.snapenhance.features.impl
-
-import me.rhunk.snapenhance.config.ConfigProperty
-import me.rhunk.snapenhance.features.Feature
-import me.rhunk.snapenhance.features.FeatureLoadParams
-import me.rhunk.snapenhance.hook.HookStage
-import me.rhunk.snapenhance.hook.Hooker
-
-class MeoPasscodeBypass : Feature("Meo Passcode Bypass", loadParams = FeatureLoadParams.ACTIVITY_CREATE_ASYNC) {
- override fun asyncOnActivityCreate() {
- Hooker.hook(
- context.mappings.getMappedClass("BCryptClass"),
- context.mappings.getMappedValue("BCryptClassHashMethod"),
- HookStage.BEFORE,
- { context.config.bool(ConfigProperty.MEO_PASSCODE_BYPASS) },
- ) { param ->
- //set the hash to the result of the method
- param.setResult(param.arg(1))
- }
- }
-}-
\ No newline at end of file
diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/features/impl/experiments/AppPasscode.kt b/app/src/main/kotlin/me/rhunk/snapenhance/features/impl/experiments/AppPasscode.kt
@@ -0,0 +1,105 @@
+package me.rhunk.snapenhance.features.impl.experiments
+
+import android.annotation.SuppressLint
+import android.app.AlertDialog
+import android.content.Context
+import android.os.Build
+import android.text.Editable
+import android.text.InputType
+import android.text.TextWatcher
+import android.view.inputmethod.InputMethodManager
+import android.widget.EditText
+import me.rhunk.snapenhance.config.ConfigProperty
+import me.rhunk.snapenhance.features.Feature
+import me.rhunk.snapenhance.features.FeatureLoadParams
+
+//TODO: fingerprint unlock
+class AppPasscode : Feature("App Passcode", loadParams = FeatureLoadParams.ACTIVITY_CREATE_SYNC) {
+ private var isLocked = false
+
+ private fun setActivityVisibility(isVisible: Boolean) {
+ context.mainActivity?.let {
+ it.window.attributes = it.window.attributes.apply { alpha = if (isVisible) 1.0F else 0.0F }
+ }
+ }
+
+ fun lock() {
+ if (isLocked) return
+ isLocked = true
+ val passcode = context.config.string(ConfigProperty.APP_PASSCODE).also { if (it.isEmpty()) return }
+ val isDigitPasscode = passcode.all { it.isDigit() }
+
+ val mainActivity = context.mainActivity!!
+ setActivityVisibility(false)
+
+ val prompt = AlertDialog.Builder(mainActivity)
+ val createPrompt = {
+ val alertDialog = prompt.create()
+ val textView = EditText(mainActivity)
+ textView.setSingleLine()
+ textView.inputType = if (isDigitPasscode) {
+ (InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_VARIATION_PASSWORD)
+ } else {
+ (InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD)
+ }
+ textView.hint = "Code :"
+ textView.setPadding(100, 100, 100, 100)
+
+ textView.addTextChangedListener(object: TextWatcher {
+ override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
+ if (s.contentEquals(passcode)) {
+ alertDialog.dismiss()
+ isLocked = false
+ setActivityVisibility(true)
+ }
+ }
+ override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
+ override fun afterTextChanged(s: Editable?) {}
+ })
+
+ alertDialog.setView(textView)
+
+ textView.viewTreeObserver.addOnWindowFocusChangeListener { hasFocus ->
+ if (!hasFocus) return@addOnWindowFocusChangeListener
+ val imm = mainActivity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
+ imm.showSoftInput(textView, InputMethodManager.SHOW_IMPLICIT)
+ }
+
+ alertDialog.window?.let {
+ it.attributes.verticalMargin = -0.18F
+ }
+
+ alertDialog.show()
+ textView.requestFocus()
+ }
+
+ prompt.setOnCancelListener {
+ createPrompt()
+ }
+
+ createPrompt()
+ }
+
+ @SuppressLint("MissingPermission")
+ override fun onActivityCreate() {
+ if (!context.database.hasArroyo()) return
+
+ context.runOnUiThread {
+ lock()
+ }
+
+ if (!context.config.bool(ConfigProperty.APP_LOCK_ON_RESUME)) return
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ context.mainActivity?.registerActivityLifecycleCallbacks(object: android.app.Application.ActivityLifecycleCallbacks {
+ override fun onActivityPaused(activity: android.app.Activity) { lock() }
+ override fun onActivityResumed(activity: android.app.Activity) {}
+ override fun onActivityStarted(activity: android.app.Activity) {}
+ override fun onActivityDestroyed(activity: android.app.Activity) {}
+ override fun onActivitySaveInstanceState(activity: android.app.Activity, outState: android.os.Bundle) {}
+ override fun onActivityStopped(activity: android.app.Activity) {}
+ override fun onActivityCreated(activity: android.app.Activity, savedInstanceState: android.os.Bundle?) {}
+ })
+ }
+ }
+}+
\ No newline at end of file
diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/features/impl/experiments/MeoPasscodeBypass.kt b/app/src/main/kotlin/me/rhunk/snapenhance/features/impl/experiments/MeoPasscodeBypass.kt
@@ -0,0 +1,21 @@
+package me.rhunk.snapenhance.features.impl.experiments
+
+import me.rhunk.snapenhance.config.ConfigProperty
+import me.rhunk.snapenhance.features.Feature
+import me.rhunk.snapenhance.features.FeatureLoadParams
+import me.rhunk.snapenhance.hook.HookStage
+import me.rhunk.snapenhance.hook.Hooker
+
+class MeoPasscodeBypass : Feature("Meo Passcode Bypass", loadParams = FeatureLoadParams.ACTIVITY_CREATE_ASYNC) {
+ override fun asyncOnActivityCreate() {
+ Hooker.hook(
+ context.mappings.getMappedClass("BCryptClass"),
+ context.mappings.getMappedValue("BCryptClassHashMethod"),
+ HookStage.BEFORE,
+ { context.config.bool(ConfigProperty.MEO_PASSCODE_BYPASS) },
+ ) { param ->
+ //set the hash to the result of the method
+ param.setResult(param.arg(1))
+ }
+ }
+}+
\ No newline at end of file
diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/features/impl/extras/AppPasscode.kt b/app/src/main/kotlin/me/rhunk/snapenhance/features/impl/extras/AppPasscode.kt
@@ -1,101 +0,0 @@
-package me.rhunk.snapenhance.features.impl.extras
-
-import android.annotation.SuppressLint
-import android.app.AlertDialog
-import android.content.Context
-import android.os.Build
-import android.text.Editable
-import android.text.InputType
-import android.text.TextWatcher
-import android.view.inputmethod.InputMethodManager
-import android.widget.EditText
-import me.rhunk.snapenhance.config.ConfigProperty
-import me.rhunk.snapenhance.features.Feature
-import me.rhunk.snapenhance.features.FeatureLoadParams
-
-//TODO: fingerprint unlock
-class AppPasscode : Feature("App Passcode", loadParams = FeatureLoadParams.ACTIVITY_CREATE_SYNC) {
- private var isLocked = false
-
- private fun setActivityVisibility(isVisible: Boolean) {
- context.mainActivity?.let {
- it.window.attributes = it.window.attributes.apply { alpha = if (isVisible) 1.0F else 0.0F }
- }
- }
-
- fun lock() {
- if (isLocked) return
- isLocked = true
- val passcode = context.config.string(ConfigProperty.APP_PASSCODE).also { if (it.isEmpty()) return }
- val isDigitPasscode = passcode.all { it.isDigit() }
-
- val mainActivity = context.mainActivity!!
- setActivityVisibility(false)
-
- val prompt = AlertDialog.Builder(mainActivity)
- val createPrompt = {
- val alertDialog = prompt.create()
- val textView = EditText(mainActivity)
- textView.setSingleLine()
- textView.inputType = if (isDigitPasscode) InputType.TYPE_CLASS_NUMBER else InputType.TYPE_CLASS_TEXT
- textView.hint = "Code :"
- textView.setPadding(100, 100, 100, 100)
-
- textView.addTextChangedListener(object: TextWatcher {
- override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
- if (s.contentEquals(passcode)) {
- alertDialog.dismiss()
- isLocked = false
- setActivityVisibility(true)
- }
- }
- override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
- override fun afterTextChanged(s: Editable?) {}
- })
-
- alertDialog.setView(textView)
-
- textView.viewTreeObserver.addOnWindowFocusChangeListener { hasFocus ->
- if (!hasFocus) return@addOnWindowFocusChangeListener
- val imm = mainActivity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
- imm.showSoftInput(textView, InputMethodManager.SHOW_IMPLICIT)
- }
-
- alertDialog.window?.let {
- it.attributes.verticalMargin = -0.18F
- }
-
- alertDialog.show()
- textView.requestFocus()
- }
-
- prompt.setOnCancelListener {
- createPrompt()
- }
-
- createPrompt()
- }
-
- @SuppressLint("MissingPermission")
- override fun onActivityCreate() {
- if (!context.database.hasArroyo()) return
-
- context.runOnUiThread {
- lock()
- }
-
- if (!context.config.bool(ConfigProperty.APP_LOCK_ON_RESUME)) return
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
- context.mainActivity?.registerActivityLifecycleCallbacks(object: android.app.Application.ActivityLifecycleCallbacks {
- override fun onActivityPaused(activity: android.app.Activity) { lock() }
- override fun onActivityResumed(activity: android.app.Activity) {}
- override fun onActivityStarted(activity: android.app.Activity) {}
- override fun onActivityDestroyed(activity: android.app.Activity) {}
- override fun onActivitySaveInstanceState(activity: android.app.Activity, outState: android.os.Bundle) {}
- override fun onActivityStopped(activity: android.app.Activity) {}
- override fun onActivityCreated(activity: android.app.Activity, savedInstanceState: android.os.Bundle?) {}
- })
- }
- }
-}-
\ No newline at end of file
diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/manager/impl/FeatureManager.kt b/app/src/main/kotlin/me/rhunk/snapenhance/manager/impl/FeatureManager.kt
@@ -5,12 +5,12 @@ import me.rhunk.snapenhance.ModContext
import me.rhunk.snapenhance.features.Feature
import me.rhunk.snapenhance.features.FeatureLoadParams
import me.rhunk.snapenhance.features.impl.ConfigEnumKeys
-import me.rhunk.snapenhance.features.impl.MeoPasscodeBypass
+import me.rhunk.snapenhance.features.impl.experiments.MeoPasscodeBypass
import me.rhunk.snapenhance.features.impl.Messaging
import me.rhunk.snapenhance.features.impl.downloader.AntiAutoDownload
import me.rhunk.snapenhance.features.impl.downloader.MediaDownloader
import me.rhunk.snapenhance.features.impl.extras.AntiAutoSave
-import me.rhunk.snapenhance.features.impl.extras.AppPasscode
+import me.rhunk.snapenhance.features.impl.experiments.AppPasscode
import me.rhunk.snapenhance.features.impl.extras.AutoSave
import me.rhunk.snapenhance.features.impl.extras.DisableVideoLengthRestriction
import me.rhunk.snapenhance.features.impl.extras.GalleryMediaSendOverride