Fix file exporter worker on devices running android < 12
This commit is contained in:
committed by
Aayush Gupta
parent
7957a04ecf
commit
33b398cb3b
@@ -304,7 +304,7 @@ class DownloadWorker @AssistedInject constructor(
|
||||
Log.e(TAG, "Incorrect hash for ${request.file}")
|
||||
throw Exception("Incorrect hash")
|
||||
}
|
||||
|
||||
|
||||
} catch (exception: Exception) {
|
||||
Log.e(TAG, "Failed to download ${request.file}!", exception)
|
||||
notifyStatus(DownloadStatus.FAILED)
|
||||
@@ -357,6 +357,7 @@ class DownloadWorker @AssistedInject constructor(
|
||||
} else {
|
||||
NotificationUtil.getDownloadNotification(appContext)
|
||||
}
|
||||
|
||||
return if (isQAndAbove()) {
|
||||
ForegroundInfo(NOTIFICATION_ID, notification, FOREGROUND_SERVICE_TYPE_DATA_SYNC)
|
||||
} else {
|
||||
@@ -441,7 +442,7 @@ class DownloadWorker @AssistedInject constructor(
|
||||
}
|
||||
return proxy
|
||||
} else {
|
||||
Log.i(TAG,"Proxy is disabled")
|
||||
Log.i(TAG, "Proxy is disabled")
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,11 @@ import android.util.Log
|
||||
import androidx.hilt.work.HiltWorker
|
||||
import androidx.work.CoroutineWorker
|
||||
import androidx.work.Data
|
||||
import androidx.work.ForegroundInfo
|
||||
import androidx.work.OneTimeWorkRequestBuilder
|
||||
import androidx.work.OutOfQuotaPolicy
|
||||
import androidx.work.WorkManager
|
||||
import androidx.work.WorkerParameters
|
||||
import com.aurora.gplayapi.data.models.App
|
||||
import com.aurora.store.data.model.MinimalApp
|
||||
import com.aurora.store.data.room.download.Download
|
||||
import com.aurora.store.util.NotificationUtil
|
||||
@@ -104,7 +104,7 @@ class ExportWorker @AssistedInject constructor(
|
||||
|
||||
if (packageName.isNullOrEmpty() || isDownload && versionCode == -1) {
|
||||
Log.e(TAG, "Input data is corrupt, bailing out!")
|
||||
notifyStatus(displayName?: String(), uri, false)
|
||||
notifyStatus(displayName ?: String(), uri, false)
|
||||
return Result.failure()
|
||||
}
|
||||
|
||||
@@ -117,13 +117,20 @@ class ExportWorker @AssistedInject constructor(
|
||||
notifyStatus(displayName ?: packageName, uri)
|
||||
} catch (exception: Exception) {
|
||||
Log.e(TAG, "Failed to export $packageName", exception)
|
||||
notifyStatus(displayName?: packageName, uri, false)
|
||||
notifyStatus(displayName ?: packageName, uri, false)
|
||||
return Result.failure()
|
||||
}
|
||||
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
override suspend fun getForegroundInfo(): ForegroundInfo {
|
||||
return ForegroundInfo(
|
||||
NOTIFICATION_ID,
|
||||
NotificationUtil.getExportNotification(appContext)
|
||||
)
|
||||
}
|
||||
|
||||
private fun notifyStatus(packageName: String, uri: Uri, success: Boolean = true) {
|
||||
notificationManager.notify(
|
||||
NOTIFICATION_ID,
|
||||
|
||||
@@ -19,7 +19,6 @@ import androidx.navigation.NavDeepLinkBuilder
|
||||
import androidx.work.WorkManager
|
||||
import com.aurora.Constants
|
||||
import com.aurora.extensions.getStyledAttributeColor
|
||||
import com.aurora.gplayapi.data.models.App
|
||||
import com.aurora.store.MainActivity
|
||||
import com.aurora.store.R
|
||||
import com.aurora.store.data.activity.InstallActivity
|
||||
@@ -252,6 +251,16 @@ object NotificationUtil {
|
||||
.build()
|
||||
}
|
||||
|
||||
fun getExportNotification(context: Context): Notification {
|
||||
return NotificationCompat.Builder(context, Constants.NOTIFICATION_CHANNEL_ALERT)
|
||||
.setSmallIcon(R.drawable.ic_file_copy)
|
||||
.setColor(context.getStyledAttributeColor(R.color.colorAccent))
|
||||
.setContentTitle(context.getString(R.string.export_app_title))
|
||||
.setContentText(context.getString(R.string.export_app_summary))
|
||||
.setOngoing(false)
|
||||
.build()
|
||||
}
|
||||
|
||||
fun getExportStatusNotification(
|
||||
context: Context,
|
||||
displayName: String,
|
||||
|
||||
Reference in New Issue
Block a user