mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-22 07:57:39 +00:00
Add option to disable filename randomization
This commit is contained in:
parent
4a2a37c87a
commit
e9694c6195
@ -59,6 +59,7 @@ object Config : PreferenceConfig, DBConfig {
|
|||||||
const val THEME_ORDINAL = "theme_ordinal"
|
const val THEME_ORDINAL = "theme_ordinal"
|
||||||
const val ASKED_HOME = "asked_home"
|
const val ASKED_HOME = "asked_home"
|
||||||
const val DOH = "doh"
|
const val DOH = "doh"
|
||||||
|
const val RAND_NAME = "rand_name"
|
||||||
}
|
}
|
||||||
|
|
||||||
object Value {
|
object Value {
|
||||||
@ -125,6 +126,7 @@ object Config : PreferenceConfig, DBConfig {
|
|||||||
var updateChannel by preferenceStrInt(Key.UPDATE_CHANNEL, defaultChannel)
|
var updateChannel by preferenceStrInt(Key.UPDATE_CHANNEL, defaultChannel)
|
||||||
var customChannelUrl by preference(Key.CUSTOM_CHANNEL, "")
|
var customChannelUrl by preference(Key.CUSTOM_CHANNEL, "")
|
||||||
var downloadDir by preference(Key.DOWNLOAD_DIR, "")
|
var downloadDir by preference(Key.DOWNLOAD_DIR, "")
|
||||||
|
var randName by preference(Key.RAND_NAME, true)
|
||||||
var checkUpdate
|
var checkUpdate
|
||||||
get() = checkUpdatePrefs
|
get() = checkUpdatePrefs
|
||||||
set(value) {
|
set(value) {
|
||||||
|
@ -71,14 +71,18 @@ abstract class MagiskInstallImpl protected constructor(
|
|||||||
private val localFS get() = FileSystemManager.getLocal()
|
private val localFS get() = FileSystemManager.getLocal()
|
||||||
|
|
||||||
private val destName: String by lazy {
|
private val destName: String by lazy {
|
||||||
val alpha = "abcdefghijklmnopqrstuvwxyz"
|
if (Config.randName) {
|
||||||
val alphaNum = "$alpha${alpha.uppercase(Locale.ROOT)}0123456789"
|
val alpha = "abcdefghijklmnopqrstuvwxyz"
|
||||||
val random = SecureRandom()
|
val alphaNum = "$alpha${alpha.uppercase(Locale.ROOT)}0123456789"
|
||||||
StringBuilder("magisk_patched-${BuildConfig.VERSION_CODE}_").run {
|
val random = SecureRandom()
|
||||||
for (i in 1..5) {
|
StringBuilder("magisk_patched-${BuildConfig.VERSION_CODE}_").run {
|
||||||
append(alphaNum[random.nextInt(alphaNum.length)])
|
for (i in 1..5) {
|
||||||
|
append(alphaNum[random.nextInt(alphaNum.length)])
|
||||||
|
}
|
||||||
|
toString()
|
||||||
}
|
}
|
||||||
toString()
|
} else {
|
||||||
|
"magisk_patched"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -440,7 +444,7 @@ abstract class MagiskInstallImpl protected constructor(
|
|||||||
|
|
||||||
srcBoot = if (tarMagic.contentEquals("ustar".toByteArray())) {
|
srcBoot = if (tarMagic.contentEquals("ustar".toByteArray())) {
|
||||||
// tar file
|
// tar file
|
||||||
outFile = MediaStoreUtils.getFile("$destName.tar", true)
|
outFile = MediaStoreUtils.getFile("$destName.tar")
|
||||||
outStream = TarArchiveOutputStream(outFile.uri.outputStream()).also {
|
outStream = TarArchiveOutputStream(outFile.uri.outputStream()).also {
|
||||||
it.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_STAR)
|
it.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_STAR)
|
||||||
it.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU)
|
it.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU)
|
||||||
@ -456,7 +460,7 @@ abstract class MagiskInstallImpl protected constructor(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// raw image
|
// raw image
|
||||||
outFile = MediaStoreUtils.getFile("$destName.img", true)
|
outFile = MediaStoreUtils.getFile("$destName.img")
|
||||||
outStream = outFile.uri.outputStream()
|
outStream = outFile.uri.outputStream()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -212,6 +212,12 @@ object SystemlessHosts : BaseSettingsItem.Blank() {
|
|||||||
override val description = R.string.settings_hosts_summary.asText()
|
override val description = R.string.settings_hosts_summary.asText()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object RandNameToggle : BaseSettingsItem.Toggle() {
|
||||||
|
override val title = R.string.settings_random_name_title.asText()
|
||||||
|
override val description = R.string.settings_random_name_description.asText()
|
||||||
|
override var value by Config::randName
|
||||||
|
}
|
||||||
|
|
||||||
// --- Magisk
|
// --- Magisk
|
||||||
|
|
||||||
object Magisk : BaseSettingsItem.Section() {
|
object Magisk : BaseSettingsItem.Section() {
|
||||||
|
@ -51,7 +51,7 @@ class SettingsViewModel : BaseViewModel(), BaseSettingsItem.Handler {
|
|||||||
// Manager
|
// Manager
|
||||||
list.addAll(listOf(
|
list.addAll(listOf(
|
||||||
AppSettings,
|
AppSettings,
|
||||||
UpdateChannel, UpdateChannelUrl, DoHToggle, UpdateChecker, DownloadPath
|
UpdateChannel, UpdateChannelUrl, DoHToggle, UpdateChecker, DownloadPath, RandNameToggle
|
||||||
))
|
))
|
||||||
if (Info.env.isActive && Const.USER_ID == 0) {
|
if (Info.env.isActive && Const.USER_ID == 0) {
|
||||||
if (hidden) list.add(Restore) else list.add(Hide)
|
if (hidden) list.add(Restore) else list.add(Hide)
|
||||||
|
@ -178,6 +178,8 @@
|
|||||||
<string name="setting_add_shortcut_summary">Add a pretty shortcut to the home screen in case the name and icon are difficult to recognize after hiding the app</string>
|
<string name="setting_add_shortcut_summary">Add a pretty shortcut to the home screen in case the name and icon are difficult to recognize after hiding the app</string>
|
||||||
<string name="settings_doh_title">DNS over HTTPS</string>
|
<string name="settings_doh_title">DNS over HTTPS</string>
|
||||||
<string name="settings_doh_description">Workaround DNS poisoning in some nations</string>
|
<string name="settings_doh_description">Workaround DNS poisoning in some nations</string>
|
||||||
|
<string name="settings_random_name_title">Randomize output name</string>
|
||||||
|
<string name="settings_random_name_description">Randomize the output file name of patched images and tar files to prevent detection</string>
|
||||||
|
|
||||||
<string name="multiuser_mode">Multiuser Mode</string>
|
<string name="multiuser_mode">Multiuser Mode</string>
|
||||||
<string name="settings_owner_only">Device Owner Only</string>
|
<string name="settings_owner_only">Device Owner Only</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user