diff options
author | Joey Grover <joeygrover@gmail.com> | 2018-06-20 11:04:06 -0400 |
---|---|---|
committer | Joey Grover <joeygrover@gmail.com> | 2018-06-20 11:04:06 -0400 |
commit | cdd0146ab176dd70e7db56f374e9e5a6b7f7b21f (patch) | |
tree | 83696db8358e9e8d249ec833fe5a5398a5ec87d8 | |
parent | 53e495d6f4b932db0398b99e389668704dd87f09 (diff) | |
download | sdl_android-cdd0146ab176dd70e7db56f374e9e5a6b7f7b21f.tar.gz |
Make router service notificaiton even less intrusive
- Treat first bt device sighting as not SDL enabled
- Reduce notificaiton removal timeout to 10ms
- Set ongoing to false when waiting for a connection
-rw-r--r-- | sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java b/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java index 8862dea24..ee5fd9ead 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java +++ b/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java @@ -908,7 +908,7 @@ public class SdlRouterService extends Service{ } } int timeout = getNotificationTimeout(address); - enterForeground("Waiting for connection...", timeout); + enterForeground("Waiting for connection...", timeout, false); resetForegroundTimeOut(timeout); } if(intent.hasExtra(TransportConstants.PING_ROUTER_SERVICE_EXTRA)){ @@ -1012,18 +1012,15 @@ public class SdlRouterService extends Service{ if(address != null){ if(hasSDLConnected(address)){ return FOREGROUND_TIMEOUT * 2; - }else if(this.isFirstStatusCheck(address)){ + }else if(this.isFirstStatusCheck(address)) { // If this is the first time the service has ever connected to this device we want - // to give it a few extra seconds. - setSDLConnectedStatus(address,false); - return FOREGROUND_TIMEOUT; - }else{ - // If the service has seen this device before but hasn't ever connected, the - // notification can be removed ASAP. - return FOREGROUND_TIMEOUT/100; + // to ensure we have a record of it + setSDLConnectedStatus(address, false); } } - return FOREGROUND_TIMEOUT/100; + // If this is a new device or hasn't connected through SDL we want to limit the exposure + // of the SDL service in the foreground + return FOREGROUND_TIMEOUT/1000; } public void resetForegroundTimeOut(long delay){ @@ -1056,7 +1053,7 @@ public class SdlRouterService extends Service{ @SuppressLint("NewApi") @SuppressWarnings("deprecation") - private void enterForeground(String content, long chronometerLength) { + private void enterForeground(String content, long chronometerLength, boolean ongoing) { if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB){ Log.w(TAG, "Unable to start service as foreground due to OS SDK version being lower than 11"); isForeground = false; @@ -1094,7 +1091,7 @@ public class SdlRouterService extends Service{ builder.setSmallIcon(android.R.drawable.stat_sys_data_bluetooth); } builder.setLargeIcon(icon); - builder.setOngoing(true); + builder.setOngoing(ongoing); // Create an intent that will be fired when the user clicks the notification. Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(SDL_NOTIFICATION_FAQS_PAGE)); @@ -1240,7 +1237,7 @@ public class SdlRouterService extends Service{ public void onTransportConnected(final TransportType type){ isTransportConnected = true; cancelForegroundTimeOut(); - enterForeground("Connected to " + this.getConnectedDeviceName(),0); + enterForeground("Connected to " + this.getConnectedDeviceName(),0, true); if(packetWriteTaskMaster!=null){ packetWriteTaskMaster.close(); packetWriteTaskMaster = null; |