Remove unnecessary App usage

This commit is contained in:
topjohnwu 2019-08-05 00:21:38 -07:00
parent 010e4de4e1
commit 223913c30a
3 changed files with 9 additions and 15 deletions

View File

@ -1,12 +1,11 @@
package com.topjohnwu.magisk.data.repository
import android.content.pm.PackageManager
import com.topjohnwu.magisk.App
import com.topjohnwu.magisk.Config
import com.topjohnwu.magisk.Info
import com.topjohnwu.magisk.data.database.base.su
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.model.entity.HideAppInfo
import com.topjohnwu.magisk.model.entity.HideTarget
@ -63,8 +62,8 @@ class MagiskRepository(
private val Boolean.state get() = if (this) "add" else "rm"
companion object {
private val blacklist = listOf(
let { val app: App by inject(); app }.packageName,
private val blacklist by lazy { listOf(
packageName,
"android",
"com.android.chrome",
"com.chrome.beta",
@ -72,7 +71,7 @@ class MagiskRepository(
"com.chrome.canary",
"com.android.webview",
"com.google.android.webview"
)
) }
}
}

View File

@ -10,16 +10,11 @@ import android.content.pm.PackageManager.*
import android.database.Cursor
import android.net.Uri
import android.provider.OpenableColumns
import com.topjohnwu.magisk.App
import com.topjohnwu.magisk.utils.FileProvider
import java.io.File
import java.io.FileNotFoundException
val packageName: String
get() {
val app: App by inject()
return app.packageName
}
val packageName: String get() = get<Context>().packageName
val PackageInfo.processes
get() = activities?.processNames.orEmpty() +

View File

@ -1,8 +1,8 @@
package com.topjohnwu.magisk.tasks
import android.content.Context
import android.net.Uri
import com.skoumal.teanity.extensions.subscribeK
import com.topjohnwu.magisk.App
import com.topjohnwu.magisk.Const
import com.topjohnwu.magisk.extensions.fileName
import com.topjohnwu.magisk.extensions.inject
@ -20,8 +20,8 @@ abstract class FlashZip(
private val logs: MutableList<String>
) {
private val app: App by inject()
private val installFolder = File(app.cacheDir, "flash").apply {
private val context: Context by inject()
private val installFolder = File(context.cacheDir, "flash").apply {
if (!exists()) mkdirs()
}
private val tmpFile: File = File(installFolder, "install.zip")
@ -43,7 +43,7 @@ abstract class FlashZip(
console.add("- Copying zip to temp directory")
runCatching {
app.readUri(mUri).use { input ->
context.readUri(mUri).use { input ->
tmpFile.outputStream().use { out -> input.copyTo(out) }
}
}.getOrElse {