0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-28 22:13:01 +00:00

package refactor

This commit is contained in:
X1nto 2022-03-02 15:24:22 +04:00
parent d192c967d5
commit e010ed0e80
63 changed files with 331 additions and 310 deletions

View file

@ -41,8 +41,8 @@
android:theme="@style/Theme.MaterialComponents.NoActionBar"
android:label="@string/app_name"/>
<service android:name=".core.installer.service.AppInstallService" />
<service android:name=".core.installer.service.AppUninstallService" />
<service android:name="com.vanced.manager.installer.service.AppInstallService" />
<service android:name="com.vanced.manager.installer.service.AppUninstallService" />
</application>

View file

@ -1,21 +0,0 @@
package com.vanced.manager.core.util
import com.vanced.manager.domain.model.NotificationPrefModel
import com.vanced.manager.network.util.MICROG_NAME
import com.vanced.manager.network.util.MUSIC_NAME
import com.vanced.manager.network.util.VANCED_NAME
val notificationApps = arrayOf(
NotificationPrefModel(
app = VANCED_NAME,
prefKey = "vanced"
),
NotificationPrefModel(
app = MUSIC_NAME,
prefKey = "music"
),
NotificationPrefModel(
app = MICROG_NAME,
prefKey = "microg"
)
)

View file

@ -1,7 +0,0 @@
package com.vanced.manager.core.util
const val VANCED_YOUTUBE_PACKAGE = "com.vanced.android.youtube"
const val VANCED_YOUTUBE_PACKAGE_ROOT = "com.google.android.youtube"
const val VANCED_MUSIC_PACKAGE = "com.vanced.android.apps.youtube.music"
const val VANCED_MUSIC_PACKAGE_ROOT = "com.google.android.apps.youtube.music"

View file

@ -1,9 +0,0 @@
package com.vanced.manager.core.util
import android.os.Build
val arch get() = when {
Build.SUPPORTED_ABIS.contains("x86") -> "x86"
Build.SUPPORTED_ABIS.contains("arm64-v8a") -> "arm64_v8a"
else -> "armeabi_v7a"
}

View file

@ -1,61 +0,0 @@
package com.vanced.manager.core.util
import com.vanced.manager.R
import com.vanced.manager.domain.model.Link
import com.vanced.manager.network.util.*
val sponsors = listOf(
Link(
title = "Brave",
link = BRAVE,
icon = R.drawable.ic_brave
),
Link(
title = "Adguard",
link = ADGUARD,
icon = R.drawable.ic_adguard
)
)
val socialMedia = listOf(
Link(
title = "Instagram",
link = INSTAGRAM,
icon = R.drawable.ic_instagram
),
Link(
title = "YouTube",
link = YOUTUBE,
icon = R.drawable.ic_youtube
),
Link(
title = "GitHub",
link = GITHUB,
icon = R.drawable.ic_github
),
Link(
title = "Website",
link = WEBSITE,
icon = R.drawable.ic_website
),
Link(
title = "Telegram",
link = TELEGRAM,
icon = R.drawable.ic_telegram
),
Link(
title = "Twitter",
link = TWITTER,
icon = R.drawable.ic_twitter
),
Link(
title = "Discord",
link = DISCORD,
icon = R.drawable.ic_discord
),
Link(
title = "Reddit",
link = REDDIT,
icon = R.drawable.ic_reddit
),
)

View file

@ -1,8 +1,8 @@
package com.vanced.manager.di
import com.vanced.manager.core.downloader.api.MicrogAPI
import com.vanced.manager.core.downloader.api.MusicAPI
import com.vanced.manager.core.downloader.api.VancedAPI
import com.vanced.manager.downloader.api.MicrogAPI
import com.vanced.manager.downloader.api.MusicAPI
import com.vanced.manager.downloader.api.VancedAPI
import com.vanced.manager.network.util.BASE
import okhttp3.OkHttpClient
import org.koin.dsl.module

View file

@ -1,10 +1,10 @@
package com.vanced.manager.di
import android.content.Context
import com.vanced.manager.datasource.PkgInfoDatasource
import com.vanced.manager.datasource.PkgInfoDatasourceImpl
import com.vanced.manager.datasource.PreferenceDatasource
import com.vanced.manager.datasource.PreferenceDatasourceImpl
import com.vanced.manager.repository.source.PkgInfoDatasource
import com.vanced.manager.repository.source.PkgInfoDatasourceImpl
import com.vanced.manager.repository.source.PreferenceDatasource
import com.vanced.manager.repository.source.PreferenceDatasourceImpl
import org.koin.android.ext.koin.androidContext
import org.koin.dsl.module
@ -22,7 +22,10 @@ val datasourceModule = module {
context: Context
): PreferenceDatasource {
return PreferenceDatasourceImpl(
sharedPreferences = context.getSharedPreferences("manager_settings", Context.MODE_PRIVATE)
sharedPreferences = context.getSharedPreferences(
"manager_settings",
Context.MODE_PRIVATE
)
)
}

View file

@ -1,12 +1,12 @@
package com.vanced.manager.di
import android.content.Context
import com.vanced.manager.core.downloader.api.MicrogAPI
import com.vanced.manager.core.downloader.api.MusicAPI
import com.vanced.manager.core.downloader.api.VancedAPI
import com.vanced.manager.core.downloader.impl.MicrogDownloader
import com.vanced.manager.core.downloader.impl.MusicDownloader
import com.vanced.manager.core.downloader.impl.VancedDownloader
import com.vanced.manager.downloader.api.MicrogAPI
import com.vanced.manager.downloader.api.MusicAPI
import com.vanced.manager.downloader.api.VancedAPI
import com.vanced.manager.downloader.impl.MicrogDownloader
import com.vanced.manager.downloader.impl.MusicDownloader
import com.vanced.manager.downloader.impl.VancedDownloader
import org.koin.android.ext.koin.androidContext
import org.koin.dsl.module

View file

@ -1,9 +1,9 @@
package com.vanced.manager.di
import android.content.Context
import com.vanced.manager.core.installer.impl.MicrogInstaller
import com.vanced.manager.core.installer.impl.MusicInstaller
import com.vanced.manager.core.installer.impl.VancedInstaller
import com.vanced.manager.installer.impl.MicrogInstaller
import com.vanced.manager.installer.impl.MusicInstaller
import com.vanced.manager.installer.impl.VancedInstaller
import org.koin.android.ext.koin.androidContext
import org.koin.dsl.module

View file

@ -1,9 +1,12 @@
package com.vanced.manager.di
import com.vanced.manager.datasource.PkgInfoDatasource
import com.vanced.manager.datasource.PreferenceDatasource
import com.vanced.manager.network.GithubService
import com.vanced.manager.repository.*
import com.vanced.manager.repository.AppRepository
import com.vanced.manager.repository.AppRepositoryImpl
import com.vanced.manager.repository.PreferenceRepository
import com.vanced.manager.repository.PreferenceRepositoryImpl
import com.vanced.manager.repository.source.PkgInfoDatasource
import com.vanced.manager.repository.source.PreferenceDatasource
import org.koin.dsl.module
val repositoryModule = module {

View file

@ -1,12 +1,12 @@
package com.vanced.manager.di
import android.app.Application
import com.vanced.manager.core.downloader.impl.MicrogDownloader
import com.vanced.manager.core.downloader.impl.MusicDownloader
import com.vanced.manager.core.downloader.impl.VancedDownloader
import com.vanced.manager.core.installer.impl.MicrogInstaller
import com.vanced.manager.core.installer.impl.MusicInstaller
import com.vanced.manager.core.installer.impl.VancedInstaller
import com.vanced.manager.downloader.impl.MicrogDownloader
import com.vanced.manager.downloader.impl.MusicDownloader
import com.vanced.manager.downloader.impl.VancedDownloader
import com.vanced.manager.installer.impl.MicrogInstaller
import com.vanced.manager.installer.impl.MusicInstaller
import com.vanced.manager.installer.impl.VancedInstaller
import com.vanced.manager.repository.AppRepository
import com.vanced.manager.repository.PreferenceRepository
import com.vanced.manager.ui.viewmodel.ConfigurationViewModel

View file

@ -37,7 +37,8 @@ object AppData {
const val PACKAGE_ROOT_VANCED_YOUTUBE_MUSIC = "com.google.android.youtube.apps.music"
const val LAUNCH_ACTIVITY_VANCED_YOUTUBE = "com.google.android.youtube.HomeActivity"
const val LAUNCH_ACTIVITY_VANCED_YOUTUBE_MUSIC = "com.google.android.apps.youtube.music.activities.MusicActivity"
const val LAUNCH_ACTIVITY_VANCED_YOUTUBE_MUSIC =
"com.google.android.apps.youtube.music.activities.MusicActivity"
const val LAUNCH_ACTIVITY_VANCED_MICROG = "org.microg.gms.ui.SettingsActivity"
const val LAUNCH_ACTIVITY_VANCED_MANAGER = ""
}

View file

@ -1,9 +0,0 @@
package com.vanced.manager.domain.model
import androidx.annotation.DrawableRes
data class Link(
val title: String,
val link: String,
@DrawableRes val icon: Int
)

View file

@ -1,6 +0,0 @@
package com.vanced.manager.domain.model
data class NotificationPrefModel(
val app: String,
val prefKey: String
)

View file

@ -1,4 +1,4 @@
package com.vanced.manager.core.downloader.api
package com.vanced.manager.downloader.api
import okhttp3.ResponseBody
import retrofit2.Call

View file

@ -1,4 +1,4 @@
package com.vanced.manager.core.downloader.api
package com.vanced.manager.downloader.api
import okhttp3.ResponseBody
import retrofit2.Call

View file

@ -1,4 +1,4 @@
package com.vanced.manager.core.downloader.api
package com.vanced.manager.downloader.api
import okhttp3.ResponseBody
import retrofit2.Call

View file

@ -1,6 +1,6 @@
package com.vanced.manager.core.downloader.base
package com.vanced.manager.downloader.base
import com.vanced.manager.core.io.writeFile
import com.vanced.manager.util.writeFile
import okhttp3.ResponseBody
import retrofit2.Call
import retrofit2.awaitResponse

View file

@ -1,9 +1,9 @@
package com.vanced.manager.core.downloader.impl
package com.vanced.manager.downloader.impl
import android.content.Context
import com.vanced.manager.core.downloader.api.MicrogAPI
import com.vanced.manager.core.downloader.base.AppDownloader
import com.vanced.manager.core.downloader.util.getMicrogPath
import com.vanced.manager.downloader.api.MicrogAPI
import com.vanced.manager.downloader.base.AppDownloader
import com.vanced.manager.downloader.util.getMicrogPath
import java.io.File
class MicrogDownloader(

View file

@ -1,12 +1,12 @@
package com.vanced.manager.core.downloader.impl
package com.vanced.manager.downloader.impl
import android.content.Context
import com.vanced.manager.core.downloader.api.MusicAPI
import com.vanced.manager.core.downloader.base.AppDownloader
import com.vanced.manager.core.downloader.util.getVancedYoutubeMusicPath
import com.vanced.manager.core.preferences.holder.managerVariantPref
import com.vanced.manager.core.preferences.holder.musicVersionPref
import com.vanced.manager.core.util.getLatestOrProvidedAppVersion
import com.vanced.manager.downloader.api.MusicAPI
import com.vanced.manager.downloader.base.AppDownloader
import com.vanced.manager.downloader.util.getVancedYoutubeMusicPath
import com.vanced.manager.preferences.holder.managerVariantPref
import com.vanced.manager.preferences.holder.musicVersionPref
import com.vanced.manager.util.getLatestOrProvidedAppVersion
import java.io.File
class MusicDownloader(
@ -51,7 +51,8 @@ class MusicDownloader(
}
override fun getSavedFilePath(): String {
val directory = File(getVancedYoutubeMusicPath(absoluteVersion, managerVariantPref, context))
val directory =
File(getVancedYoutubeMusicPath(absoluteVersion, managerVariantPref, context))
if (!directory.exists())
directory.mkdirs()

View file

@ -1,15 +1,15 @@
package com.vanced.manager.core.downloader.impl
package com.vanced.manager.downloader.impl
import android.content.Context
import com.vanced.manager.core.downloader.api.VancedAPI
import com.vanced.manager.core.downloader.base.AppDownloader
import com.vanced.manager.core.downloader.util.getVancedYoutubePath
import com.vanced.manager.core.preferences.holder.managerVariantPref
import com.vanced.manager.core.preferences.holder.vancedLanguagesPref
import com.vanced.manager.core.preferences.holder.vancedThemePref
import com.vanced.manager.core.preferences.holder.vancedVersionPref
import com.vanced.manager.core.util.arch
import com.vanced.manager.core.util.getLatestOrProvidedAppVersion
import com.vanced.manager.downloader.api.VancedAPI
import com.vanced.manager.downloader.base.AppDownloader
import com.vanced.manager.downloader.util.getVancedYoutubePath
import com.vanced.manager.preferences.holder.managerVariantPref
import com.vanced.manager.preferences.holder.vancedLanguagesPref
import com.vanced.manager.preferences.holder.vancedThemePref
import com.vanced.manager.preferences.holder.vancedVersionPref
import com.vanced.manager.util.arch
import com.vanced.manager.util.getLatestOrProvidedAppVersion
import java.io.File
class VancedDownloader(

View file

@ -1,4 +1,4 @@
package com.vanced.manager.core.downloader.util
package com.vanced.manager.downloader.util
import android.content.Context

View file

@ -1,6 +1,6 @@
package com.vanced.manager.core.installer.base
package com.vanced.manager.installer.base
import com.vanced.manager.core.installer.util.PMRootResult
import com.vanced.manager.installer.util.PMRootResult
abstract class AppInstaller {

View file

@ -1,10 +1,10 @@
package com.vanced.manager.core.installer.impl
package com.vanced.manager.installer.impl
import android.content.Context
import com.vanced.manager.core.downloader.util.getMicrogPath
import com.vanced.manager.core.installer.base.AppInstaller
import com.vanced.manager.core.installer.util.PM
import com.vanced.manager.core.installer.util.PMRootResult
import com.vanced.manager.downloader.util.getMicrogPath
import com.vanced.manager.installer.base.AppInstaller
import com.vanced.manager.installer.util.PM
import com.vanced.manager.installer.util.PMRootResult
import java.io.File
class MicrogInstaller(

View file

@ -1,15 +1,18 @@
package com.vanced.manager.core.installer.impl
package com.vanced.manager.installer.impl
import android.content.Context
import com.vanced.manager.core.downloader.util.getStockYoutubeMusicPath
import com.vanced.manager.core.downloader.util.getVancedYoutubeMusicPath
import com.vanced.manager.core.installer.base.AppInstaller
import com.vanced.manager.core.installer.util.*
import com.vanced.manager.core.preferences.holder.managerVariantPref
import com.vanced.manager.core.preferences.holder.musicVersionPref
import com.vanced.manager.core.preferences.holder.vancedVersionPref
import com.vanced.manager.core.util.VANCED_MUSIC_PACKAGE_ROOT
import com.vanced.manager.core.util.getLatestOrProvidedAppVersion
import com.vanced.manager.domain.model.AppData
import com.vanced.manager.downloader.util.getStockYoutubeMusicPath
import com.vanced.manager.downloader.util.getVancedYoutubeMusicPath
import com.vanced.manager.installer.base.AppInstaller
import com.vanced.manager.installer.util.PM
import com.vanced.manager.installer.util.PMRoot
import com.vanced.manager.installer.util.PMRootResult
import com.vanced.manager.installer.util.RootPatchHelper
import com.vanced.manager.preferences.holder.managerVariantPref
import com.vanced.manager.preferences.holder.musicVersionPref
import com.vanced.manager.preferences.holder.vancedVersionPref
import com.vanced.manager.util.getLatestOrProvidedAppVersion
import java.io.File
class MusicInstaller(
@ -21,7 +24,13 @@ class MusicInstaller(
) {
val absoluteVersion = getLatestOrProvidedAppVersion(musicVersionPref, appVersions)
val musicApk = File(getVancedYoutubeMusicPath(absoluteVersion, managerVariantPref, context) + "/music.apk")
val musicApk = File(
getVancedYoutubeMusicPath(
absoluteVersion,
managerVariantPref,
context
) + "/music.apk"
)
PM.installApp(musicApk, context)
}
@ -33,7 +42,7 @@ class MusicInstaller(
val vancedPath = getVancedYoutubeMusicPath(absoluteVersion, "root", context) + "/base.apk"
val prepareStock = RootPatchHelper.prepareStock(
stockPackage = VANCED_MUSIC_PACKAGE_ROOT,
stockPackage = AppData.PACKAGE_ROOT_VANCED_YOUTUBE_MUSIC,
stockVersion = absoluteVersion
) {
PMRoot.installApp(stockPath)
@ -43,7 +52,7 @@ class MusicInstaller(
val patchStock = RootPatchHelper.patchStock(
patchPath = vancedPath,
stockPackage = VANCED_MUSIC_PACKAGE_ROOT,
stockPackage = AppData.PACKAGE_ROOT_VANCED_YOUTUBE_MUSIC,
app = APP_KEY
)
if (patchStock.isError)

View file

@ -1,13 +1,16 @@
package com.vanced.manager.core.installer.impl
package com.vanced.manager.installer.impl
import android.content.Context
import com.vanced.manager.core.downloader.util.getStockYoutubePath
import com.vanced.manager.core.downloader.util.getVancedYoutubePath
import com.vanced.manager.core.installer.base.AppInstaller
import com.vanced.manager.core.installer.util.*
import com.vanced.manager.core.preferences.holder.vancedVersionPref
import com.vanced.manager.core.util.VANCED_YOUTUBE_PACKAGE_ROOT
import com.vanced.manager.core.util.getLatestOrProvidedAppVersion
import com.vanced.manager.domain.model.AppData
import com.vanced.manager.downloader.util.getStockYoutubePath
import com.vanced.manager.downloader.util.getVancedYoutubePath
import com.vanced.manager.installer.base.AppInstaller
import com.vanced.manager.installer.util.PM
import com.vanced.manager.installer.util.PMRoot
import com.vanced.manager.installer.util.PMRootResult
import com.vanced.manager.installer.util.RootPatchHelper
import com.vanced.manager.preferences.holder.vancedVersionPref
import com.vanced.manager.util.getLatestOrProvidedAppVersion
import java.io.File
class VancedInstaller(
@ -33,7 +36,7 @@ class VancedInstaller(
val vancedBaseApk = getVancedYoutubePath(absoluteVersion, "root", context) + "/base.apk"
val prepareStock = RootPatchHelper.prepareStock(
stockPackage = VANCED_YOUTUBE_PACKAGE_ROOT,
stockPackage = AppData.PACKAGE_ROOT_VANCED_YOUTUBE,
stockVersion = absoluteVersion,
) {
PMRoot.installSplitApp(stockApks!!)
@ -43,7 +46,7 @@ class VancedInstaller(
val patchStock = RootPatchHelper.patchStock(
patchPath = vancedBaseApk,
stockPackage = VANCED_YOUTUBE_PACKAGE_ROOT,
stockPackage = AppData.PACKAGE_ROOT_VANCED_YOUTUBE,
app = APP_KEY
)
if (patchStock.isError)

View file

@ -1,4 +1,4 @@
package com.vanced.manager.core.installer.service
package com.vanced.manager.installer.service
import android.app.Service
import android.content.Intent

View file

@ -1,4 +1,4 @@
package com.vanced.manager.core.installer.service
package com.vanced.manager.installer.service
import android.app.Service
import android.content.Intent

View file

@ -1,4 +1,4 @@
package com.vanced.manager.core.installer.util
package com.vanced.manager.installer.util
import android.app.PendingIntent
import android.content.Context
@ -6,8 +6,8 @@ import android.content.Intent
import android.content.pm.PackageInstaller
import android.content.pm.PackageManager
import android.os.Build
import com.vanced.manager.core.installer.service.AppInstallService
import com.vanced.manager.core.installer.service.AppUninstallService
import com.vanced.manager.installer.service.AppInstallService
import com.vanced.manager.installer.service.AppUninstallService
import java.io.File
private const val byteArraySize = 1024 * 1024 // Because 1,048,576 is not readable

View file

@ -1,10 +1,10 @@
package com.vanced.manager.core.installer.util
package com.vanced.manager.installer.util
import com.topjohnwu.superuser.Shell
import com.topjohnwu.superuser.io.SuFile
import com.topjohnwu.superuser.io.SuFileOutputStream
import com.vanced.manager.core.util.errString
import com.vanced.manager.core.util.outString
import com.vanced.manager.util.errString
import com.vanced.manager.util.outString
import java.io.File
import java.io.IOException
@ -13,7 +13,10 @@ object PMRoot {
fun installApp(apkPath: String): PMRootResult<Nothing> {
val apk = File(apkPath)
val tmpApk = copyApkToTemp(apk).getOrElse { exception ->
return PMRootResult.Error(PMRootStatus.SESSION_FAILED_COPY, exception.stackTraceToString())
return PMRootResult.Error(
PMRootStatus.SESSION_FAILED_COPY,
exception.stackTraceToString()
)
}
val install = Shell.su("pm", "install", "-r", tmpApk.absolutePath).exec()
@ -42,7 +45,10 @@ object PMRoot {
for (apkPath in apkPaths) {
val apk = File(apkPath)
val tmpApk = copyApkToTemp(apk).getOrElse { exception ->
return PMRootResult.Error(PMRootStatus.SESSION_FAILED_COPY, exception.stackTraceToString())
return PMRootResult.Error(
PMRootStatus.SESSION_FAILED_COPY,
exception.stackTraceToString()
)
}
val installWrite =
@ -79,7 +85,10 @@ object PMRoot {
.exec()
if (!setInstaller.isSuccess)
return PMRootResult.Error(PMRootStatus.ACTION_FAILED_SET_INSTALLER, setInstaller.errString)
return PMRootResult.Error(
PMRootStatus.ACTION_FAILED_SET_INSTALLER,
setInstaller.errString
)
return PMRootResult.Success()
}
@ -98,8 +107,10 @@ object PMRoot {
val dumpsys = Shell.su("dumpsys", "package", pkg, "|", "grep", keyword).exec()
if (!dumpsys.isSuccess)
return PMRootResult.Error(PMRootStatus.ACTION_FAILED_GET_PACKAGE_VERSION_NAME,
dumpsys.errString)
return PMRootResult.Error(
PMRootStatus.ACTION_FAILED_GET_PACKAGE_VERSION_NAME,
dumpsys.errString
)
return PMRootResult.Success(dumpsys.outString.removePrefix(keyword))
}
@ -109,11 +120,15 @@ object PMRoot {
val dumpsys = Shell.su("dumpsys", "package", pkg, "|", "grep", keyword).exec()
if (!dumpsys.isSuccess)
return PMRootResult.Error(PMRootStatus.ACTION_FAILED_GET_PACKAGE_VERSION_CODE,
dumpsys.errString)
return PMRootResult.Error(
PMRootStatus.ACTION_FAILED_GET_PACKAGE_VERSION_CODE,
dumpsys.errString
)
return PMRootResult.Success(dumpsys.outString.removePrefix(keyword).substringAfter("minSdk")
.toLong())
return PMRootResult.Success(
dumpsys.outString.removePrefix(keyword).substringAfter("minSdk")
.toLong()
)
}
fun getPackageDir(pkg: String): PMRootResult<String> {
@ -127,7 +142,7 @@ object PMRoot {
}
}
private fun copyApkToTemp(apk: File, ): Result<SuFile> {
private fun copyApkToTemp(apk: File): Result<SuFile> {
val tmpPath = "/data/local/tmp/${apk.name}"
val tmpApk = SuFile(tmpPath).apply {

View file

@ -1,4 +1,4 @@
package com.vanced.manager.core.installer.util
package com.vanced.manager.installer.util
enum class PMRootStatus {
ACTION_FAILED_SET_INSTALLER,

View file

@ -1,11 +1,11 @@
package com.vanced.manager.core.installer.util
package com.vanced.manager.installer.util
import com.topjohnwu.superuser.Shell
import com.topjohnwu.superuser.io.SuFile
import com.topjohnwu.superuser.io.SuFileOutputStream
import com.vanced.manager.core.io.ManagerSuFile
import com.vanced.manager.core.io.SUIOException
import com.vanced.manager.core.util.errString
import com.vanced.manager.io.ManagerSuFile
import com.vanced.manager.io.SUIOException
import com.vanced.manager.util.errString
import java.io.File
import java.io.IOException
@ -24,13 +24,17 @@ object Patcher {
val copyServiceDScript = copyScriptToDestination(postFsDataScript, postFsDataScriptPath)
if (copyServiceDScript.isFailure)
return PMRootResult.Error(PMRootStatus.SCRIPT_FAILED_SETUP_POST_FS,
copyServiceDScript.exceptionOrNull()!!.stackTraceToString())
return PMRootResult.Error(
PMRootStatus.SCRIPT_FAILED_SETUP_POST_FS,
copyServiceDScript.exceptionOrNull()!!.stackTraceToString()
)
val copyPostFsDataScript = copyScriptToDestination(serviceDScript, serviceDScriptPath)
if (copyPostFsDataScript.isFailure)
return PMRootResult.Error(PMRootStatus.SCRIPT_FAILED_SETUP_SERVICE_D,
copyPostFsDataScript.exceptionOrNull()!!.stackTraceToString())
return PMRootResult.Error(
PMRootStatus.SCRIPT_FAILED_SETUP_SERVICE_D,
copyPostFsDataScript.exceptionOrNull()!!.stackTraceToString()
)
return PMRootResult.Success()
}
@ -72,11 +76,15 @@ object Patcher {
}
fun linkPatch(app: String, stockPackage: String, stockPath: String): PMRootResult<Nothing> {
val umount = Shell.su("""for i in ${'$'}(ls /data/app/ | grep $stockPackage | tr " "); do umount -l "/data/app/${"$"}i/base.apk"; done """).exec()
val umount =
Shell.su("""for i in ${'$'}(ls /data/app/ | grep $stockPackage | tr " "); do umount -l "/data/app/${"$"}i/base.apk"; done """)
.exec()
if (!umount.isSuccess)
return PMRootResult.Error(PMRootStatus.LINK_FAILED_UNMOUNT, umount.errString)
val mount = Shell.su("su", "-mm", "-c", """"mount -o bind ${getAppPatchPath(app)} $stockPath"""").exec()
val mount =
Shell.su("su", "-mm", "-c", """"mount -o bind ${getAppPatchPath(app)} $stockPath"""")
.exec()
if (!mount.isSuccess)
return PMRootResult.Error(PMRootStatus.LINK_FAILED_MOUNT, mount.errString)

View file

@ -1,4 +1,4 @@
package com.vanced.manager.core.installer.util
package com.vanced.manager.installer.util
object RootPatchHelper {

View file

@ -1,11 +1,10 @@
package com.vanced.manager.core.io
package com.vanced.manager.io
import com.topjohnwu.superuser.Shell
import com.topjohnwu.superuser.io.SuFile
import com.vanced.manager.core.util.errString
import com.vanced.manager.core.util.outString
import com.vanced.manager.util.errString
import com.vanced.manager.util.outString
import java.io.File
import java.io.IOException
class ManagerSuFile : SuFile {
@ -15,9 +14,7 @@ class ManagerSuFile : SuFile {
}
constructor(pathName: String) : super(pathName)
constructor(parent: String, child: String) : super(parent, child)
constructor(parent: File, child: String) : super(parent, child)
private fun cmd(input: String): SuFileResult {
@ -35,5 +32,4 @@ class ManagerSuFile : SuFile {
return true
}
}

View file

@ -1,4 +1,4 @@
package com.vanced.manager.core.io
package com.vanced.manager.io
import java.io.IOException

View file

@ -8,14 +8,14 @@ const val VANCED_NAME = "YouTube Vanced"
const val MUSIC_NAME = "YouTube Vanced Music"
const val MICROG_NAME = "Vanced microG"
const val BRAVE = "https://vancedapp.com/brave"
const val ADGUARD = "https://adguard.com/?aid=31141&source=manager"
const val URL_SPONSOR_BRAVE = "https://vancedapp.com/brave"
const val URL_SPONSOR_ADGUARD = "https://adguard.com/?aid=31141&source=manager"
const val INSTAGRAM = "https://instagram.com/vanced.youtube"
const val YOUTUBE = "https://youtube.com/c/YouTubeVanced"
const val GITHUB = "https://github.com/YTVanced/VancedManager"
const val WEBSITE = "https://vancedapp.com"
const val TELEGRAM = "https://t.me/joinchat/AAAAAEHf-pi4jH1SDlAL4w"
const val TWITTER = "https://twitter.com/YTVanced"
const val DISCORD = "https://discord.gg/WCGNdRruzb"
const val REDDIT = "https://www.reddit.com/r/Vanced/"
const val URL_MEDIA_INSTAGRAM = "https://instagram.com/vanced.youtube"
const val URL_MEDIA_YOUTUBE = "https://youtube.com/c/YouTubeVanced"
const val URL_MEDIA_GITHUB = "https://github.com/YTVanced/VancedManager"
const val URL_MEDIA_WEBSITE = "https://vancedapp.com"
const val URL_MEDIA_TELEGRAM = "https://t.me/joinchat/AAAAAEHf-pi4jH1SDlAL4w"
const val URL_MEDIA_TWITTER = "https://twitter.com/YTVanced"
const val URL_MEDIA_DISCORD = "https://discord.gg/WCGNdRruzb"
const val URL_MEDIA_REDDIT = "https://www.reddit.com/r/Vanced/"

View file

@ -1,4 +1,4 @@
package com.vanced.manager.core.preferences
package com.vanced.manager.preferences
import android.content.SharedPreferences
import androidx.compose.runtime.getValue

View file

@ -1,4 +1,4 @@
package com.vanced.manager.core.preferences.holder
package com.vanced.manager.preferences.holder
const val MANAGER_VARIANT_DEFAULT_VALUE = "nonroot"

View file

@ -1,7 +1,7 @@
package com.vanced.manager.core.preferences.holder
package com.vanced.manager.preferences.holder
import com.vanced.manager.core.preferences.managerStringPreference
import com.vanced.manager.core.preferences.managerStringSetPreference
import com.vanced.manager.preferences.managerStringPreference
import com.vanced.manager.preferences.managerStringSetPreference
var managerVariantPref by managerStringPreference(
MANAGER_VARIANT_KEY,

View file

@ -1,4 +1,4 @@
package com.vanced.manager.core.preferences.holder
package com.vanced.manager.preferences.holder
const val USE_CUSTOM_TABS_KEY = "use_custom_tabs"
const val MANAGER_VARIANT_KEY = "manager_variant"

View file

@ -1,12 +1,12 @@
package com.vanced.manager.repository
import com.vanced.manager.datasource.PkgInfoDatasource
import com.vanced.manager.domain.model.App
import com.vanced.manager.domain.model.AppData
import com.vanced.manager.domain.model.AppState
import com.vanced.manager.domain.model.AppType
import com.vanced.manager.domain.model.App
import com.vanced.manager.network.GithubService
import com.vanced.manager.network.dto.GithubReleaseDto
import com.vanced.manager.repository.source.PkgInfoDatasource
interface AppRepository {
@ -54,8 +54,10 @@ class AppRepositoryImpl(
val githubRelease = githubService.getVancedYoutubeRelease()
val remoteVersionCode = githubRelease.getVersionCode()
val remoteVersionName = githubRelease.getVersionName()
val installedVersionCode = pkgInfoDatasource.getVersionCode(AppData.PACKAGE_ROOT_VANCED_YOUTUBE)
val installedVersionName = pkgInfoDatasource.getVersionName(AppData.PACKAGE_ROOT_VANCED_YOUTUBE)
val installedVersionCode =
pkgInfoDatasource.getVersionCode(AppData.PACKAGE_ROOT_VANCED_YOUTUBE)
val installedVersionName =
pkgInfoDatasource.getVersionName(AppData.PACKAGE_ROOT_VANCED_YOUTUBE)
return App(
name = AppData.NAME_VANCED_YOUTUBE,
iconResId = AppData.ICON_VANCED_YOUTUBE,
@ -75,8 +77,10 @@ class AppRepositoryImpl(
val githubRelease = githubService.getVancedYoutubeMusicRelease()
val remoteVersionCode = githubRelease.getVersionCode()
val remoteVersionName = githubRelease.getVersionName()
val installedVersionCode = pkgInfoDatasource.getVersionCode(AppData.PACKAGE_VANCED_YOUTUBE_MUSIC)
val installedVersionName = pkgInfoDatasource.getVersionName(AppData.PACKAGE_VANCED_YOUTUBE_MUSIC)
val installedVersionCode =
pkgInfoDatasource.getVersionCode(AppData.PACKAGE_VANCED_YOUTUBE_MUSIC)
val installedVersionName =
pkgInfoDatasource.getVersionName(AppData.PACKAGE_VANCED_YOUTUBE_MUSIC)
return App(
name = AppData.NAME_VANCED_YOUTUBE_MUSIC,
iconResId = AppData.ICON_VANCED_YOUTUBE_MUSIC,
@ -96,8 +100,10 @@ class AppRepositoryImpl(
val githubRelease = githubService.getVancedYoutubeMusicRelease()
val remoteVersionCode = githubRelease.getVersionCode()
val remoteVersionName = githubRelease.getVersionName()
val installedVersionCode = pkgInfoDatasource.getVersionCode(AppData.PACKAGE_ROOT_VANCED_YOUTUBE_MUSIC)
val installedVersionName = pkgInfoDatasource.getVersionName(AppData.PACKAGE_ROOT_VANCED_YOUTUBE_MUSIC)
val installedVersionCode =
pkgInfoDatasource.getVersionCode(AppData.PACKAGE_ROOT_VANCED_YOUTUBE_MUSIC)
val installedVersionName =
pkgInfoDatasource.getVersionName(AppData.PACKAGE_ROOT_VANCED_YOUTUBE_MUSIC)
return App(
name = AppData.NAME_VANCED_YOUTUBE_MUSIC,
iconResId = AppData.ICON_VANCED_YOUTUBE_MUSIC,

View file

@ -2,8 +2,8 @@ package com.vanced.manager.repository
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import com.vanced.manager.datasource.PreferenceData
import com.vanced.manager.datasource.PreferenceDatasource
import com.vanced.manager.repository.source.PreferenceData
import com.vanced.manager.repository.source.PreferenceDatasource
interface PreferenceRepository {

View file

@ -1,4 +1,4 @@
package com.vanced.manager.datasource
package com.vanced.manager.repository.source
import android.annotation.SuppressLint
import android.content.pm.PackageManager
@ -40,7 +40,7 @@ class PkgInfoDatasourceImpl(
@SuppressLint("WrongConstant")
override fun getVersionName(packageName: String): String? {
return try {
packageManager
packageManager
.getPackageInfo(packageName, FLAG_NOTHING)
.versionName
} catch (e: PackageManager.NameNotFoundException) {

View file

@ -1,4 +1,4 @@
package com.vanced.manager.datasource
package com.vanced.manager.repository.source
import android.content.SharedPreferences
@ -15,19 +15,28 @@ class PreferenceDatasourceImpl(
) : PreferenceDatasource {
override var managerUseCustomTabs: Boolean
get() = getBoolean(PreferenceData.MANAGER_USE_CUSTOM_TABS_KEY, PreferenceData.MANAGER_USE_CUSTOM_TABS_DEFAULT_VALUE)
get() = getBoolean(
PreferenceData.MANAGER_USE_CUSTOM_TABS_KEY,
PreferenceData.MANAGER_USE_CUSTOM_TABS_DEFAULT_VALUE
)
set(value) {
putBoolean(PreferenceData.MANAGER_USE_CUSTOM_TABS_KEY, value)
}
override var managerMode: String
get() = getString(PreferenceData.MANAGER_MODE_KEY, PreferenceData.MANAGER_MODE_DEFAULT_VALUE)
get() = getString(
PreferenceData.MANAGER_MODE_KEY,
PreferenceData.MANAGER_MODE_DEFAULT_VALUE
)
set(value) {
putString(PreferenceData.MANAGER_MODE_KEY, value)
}
override var managerTheme: String
get() = getString(PreferenceData.MANAGER_THEME_KEY, PreferenceData.MANAGER_THEME_DEFAULT_VALUE)
get() = getString(
PreferenceData.MANAGER_THEME_KEY,
PreferenceData.MANAGER_THEME_DEFAULT_VALUE
)
set(value) {
putString(PreferenceData.MANAGER_THEME_KEY, value)
}
@ -39,11 +48,11 @@ class PreferenceDatasourceImpl(
private fun getBoolean(key: String, defaultValue: Boolean): Boolean {
return sharedPreferences.getBoolean(key, defaultValue)
}
private fun putString(key: String, value: String) {
sharedPreferences.edit().putString(key, value).apply()
}
private fun putBoolean(key: String, value: Boolean) {
sharedPreferences.edit().putBoolean(key, value).apply()
}
@ -56,7 +65,7 @@ object PreferenceData {
const val MANAGER_MODE_KEY = "manager_behaviour_mode"
const val MANAGER_MODE_VALUE_ROOT = "root"
const val MANAGER_MODE_VALUE_NONROOT= "nonroot"
const val MANAGER_MODE_VALUE_NONROOT = "nonroot"
const val MANAGER_MODE_DEFAULT_VALUE = MANAGER_MODE_VALUE_NONROOT
const val MANAGER_THEME_KEY = "manager_appearance_theme"

View file

@ -14,8 +14,8 @@ import com.github.zsoltk.compose.backpress.BackPressHandler
import com.github.zsoltk.compose.backpress.LocalBackPressHandler
import com.github.zsoltk.compose.router.Router
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import com.vanced.manager.core.installer.service.AppInstallService
import com.vanced.manager.core.installer.service.AppUninstallService
import com.vanced.manager.installer.service.AppInstallService
import com.vanced.manager.installer.service.AppUninstallService
import com.vanced.manager.ui.screen.*
import com.vanced.manager.ui.theme.ManagerTheme
import com.vanced.manager.ui.util.Screen

View file

@ -10,7 +10,7 @@ import com.vanced.manager.BuildConfig
class SplashScreenActivity : ComponentActivity() {
init {
Shell.enableVerboseLogging = BuildConfig.DEBUG;
Shell.enableVerboseLogging = BuildConfig.DEBUG
Shell.setDefaultBuilder(
Shell.Builder
.create()

View file

@ -49,6 +49,7 @@ fun ManagerCard(
)
}
}
@Composable
fun ManagerElevatedCard(
modifier: Modifier = Modifier,
@ -86,6 +87,7 @@ fun ManagerElevatedCard(
)
}
}
@Composable
fun ManagerOutlinedCard(
modifier: Modifier = Modifier,

View file

@ -37,7 +37,7 @@ fun ManagerListItem(
.weight(1f)
.padding(
vertical =
if (description != null) DefaultContentPaddingVertical - 4.dp else DefaultContentPaddingVertical,
if (description != null) DefaultContentPaddingVertical - 4.dp else DefaultContentPaddingVertical,
)
.align(Alignment.CenterVertically)
) {

View file

@ -1,4 +1,4 @@
package com.vanced.manager.ui.navigation
package com.vanced.manager.ui.component
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedContentScope

View file

@ -212,7 +212,7 @@ private fun ListDialogRadiobuttonItem(
) {
ListDialogItem(
modifier = modifier,
text = text,
text = text,
onClick = onClick,
trailing = {
RadioButton(
@ -232,7 +232,7 @@ private fun ListDialogCheckboxItem(
) {
ListDialogItem(
modifier = modifier,
text = text,
text = text,
onClick = {
onCheckedChange(!checked)
},

View file

@ -178,7 +178,7 @@ private fun ConfigurationBottomBar(
shrinkHorizontally(tween(exitDuration)) +
scaleOut(tween(exitDuration)),
) {
) {
TextButton(onClick = onBackClick) {
ManagerText(text = "Back")
}

View file

@ -1,5 +1,6 @@
package com.vanced.manager.ui.screen
import androidx.annotation.DrawableRes
import androidx.compose.animation.*
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
@ -17,9 +18,8 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.google.accompanist.swiperefresh.rememberSwipeRefreshState
import com.vanced.manager.R
import com.vanced.manager.core.util.socialMedia
import com.vanced.manager.core.util.sponsors
import com.vanced.manager.domain.model.App
import com.vanced.manager.network.util.*
import com.vanced.manager.ui.component.*
import com.vanced.manager.ui.resource.managerString
import com.vanced.manager.ui.util.Screen
@ -257,3 +257,66 @@ private inline fun HomeScreenBody(
}
}
}
data class Link(
val title: String,
val link: String,
@DrawableRes val icon: Int
)
val sponsors = listOf(
Link(
title = "Brave",
link = URL_SPONSOR_BRAVE,
icon = R.drawable.ic_brave
),
Link(
title = "Adguard",
link = URL_SPONSOR_ADGUARD,
icon = R.drawable.ic_adguard
)
)
val socialMedia = listOf(
Link(
title = "Instagram",
link = URL_MEDIA_INSTAGRAM,
icon = R.drawable.ic_instagram
),
Link(
title = "YouTube",
link = URL_MEDIA_YOUTUBE,
icon = R.drawable.ic_youtube
),
Link(
title = "GitHub",
link = URL_MEDIA_GITHUB,
icon = R.drawable.ic_github
),
Link(
title = "Website",
link = URL_MEDIA_WEBSITE,
icon = R.drawable.ic_website
),
Link(
title = "Telegram",
link = URL_MEDIA_TELEGRAM,
icon = R.drawable.ic_telegram
),
Link(
title = "Twitter",
link = URL_MEDIA_TWITTER,
icon = R.drawable.ic_twitter
),
Link(
title = "Discord",
link = URL_MEDIA_DISCORD,
icon = R.drawable.ic_discord
),
Link(
title = "Reddit",
link = URL_MEDIA_REDDIT,
icon = R.drawable.ic_reddit
),
)

View file

@ -11,13 +11,13 @@ import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import com.vanced.manager.R
import com.vanced.manager.core.util.isMagiskInstalled
import com.vanced.manager.repository.ManagerMode
import com.vanced.manager.repository.ManagerTheme
import com.vanced.manager.ui.component.*
import com.vanced.manager.ui.resource.managerString
import com.vanced.manager.ui.util.Screen
import com.vanced.manager.ui.viewmodel.SettingsViewModel
import com.vanced.manager.util.isMagiskInstalled
import org.koin.androidx.compose.viewModel
@ExperimentalMaterial3Api

View file

@ -92,7 +92,7 @@ fun ManagerTheme(
)
} else {
apiDependantColorScheme(
dynamic = { dynamicLightColorScheme(context)},
dynamic = { dynamicLightColorScheme(context) },
static = { LightThemeColors }
)
}

View file

@ -7,18 +7,18 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.vanced.manager.core.downloader.base.AppDownloader
import com.vanced.manager.core.downloader.impl.MicrogDownloader
import com.vanced.manager.core.downloader.impl.MusicDownloader
import com.vanced.manager.core.downloader.impl.VancedDownloader
import com.vanced.manager.core.installer.impl.MicrogInstaller
import com.vanced.manager.core.installer.impl.MusicInstaller
import com.vanced.manager.core.installer.impl.VancedInstaller
import com.vanced.manager.core.installer.util.PMRootResult
import com.vanced.manager.core.preferences.holder.managerVariantPref
import com.vanced.manager.downloader.base.AppDownloader
import com.vanced.manager.downloader.impl.MicrogDownloader
import com.vanced.manager.downloader.impl.MusicDownloader
import com.vanced.manager.downloader.impl.VancedDownloader
import com.vanced.manager.installer.impl.MicrogInstaller
import com.vanced.manager.installer.impl.MusicInstaller
import com.vanced.manager.installer.impl.VancedInstaller
import com.vanced.manager.installer.util.PMRootResult
import com.vanced.manager.network.util.MICROG_NAME
import com.vanced.manager.network.util.MUSIC_NAME
import com.vanced.manager.network.util.VANCED_NAME
import com.vanced.manager.preferences.holder.managerVariantPref
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@ -107,10 +107,12 @@ class InstallViewModel(
installApp(appName, appVersions)
}
is AppDownloader.DownloadStatus.Error -> {
log(Log.Error(
displayText = "Failed to download ${download.fileName}",
stacktrace = download.error
))
log(
Log.Error(
displayText = "Failed to download ${download.fileName}",
stacktrace = download.error
)
)
}
}
}

View file

@ -8,9 +8,11 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.viewModelScope
import com.vanced.manager.core.installer.util.PM
import com.vanced.manager.domain.model.App
import com.vanced.manager.repository.*
import com.vanced.manager.installer.util.PM
import com.vanced.manager.repository.AppRepository
import com.vanced.manager.repository.ManagerMode
import com.vanced.manager.repository.PreferenceRepository
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.launch

View file

@ -5,8 +5,6 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import com.vanced.manager.R
import com.vanced.manager.core.preferences.managerBooleanPreference
import com.vanced.manager.core.preferences.managerStringPreference
import com.vanced.manager.repository.ManagerMode
import com.vanced.manager.repository.ManagerTheme
import com.vanced.manager.repository.PreferenceRepository
@ -21,17 +19,17 @@ class SettingsViewModel(
private set
var managerTheme by mutableStateOf(preferenceRepository.managerTheme)
private set
fun saveManagerUseCustomTabs(value: Boolean) {
managerUseCustomTabs = value
preferenceRepository.managerUseCustomTabs = value
}
fun saveManagerMode(value: ManagerMode) {
managerMode = value
preferenceRepository.managerMode = value
}
fun saveManagerTheme(value: ManagerTheme) {
managerTheme = value
preferenceRepository.managerTheme = value

View file

@ -5,7 +5,10 @@ import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Info
import androidx.compose.material.icons.rounded.*
import androidx.compose.material.icons.rounded.DeleteForever
import androidx.compose.material.icons.rounded.GetApp
import androidx.compose.material.icons.rounded.Launch
import androidx.compose.material.icons.rounded.Update
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment

View file

@ -1,4 +1,4 @@
package com.vanced.manager.core.util
package com.vanced.manager.util
fun getLatestOrProvidedAppVersion(
version: String,

View file

@ -0,0 +1,10 @@
package com.vanced.manager.util
import android.os.Build
val arch
get() = when {
Build.SUPPORTED_ABIS.contains("x86") -> "x86"
Build.SUPPORTED_ABIS.contains("arm64-v8a") -> "arm64_v8a"
else -> "armeabi_v7a"
}

View file

@ -1,4 +1,4 @@
package com.vanced.manager.core.util
package com.vanced.manager.util
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch

View file

@ -1,4 +1,4 @@
package com.vanced.manager.core.io
package com.vanced.manager.util
import okhttp3.ResponseBody
import java.io.FileOutputStream

View file

@ -1,4 +1,4 @@
package com.vanced.manager.core.util
package com.vanced.manager.util
import com.topjohnwu.superuser.Shell
import kotlin.coroutines.resume