Compare commits

..

No commits in common. "54b4f61fd7e5560bd49578640ea25bd3943fa3a5" and "479e0ff34ade33af57204964aa0e6596202de99c" have entirely different histories.

View file

@ -4,7 +4,6 @@ import android.content.Intent
import android.content.pm.PackageManager
import android.os.Binder
import android.os.IBinder
import android.util.Log
import androidx.core.app.NotificationChannelCompat
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
@ -50,7 +49,6 @@ import net.typeblog.lpac_jni.ProfileDownloadCallback
*/
class EuiccChannelManagerService : LifecycleService(), OpenEuiccContextMarker {
companion object {
private const val TAG = "EuiccChannelManagerService"
private const val CHANNEL_ID = "tasks"
private const val FOREGROUND_ID = 1000
}
@ -107,18 +105,12 @@ class EuiccChannelManagerService : LifecycleService(), OpenEuiccContextMarker {
}
private suspend fun updateForegroundNotification(title: String, iconRes: Int) {
val nm = NotificationManagerCompat.from(this)
if (nm.getNotificationChannelCompat(CHANNEL_ID) == null) {
val channel =
NotificationChannelCompat.Builder(
CHANNEL_ID,
NotificationManagerCompat.IMPORTANCE_LOW
)
.setName(getString(R.string.task_notification))
.setVibrationEnabled(false)
.build()
nm.createNotificationChannel(channel)
}
val channel =
NotificationChannelCompat.Builder(CHANNEL_ID, NotificationManagerCompat.IMPORTANCE_LOW)
.setName(getString(R.string.task_notification))
.setVibrationEnabled(false)
.build()
NotificationManagerCompat.from(this).createNotificationChannel(channel)
val state = foregroundTaskState.value
@ -135,7 +127,7 @@ class EuiccChannelManagerService : LifecycleService(), OpenEuiccContextMarker {
if (state.progress == 0) {
startForeground(FOREGROUND_ID, notification)
} else if (checkSelfPermission(android.Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) {
nm.notify(FOREGROUND_ID, notification)
NotificationManagerCompat.from(this).notify(FOREGROUND_ID, notification)
}
// Yield out so that the main looper can handle the notification event
@ -200,8 +192,6 @@ class EuiccChannelManagerService : LifecycleService(), OpenEuiccContextMarker {
// This update will be sent by the subscriber (as shown below)
foregroundTaskState.value = ForegroundTaskState.Done(null)
} catch (t: Throwable) {
Log.e(TAG, "Foreground task encountered an error")
Log.e(TAG, Log.getStackTraceString(t))
foregroundTaskState.value = ForegroundTaskState.Done(t)
} finally {
stopSelf()