From ab122d76847fa252ac4338e0b0fe4729d488fc93 Mon Sep 17 00:00:00 2001 From: WrBug Date: Thu, 12 Sep 2024 02:38:27 +0800 Subject: [PATCH] data opt --- .../developerhelper/DeveloperApplication.kt | 6 +- .../DeveloperHelperAccessibilityService.kt | 1 - .../ui/activity/hierachy/AppInfoDialog.kt | 2 +- .../activity/hierachy/AppInfoPagerAdapter.kt | 6 +- .../widget/appsettingview/AppSettingView.kt | 162 ++++++------------ .../developerhelper/util/AppStatusRegister.kt | 56 ++++++ .../util/OutSharedPreferenceManager.kt | 34 +++- .../res/layout/activity_xposed_setting.xml | 68 -------- app/src/main/res/layout/view_app_setting.xml | 59 ++----- app/src/main/res/values/strings.xml | 18 +- .../commonutil/AppInfoManager.kt | 6 +- .../developerhelper/commonutil/Constant.kt | 13 +- .../commonutil/shell/ShellManager.kt | 6 +- commonwidget/build.gradle | 1 + .../commonwidget/util/ViewExt.kt | 19 ++ commonwidget/src/main/res/values/strings.xml | 3 +- 16 files changed, 195 insertions(+), 265 deletions(-) create mode 100644 app/src/main/java/com/wrbug/developerhelper/util/AppStatusRegister.kt delete mode 100644 app/src/main/res/layout/activity_xposed_setting.xml diff --git a/app/src/main/java/com/wrbug/developerhelper/DeveloperApplication.kt b/app/src/main/java/com/wrbug/developerhelper/DeveloperApplication.kt index 1eb1c60..a2c0276 100644 --- a/app/src/main/java/com/wrbug/developerhelper/DeveloperApplication.kt +++ b/app/src/main/java/com/wrbug/developerhelper/DeveloperApplication.kt @@ -18,9 +18,10 @@ import java.io.FileOutputStream import com.wrbug.developerhelper.ipc.processshare.tcp.TcpManager import com.wrbug.developerhelper.ipcserver.IpcManager import com.wrbug.developerhelper.ui.activity.main.MainActivity +import com.wrbug.developerhelper.util.AppStatusRegister import org.jetbrains.anko.doAsync -class DeveloperApplication: BaseApp() { +class DeveloperApplication : BaseApp() { companion object { private lateinit var instance: DeveloperApplication @@ -45,6 +46,7 @@ class DeveloperApplication: BaseApp() { BaseModule.init(this) releaseAssetsFile() registerLifecycle() + AppStatusRegister.init(this) } private fun registerIpcServer() { @@ -58,7 +60,7 @@ class DeveloperApplication: BaseApp() { } private fun registerLifecycle() { - registerActivityLifecycleCallbacks(object: ActivityLifecycleCallbacks { + registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks { private var count = 0 override fun onActivityPaused(activity: Activity) { diff --git a/app/src/main/java/com/wrbug/developerhelper/service/DeveloperHelperAccessibilityService.kt b/app/src/main/java/com/wrbug/developerhelper/service/DeveloperHelperAccessibilityService.kt index 7654964..95c009c 100644 --- a/app/src/main/java/com/wrbug/developerhelper/service/DeveloperHelperAccessibilityService.kt +++ b/app/src/main/java/com/wrbug/developerhelper/service/DeveloperHelperAccessibilityService.kt @@ -205,7 +205,6 @@ class DeveloperHelperAccessibilityService : AccessibilityService() { inner class DeveloperHelperAccessibilityReceiver : BroadcastReceiver() { override fun onReceive(context: Context?, data: Intent?) { - showToast(getString(R.string.getting_app_info)) val nodesInfo = readNode() HierarchyActivity.start(context, currentAppInfo, nodesInfo) } diff --git a/app/src/main/java/com/wrbug/developerhelper/ui/activity/hierachy/AppInfoDialog.kt b/app/src/main/java/com/wrbug/developerhelper/ui/activity/hierachy/AppInfoDialog.kt index c0a4cb4..5fa4e5e 100644 --- a/app/src/main/java/com/wrbug/developerhelper/ui/activity/hierachy/AppInfoDialog.kt +++ b/app/src/main/java/com/wrbug/developerhelper/ui/activity/hierachy/AppInfoDialog.kt @@ -74,8 +74,8 @@ class AppInfoDialog : DialogFragment() { } override fun onDestroyView() { - super.onDestroyView() listener?.close() disposable.dispose() + super.onDestroyView() } } \ No newline at end of file diff --git a/app/src/main/java/com/wrbug/developerhelper/ui/activity/hierachy/AppInfoPagerAdapter.kt b/app/src/main/java/com/wrbug/developerhelper/ui/activity/hierachy/AppInfoPagerAdapter.kt index 364401d..f6f6aec 100644 --- a/app/src/main/java/com/wrbug/developerhelper/ui/activity/hierachy/AppInfoPagerAdapter.kt +++ b/app/src/main/java/com/wrbug/developerhelper/ui/activity/hierachy/AppInfoPagerAdapter.kt @@ -67,7 +67,7 @@ class AppInfoPagerAdapter( private fun initAppSettingTab(apkInfo: ApkInfo?) { tabList.add(context.getString(R.string.app_setting)) val view = AppSettingView(context) - view.apkInfo = apkInfo + view.setApkInfo(apkInfo) viewList.add(view) } @@ -89,11 +89,11 @@ class AppInfoPagerAdapter( itemDecoration.setFirstTopPadding(UiUtils.dp2px(context, 10F)) rv.addItemDecoration(itemDecoration) apkInfo?.let { it -> - itemInfos.add(ItemInfo("VersionName", it.packageInfo.versionName)) - itemInfos.add(ItemInfo("VersionCode", it.packageInfo.versionCode)) it.applicationInfo.className?.let { name -> itemInfos.add(ItemInfo("Application", name)) } + itemInfos.add(ItemInfo("VersionName", it.packageInfo.versionName)) + itemInfos.add(ItemInfo("VersionCode", it.packageInfo.versionCode)) itemInfos.add(ItemInfo("uid", it.applicationInfo.uid)) ShellManager.getPid(it.packageInfo.packageName).takeUnless { it.isEmpty() }?.let { itemInfos.add(ItemInfo("Pid", it)) diff --git a/app/src/main/java/com/wrbug/developerhelper/ui/widget/appsettingview/AppSettingView.kt b/app/src/main/java/com/wrbug/developerhelper/ui/widget/appsettingview/AppSettingView.kt index e6d3394..c57d659 100644 --- a/app/src/main/java/com/wrbug/developerhelper/ui/widget/appsettingview/AppSettingView.kt +++ b/app/src/main/java/com/wrbug/developerhelper/ui/widget/appsettingview/AppSettingView.kt @@ -17,11 +17,15 @@ import com.wrbug.developerhelper.mmkv.manager.MMKVManager import android.content.Intent import android.net.Uri import androidx.appcompat.widget.AppCompatButton +import com.wrbug.developerhelper.BuildConfig import com.wrbug.developerhelper.basecommon.BaseActivity import com.wrbug.developerhelper.commonutil.shell.ShellManager import com.wrbug.developerhelper.commonutil.zip import com.wrbug.developerhelper.util.BackupUtils import com.wrbug.developerhelper.commonutil.toUri +import com.wrbug.developerhelper.commonwidget.util.setOnDoubleCheckClickListener +import com.wrbug.developerhelper.commonwidget.util.setOnRootCheckClickListener +import com.wrbug.developerhelper.commonwidget.util.visible import com.wrbug.developerhelper.databinding.ViewAppSettingBinding import gdut.bsx.share2.Share2 import gdut.bsx.share2.ShareContentType @@ -29,105 +33,51 @@ import org.jetbrains.anko.doAsync import org.jetbrains.anko.uiThread import java.io.File -class AppSettingView: ScrollView { +class AppSettingView : ScrollView { - var apkInfo: ApkInfo? = null + private var apkInfo: ApkInfo? = null private val configKv = MMKVManager.get(ConfigKv::class.java) - private var exportDexBtn: AppCompatButton? = null private lateinit var binding: ViewAppSettingBinding - constructor(context: Context): super(context) { + constructor(context: Context) : super(context) { initView() } - constructor(context: Context, attrs: AttributeSet): super(context, attrs) { + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { initView() } + fun setApkInfo(apkInfo: ApkInfo?) { + this.apkInfo = apkInfo + if (apkInfo?.applicationInfo?.packageName == BuildConfig.APPLICATION_ID) { + binding.uninstallAppBtn.visible = false + } + } + private fun initView() { binding = ViewAppSettingBinding.inflate(LayoutInflater.from(context), this, true) - exportDexBtn = findViewById(R.id.exportDexBtn) - if (configKv.isOpenRoot().not()) { - binding.backupApkBtn.isEnabled = false - binding.backupApkDataDirBtn.isEnabled = false - binding.restartAppBtn.isEnabled = false - binding.stopAppBtn.isEnabled = false - binding.deleteAppDataBtn.isEnabled = false - exportDexBtn?.isEnabled = false - } initListener() } private fun initListener() { - binding.backupApkBtn.setOnClickListener { + binding.backupApkBtn.setOnRootCheckClickListener { doBackupApk() } - binding.backupApkDataDirBtn.setOnClickListener { + binding.backupApkDataDirBtn.setOnRootCheckClickListener { doBackupDataDir() } - binding.restartAppBtn.setOnClickListener { + binding.restartAppBtn.setOnRootCheckClickListener { doRestartApp() } - binding.stopAppBtn.setOnClickListener { + binding.stopAppBtn.setOnRootCheckClickListener { doStopApp() } - binding.deleteAppDataBtn.setOnClickListener { + binding.deleteAppDataBtn.setOnRootCheckClickListener { doDeleteAppData() } - binding.uninstallAppBtn.setOnClickListener { + binding.uninstallAppBtn.setOnRootCheckClickListener { doUninstallApp() } - - exportDexBtn?.setOnClickListener { - doBackupDexData() - } - } - - private fun doBackupDexData() { - apkInfo?.apply { - showToast(context.getString(R.string.packing_files)) - doAsync { - val dir = File(context.externalCacheDir, "dex/${applicationInfo.packageName}") - if (dir.exists()) { - ShellManager.rmFile(dir.absolutePath) - } - dir.mkdirs() - val dexDir = "/data/data/${applicationInfo.packageName}/dump" - val lsDir = ShellManager.lsDir(dexDir) - if (lsDir.isEmpty()) { - uiThread { - showToast(context.getString(R.string.no_dex_files)) - } - return@doAsync - } - if (ShellManager.cpFile(dexDir, dir.absolutePath)) { - val zipFile = - File(context.externalCacheDir, "${apkInfo?.getAppName() ?: ""}-dex.zip") - dir.zip(zipFile) - val uri = zipFile.toUri(context) - if (uri == null) { - showToast(R.string.export_failed) - return@doAsync - } - uiThread { - showShareDexNotice(uri) - } - } else { - uiThread { - showToast(context.getString(R.string.export_failed)) - } - } - } - } - } - - private fun showShareDexNotice(uri: Uri) { - Share2.Builder(context as Activity) - .setContentType(ShareContentType.FILE) - .setShareFileUri(uri) - .setOnActivityResult(10) - .build() - .shareBySystem() } private fun doUninstallApp() { @@ -142,13 +92,13 @@ class AppSettingView: ScrollView { } apkInfo?.apply { showNotice( - context.getString(R.string.confirm_delete_app_data), - DialogInterface.OnClickListener { _, _ -> - if (AppManagerUtils.clearAppData(applicationInfo.packageName)) { - activityFinish() - showToast(context.getString(R.string.clear_complete)) - } - }) + context.getString(R.string.confirm_delete_app_data) + ) { _, _ -> + if (AppManagerUtils.clearAppData(applicationInfo.packageName)) { + activityFinish() + showToast(context.getString(R.string.clear_complete)) + } + } } } @@ -158,13 +108,11 @@ class AppSettingView: ScrollView { return } apkInfo?.apply { - showNotice( - context.getString(R.string.confirm_stop_app), - DialogInterface.OnClickListener { _, _ -> - if (AppManagerUtils.forceStopApp(applicationInfo.packageName)) { - activityFinish() - } - }) + showNotice(context.getString(R.string.confirm_stop_app)) { _, _ -> + if (AppManagerUtils.forceStopApp(applicationInfo.packageName)) { + activityFinish() + } + } } } @@ -173,8 +121,7 @@ class AppSettingView: ScrollView { return } apkInfo?.apply { - showNotice( - context.getString(R.string.confirm_restart_app), + showNotice(context.getString(R.string.confirm_restart_app), DialogInterface.OnClickListener { _, _ -> AppManagerUtils.restartApp(context, applicationInfo.packageName) activityFinish() @@ -202,15 +149,13 @@ class AppSettingView: ScrollView { } private fun showShareDataNotice(backupAppData: File) { - showNotice( - context.getString(R.string.backup_success_and_share_msg), + showNotice(context.getString(R.string.backup_success_and_share_msg), DialogInterface.OnClickListener { _, _ -> (context as BaseActivity).requestPermission(arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), - object: BaseActivity.PermissionCallback() { + object : BaseActivity.PermissionCallback() { override fun granted() { val zipFile = File( - context.externalCacheDir, - "${apkInfo?.getAppName() ?: ""}-data.zip" + context.externalCacheDir, "${apkInfo?.getAppName() ?: ""}-data.zip" ) backupAppData.zip(zipFile) val uri = zipFile.toUri(context) @@ -220,11 +165,8 @@ class AppSettingView: ScrollView { } activityFinish() Share2.Builder(context as Activity) - .setContentType(ShareContentType.FILE) - .setShareFileUri(uri) - .setOnActivityResult(10) - .build() - .shareBySystem() + .setContentType(ShareContentType.FILE).setShareFileUri(uri) + .setOnActivityResult(10).build().shareBySystem() } }) @@ -260,19 +202,14 @@ class AppSettingView: ScrollView { (context as BaseActivity).requestPermission(arrayOf( Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE - ), - object: BaseActivity.PermissionCallback() { - override fun granted() { - activityFinish() - Share2.Builder(context as Activity) - .setContentType(ShareContentType.FILE) - .setShareFileUri(uri) - .setOnActivityResult(10) - .build() - .shareBySystem() - } + ), object : BaseActivity.PermissionCallback() { + override fun granted() { + activityFinish() + Share2.Builder(context as Activity).setContentType(ShareContentType.FILE) + .setShareFileUri(uri).setOnActivityResult(10).build().shareBySystem() + } - }) + }) } } @@ -292,11 +229,8 @@ class AppSettingView: ScrollView { } private fun showNotice(msg: String, listener: DialogInterface.OnClickListener) { - AlertDialog.Builder(context) - .setTitle(R.string.notice) - .setMessage(msg) - .setNegativeButton(R.string.cancel, null) - .setPositiveButton(R.string.ok, listener) + AlertDialog.Builder(context).setTitle(R.string.notice).setMessage(msg) + .setNegativeButton(R.string.cancel, null).setPositiveButton(R.string.ok, listener) .create().show() } } \ No newline at end of file diff --git a/app/src/main/java/com/wrbug/developerhelper/util/AppStatusRegister.kt b/app/src/main/java/com/wrbug/developerhelper/util/AppStatusRegister.kt new file mode 100644 index 0000000..1d49973 --- /dev/null +++ b/app/src/main/java/com/wrbug/developerhelper/util/AppStatusRegister.kt @@ -0,0 +1,56 @@ +package com.wrbug.developerhelper.util + +import android.app.Activity +import android.app.Application +import android.os.Bundle + +object AppStatusRegister { + private var count = 0 + private val backgroundMap = hashMapOf Unit>() + fun init(application: Application) { + application.registerActivityLifecycleCallbacks(object : + Application.ActivityLifecycleCallbacks { + override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { + + } + + override fun onActivityStarted(activity: Activity) { + count++ + } + + override fun onActivityResumed(activity: Activity) { + } + + override fun onActivityPaused(activity: Activity) { + } + + override fun onActivityStopped(activity: Activity) { + count-- + backgroundCheck() + } + + override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) { + } + + override fun onActivityDestroyed(activity: Activity) { + } + + }) + } + + + fun registerBackgroundListener(key: String, listener: () -> Unit) { + backgroundMap[key] = listener + } + + fun removeBackgroundListener(key: String) { + backgroundMap.remove(key) + } + + private fun backgroundCheck() { + if (count == 0) { + backgroundMap.values.forEach { it() } + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/wrbug/developerhelper/util/OutSharedPreferenceManager.kt b/app/src/main/java/com/wrbug/developerhelper/util/OutSharedPreferenceManager.kt index cc64336..4dcb1b4 100644 --- a/app/src/main/java/com/wrbug/developerhelper/util/OutSharedPreferenceManager.kt +++ b/app/src/main/java/com/wrbug/developerhelper/util/OutSharedPreferenceManager.kt @@ -1,6 +1,7 @@ package com.wrbug.developerhelper.util import android.content.Context +import com.wrbug.developerhelper.commonutil.Constant import com.wrbug.developerhelper.commonutil.toBoolean import com.wrbug.developerhelper.commonutil.toInt import com.wrbug.developerhelper.commonutil.toLong @@ -13,25 +14,44 @@ object OutSharedPreferenceManager { val sp = context.applicationContext.getSharedPreferences(name, Context.MODE_PRIVATE) val edit = sp.edit() for (sharedPreferenceItemInfo in list) { - when (sharedPreferenceItemInfo.type.toLowerCase()) { + when (sharedPreferenceItemInfo.type.lowercase()) { "string" -> { - edit.putString(sharedPreferenceItemInfo.key, sharedPreferenceItemInfo.getValidValue()) + edit.putString( + sharedPreferenceItemInfo.key, + sharedPreferenceItemInfo.getValidValue() + ) } + "int" -> { - edit.putInt(sharedPreferenceItemInfo.key, sharedPreferenceItemInfo.getValidValue().toInt()) + edit.putInt( + sharedPreferenceItemInfo.key, + sharedPreferenceItemInfo.getValidValue().toInt() + ) } + "long" -> { - edit.putLong(sharedPreferenceItemInfo.key, sharedPreferenceItemInfo.getValidValue().toLong()) + edit.putLong( + sharedPreferenceItemInfo.key, + sharedPreferenceItemInfo.getValidValue().toLong() + ) } + "boolean" -> { - edit.putBoolean(sharedPreferenceItemInfo.key, sharedPreferenceItemInfo.getValidValue().toBoolean()) + edit.putBoolean( + sharedPreferenceItemInfo.key, + sharedPreferenceItemInfo.getValidValue().toBoolean() + ) } + "float" -> { - edit.putFloat(sharedPreferenceItemInfo.key, sharedPreferenceItemInfo.getValidValue().toFloat()) + edit.putFloat( + sharedPreferenceItemInfo.key, + sharedPreferenceItemInfo.getValidValue().toFloat() + ) } } } edit.commit() - return File("/data/data/${context.packageName}/shared_prefs/$name.xml") + return File("${Constant.dataDir}/${context.packageName}/shared_prefs/$name.xml") } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_xposed_setting.xml b/app/src/main/res/layout/activity_xposed_setting.xml deleted file mode 100644 index 3a36541..0000000 --- a/app/src/main/res/layout/activity_xposed_setting.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/view_app_setting.xml b/app/src/main/res/layout/view_app_setting.xml index 307d8c8..13ca456 100644 --- a/app/src/main/res/layout/view_app_setting.xml +++ b/app/src/main/res/layout/view_app_setting.xml @@ -5,48 +5,41 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - + android:paddingTop="24dp" + app:constraint_referenced_ids="backupApkBtn,backupApkDataDirBtn,restartAppBtn,stopAppBtn,deleteAppDataBtn,uninstallAppBtn" + app:flow_verticalGap="16dp" + app:flow_wrapMode="aligned" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + app:layout_constraintWidth_percent="0.45" /> + app:layout_constraintWidth_percent="0.45" /> + app:layout_constraintWidth_percent="0.45" /> + app:layout_constraintWidth_percent="0.45" /> + app:layout_constraintWidth_percent="0.45" /> - - + app:layout_constraintWidth_percent="0.45" /> \ 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 5f2e26e..7e18dbc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -21,8 +21,8 @@ 辅助功能用于界面布局分析等 关于 软件开发中,交流群:627962572 - 界面分析 - 点击分析 + 界面布局 + 点击查看 首次安装时间 最后更新时间 守护进程 @@ -64,7 +64,6 @@ 清理应用数据 卸载应用 请开启root权限 - 部分功能需要root权限,请打开后使用! 是否清除数据和缓存? 清理完成 是否停止该应用? @@ -74,23 +73,14 @@ 备份失败 备份成功,文件已备份到内部存储下com.wrbug.developerHelper目录中,是否立即分享给好友? 分享失败 - 导出脱壳数据 正在打包文件 导出失败! - 无脱壳文件 - Xposed设置 - 管理、移除需要脱壳的应用 - 应用脱壳 移除该项 请先开启Xposed设置 检查更新 - 正在检查新版本... + 正在检查新版本… 暂无新版本 - 检查失败... + 检查失败… 发现新版本 下载 - 应用Xposed功能管理 - 应用Xposed总开关,开启后其他xposed模块才会生效 - DataFinder - DataFinder服务,开启后可以在浏览器访问数据库等信息,需要wifi环境 diff --git a/commonutil/src/main/java/com/wrbug/developerhelper/commonutil/AppInfoManager.kt b/commonutil/src/main/java/com/wrbug/developerhelper/commonutil/AppInfoManager.kt index 2504493..e36f1d9 100644 --- a/commonutil/src/main/java/com/wrbug/developerhelper/commonutil/AppInfoManager.kt +++ b/commonutil/src/main/java/com/wrbug/developerhelper/commonutil/AppInfoManager.kt @@ -32,11 +32,7 @@ object AppInfoManager { fun getSharedPreferencesFiles(packageName: String): Array { - val list = getSharedPreferencesFiles("/data/data", packageName) - if (list.isNotEmpty()) { - return list - } - return getSharedPreferencesFiles(Constant.DATA_MIRROR, packageName) + return getSharedPreferencesFiles(Constant.dataDir, packageName) } private fun getSharedPreferencesFiles(dir: String, packageName: String): Array { diff --git a/commonutil/src/main/java/com/wrbug/developerhelper/commonutil/Constant.kt b/commonutil/src/main/java/com/wrbug/developerhelper/commonutil/Constant.kt index 7fffcfc..a7f20b0 100644 --- a/commonutil/src/main/java/com/wrbug/developerhelper/commonutil/Constant.kt +++ b/commonutil/src/main/java/com/wrbug/developerhelper/commonutil/Constant.kt @@ -1,5 +1,16 @@ package com.wrbug.developerhelper.commonutil +import android.os.Build + object Constant { - const val DATA_MIRROR = "/data_mirror/data_ce/null/0" + private const val DATA_MIRROR_DIR = "/data_mirror/data_ce/null/0" + private const val DATA_DIR = "/data/data" + + val dataDir by lazy { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + DATA_MIRROR_DIR + } else { + DATA_DIR + } + } } \ No newline at end of file diff --git a/commonutil/src/main/java/com/wrbug/developerhelper/commonutil/shell/ShellManager.kt b/commonutil/src/main/java/com/wrbug/developerhelper/commonutil/shell/ShellManager.kt index 0fc2cfe..0f6818e 100644 --- a/commonutil/src/main/java/com/wrbug/developerhelper/commonutil/shell/ShellManager.kt +++ b/commonutil/src/main/java/com/wrbug/developerhelper/commonutil/shell/ShellManager.kt @@ -189,11 +189,7 @@ object ShellManager { } fun getSqliteFiles(packageName: String): Array { - val list = getSqliteFiles("/data/data", packageName) - if (list.isNotEmpty()) { - return list - } - return getSqliteFiles(Constant.DATA_MIRROR, packageName) + return getSqliteFiles(Constant.dataDir, packageName) } private fun getSqliteFiles(dir: String, packageName: String): Array { diff --git a/commonwidget/build.gradle b/commonwidget/build.gradle index 75a8748..d3366d0 100644 --- a/commonwidget/build.gradle +++ b/commonwidget/build.gradle @@ -29,6 +29,7 @@ android { dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation project(':mmkv') testImplementation 'junit:junit:4.12' implementation project(':commonutil') } diff --git a/commonwidget/src/main/java/com/wrbug/developerhelper/commonwidget/util/ViewExt.kt b/commonwidget/src/main/java/com/wrbug/developerhelper/commonwidget/util/ViewExt.kt index 8364083..d79af4c 100644 --- a/commonwidget/src/main/java/com/wrbug/developerhelper/commonwidget/util/ViewExt.kt +++ b/commonwidget/src/main/java/com/wrbug/developerhelper/commonwidget/util/ViewExt.kt @@ -2,7 +2,15 @@ package com.wrbug.developerhelper.commonwidget.util import android.os.SystemClock import android.view.View +import android.widget.Toast +import com.wrbug.developerhelper.commonutil.ShellUtils import com.wrbug.developerhelper.commonwidget.R +import com.wrbug.developerhelper.mmkv.ConfigKv +import com.wrbug.developerhelper.mmkv.manager.MMKVManager + +private val configKv by lazy { + MMKVManager.get(ConfigKv::class.java) +} fun View?.setOnDoubleCheckClickListener(duration: Long = 800, clickListener: (View) -> Unit) { this?.setOnClickListener { @@ -16,6 +24,17 @@ fun View?.setOnDoubleCheckClickListener(duration: Long = 800, clickListener: (Vi } +fun View?.setOnRootCheckClickListener(clickListener: (View) -> Unit) { + setOnDoubleCheckClickListener { + if (!configKv.isOpenRoot()) { + Toast.makeText(it.context, R.string.open_root_notice, Toast.LENGTH_SHORT).show() + return@setOnDoubleCheckClickListener + } + clickListener(it) + } +} + + inline var View.visible: Boolean set(value) { visibility = if (value) { diff --git a/commonwidget/src/main/res/values/strings.xml b/commonwidget/src/main/res/values/strings.xml index f6c0897..25d63d4 100644 --- a/commonwidget/src/main/res/values/strings.xml +++ b/commonwidget/src/main/res/values/strings.xml @@ -1,3 +1,4 @@ - commonwidget + 功能需要root权限,请开启后使用! +