summaryrefslogtreecommitdiff
path: root/android/sdl_android/src
diff options
context:
space:
mode:
authorHenigan <rheniga1@MGC12Z921DLVCG.fbpld77.ford.com>2021-09-16 14:01:30 -0400
committerHenigan <rheniga1@MGC12Z921DLVCG.fbpld77.ford.com>2021-09-16 14:01:30 -0400
commit250dffbdf2b6574ca5d609e396b2eae123c1433c (patch)
tree99e16b4ccd8de1f843992720c81f772affbe4660 /android/sdl_android/src
parent4cb096b86a19c80eff1916c8420a9a90c0521ea7 (diff)
downloadsdl_android-250dffbdf2b6574ca5d609e396b2eae123c1433c.tar.gz
RS Notificaiton only if has connected before
Diffstat (limited to 'android/sdl_android/src')
-rw-r--r--android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
index 90a59dfd4..c9433dbd5 100644
--- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
+++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
@@ -202,6 +202,7 @@ public class SdlRouterService extends Service {
private boolean wrongProcess = false;
private boolean initPassed = false;
private boolean hasCalledStartForeground = false;
+ private boolean hasConnectedBefore = false;
boolean firstStart = true;
public static HashMap<String, RegisteredApp> registeredApps;
@@ -1284,6 +1285,7 @@ public class SdlRouterService extends Service {
}
if (intent != null) {
if (intent.getBooleanExtra(FOREGROUND_EXTRA, false)) {
+ hasConnectedBefore = false;
hasCalledStartForeground = false;
if (!this.isPrimaryTransportConnected()) { //If there is no transport connected we need to ensure the service is moved to the foreground
@@ -1296,6 +1298,7 @@ public class SdlRouterService extends Service {
}
boolean confirmedDevice = intent.getBooleanExtra(TransportConstants.CONFIRMED_SDL_DEVICE, false);
int timeout = getNotificationTimeout(address, confirmedDevice);
+ hasConnectedBefore = hasSDLConnected(address);
enterForeground("Waiting for connection...", timeout, false);
resetForegroundTimeOut(timeout);
@@ -1499,7 +1502,7 @@ public class SdlRouterService extends Service {
builder = new Notification.Builder(this, SDL_NOTIFICATION_CHANNEL_ID);
}
- if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
+ if (hasConnectedBefore && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
builder.setForegroundServiceBehavior(Notification.FOREGROUND_SERVICE_IMMEDIATE);
}
@@ -1573,7 +1576,7 @@ public class SdlRouterService extends Service {
private void safeStartForeground(int id, Notification notification) {
try {
if (notification == null) {
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
+ if (hasConnectedBefore && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
Notification.Builder builder =
new Notification.Builder(this, SDL_NOTIFICATION_CHANNEL_ID)
.setContentTitle("SmartDeviceLink")
@@ -3820,7 +3823,7 @@ public class SdlRouterService extends Service {
builder = new Notification.Builder(getApplicationContext(), TransportConstants.SDL_ERROR_NOTIFICATION_CHANNEL_ID);
}
- if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
+ if (hasConnectedBefore && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
builder.setForegroundServiceBehavior(Notification.FOREGROUND_SERVICE_IMMEDIATE);
}
ComponentName name = new ComponentName(this, this.getClass());