Compare commits
No commits in common. "54b4f61fd7e5560bd49578640ea25bd3943fa3a5" and "479e0ff34ade33af57204964aa0e6596202de99c" have entirely different histories.
54b4f61fd7
...
479e0ff34a
1 changed files with 7 additions and 17 deletions
|
@ -4,7 +4,6 @@ import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.os.Binder
|
import android.os.Binder
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import android.util.Log
|
|
||||||
import androidx.core.app.NotificationChannelCompat
|
import androidx.core.app.NotificationChannelCompat
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.app.NotificationManagerCompat
|
import androidx.core.app.NotificationManagerCompat
|
||||||
|
@ -50,7 +49,6 @@ import net.typeblog.lpac_jni.ProfileDownloadCallback
|
||||||
*/
|
*/
|
||||||
class EuiccChannelManagerService : LifecycleService(), OpenEuiccContextMarker {
|
class EuiccChannelManagerService : LifecycleService(), OpenEuiccContextMarker {
|
||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "EuiccChannelManagerService"
|
|
||||||
private const val CHANNEL_ID = "tasks"
|
private const val CHANNEL_ID = "tasks"
|
||||||
private const val FOREGROUND_ID = 1000
|
private const val FOREGROUND_ID = 1000
|
||||||
}
|
}
|
||||||
|
@ -107,18 +105,12 @@ class EuiccChannelManagerService : LifecycleService(), OpenEuiccContextMarker {
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun updateForegroundNotification(title: String, iconRes: Int) {
|
private suspend fun updateForegroundNotification(title: String, iconRes: Int) {
|
||||||
val nm = NotificationManagerCompat.from(this)
|
val channel =
|
||||||
if (nm.getNotificationChannelCompat(CHANNEL_ID) == null) {
|
NotificationChannelCompat.Builder(CHANNEL_ID, NotificationManagerCompat.IMPORTANCE_LOW)
|
||||||
val channel =
|
.setName(getString(R.string.task_notification))
|
||||||
NotificationChannelCompat.Builder(
|
.setVibrationEnabled(false)
|
||||||
CHANNEL_ID,
|
.build()
|
||||||
NotificationManagerCompat.IMPORTANCE_LOW
|
NotificationManagerCompat.from(this).createNotificationChannel(channel)
|
||||||
)
|
|
||||||
.setName(getString(R.string.task_notification))
|
|
||||||
.setVibrationEnabled(false)
|
|
||||||
.build()
|
|
||||||
nm.createNotificationChannel(channel)
|
|
||||||
}
|
|
||||||
|
|
||||||
val state = foregroundTaskState.value
|
val state = foregroundTaskState.value
|
||||||
|
|
||||||
|
@ -135,7 +127,7 @@ class EuiccChannelManagerService : LifecycleService(), OpenEuiccContextMarker {
|
||||||
if (state.progress == 0) {
|
if (state.progress == 0) {
|
||||||
startForeground(FOREGROUND_ID, notification)
|
startForeground(FOREGROUND_ID, notification)
|
||||||
} else if (checkSelfPermission(android.Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) {
|
} 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
|
// 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)
|
// This update will be sent by the subscriber (as shown below)
|
||||||
foregroundTaskState.value = ForegroundTaskState.Done(null)
|
foregroundTaskState.value = ForegroundTaskState.Done(null)
|
||||||
} catch (t: Throwable) {
|
} catch (t: Throwable) {
|
||||||
Log.e(TAG, "Foreground task encountered an error")
|
|
||||||
Log.e(TAG, Log.getStackTraceString(t))
|
|
||||||
foregroundTaskState.value = ForegroundTaskState.Done(t)
|
foregroundTaskState.value = ForegroundTaskState.Done(t)
|
||||||
} finally {
|
} finally {
|
||||||
stopSelf()
|
stopSelf()
|
||||||
|
|
Loading…
Add table
Reference in a new issue