0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-04 18:05:04 +00:00

Merge pull request #135 from ostajic/dev

New fixes for new root install using shell to get package install folder and version of package for devices where pm fails
This commit is contained in:
Tornike Khintibidze 2020-08-31 21:53:29 +04:00 committed by GitHub
commit c7075e2ccb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 72 additions and 7 deletions

View file

@ -52,8 +52,8 @@ class VancedDownloadService: Service() {
private var hashUrl = ""
private val yPkg = "com.google.android.youtube"
private val vancedVersionCode: Int = runBlocking { InternetTools.getJsonInt("vanced.json", "versionCode", application) }
private val vancedVersion = runBlocking { getObjectFromJson("$installUrl/vanced.json", "version") }
private val vancedVersionCode by lazy {runBlocking { InternetTools.getJsonInt("vanced.json", "versionCode", applicationContext) }}
private val vancedVersion by lazy { runBlocking { getObjectFromJson("$installUrl/vanced.json", "version") }}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
//registerReceiver(receiver, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE))

View file

@ -32,7 +32,7 @@ import kotlin.collections.ArrayList
class RootSplitInstallerService: Service() {
private var vancedVersionCode: Int = runBlocking { getJsonInt("vanced.json","versionCode", application) }
private val vancedVersionCode by lazy{ runBlocking { getJsonInt("vanced.json","versionCode", applicationContext) }}
private val yPkg = "com.google.android.youtube"
private val localBroadcastManager by lazy { LocalBroadcastManager.getInstance(this) }
@ -178,11 +178,10 @@ class RootSplitInstallerService: Service() {
//install Vanced
private fun overwriteBase(apkFile: FileInfo,baseApkFiles: ArrayList<FileInfo>, versionCode: Int): Boolean {
if (checkVersion(versionCode,baseApkFiles)) {
val path = getVPath()
val path = getPackageDir()
apkFile.file?.let {
val apath = it.absolutePath
if(path?.let { it1 -> moveAPK(apath, it1) }!!) {
SuFile.open(path).parent!!
return chConV(path)
}
@ -193,11 +192,11 @@ class RootSplitInstallerService: Service() {
//check version and perform action based on result
private fun checkVersion(versionCode: Int, baseApkFiles: ArrayList<FileInfo>): Boolean {
val path = getVPath()
val path = getPackageDir()
if (path != null) {
if(path.contains("/data/app/"))
{
when(getPkgVerCode(yPkg,packageManager)?.let { compareVersion(it,versionCode) })
when(getVersionNumber()?.let { compareVersion(it,versionCode) })
{
1 -> {return fixHigherVer(baseApkFiles) }
-1 -> {return fixLowerVer(baseApkFiles) }
@ -312,6 +311,70 @@ class RootSplitInstallerService: Service() {
}
private fun getVersionNumber(): Int?
{
try {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
packageManager.getPackageInfo(yPkg, 0)?.longVersionCode?.and(0xFFFFFFFF)?.toInt()
else
packageManager.getPackageInfo(yPkg, 0)?.versionCode
}
catch (e : Exception)
{
val execRes = Shell.su("dumpsys package com.google.android.youtube | grep versionCode").exec()
if(execRes.isSuccess)
{
val result = execRes.out
var version: Int = 0
for(line in result)
{
val versionCode = line.substringAfter("=")
val versionCodeFiltered = versionCode.substringBefore(" ")
if(version < Integer.valueOf(versionCodeFiltered))
{
version = Integer.valueOf(versionCodeFiltered)
}
}
return version
}
}
return null
}
private fun getPackageDir(): String?
{
val execRes = Shell.su("dumpsys package com.google.android.youtube | grep codePath").exec()
if(execRes.isSuccess)
{
val result = execRes.out
for (line in result)
{
if(line.contains("data/app")) return "${line.substringAfter("=")}/base.apk"
}
}
return null
/*
return try {
val p = getPkgInfo(yPkg)
p?.applicationInfo?.sourceDir
} catch (e: Exception) {
val execRes = Shell.su("dumpsys package com.google.android.youtube | grep codePath").exec()
if(execRes.isSuccess)
{
val result = execRes.out
for (line in result)
{
if(line.contains("data/app")) return line.substringAfter("=")
}
}
null
}
*/
}
}

View file

@ -44,6 +44,7 @@ object AppUtils {
status.contains("IFile_Missing") -> context.getString(R.string.ifile_missing)
status.contains("ModApk_Missing") -> context.getString(R.string.modapk_missing)
status.contains("Files_Missing_VA") -> context.getString(R.string.files_missing_va)
status.contains("Path_Missing") -> context.getString(R.string.path_missing)
else ->
if (MiuiHelper.isMiui())
context.getString(R.string.installation_miui)

View file

@ -109,5 +109,6 @@
<string name="installation_miui">Installation failed because MIUI Optimization is enabled. Disable MIUI Optimization, then try again.</string>
<string name="installation_storage">Installation failed due to a storage error.</string>
<string name="modapk_missing">Black/Dark apk missing from installer, This should not happen, please clear app data of manager</string>
<string name="path_missing">Stock Youtube Install Path Is Not Accessible Or Missing After Stock Split Install</string>
</resources>