1.修改在Android11上dex的储存位置

pull/1/head
kai-city 4 years ago
parent f8e7c18521
commit e50208e18f
  1. 23
      app/src/main/java/top/niunaijun/blackdex/data/BlackDexConfiguration.kt
  2. 27
      app/src/main/java/top/niunaijun/blackdex/util/FileUtil.kt

@ -2,6 +2,9 @@ package top.niunaijun.blackdex.data
import android.content.Context
import top.niunaijun.blackbox.app.configuration.ClientConfiguration
import top.niunaijun.blackbox.utils.FileUtils
import top.niunaijun.blackbox.utils.compat.BuildCompat
import java.io.File
/**
*
@ -10,9 +13,29 @@ import top.niunaijun.blackbox.app.configuration.ClientConfiguration
* @CreateDate: 2021/5/23 14:04
*/
class BlackDexConfiguration(private val context: Context) : ClientConfiguration() {
companion object {
fun getDexDumpDir(context: Context): String {
return if (BuildCompat.isR()) {
val dump = File(context.externalCacheDir?.parentFile?.parentFile?.parentFile?.parentFile, "Download/dexDump")
FileUtils.mkdirs(dump)
dump.absolutePath
} else {
val dump = File(context.externalCacheDir?.parentFile, "dump")
FileUtils.mkdirs(dump)
dump.absolutePath
}
}
}
private val dir = getDexDumpDir(context)
override fun getHostPackageName(): String {
return context.packageName
}
override fun getDexDumpDir(): String {
return dir
}
}

@ -1,27 +0,0 @@
package top.niunaijun.blackdex.util
import top.niunaijun.blackbox.BlackBoxCore
import top.niunaijun.blackbox.utils.FileUtils
import top.niunaijun.blackbox.utils.compat.BuildCompat
import java.io.File
/**
*
* @Description:
* @Author: wukaicheng
* @CreateDate: 2021/5/23 14:54
*/
object FileUtil {
fun getDexDumpDir(): String {
if (BuildCompat.isR()) {
val dump = File(BlackBoxCore.getContext().externalCacheDir?.parentFile?.parentFile?.parentFile, "Download/dexDump")
FileUtils.mkdirs(dump)
return dump.absolutePath
}else{
val dump = File(BlackBoxCore.getContext().externalCacheDir?.parentFile, "dump")
FileUtils.mkdirs(dump)
return dump.absolutePath
}
}
}
Loading…
Cancel
Save