Revert "Add back toggle for auto install post app download"

This reverts commit 24496b1405.
This commit is contained in:
Rahul Patel
2023-10-17 05:59:52 +05:30
parent 4fe7d453f5
commit 1ce09c5c35
5 changed files with 32 additions and 89 deletions

View File

@@ -45,7 +45,7 @@ import java.util.*
import java.util.concurrent.locks.ReentrantLock
import kotlin.concurrent.timerTask
class UpdateService : LifecycleService() {
class UpdateService: LifecycleService() {
lateinit var fetch: Fetch
lateinit var downloadManager: DownloadManager
@@ -53,7 +53,7 @@ class UpdateService : LifecycleService() {
private var fetchActiveDownloadObserver = object : FetchObserver<Boolean> {
override fun onChanged(data: Boolean, reason: Reason) {
if (!data && isEmptyInstalling() && fetchListeners.isEmpty() && appMetadataListeners.isEmpty()) {
Handler(Looper.getMainLooper()).postDelayed({
Handler(Looper.getMainLooper()).postDelayed ({
if (isEmptyInstalling() && fetchListeners.isEmpty() && appMetadataListeners.isEmpty()) {
stopSelf()
}
@@ -74,7 +74,7 @@ class UpdateService : LifecycleService() {
var liveUpdateData: MutableLiveData<MutableMap<Int, UpdateFile>> = MutableLiveData()
inner class UpdateServiceBinder : Binder() {
fun getUpdateService(): UpdateService {
fun getUpdateService() : UpdateService {
return this@UpdateService
}
}
@@ -181,11 +181,9 @@ class UpdateService : LifecycleService() {
private lateinit var authData: AuthData
data class AppDownloadStatus(
val download: Download, val fetchGroup: FetchGroup,
val isCancelled: Boolean = false,
val isComplete: Boolean = false
)
data class AppDownloadStatus(val download: Download, val fetchGroup: FetchGroup,
val isCancelled: Boolean = false,
val isComplete: Boolean = false)
data class AppMetadataStatus(val reason: String, val app: App)
@@ -254,32 +252,17 @@ class UpdateService : LifecycleService() {
fetchGroup: FetchGroup
) {
fetchListeners.forEach {
it.onProgress(
groupId,
download,
etaInMilliSeconds,
downloadedBytesPerSecond,
fetchGroup
)
it.onProgress(groupId, download, etaInMilliSeconds, downloadedBytesPerSecond, fetchGroup)
}
}
override fun onProgress(
download: Download,
etaInMilliSeconds: Long,
downloadedBytesPerSecond: Long
) {
override fun onProgress(download: Download, etaInMilliSeconds: Long, downloadedBytesPerSecond: Long) {
fetchListeners.forEach {
it.onProgress(download, etaInMilliSeconds, downloadedBytesPerSecond)
}
}
override fun onQueued(
groupId: Int,
download: Download,
waitingNetwork: Boolean,
fetchGroup: FetchGroup
) {
override fun onQueued(groupId: Int, download: Download, waitingNetwork: Boolean, fetchGroup: FetchGroup) {
fetchListeners.forEach {
it.onQueued(groupId, download, waitingNetwork, fetchGroup)
}
@@ -328,30 +311,20 @@ class UpdateService : LifecycleService() {
download,
downloadBlocks,
totalBlocks,
fetchGroup
)
fetchGroup)
}
}
override fun onStarted(
download: Download,
downloadBlocks: List<DownloadBlock>,
totalBlocks: Int
) {
override fun onStarted(download: Download, downloadBlocks: List<DownloadBlock>, totalBlocks: Int) {
fetchListeners.forEach {
it.onStarted(
download,
downloadBlocks,
totalBlocks
)
totalBlocks)
}
}
override fun onWaitingNetwork(
groupId: Int,
download: Download,
fetchGroup: FetchGroup
) {
override fun onWaitingNetwork(groupId: Int, download: Download, fetchGroup: FetchGroup) {
fetchListeners.forEach {
it.onWaitingNetwork(groupId, download, fetchGroup)
}
@@ -368,8 +341,7 @@ class UpdateService : LifecycleService() {
it.onCompleted(groupId, download, fetchGroup)
}
if (fetchListeners.isEmpty()) {
fetchPendingEvents[groupId] =
AppDownloadStatus(download, fetchGroup, isComplete = true)
fetchPendingEvents[groupId] = AppDownloadStatus(download, fetchGroup, isComplete = true)
}
var packageDownloadFilesWhichCompleted = downloadsInCompletedGroup[download.tag!!]
if (packageDownloadFilesWhichCompleted == null) {
@@ -377,11 +349,7 @@ class UpdateService : LifecycleService() {
downloadsInCompletedGroup[download.tag!!] = packageDownloadFilesWhichCompleted
}
packageDownloadFilesWhichCompleted.add(download.file)
if (fetchGroup.groupDownloadProgress == 100 && fetchGroup.downloads.all {
packageDownloadFilesWhichCompleted.contains(
it.file
)
}) {
if (fetchGroup.groupDownloadProgress == 100 && fetchGroup.downloads.all { packageDownloadFilesWhichCompleted.contains(it.file) }) {
downloadsInCompletedGroup.remove(download.tag!!)
if (download.tag != null) {
removeFromInstalling(download.tag, runFromCurrentThread = true)
@@ -413,8 +381,7 @@ class UpdateService : LifecycleService() {
it.onCancelled(groupId, download, fetchGroup)
}
if (fetchListeners.isEmpty()) {
fetchPendingEvents[groupId] =
AppDownloadStatus(download, fetchGroup, isCancelled = true)
fetchPendingEvents[groupId] = AppDownloadStatus(download, fetchGroup, isCancelled = true)
}
}
@@ -429,8 +396,7 @@ class UpdateService : LifecycleService() {
it.onDeleted(groupId, download, fetchGroup)
}
if (fetchListeners.isEmpty()) {
fetchPendingEvents[groupId] =
AppDownloadStatus(download, fetchGroup, isCancelled = true)
fetchPendingEvents[groupId] = AppDownloadStatus(download, fetchGroup, isCancelled = true)
}
}
@@ -458,11 +424,7 @@ class UpdateService : LifecycleService() {
}
}
override fun onDownloadBlockUpdated(
download: Download,
downloadBlock: DownloadBlock,
totalBlocks: Int
) {
override fun onDownloadBlockUpdated(download: Download, downloadBlock: DownloadBlock, totalBlocks: Int) {
fetchListeners.forEach {
it.onDownloadBlockUpdated(
download,
@@ -650,19 +612,11 @@ class UpdateService : LifecycleService() {
if (downloads.all { File(it.file).exists() }) {
serviceScope.launch {
try {
val autoInstall = Preferences.getBoolean(
this@UpdateService,
Preferences.PREFERENCE_AUTO_INSTALL
)
if (autoInstall) {
AppInstaller.getInstance(this@UpdateService).getPreferredInstaller()
.install(
packageName,
files.filter { it.file.endsWith(".apk") }.map { it.file }
.toList()
)
}
AppInstaller.getInstance(this@UpdateService).getPreferredInstaller()
.install(
packageName,
files.filter { it.file.endsWith(".apk") }.map { it.file }.toList()
)
} catch (exception: Exception) {
removeFromInstalling(packageName)
Log.e(exception.stackTraceToString())
@@ -691,16 +645,16 @@ class UpdateService : LifecycleService() {
removeFromInstalling(this)
}
synchronized(timerLock) {
timer = if (timer != null) {
if (timer != null) {
timer!!.cancel()
null
} else {
Timer()
timer = null
}
if (timer == null) {
timer = Timer()
}
timer!!.schedule(timerTask { timerTaskRun.run() }, 5 * 1000)
}
}
else -> {
}

View File

@@ -182,7 +182,7 @@ class AppDetailsFragment : BaseFragment(R.layout.fragment_details) {
private var isInstalled: Boolean = false
private var isUpdatable: Boolean = false
private var autoDownload: Boolean = false
private var autoInstall: Boolean = true
private var downloadOnly: Boolean = false
private var uninstallActionEnabled = false
val listOfActionsWhenServiceAttaches = ArrayList<Runnable>()
@@ -445,9 +445,7 @@ class AppDetailsFragment : BaseFragment(R.layout.fragment_details) {
}
private fun verifyAndInstall(files: List<Download>) {
autoInstall = Preferences.getBoolean(requireContext(), Preferences.PREFERENCE_AUTO_INSTALL)
if (!autoInstall)
if (downloadOnly)
return
var filesExist = true

View File

@@ -35,7 +35,6 @@ import com.aurora.store.databinding.FragmentOnboardingBinding
import com.aurora.store.util.PathUtil
import com.aurora.store.util.Preferences
import com.aurora.store.util.Preferences.PREFERENCE_AUTO_DELETE
import com.aurora.store.util.Preferences.PREFERENCE_AUTO_INSTALL
import com.aurora.store.util.Preferences.PREFERENCE_DEFAULT
import com.aurora.store.util.Preferences.PREFERENCE_DEFAULT_SELECTED_TAB
import com.aurora.store.util.Preferences.PREFERENCE_DOWNLOAD_ACTIVE
@@ -172,7 +171,6 @@ class OnboardingFragment : Fragment(R.layout.fragment_onboarding) {
/*Installer*/
save(PREFERENCE_AUTO_DELETE, true)
save(PREFERENCE_AUTO_INSTALL, true)
save(PREFERENCE_INSTALLER_ID, 0)
/*Updates*/

View File

@@ -14,7 +14,6 @@ import com.aurora.store.data.model.ExodusReport
import com.aurora.store.data.model.Report
import com.aurora.store.data.network.HttpClient
import com.aurora.store.data.providers.AuthProvider
import com.aurora.store.util.Preferences
import com.google.gson.GsonBuilder
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableSharedFlow
@@ -132,12 +131,6 @@ class AppDetailsViewModel : ViewModel() {
@Synchronized
fun install(context: Context, packageName: String, files: List<Any>) {
val autoInstall = Preferences.getBoolean(context, Preferences.PREFERENCE_AUTO_INSTALL)
if (!autoInstall) {
return
}
try {
viewModelScope.launch(Dispatchers.IO) {
AppInstaller.getInstance(context).getPreferredInstaller()

View File

@@ -19,9 +19,9 @@
<androidx.preference.PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
<SwitchPreferenceCompat
app:defaultValue="true"
app:defaultValue="false"
app:iconSpaceReserved="false"
app:isPreferenceVisible="true"
app:isPreferenceVisible="false"
app:key="PREFERENCE_AUTO_INSTALL"
app:summary="@string/pref_install_auto_summary"
app:title="@string/pref_install_auto_title" />