mirror of
https://github.com/YTVanced/VancedManager
synced 2025-01-06 23:41:00 +00:00
Merge branch 'dev' of https://github.com/YTVanced/VancedManager into dev
This commit is contained in:
commit
fe6a0386f1
3 changed files with 20 additions and 0 deletions
|
@ -21,6 +21,7 @@
|
|||
<package android:name="com.vanced.android.apps.youtube.music" />
|
||||
<package android:name="com.google.android.apps.youtube.music" />
|
||||
<package android:name="com.mgoogle.android.gms" />
|
||||
<package android:name="com.android.vending" />
|
||||
</queries>
|
||||
|
||||
<application
|
||||
|
|
|
@ -22,6 +22,7 @@ object AppUtils: CoroutineScope by CoroutineScope(Dispatchers.IO) {
|
|||
const val musicRootPkg = "com.google.android.apps.youtube.music"
|
||||
const val microgPkg = "com.mgoogle.android.gms"
|
||||
const val managerPkg = APPLICATION_ID
|
||||
const val playStorePkg = "com.android.vending"
|
||||
|
||||
fun sendRefresh(context: Context): Job {
|
||||
return launch {
|
||||
|
|
|
@ -14,6 +14,7 @@ import com.vanced.manager.BuildConfig
|
|||
import com.vanced.manager.core.installer.AppInstallerService
|
||||
import com.vanced.manager.core.installer.AppUninstallerService
|
||||
import com.vanced.manager.utils.AppUtils.musicRootPkg
|
||||
import com.vanced.manager.utils.AppUtils.playStorePkg
|
||||
import com.vanced.manager.utils.AppUtils.sendCloseDialog
|
||||
import com.vanced.manager.utils.AppUtils.sendFailure
|
||||
import com.vanced.manager.utils.AppUtils.sendRefresh
|
||||
|
@ -214,6 +215,7 @@ object PackageHelper {
|
|||
val modApk: FileInfo? = fileInfoList.lastOrNull { modApkBool(it.name) }
|
||||
if (modApk != null) {
|
||||
if (overwriteBase(modApk, fileInfoList, appVerCode, pkg, app, context)) {
|
||||
setInstallerPackage(context, pkg, playStorePkg)
|
||||
Log.d(INSTALLER_TAG, "Finished installation")
|
||||
sendRefresh(context)
|
||||
sendCloseDialog(context)
|
||||
|
@ -649,4 +651,20 @@ object PackageHelper {
|
|||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun setInstallerPackage(context: Context, target: String, installer: String) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) return
|
||||
try {
|
||||
Log.d(INSTALLER_TAG, "Setting installer package to $installer for $target")
|
||||
val installerUid = context.packageManager.getPackageUid(installer, 0)
|
||||
val res = Shell.su("""su $installerUid -c 'pm set-installer $target $installer'""").exec()
|
||||
if (res.out.any { line -> line.contains("Success") }) {
|
||||
Log.d(INSTALLER_TAG, "Installer package successfully set")
|
||||
return
|
||||
}
|
||||
Log.d(INSTALLER_TAG, "Failed setting installer package")
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
Log.d(INSTALLER_TAG, "Installer package $installer not found. Skipping setting installer")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue