From c8fcba483f88b51ca89730e7c3978410843f64b7 Mon Sep 17 00:00:00 2001 From: kai-city <1830170041@qq.com> Date: Mon, 7 Jun 2021 23:18:10 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=94=AF=E6=8C=81=E6=8A=BD=E5=8F=96=E5=A3=B3?= =?UTF-8?q?=E7=9A=84=E4=BF=AE=E5=A4=8D=EF=BC=88=E8=AF=B7=E5=9C=A8=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=87=8C=E5=88=87=E6=8D=A2=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../blackbox/app/BActivityThread.java | 2 +- app/build.gradle | 6 +-- .../niunaijun/blackdex/app/BlackDexLoader.kt | 12 ++++- .../blackdex/data/DexDumpRepository.kt | 15 +++++- .../niunaijun/blackdex/util/LoadingUtil.kt | 30 ----------- .../blackdex/view/main/MainActivity.kt | 27 ++++------ .../blackdex/view/setting/SettingFragment.kt | 27 ++++++++++ .../blackdex/view/widget/ProgressDialog.kt | 53 +++++++++++++++++++ app/src/main/res/layout/dialog_progress.xml | 24 +++++++++ app/src/main/res/values-zh/string.xml | 10 ++++ app/src/main/res/values/strings.xml | 9 ++++ app/src/main/res/xml/setting.xml | 8 +++ 12 files changed, 168 insertions(+), 55 deletions(-) delete mode 100644 app/src/main/java/top/niunaijun/blackdex/util/LoadingUtil.kt create mode 100644 app/src/main/java/top/niunaijun/blackdex/view/widget/ProgressDialog.kt create mode 100644 app/src/main/res/layout/dialog_progress.xml diff --git a/Bcore/src/main/java/top/niunaijun/blackbox/app/BActivityThread.java b/Bcore/src/main/java/top/niunaijun/blackbox/app/BActivityThread.java index b28fc9f..e3239cb 100644 --- a/Bcore/src/main/java/top/niunaijun/blackbox/app/BActivityThread.java +++ b/Bcore/src/main/java/top/niunaijun/blackbox/app/BActivityThread.java @@ -212,7 +212,7 @@ public class BActivityThread extends IBActivityThread.Stub { private void handleDumpDex(String packageName, DumpResult result, ClassLoader classLoader) { new Thread(() -> { try { - Thread.sleep(500); + Thread.sleep(20*1000); } catch (InterruptedException ignored) { } try { diff --git a/app/build.gradle b/app/build.gradle index 730e6f6..55011b4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,8 +11,8 @@ android { applicationId "top.niunaijun.blackdex" minSdkVersion 21 targetSdkVersion 30 - versionCode 2 - versionName "1.1.0" + versionCode 3 + versionName "2.0.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -91,8 +91,6 @@ dependencies { //dialog implementation 'com.github.nukc.stateview:kotlin:2.2.0' //状态控制控件 - implementation 'com.roger.catloadinglibrary:catloadinglibrary:1.0.9' - //加载dialog implementation 'com.github.Ferfalk:SimpleSearchView:0.2.0' //searchView diff --git a/app/src/main/java/top/niunaijun/blackdex/app/BlackDexLoader.kt b/app/src/main/java/top/niunaijun/blackdex/app/BlackDexLoader.kt index f7994ba..2eae60a 100644 --- a/app/src/main/java/top/niunaijun/blackdex/app/BlackDexLoader.kt +++ b/app/src/main/java/top/niunaijun/blackdex/app/BlackDexLoader.kt @@ -21,6 +21,8 @@ class BlackDexLoader { private var mSaveEnable by AppSharedPreferenceDelegate(App.getContext(), true) + private var mFixCodeItem by AppSharedPreferenceDelegate(App.getContext(),false) + private var mDir = if (mSaveEnable) { getDexDumpDir(App.getContext()) } else { @@ -42,7 +44,7 @@ class BlackDexLoader { } override fun isFixCodeItem(): Boolean { - return false + return mFixCodeItem } }) } @@ -67,6 +69,14 @@ class BlackDexLoader { this.mSavePath = path } + fun setFixCodeItem(enable:Boolean){ + this.mFixCodeItem = enable + } + + fun isFixCodeItem():Boolean{ + return this.mFixCodeItem + } + companion object { diff --git a/app/src/main/java/top/niunaijun/blackdex/data/DexDumpRepository.kt b/app/src/main/java/top/niunaijun/blackdex/data/DexDumpRepository.kt index af6ced9..9a4939e 100644 --- a/app/src/main/java/top/niunaijun/blackdex/data/DexDumpRepository.kt +++ b/app/src/main/java/top/niunaijun/blackdex/data/DexDumpRepository.kt @@ -12,6 +12,9 @@ import top.niunaijun.blackbox.BlackBoxCore.getPackageManager import top.niunaijun.blackbox.BlackDexCore import top.niunaijun.blackbox.utils.AbiUtils import top.niunaijun.blackbox.utils.FileUtils +import top.niunaijun.blackdex.app.App +import top.niunaijun.blackdex.app.AppManager +import top.niunaijun.blackdex.app.BlackDexLoader import top.niunaijun.blackdex.data.entity.AppInfo import top.niunaijun.blackdex.data.entity.DumpInfo import java.io.File @@ -80,7 +83,17 @@ class DexDumpRepository { private fun startCountdown(dexDumpLiveData: MutableLiveData) { GlobalScope.launch { val tempId = dumpTaskId - delay(10000) + + while (BlackDexCore.get().isRunning){ + delay(10000) + //10s + + if(!AppManager.mBlackBoxLoader.isFixCodeItem()){ + break + } + //fixCodeItem 需要长时间运行,普通内存dump不需要 + } + if (tempId == dumpTaskId) { dexDumpLiveData.postValue(DumpInfo(DumpInfo.TIMEOUT)) diff --git a/app/src/main/java/top/niunaijun/blackdex/util/LoadingUtil.kt b/app/src/main/java/top/niunaijun/blackdex/util/LoadingUtil.kt deleted file mode 100644 index d6d91d3..0000000 --- a/app/src/main/java/top/niunaijun/blackdex/util/LoadingUtil.kt +++ /dev/null @@ -1,30 +0,0 @@ -package top.niunaijun.blackdex.util - -import android.view.KeyEvent -import androidx.fragment.app.FragmentManager -import com.roger.catloadinglibrary.CatLoadingView -import top.niunaijun.blackdex.R - -/** - * - * @Description: - * @Author: wukaicheng - * @CreateDate: 2021/4/30 23:04 - */ -object LoadingUtil { - - fun showLoading(loadingView: CatLoadingView, fragmentManager: FragmentManager) { - if (!loadingView.isAdded) { - loadingView.setBackgroundColor(R.color.primary) - loadingView.show(fragmentManager, "") - fragmentManager.executePendingTransactions() - loadingView.setClickCancelAble(false) - loadingView.dialog?.setOnKeyListener { _, keyCode, _ -> - if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE) { - return@setOnKeyListener true - } - false - } - } - } -} \ No newline at end of file diff --git a/app/src/main/java/top/niunaijun/blackdex/view/main/MainActivity.kt b/app/src/main/java/top/niunaijun/blackdex/view/main/MainActivity.kt index f40e983..cd32d3a 100644 --- a/app/src/main/java/top/niunaijun/blackdex/view/main/MainActivity.kt +++ b/app/src/main/java/top/niunaijun/blackdex/view/main/MainActivity.kt @@ -13,7 +13,6 @@ import androidx.recyclerview.widget.LinearLayoutManager import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.files.fileChooser import com.ferfalk.simplesearchview.SimpleSearchView -import com.roger.catloadinglibrary.CatLoadingView import com.umeng.analytics.MobclickAgent import top.niunaijun.blackbox.BlackDexCore import top.niunaijun.blackbox.core.system.dump.IBDumpMonitor @@ -24,10 +23,10 @@ import top.niunaijun.blackdex.data.entity.DumpInfo import top.niunaijun.blackdex.databinding.ActivityMainBinding import top.niunaijun.blackdex.util.FileUtil import top.niunaijun.blackdex.util.InjectionUtil -import top.niunaijun.blackdex.util.LoadingUtil import top.niunaijun.blackdex.util.inflate import top.niunaijun.blackdex.view.base.PermissionActivity import top.niunaijun.blackdex.view.setting.SettingActivity +import top.niunaijun.blackdex.view.widget.ProgressDialog import java.io.File @@ -39,7 +38,7 @@ class MainActivity : PermissionActivity() { private lateinit var mAdapter: MainAdapter - private lateinit var loadingView: CatLoadingView + private var loadingView: ProgressDialog? = null private var initialDir: File? = null @@ -124,11 +123,6 @@ class MainActivity : PermissionActivity() { showLoading() } DumpInfo.TIMEOUT -> { - // 判断是否running - Log.e("Tag", "isRunning ${BlackDexCore.get().isRunning}") - if (BlackDexCore.get().isRunning) { - return@let - } hideLoading() MaterialDialog(this).show { title(R.string.unpack_fail) @@ -167,14 +161,13 @@ class MainActivity : PermissionActivity() { private val mMonitor = object : IBDumpMonitor.Stub() { override fun onDump(result: DumpResult?) { result?.let { - Log.e("mMonitor", "onDump: ${result.toString()}") // 此处做进度条 if (result.isRunning) { - val totalProcess = result.totalProcess - val currProcess = result.currProcess + loadingView?.setProgress(result.currProcess, result.totalProcess) return } + if (result.isSuccess) { viewModel.mDexDumpLiveData.postValue( DumpInfo( @@ -223,17 +216,15 @@ class MainActivity : PermissionActivity() { } private fun showLoading() { - if (!this::loadingView.isInitialized) { - loadingView = CatLoadingView() + if (this.loadingView == null) { + loadingView = ProgressDialog() } - - LoadingUtil.showLoading(loadingView, supportFragmentManager) + loadingView?.show(supportFragmentManager, "") } private fun hideLoading() { - if (this::loadingView.isInitialized) { - loadingView.dismiss() - } + loadingView?.dismiss() + loadingView = null } private fun hideKeyboard() { diff --git a/app/src/main/java/top/niunaijun/blackdex/view/setting/SettingFragment.kt b/app/src/main/java/top/niunaijun/blackdex/view/setting/SettingFragment.kt index 6905224..1233fe4 100644 --- a/app/src/main/java/top/niunaijun/blackdex/view/setting/SettingFragment.kt +++ b/app/src/main/java/top/niunaijun/blackdex/view/setting/SettingFragment.kt @@ -26,6 +26,8 @@ class SettingFragment : PreferenceFragmentCompat() { private lateinit var saveEnablePreference: SwitchPreferenceCompat + private lateinit var fixCodeItemPreference: SwitchPreferenceCompat + private val initialDirectory = AppManager.mBlackBoxLoader.getSavePath() override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { @@ -38,6 +40,10 @@ class SettingFragment : PreferenceFragmentCompat() { saveEnablePreference.onPreferenceChangeListener = mSaveEnableChange saveEnablePreference.isChecked = AppManager.mBlackBoxLoader.saveEnable() + fixCodeItemPreference = findPreference("fix_code_item")!! + fixCodeItemPreference.onPreferenceChangeListener = mFixCodeItemChange + fixCodeItemPreference.isChecked = AppManager.mBlackBoxLoader.isFixCodeItem() + } private val mSavedPathClick = Preference.OnPreferenceClickListener { @@ -73,6 +79,27 @@ class SettingFragment : PreferenceFragmentCompat() { return@OnPreferenceChangeListener true } + private val mFixCodeItemChange = Preference.OnPreferenceChangeListener { _, newValue -> + if (newValue as Boolean) { + + MaterialDialog(requireContext()).show { + title(R.string.warn) + message(R.string.fix_code_item_message) + positiveButton(R.string.confirm) { + AppManager.mBlackBoxLoader.setFixCodeItem(true) + } + negativeButton(R.string.cancel) { + fixCodeItemPreference.isChecked = false + AppManager.mBlackBoxLoader.setFixCodeItem(false) + } + } + + } else { + AppManager.mBlackBoxLoader.setFixCodeItem(newValue) + } + return@OnPreferenceChangeListener true + } + private val requestResult = { hasPermission: Boolean -> AppManager.mBlackBoxLoader.saveEnable(!hasPermission) diff --git a/app/src/main/java/top/niunaijun/blackdex/view/widget/ProgressDialog.kt b/app/src/main/java/top/niunaijun/blackdex/view/widget/ProgressDialog.kt new file mode 100644 index 0000000..bef3460 --- /dev/null +++ b/app/src/main/java/top/niunaijun/blackdex/view/widget/ProgressDialog.kt @@ -0,0 +1,53 @@ +package top.niunaijun.blackdex.view.widget + +import android.app.Dialog +import android.os.Bundle +import android.util.Log +import android.view.KeyEvent +import android.view.View +import androidx.appcompat.app.AlertDialog +import androidx.fragment.app.DialogFragment +import top.niunaijun.blackdex.R +import top.niunaijun.blackdex.databinding.DialogProgressBinding +import top.niunaijun.blackdex.util.inflate + +/** + * + * @Description: progress dialog + * @Author: wukaicheng + * @CreateDate: 2021/6/7 21:16 + */ +class ProgressDialog : DialogFragment() { + + private val TAG = "ProgressDialog" + + private val viewBinding: DialogProgressBinding by inflate() + + override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { + val dialog = AlertDialog.Builder(requireContext()) + .setView(viewBinding.root) + .setTitle(getString(R.string.classes_progress,1,1)) + .setCancelable(false) + .show() + + dialog.setCanceledOnTouchOutside(false) + dialog.setOnKeyListener { _, keyCode, _ -> + return@setOnKeyListener keyCode == KeyEvent.KEYCODE_BACK + } + + return dialog + } + + + fun setProgress(progress: Int, maxProgress: Int) { + requireActivity().runOnUiThread { + if (progress == 0) { + viewBinding.progress.max = maxProgress + } + viewBinding.progress.progress = progress + dialog?.setTitle(getString(R.string.classes_progress,progress,maxProgress)) + + } + } + +} \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_progress.xml b/app/src/main/res/layout/dialog_progress.xml new file mode 100644 index 0000000..73db47c --- /dev/null +++ b/app/src/main/res/layout/dialog_progress.xml @@ -0,0 +1,24 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-zh/string.xml b/app/src/main/res/values-zh/string.xml index 43c892c..c4cf813 100644 --- a/app/src/main/res/values-zh/string.xml +++ b/app/src/main/res/values-zh/string.xml @@ -23,4 +23,14 @@ 文件储存 使用默认储存路径 自定义储存路径 + 警告 + 高级设置 + 深度脱壳 + 自主修复抽取指令,还原Dex文件 + 开启后将进行深度脱壳,深度脱壳会自主修复被抽取的指令,开启后请注意以下变化。\n\n1.脱壳时间会大幅度上升,预计几分钟都十几分钟不等\n2.脱壳期间有可能会出现应用闪退(遇到反检测等)\n3.会增加脱壳失败几率\n4.不一定能够100%还原 + + + + 正在脱壳… + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d423754..6713641 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -23,4 +23,13 @@ File Use Default Path Customize the storage path + Warning + Advanced Settings + FixCodeItem + Self-repair extraction instructions and restore Dex files + After opening, deep shelling will be carried out. Deep shelling will automatically repair the extracted commands. Please pay attention to the following changes after opening. \n\n1. The shelling time will increase significantly, and it is expected to take a few minutes to ten minutes. \n2. During the shelling, there may be application crashes (in case of anti-detection, etc.) \n3. It will increase the chance of shelling failure \n4. Not necessarily 100% reduction + + + classes.dex (%1d/%1d) + dumping… \ No newline at end of file diff --git a/app/src/main/res/xml/setting.xml b/app/src/main/res/xml/setting.xml index 155e6b3..df45442 100644 --- a/app/src/main/res/xml/setting.xml +++ b/app/src/main/res/xml/setting.xml @@ -12,4 +12,12 @@ android:key="save_path" android:title="@string/rewrite_file_path" /> + + + + + \ No newline at end of file