|
32 | 32 |
|
33 | 33 | package com.smartdevicelink.transport; |
34 | 34 |
|
| 35 | +import android.annotation.SuppressLint; |
35 | 36 | import android.app.ActivityManager; |
36 | 37 | import android.app.ActivityManager.RunningServiceInfo; |
| 38 | +import android.app.ForegroundServiceStartNotAllowedException; |
37 | 39 | import android.bluetooth.BluetoothAdapter; |
38 | 40 | import android.bluetooth.BluetoothDevice; |
39 | 41 | import android.bluetooth.BluetoothProfile; |
@@ -284,6 +286,8 @@ private static void startRouterService(Context context, ComponentName componentN |
284 | 286 |
|
285 | 287 | } catch (SecurityException e) { |
286 | 288 | DebugTool.logError(TAG, "Security exception, process is bad"); |
| 289 | + } catch (@SuppressLint({"NewApi", "LocalSuppress"}) ForegroundServiceStartNotAllowedException e) { |
| 290 | + DebugTool.logError(TAG, "Not allowed to start service in Foreground"); |
287 | 291 | } |
288 | 292 | } |
289 | 293 |
|
@@ -481,6 +485,8 @@ protected static void pingRouterService(Context context, String packageName, Str |
481 | 485 | } catch (SecurityException e) { |
482 | 486 | DebugTool.logError(TAG, "Security exception, process is bad"); |
483 | 487 | // This service could not be started |
| 488 | + } catch (@SuppressLint({"NewApi", "LocalSuppress"}) ForegroundServiceStartNotAllowedException e) { |
| 489 | + DebugTool.logError(TAG, "Not allowed to start service in Foreground"); |
484 | 490 | } |
485 | 491 | } |
486 | 492 |
|
|
0 commit comments