Remove unnecessary App usage
This commit is contained in:
parent
010e4de4e1
commit
223913c30a
@ -1,12 +1,11 @@
|
|||||||
package com.topjohnwu.magisk.data.repository
|
package com.topjohnwu.magisk.data.repository
|
||||||
|
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import com.topjohnwu.magisk.App
|
|
||||||
import com.topjohnwu.magisk.Config
|
import com.topjohnwu.magisk.Config
|
||||||
import com.topjohnwu.magisk.Info
|
import com.topjohnwu.magisk.Info
|
||||||
import com.topjohnwu.magisk.data.database.base.su
|
import com.topjohnwu.magisk.data.database.base.su
|
||||||
import com.topjohnwu.magisk.data.network.GithubRawServices
|
import com.topjohnwu.magisk.data.network.GithubRawServices
|
||||||
import com.topjohnwu.magisk.extensions.inject
|
import com.topjohnwu.magisk.extensions.packageName
|
||||||
import com.topjohnwu.magisk.extensions.toSingle
|
import com.topjohnwu.magisk.extensions.toSingle
|
||||||
import com.topjohnwu.magisk.model.entity.HideAppInfo
|
import com.topjohnwu.magisk.model.entity.HideAppInfo
|
||||||
import com.topjohnwu.magisk.model.entity.HideTarget
|
import com.topjohnwu.magisk.model.entity.HideTarget
|
||||||
@ -63,8 +62,8 @@ class MagiskRepository(
|
|||||||
private val Boolean.state get() = if (this) "add" else "rm"
|
private val Boolean.state get() = if (this) "add" else "rm"
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val blacklist = listOf(
|
private val blacklist by lazy { listOf(
|
||||||
let { val app: App by inject(); app }.packageName,
|
packageName,
|
||||||
"android",
|
"android",
|
||||||
"com.android.chrome",
|
"com.android.chrome",
|
||||||
"com.chrome.beta",
|
"com.chrome.beta",
|
||||||
@ -72,7 +71,7 @@ class MagiskRepository(
|
|||||||
"com.chrome.canary",
|
"com.chrome.canary",
|
||||||
"com.android.webview",
|
"com.android.webview",
|
||||||
"com.google.android.webview"
|
"com.google.android.webview"
|
||||||
)
|
) }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -10,16 +10,11 @@ import android.content.pm.PackageManager.*
|
|||||||
import android.database.Cursor
|
import android.database.Cursor
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.provider.OpenableColumns
|
import android.provider.OpenableColumns
|
||||||
import com.topjohnwu.magisk.App
|
|
||||||
import com.topjohnwu.magisk.utils.FileProvider
|
import com.topjohnwu.magisk.utils.FileProvider
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileNotFoundException
|
import java.io.FileNotFoundException
|
||||||
|
|
||||||
val packageName: String
|
val packageName: String get() = get<Context>().packageName
|
||||||
get() {
|
|
||||||
val app: App by inject()
|
|
||||||
return app.packageName
|
|
||||||
}
|
|
||||||
|
|
||||||
val PackageInfo.processes
|
val PackageInfo.processes
|
||||||
get() = activities?.processNames.orEmpty() +
|
get() = activities?.processNames.orEmpty() +
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.topjohnwu.magisk.tasks
|
package com.topjohnwu.magisk.tasks
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import com.skoumal.teanity.extensions.subscribeK
|
import com.skoumal.teanity.extensions.subscribeK
|
||||||
import com.topjohnwu.magisk.App
|
|
||||||
import com.topjohnwu.magisk.Const
|
import com.topjohnwu.magisk.Const
|
||||||
import com.topjohnwu.magisk.extensions.fileName
|
import com.topjohnwu.magisk.extensions.fileName
|
||||||
import com.topjohnwu.magisk.extensions.inject
|
import com.topjohnwu.magisk.extensions.inject
|
||||||
@ -20,8 +20,8 @@ abstract class FlashZip(
|
|||||||
private val logs: MutableList<String>
|
private val logs: MutableList<String>
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private val app: App by inject()
|
private val context: Context by inject()
|
||||||
private val installFolder = File(app.cacheDir, "flash").apply {
|
private val installFolder = File(context.cacheDir, "flash").apply {
|
||||||
if (!exists()) mkdirs()
|
if (!exists()) mkdirs()
|
||||||
}
|
}
|
||||||
private val tmpFile: File = File(installFolder, "install.zip")
|
private val tmpFile: File = File(installFolder, "install.zip")
|
||||||
@ -43,7 +43,7 @@ abstract class FlashZip(
|
|||||||
console.add("- Copying zip to temp directory")
|
console.add("- Copying zip to temp directory")
|
||||||
|
|
||||||
runCatching {
|
runCatching {
|
||||||
app.readUri(mUri).use { input ->
|
context.readUri(mUri).use { input ->
|
||||||
tmpFile.outputStream().use { out -> input.copyTo(out) }
|
tmpFile.outputStream().use { out -> input.copyTo(out) }
|
||||||
}
|
}
|
||||||
}.getOrElse {
|
}.getOrElse {
|
||||||
|
Loading…
Reference in New Issue
Block a user