0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-16 07:45:06 +00:00

Merge pull request #147 from ostajic/dev

New Root Install Variant
This commit is contained in:
Zoran Ostojic 2020-09-13 03:49:35 +02:00 committed by GitHub
commit e798e929d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -34,7 +34,7 @@ class RootSplitInstallerService: Service() {
private val vancedVersionCode by lazy{ runBlocking { getJsonInt("vanced.json","versionCode", applicationContext) }}
private val yPkg = "com.google.android.youtube"
private val apkInstallPath = "/data/adb/Vanced/"
private val localBroadcastManager by lazy { LocalBroadcastManager.getInstance(this) }
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
@ -181,8 +181,23 @@ class RootSplitInstallerService: Service() {
val path = getPackageDir()
apkFile.file?.let {
val apath = it.absolutePath
if(path?.let { it1 -> moveAPK(apath, it1) }!!) {
return chConV(path)
setupFolder(apkInstallPath)
if(path != null)
{
val apkFPath = apkInstallPath + "base.apk"
if(moveAPK(apath, apkFPath))
{
if(chConV(apkFPath))
{
if(setupScript(apkFPath,path))
{
return linkVanced(apkFPath,path)
}
}
}
}
}
@ -190,6 +205,28 @@ class RootSplitInstallerService: Service() {
return false
}
private fun setupScript(apkFPath: String, path: String): Boolean
{
if(Shell.su("""echo "#!/system/bin/sh\nsleep 1m\nmount -o bind $apkFPath $path" > /data/adb/service.d/vanced.sh""").exec().isSuccess)
{
return Shell.su("chmod 744 /data/adb/service.d/vanced.sh").exec().isSuccess
}
return false
}
private fun linkVanced(apkFPath: String, path: String): Boolean
{
Shell.su("am force-stop $yPkg").exec()
Thread.sleep(500)
val response = Shell.su("""su -mm -c "mount -o bind $apkFPath $path"""").exec()
return response.isSuccess
}
private fun setupFolder(apkInstallPath: String): Boolean {
return Shell.su("mkdir -p $apkInstallPath").exec().isSuccess
}
//check version and perform action based on result
private fun checkVersion(versionCode: Int, baseApkFiles: ArrayList<FileInfo>): Boolean {
val path = getPackageDir()
@ -355,7 +392,6 @@ class RootSplitInstallerService: Service() {
{
if(line.contains("data/app")) "${line.substringAfter("=")}/base.apk"
}
}
null
}