Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-client-android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-client-android
Commits
0dd83be7
Commit
0dd83be7
authored
1 year ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
JamiJobService: use EXTRA_TIMEOUT to manage service timeout
Change-Id: Iaf6504c2aab085c9f6ed5d7fd631b8276ee3ffc3
parent
7227365d
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
jami-android/app/src/main/java/cx/ring/service/JamiJobService.kt
+4
-7
4 additions, 7 deletions
...droid/app/src/main/java/cx/ring/service/JamiJobService.kt
jami-android/app/src/main/java/cx/ring/service/SyncService.kt
+14
-8
14 additions, 8 deletions
...-android/app/src/main/java/cx/ring/service/SyncService.kt
with
18 additions
and
15 deletions
jami-android/app/src/main/java/cx/ring/service/JamiJobService.kt
+
4
−
7
View file @
0dd83be7
...
...
@@ -32,19 +32,16 @@ class JamiJobService : JobService() {
try
{
try
{
ContextCompat
.
startForegroundService
(
this
,
Intent
(
SyncService
.
ACTION_START
)
.
putExtra
(
SyncService
.
EXTRA_TIMEOUT
,
JOB_DURATION
)
.
setClass
(
this
,
SyncService
::
class
.
java
))
}
catch
(
e
:
IllegalStateException
)
{
Log
.
e
(
TAG
,
"Error starting service"
,
e
)
}
JamiApplication
.
instance
?.
startDaemon
(
this
)
Handler
().
postDelayed
({
Log
.
w
(
TAG
,
"jobFinished() $params"
)
try
{
startService
(
Intent
(
SyncService
.
ACTION_STOP
).
setClass
(
this
,
SyncService
::
class
.
java
))
}
catch
(
ignored
:
IllegalStateException
)
{
}
jobFinished
(
params
,
false
)
},
JOB_DURATION
)
JamiApplication
.
instance
?.
startDaemon
(
this
)
},
JOB_DURATION
+
500
)
}
catch
(
e
:
Exception
)
{
Log
.
e
(
TAG
,
"onStartJob failed"
,
e
)
}
...
...
@@ -67,7 +64,7 @@ class JamiJobService : JobService() {
private
val
TAG
=
JamiJobService
::
class
.
java
.
name
const
val
JOB_INTERVAL
=
12
*
DateUtils
.
HOUR_IN_MILLIS
const
val
JOB_FLEX
=
60
*
DateUtils
.
MINUTE_IN_MILLIS
const
val
JOB_DURATION
=
10
*
DateUtils
.
SECOND_IN_MILLIS
const
val
JOB_DURATION
=
7
*
DateUtils
.
SECOND_IN_MILLIS
const
val
JOB_ID
=
3905
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
jami-android/app/src/main/java/cx/ring/service/SyncService.kt
+
14
−
8
View file @
0dd83be7
...
...
@@ -50,9 +50,11 @@ class SyncService : Service() {
if
(
notification
==
null
)
{
val
deleteIntent
=
Intent
(
ACTION_STOP
)
.
setClass
(
applicationContext
,
SyncService
::
class
.
java
)
val
contentIntent
=
Intent
(
Intent
.
ACTION_VIEW
)
.
setClass
(
applicationContext
,
HomeActivity
::
class
.
java
)
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
notification
=
NotificationCompat
.
Builder
(
this
,
NotificationServiceImpl
.
NOTIF_CHANNEL_SYNC
)
.
setContentTitle
(
getString
(
R
.
string
.
notif_sync_title
))
.
setPriority
(
NotificationCompat
.
PRIORITY_DEFAULT
)
...
...
@@ -77,21 +79,25 @@ class SyncService : Service() {
val
timeout
=
intent
.
getLongExtra
(
EXTRA_TIMEOUT
,
-
1
)
if
(
timeout
>
0
)
{
Handler
().
postDelayed
({
try
{
startService
(
Intent
(
ACTION_STOP
).
setClass
(
applicationContext
,
SyncService
::
class
.
java
))
}
catch
(
ignored
:
IllegalStateException
)
{
}
stop
()
},
timeout
)
}
}
else
if
(
ACTION_STOP
==
action
)
{
stop
()
}
return
START_NOT_STICKY
}
private
fun
stop
()
{
serviceUsers--
if
(
serviceUsers
==
0
)
{
try
{
stopForeground
(
true
)
stopSelf
()
notification
=
null
}
catch
(
ignored
:
IllegalStateException
)
{
}
notification
=
null
}
return
START_NOT_STICKY
}
override
fun
onBind
(
intent
:
Intent
):
IBinder
?
=
null
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment