@@ -95,14 +95,16 @@ class FileTransferService : LifecycleService() {
95
95
96
96
override fun onCreate () {
97
97
AndroidInjection .inject(this )
98
+ super .onCreate()
98
99
}
99
100
100
101
override fun onStartCommand (intent : Intent ? , flags : Int , startId : Int ): Int {
102
+ super .onStartCommand(intent, flags, startId)
101
103
if (intent == null || intent.action != ACTION_TRANSFER ) {
102
104
return START_NOT_STICKY
103
105
}
104
106
105
- if (! isRunning && lifecycle.currentState == Lifecycle .State .STARTED ) {
107
+ if (! isRunning && lifecycle.currentState.isAtLeast( Lifecycle .State .RESUMED ) ) {
106
108
ForegroundServiceHelper .startService(
107
109
this ,
108
110
AppNotificationManager .TRANSFER_NOTIFICATION_ID ,
@@ -112,15 +114,18 @@ class FileTransferService : LifecycleService() {
112
114
}
113
115
114
116
val request: Request = intent.getParcelableArgument(EXTRA_REQUEST , Request ::class .java)!!
115
- val transferManager = getTransferManager(request.user)
116
- transferManager.enqueue(request)
117
+
118
+ getTransferManager(request.user).run {
119
+ enqueue(request)
120
+ }
117
121
118
122
logger.d(TAG , " Enqueued new transfer: ${request.uuid} ${request.file.remotePath} " )
119
123
120
124
return START_NOT_STICKY
121
125
}
122
126
123
127
override fun onBind (intent : Intent ): IBinder ? {
128
+ super .onBind(intent)
124
129
val user = intent.getParcelableArgument(EXTRA_USER , User ::class .java) ? : return null
125
130
return Binder (getTransferManager(user), this )
126
131
}
@@ -129,7 +134,7 @@ class FileTransferService : LifecycleService() {
129
134
if (! isRunning) {
130
135
logger.d(TAG , " All downloads completed" )
131
136
notificationsManager.cancelTransferNotification()
132
- stopForeground(true )
137
+ stopForeground(STOP_FOREGROUND_DETACH )
133
138
stopSelf()
134
139
} else if (transfer.direction == Direction .DOWNLOAD ) {
135
140
notificationsManager.postDownloadTransferProgress(
0 commit comments