diff --git a/app/src/main/java/com/vanced/manager/core/downloader/VancedDownloader.kt b/app/src/main/java/com/vanced/manager/core/downloader/VancedDownloader.kt index 5485115e..d8c46a97 100644 --- a/app/src/main/java/com/vanced/manager/core/downloader/VancedDownloader.kt +++ b/app/src/main/java/com/vanced/manager/core/downloader/VancedDownloader.kt @@ -14,6 +14,7 @@ import com.vanced.manager.R import com.vanced.manager.core.App import com.vanced.manager.ui.viewmodels.HomeViewModel.Companion.vancedProgress import com.vanced.manager.utils.AppUtils.mutableInstall +import com.vanced.manager.utils.AppUtils.vancedRootPkg import com.vanced.manager.utils.InternetTools import com.vanced.manager.utils.InternetTools.baseUrl import com.vanced.manager.utils.InternetTools.getFileNameFromUrl @@ -46,7 +47,6 @@ object VancedDownloader { private var count: Int = 0 private var hashUrl = "" - private const val yPkg = "com.google.android.youtube" private var vancedVersionCode = 0 private var vancedVersion: String? = null @@ -150,7 +150,7 @@ object VancedDownloader { private fun downloadStockCheck(context: Context) :Boolean { return try { - getPkgVerCode(yPkg,context.packageManager) != vancedVersionCode + getPkgVerCode(vancedRootPkg, context.packageManager) != vancedVersionCode } catch (e: Exception) { true } diff --git a/app/src/main/java/com/vanced/manager/core/firebase/CloudMessaging.kt b/app/src/main/java/com/vanced/manager/core/firebase/CloudMessaging.kt index 9b52333d..15625f14 100644 --- a/app/src/main/java/com/vanced/manager/core/firebase/CloudMessaging.kt +++ b/app/src/main/java/com/vanced/manager/core/firebase/CloudMessaging.kt @@ -3,7 +3,7 @@ package com.vanced.manager.core.firebase import android.util.Log import com.google.firebase.messaging.FirebaseMessagingService -class CloudMessaging: FirebaseMessagingService() { +class CloudMessaging : FirebaseMessagingService() { override fun onNewToken(p0: String) { super.onNewToken(p0) diff --git a/app/src/main/java/com/vanced/manager/model/DataModel.kt b/app/src/main/java/com/vanced/manager/model/DataModel.kt index ae3a5b36..c6d3370d 100644 --- a/app/src/main/java/com/vanced/manager/model/DataModel.kt +++ b/app/src/main/java/com/vanced/manager/model/DataModel.kt @@ -1,7 +1,6 @@ package com.vanced.manager.model import android.content.Context -import android.content.pm.PackageManager import android.graphics.drawable.Drawable import android.os.Build import androidx.core.content.ContextCompat @@ -9,10 +8,7 @@ import androidx.databinding.ObservableBoolean import androidx.databinding.ObservableField import androidx.databinding.ObservableInt import com.beust.klaxon.JsonObject -import com.vanced.manager.BuildConfig.ENABLE_SIGNATURE_CHECK import com.vanced.manager.R -import com.vanced.manager.utils.AppUtils.managerPkg -import com.vanced.manager.utils.AppUtils.vancedRootPkg import com.vanced.manager.utils.PackageHelper.isPackageInstalled import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -33,13 +29,11 @@ open class DataModel( val buttonTxt = ObservableField() val buttonIcon = ObservableField() val changelog = ObservableField() - val isOfficial = ObservableBoolean() fun fetch() = CoroutineScope(Dispatchers.IO).launch { isAppInstalled.set(isPackageInstalled(appPkg, context.packageManager)) versionName.set(jsonObject.get()?.string("version")?.removeSuffix("-vanced") ?: context.getString(R.string.unavailable)) installedVersionName.set(getPkgVersionName(isAppInstalled.get(), appPkg)) - isOfficial.set(doSignaturesMatch(managerPkg, appPkg)) versionCode.set(jsonObject.get()?.int("versionCode") ?: 0) installedVersionCode.set(getPkgVersionCode(isAppInstalled.get(), appPkg)) buttonTxt.set(compareInt(installedVersionCode.get(), versionCode.get())) @@ -54,24 +48,12 @@ open class DataModel( private fun getPkgVersionName(toCheck: Boolean, pkg: String): String { val pm = context.packageManager return if (toCheck) { - if (ENABLE_SIGNATURE_CHECK) { - if (doSignaturesMatch(managerPkg, pkg) || appPkg == vancedRootPkg) - pm.getPackageInfo(pkg, 0).versionName.removeSuffix("-vanced") - else - pm.getPackageInfo(pkg, 0).versionName.removeSuffix("-vanced") + " (${context.getString(R.string.unofficial)})" - } else - pm.getPackageInfo(pkg, 0).versionName.removeSuffix("-vanced") + pm.getPackageInfo(pkg, 0).versionName.removeSuffix("-vanced") } else { context.getString(R.string.unavailable) } } - private fun doSignaturesMatch(pkg1: String, pkg2: String): Boolean = - if (isPackageInstalled(pkg2, context.packageManager)) - context.packageManager.checkSignatures(pkg1, pkg2) == PackageManager.SIGNATURE_MATCH - else - true - @Suppress("DEPRECATION") private fun getPkgVersionCode(toCheck: Boolean, pkg: String): Int { return if (toCheck) { diff --git a/app/src/main/java/com/vanced/manager/ui/MainActivity.kt b/app/src/main/java/com/vanced/manager/ui/MainActivity.kt index cd8fe2f3..c57b01c1 100644 --- a/app/src/main/java/com/vanced/manager/ui/MainActivity.kt +++ b/app/src/main/java/com/vanced/manager/ui/MainActivity.kt @@ -28,9 +28,6 @@ import com.vanced.manager.utils.InternetTools import com.vanced.manager.utils.LanguageContextWrapper import com.vanced.manager.utils.PackageHelper import com.vanced.manager.utils.ThemeHelper.setFinalTheme -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch class MainActivity : AppCompatActivity() { @@ -160,10 +157,8 @@ class MainActivity : AppCompatActivity() { } private fun checkUpdates() { - CoroutineScope(Dispatchers.Main).launch { - if (InternetTools.isUpdateAvailable()) { - UpdateCheckFragment().show(supportFragmentManager, "UpdateCheck") - } + if (InternetTools.isUpdateAvailable(this)) { + UpdateCheckFragment().show(supportFragmentManager, "UpdateCheck") } } diff --git a/app/src/main/java/com/vanced/manager/ui/dialogs/DialogContainer.kt b/app/src/main/java/com/vanced/manager/ui/dialogs/DialogContainer.kt index 8496b484..a1fc44bb 100644 --- a/app/src/main/java/com/vanced/manager/ui/dialogs/DialogContainer.kt +++ b/app/src/main/java/com/vanced/manager/ui/dialogs/DialogContainer.kt @@ -73,7 +73,6 @@ object DialogContainer { } } - //Easter Egg fun statementFalse(context: Context) { MaterialAlertDialogBuilder(context).apply { setTitle("Wait what?") diff --git a/app/src/main/java/com/vanced/manager/ui/fragments/HomeFragment.kt b/app/src/main/java/com/vanced/manager/ui/fragments/HomeFragment.kt index 8ff9bc06..66f0ac11 100644 --- a/app/src/main/java/com/vanced/manager/ui/fragments/HomeFragment.kt +++ b/app/src/main/java/com/vanced/manager/ui/fragments/HomeFragment.kt @@ -17,19 +17,13 @@ import androidx.preference.PreferenceManager.getDefaultSharedPreferences import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayoutMediator import com.topjohnwu.superuser.Shell -import com.vanced.manager.BuildConfig.ENABLE_SIGNATURE_CHECK import com.vanced.manager.R import com.vanced.manager.adapter.VariantAdapter import com.vanced.manager.databinding.FragmentHomeBinding import com.vanced.manager.ui.dialogs.DialogContainer.installAlertBuilder -import com.vanced.manager.ui.dialogs.DialogContainer.showUnofficialAppInstalledDialog import com.vanced.manager.ui.viewmodels.HomeViewModel import com.vanced.manager.ui.viewmodels.HomeViewModelFactory -import com.vanced.manager.utils.AppUtils -import com.vanced.manager.utils.AppUtils.microgPkg -import com.vanced.manager.utils.AppUtils.musicPkg -import com.vanced.manager.utils.AppUtils.vancedPkg -import com.vanced.manager.utils.AppUtils.vancedRootPkg +import com.vanced.manager.utils.AppUtils.installing open class HomeFragment : Fragment() { @@ -87,19 +81,7 @@ open class HomeFragment : Fragment() { mainTablayout.getTabAt(if (getDefaultSharedPreferences(requireActivity()).getString("vanced_variant", "nonroot") == "root") 1 else 0)?.select() } - if (ENABLE_SIGNATURE_CHECK) { - if (!viewModel.vanced.get()?.isOfficial?.get()!!) - showUnofficialAppInstalledDialog(getString(R.string.vanced), vancedPkg, requireActivity()) - - if (!viewModel.music.get()?.isOfficial?.get()!!) - showUnofficialAppInstalledDialog(getString(R.string.music), musicPkg, requireActivity()) - - if (!viewModel.microg.get()?.isOfficial?.get()!!) - showUnofficialAppInstalledDialog(getString(R.string.microg), microgPkg, requireActivity()) - - } - - AppUtils.installing.observe(viewLifecycleOwner, { value -> + installing.observe(viewLifecycleOwner, { value -> if (value) hideTab() else showTab() }) diff --git a/app/src/main/java/com/vanced/manager/ui/fragments/URLChangeFragment.kt b/app/src/main/java/com/vanced/manager/ui/fragments/URLChangeFragment.kt index 4eaf0275..3edf1d4a 100644 --- a/app/src/main/java/com/vanced/manager/ui/fragments/URLChangeFragment.kt +++ b/app/src/main/java/com/vanced/manager/ui/fragments/URLChangeFragment.kt @@ -1,6 +1,5 @@ package com.vanced.manager.ui.fragments -import android.content.Context import android.graphics.Color import android.graphics.drawable.ColorDrawable import android.os.Bundle diff --git a/app/src/main/java/com/vanced/manager/ui/fragments/UpdateCheckFragment.kt b/app/src/main/java/com/vanced/manager/ui/fragments/UpdateCheckFragment.kt index 88369802..0ddc5905 100644 --- a/app/src/main/java/com/vanced/manager/ui/fragments/UpdateCheckFragment.kt +++ b/app/src/main/java/com/vanced/manager/ui/fragments/UpdateCheckFragment.kt @@ -13,12 +13,9 @@ import com.google.android.material.button.MaterialButton import com.vanced.manager.R import com.vanced.manager.utils.DownloadHelper.downloadManager import com.vanced.manager.utils.InternetTools.isUpdateAvailable -import kotlinx.coroutines.runBlocking class UpdateCheckFragment : DialogFragment() { - //private var downloadId: Long = 0 - override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? @@ -31,7 +28,6 @@ class UpdateCheckFragment : DialogFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - //activity?.registerReceiver(receiver, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)) checkUpdates() view.findViewById