diff options
author | “JKAST” <julian.kast@live.com> | 2022-07-26 16:23:58 -0400 |
---|---|---|
committer | “JKAST” <julian.kast@live.com> | 2022-07-26 16:23:58 -0400 |
commit | 649885899a032116b0555dc99ac9927fe732ced5 (patch) | |
tree | 3f98d5c63e8f6eae148edafb2d367cb710be9c98 | |
parent | ccf0af9faa46da92a3ec10b05b3d397fa8f16a45 (diff) | |
download | sdl_android-649885899a032116b0555dc99ac9927fe732ced5.tar.gz |
Catch ForegroundServiceStartNotAllowedException in SdlBroadcastReceiver
-rw-r--r-- | android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java index 7bed1b482..07e155bac 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java @@ -32,8 +32,10 @@ package com.smartdevicelink.transport; +import android.annotation.SuppressLint; import android.app.ActivityManager; import android.app.ActivityManager.RunningServiceInfo; +import android.app.ForegroundServiceStartNotAllowedException; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothProfile; @@ -284,6 +286,8 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver { } catch (SecurityException e) { DebugTool.logError(TAG, "Security exception, process is bad"); + } catch (@SuppressLint({"NewApi", "LocalSuppress"}) ForegroundServiceStartNotAllowedException e) { + DebugTool.logError(TAG, "Not allowed to start service in Foreground"); } } @@ -481,6 +485,8 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver { } catch (SecurityException e) { DebugTool.logError(TAG, "Security exception, process is bad"); // This service could not be started + } catch (@SuppressLint({"NewApi", "LocalSuppress"}) ForegroundServiceStartNotAllowedException e) { + DebugTool.logError(TAG, "Not allowed to start service in Foreground"); } } |