Skip to content

Commit 01a47b1

Browse files
committed
Make RS go to foreground if confirmed device
1 parent 7306e2b commit 01a47b1

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public void onListObtained(boolean successful) {
230230
* @param altTransportWake if the alt transport flag should be set. Only used in debug
231231
* @param device the connected bluetooth device
232232
*/
233-
private static void startRouterService(Context context, ComponentName componentName, boolean altTransportWake, BluetoothDevice device) {
233+
private static void startRouterService(Context context, ComponentName componentName, boolean altTransportWake, BluetoothDevice device, boolean confirmedDevice) {
234234
if (componentName == null) {
235235
return;
236236
}
@@ -246,6 +246,10 @@ private static void startRouterService(Context context, ComponentName componentN
246246
serviceIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
247247
}
248248

249+
if (confirmedDevice) {
250+
serviceIntent.putExtra(TransportConstants.CONFIRMED_SDL_DEVICE, confirmedDevice);
251+
}
252+
249253
try {
250254
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
251255
context.startService(serviceIntent);
@@ -301,7 +305,7 @@ public void onComplete(Vector<ComponentName> routerServices) {
301305
}
302306

303307
if (sdlAppInfoList != null && !sdlAppInfoList.isEmpty()) {
304-
startRouterService(context, sdlAppInfoList.get(0).getRouterServiceComponentName(), altTransportWake, device);
308+
startRouterService(context, sdlAppInfoList.get(0).getRouterServiceComponentName(), altTransportWake, device, false);
305309
} else{
306310
Log.d(TAG, "No SDL Router Services found");
307311
Log.d(TAG, "WARNING: This application has not specified its SdlRouterService correctly in the manifest. THIS WILL THROW AN EXCEPTION IN FUTURE RELEASES!!");
@@ -562,7 +566,7 @@ public boolean onTransportConnected(Context context, BluetoothDevice bluetoothDe
562566
final List<SdlAppInfo> sdlAppInfoList = AndroidTools.querySdlAppInfo(context, new SdlAppInfo.BestRouterComparator());
563567
if(sdlAppInfoList != null && !sdlAppInfoList.isEmpty()) {
564568
ComponentName routerService = sdlAppInfoList.get(0).getRouterServiceComponentName();
565-
startRouterService(context, routerService, false, bluetoothDevice);
569+
startRouterService(context, routerService, false, bluetoothDevice, true);
566570
}
567571
}
568572
}

android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,9 @@ public int onStartCommand(Intent intent, int flags, int startId) {
12591259
address = device.getAddress();
12601260
}
12611261
}
1262-
int timeout = getNotificationTimeout(address);
1262+
boolean confirmedDevice = intent.getBooleanExtra(TransportConstants.CONFIRMED_SDL_DEVICE, false);
1263+
int timeout = getNotificationTimeout(address, confirmedDevice);
1264+
12631265
enterForeground("Waiting for connection...", timeout, false);
12641266
resetForegroundTimeOut(timeout);
12651267
} else {
@@ -1383,9 +1385,9 @@ private void notifyAltTransportOfClose(int reason){
13831385
* @return the amount of time for a timeout handler to remove the notification.
13841386
*/
13851387
@SuppressLint("MissingPermission")
1386-
private int getNotificationTimeout(String address){
1388+
private int getNotificationTimeout(String address, boolean confirmedDevice){
13871389
if(address != null){
1388-
if(hasSDLConnected(address)){
1390+
if(confirmedDevice || hasSDLConnected(address)){
13891391
return FOREGROUND_TIMEOUT * 2;
13901392
}else if(this.isFirstStatusCheck(address)) {
13911393
// If this is the first time the service has ever connected to this device we want

base/src/main/java/com/smartdevicelink/transport/TransportConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public class TransportConstants {
4343
public static final String START_ROUTER_SERVICE_ACTION ="sdl.router.startservice";
4444
public static final String ROUTER_SERVICE_ACTION = "com.smartdevicelink.router.service";
4545
public static final String FOREGROUND_EXTRA = "foreground";
46+
public static final String CONFIRMED_SDL_DEVICE = "confirmed_sdl_device";
4647

4748
public static final String BIND_LOCATION_PACKAGE_NAME_EXTRA = "BIND_LOCATION_PACKAGE_NAME_EXTRA";
4849
public static final String BIND_LOCATION_CLASS_NAME_EXTRA = "BIND_LOCATION_CLASS_NAME_EXTRA";

0 commit comments

Comments
 (0)