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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-client-android
Commits
ff7d8b37
Commit
ff7d8b37
authored
4 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
syncservice: always call startForeground after startService
Change-Id: I6e09df9f614bff72889e79434afaeb906ff9dddc
parent
d79b9a68
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ring-android/app/src/main/java/cx/ring/services/SyncService.java
+11
-8
11 additions, 8 deletions
...droid/app/src/main/java/cx/ring/services/SyncService.java
with
11 additions
and
8 deletions
ring-android/app/src/main/java/cx/ring/services/SyncService.java
+
11
−
8
View file @
ff7d8b37
...
...
@@ -49,6 +49,8 @@ public class SyncService extends Service {
private
int
serviceUsers
=
0
;
private
final
Random
mRandom
=
new
Random
();
private
Notification
notification
=
null
;
@Inject
NotificationService
mNotificationService
;
...
...
@@ -62,14 +64,13 @@ public class SyncService extends Service {
public
int
onStartCommand
(
Intent
intent
,
int
flags
,
int
startId
)
{
String
action
=
intent
.
getAction
();
if
(
ACTION_START
.
equals
(
action
))
{
if
(
serviceUsers
==
0
)
{
if
(
notification
==
null
)
{
final
Intent
deleteIntent
=
new
Intent
(
ACTION_STOP
)
.
setClass
(
getApplicationContext
(),
SyncService
.
class
);
final
Intent
contentIntent
=
new
Intent
(
Intent
.
ACTION_VIEW
)
.
setClass
(
getApplicationContext
(),
HomeActivity
.
class
)
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
Notification
notif
=
new
NotificationCompat
.
Builder
(
this
,
NotificationServiceImpl
.
NOTIF_CHANNEL_SYNC
)
notification
=
new
NotificationCompat
.
Builder
(
this
,
NotificationServiceImpl
.
NOTIF_CHANNEL_SYNC
)
.
setContentTitle
(
getString
(
R
.
string
.
notif_sync_title
))
.
setPriority
(
NotificationCompat
.
PRIORITY_DEFAULT
)
.
setVisibility
(
NotificationCompat
.
VISIBILITY_PRIVATE
)
...
...
@@ -81,11 +82,12 @@ public class SyncService extends Service {
.
setDeleteIntent
(
PendingIntent
.
getService
(
getApplicationContext
(),
mRandom
.
nextInt
(),
deleteIntent
,
0
))
.
setContentIntent
(
PendingIntent
.
getActivity
(
getApplicationContext
(),
mRandom
.
nextInt
(),
contentIntent
,
0
))
.
build
();
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
Q
)
startForeground
(
NOTIF_SYNC_SERVICE_ID
,
notif
,
ServiceInfo
.
FOREGROUND_SERVICE_TYPE_DATA_SYNC
);
else
startForeground
(
NOTIF_SYNC_SERVICE_ID
,
notif
);
}
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
Q
)
startForeground
(
NOTIF_SYNC_SERVICE_ID
,
notification
,
ServiceInfo
.
FOREGROUND_SERVICE_TYPE_DATA_SYNC
);
else
startForeground
(
NOTIF_SYNC_SERVICE_ID
,
notification
);
if
(
serviceUsers
==
0
)
{
JamiApplication
.
getInstance
().
startDaemon
();
}
serviceUsers
++;
...
...
@@ -105,6 +107,7 @@ public class SyncService extends Service {
if
(
serviceUsers
==
0
)
{
stopForeground
(
true
);
stopSelf
();
notification
=
null
;
}
}
return
START_NOT_STICKY
;
...
...
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