0

I'm working on an app targeting a Samsung Galaxy S8 running Oreo or Nougat that requires constant network access in the background. The app needs to send UDP packets and access user GPS location at regular intervals at ALL times, regardless of app-standby or doze mode. I know this is not standard, but this app will not be on the Google Play store, and this network activity is mission critical to our app's functionality.

I am referencing this document for development purposes:

and have made my app Oreo compliant by using startForegroundService and startForeground as described in the video below:

I have added the below code to opt out of battery optimization as well:

    Intent intent = new Intent();
    String packageName = this.getPackageName();
    PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
    if (!pm.isIgnoringBatteryOptimizations(packageName)){
        intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
        intent.setData(Uri.parse("package:" + packageName));
        this.startActivity(intent);
    }

Additionally, I have turned off all battery optimization and app monitoring, and for my app checked allow background data usage and allow app while data saver on. I've also set the Wi-Fi to "allow while sleeping". I have seen the CORRECT behavior when debugging and testing for app-standby/doze using ADB as described in this link:

but when I actually unplug the device and continue running the application, I do NOT see the behavior that was shown when I emulate unplugging and doze/standby. Eventually, the network activity stops for the app running in the background, even though the foreground service notification is still showing that the service which sends the UDP packets is still active. This makes it very hard to debug since I cannot force whatever state is causing this bis the adb like the docs suggest. It also makes me suspect that this is a Samsung issue and not an Android issue since I feel that I've complied as best as I know to the Android background execution standards.

When I'm able to examine the system logcat after noticing a network outage, I still can't find any indication of what's going wrong, and upon plugging the phone back in to debug, I can confirm my service process is still alive. Here is a snippet of the logcat that contains the last UDP message my app is able to send before it simply sends no more (at 07-09 12:10:17.206 23046-23107 in the below trace):

07-09 12:10:14.209 23046-23102/com.partyturtle.app.debug:service V/Mission: Got next location
07-09 12:10:14.347 3702-6311/? D/BatteryService: !@BatteryListener : batteryPropertiesChanged!
07-09 12:10:14.659 3702-4251/? D/libgps: OnGpsExtensionMessage: message_id(1), data(0x768b230044), size(2728)
07-09 12:10:14.659 3702-4251/? D/libgps: GpsiHook: API: gpsLocationCb(GpsiHookStateGps: e,c,G)
07-09 12:10:14.659 3702-4251/? D/libgps: proxy__gnss_sv_status_cb: called. num_svs(10)
07-09 12:10:14.660 3702-4251/? D/GnssLocationProvider_ex: SV Count : 10(7) / TOP5(v) : 23 21 19 19 15  / TOP5(u) : 23 21 19 19 15 
07-09 12:10:14.664 4240-4240/? D/DriftDetector_FLP: TCXO drift, list is full(2), Max = 435.0 / min = 435.0 / Drift = 0.0 / prevDrift = 435.0
07-09 12:10:14.665 3702-4339/? D/SamsungAlarmManager: Cancel Alarm calling from uid:10028 pid :31419 / listener:android.app.IAlarmListener$Stub$Proxy@643f1eb
07-09 12:10:14.667 3702-4339/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121102, SetElapsed=1558302195, nowELAPSED=1558254301
07-09 12:10:14.673 3702-3974/? D/SamsungAlarmManager: setExact Listener (T:3/F:1/AC:false) 20180709T121021 - CU:10028/CP:31419
07-09 12:10:14.673 3702-3974/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121021, SetElapsed=1558261297, nowELAPSED=1558254307
07-09 12:10:14.681 3702-4256/? I/LocationManagerService: remove a75c706
07-09 12:10:14.681 3702-4256/? I/LocationManagerService: removeUpdates, receiver.requestedID = a75c706
07-09 12:10:14.683 4240-4240/? E/RequestManager_FLP: [LocationManagerService] Location remove a75c706 from android
07-09 12:10:14.692 4240-4240/? D/BlacklistMonitor_FLP: checkProviderOperation, The size of providerList is larger than monitorList, mProvider = gps
07-09 12:10:14.693 4240-4240/? D/LocationManagerController_FLP: Already resume status so return
07-09 12:10:14.694 4240-4240/? D/BlacklistMonitor_FLP: checkProviderOperation, The size of providerList is larger than monitorList, mProvider = fused
07-09 12:10:14.694 4240-4240/? D/LocationManagerController_FLP: Already resume status so return
07-09 12:10:15.202 23046-23107/com.partyturtle.app.debug:service V/Mission: Got next message tick
07-09 12:10:15.203 23046-23107/com.partyturtle.app.debug:service V/Mission: Got next bullseye
07-09 12:10:15.203 23046-23107/com.partyturtle.app.debug:service V/Mission: Got next bullseye sequence
07-09 12:10:15.206 23046-23107/com.partyturtle.app.debug:service D/Mission: **UDP message sent**
07-09 12:10:15.208 23046-23102/com.partyturtle.app.debug:service V/Mission: Got next location
07-09 12:10:15.660 4240-4240/? D/DriftDetector_FLP: TCXO drift, list is full(2), Max = 435.0 / min = 435.0 / Drift = 0.0 / prevDrift = 435.0
07-09 12:10:15.663 3702-4251/? D/libgps: OnGpsExtensionMessage: message_id(1), data(0x768b230044), size(2728)
07-09 12:10:15.663 3702-4251/? D/libgps: GpsiHook: API: gpsLocationCb(GpsiHookStateGps: e,c,G)
07-09 12:10:15.663 3702-4251/? D/libgps: proxy__gnss_sv_status_cb: called. num_svs(9)
07-09 12:10:15.664 3702-4251/? D/GnssLocationProvider_ex: SV Count : 9(7) / TOP5(v) : 23 21 20 19 15  / TOP5(u) : 23 21 20 19 15 
07-09 12:10:15.668 3702-4205/? D/SamsungAlarmManager: Cancel Alarm calling from uid:10028 pid :31419 / listener:android.app.IAlarmListener$Stub$Proxy@b6dc1c7
07-09 12:10:15.670 3702-4205/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121102, SetElapsed=1558302194, nowELAPSED=1558255304
07-09 12:10:15.674 3702-4256/? I/LocationManagerService: remove 5b053f4
07-09 12:10:15.674 3702-4256/? I/LocationManagerService: removeUpdates, receiver.requestedID = 5b053f4
07-09 12:10:15.680 4240-4240/? E/RequestManager_FLP: [LocationManagerService] Location remove 5b053f4 from android
07-09 12:10:15.681 3702-17869/? D/SamsungAlarmManager: setExact Listener (T:3/F:1/AC:false) 20180709T121022 - CU:10028/CP:31419
07-09 12:10:15.681 3702-17869/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121022, SetElapsed=1558262302, nowELAPSED=1558255315
07-09 12:10:15.687 4240-4240/? D/BlacklistMonitor_FLP: checkProviderOperation, The size of providerList is larger than monitorList, mProvider = gps
07-09 12:10:15.687 4240-4240/? D/LocationManagerController_FLP: Already resume status so return
07-09 12:10:15.687 4240-4240/? D/BlacklistMonitor_FLP: checkProviderOperation, The size of providerList is larger than monitorList, mProvider = fused
07-09 12:10:15.689 4240-4240/? D/LocationManagerController_FLP: Already resume status so return
07-09 12:10:15.830 4631-4631/? D/io_stats: !@   8,0 r 73156 4780028 w 484050 9282692 d 40893 3164864 f 180121 195116 iot 475556 265003 th 458260 0 0 pt 0 inp 0 0 159684.165
07-09 12:10:16.202 23046-23107/com.partyturtle.app.debug:service V/Mission: Got next message tick
07-09 12:10:16.203 23046-23107/com.partyturtle.app.debug:service V/Mission: Got next bullseye
07-09 12:10:16.203 23046-23107/com.partyturtle.app.debug:service V/Mission: Got next bullseye sequence
07-09 12:10:16.206 23046-23107/com.partyturtle.app.debug:service D/Mission: **UDP message sent**
07-09 12:10:16.209 23046-23102/com.partyturtle.app.debug:service V/Mission: Got next location
07-09 12:10:16.658 4240-4240/? D/DriftDetector_FLP: TCXO drift, list is full(2), Max = 435.0 / min = 435.0 / Drift = 0.0 / prevDrift = 435.0
07-09 12:10:16.662 3702-4251/? D/libgps: OnGpsExtensionMessage: message_id(1), data(0x768b230044), size(2728)
07-09 12:10:16.662 3702-4251/? D/libgps: GpsiHook: API: gpsLocationCb(GpsiHookStateGps: e,c,G)
07-09 12:10:16.663 3702-4251/? D/libgps: proxy__gnss_sv_status_cb: called. num_svs(10)
07-09 12:10:16.663 3702-4251/? D/GnssLocationProvider_ex: SV Count : 10(7) / TOP5(v) : 23 21 20 19 15  / TOP5(u) : 23 21 20 19 15 
07-09 12:10:16.670 3702-5071/? D/SamsungAlarmManager: Cancel Alarm calling from uid:10028 pid :31419 / listener:android.app.IAlarmListener$Stub$Proxy@87ab363
07-09 12:10:16.672 3702-5071/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121102, SetElapsed=1558302195, nowELAPSED=1558256306
07-09 12:10:16.680 3702-20537/? D/SamsungAlarmManager: setExact Listener (T:3/F:1/AC:false) 20180709T121023 - CU:10028/CP:31419
07-09 12:10:16.680 3702-20537/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121023, SetElapsed=1558263300, nowELAPSED=1558256315
07-09 12:10:16.704 4879-4978/? D/ContactsProvider_EventLog: contents_sample_state: [ contacts(6) data(30) accounts({com.google (2)=6}) accounts deleted({}) calls([]) countryIso(US) userId(0)  ]
                                                            contents_sample_state: [ agr({[2]=6})  ]
                                                            contents_sample_state: [ actCnt({android.process.acore=1})  ]
07-09 12:10:16.707 4879-4978/? E/ContactsProvider_EventLog: Flush buffer to file cnt : 1 size : 0Kb duration : 2ms lastUpdatedAfter : 60107 ms mFlush_time_threasold : 2000 mCurrentSize : 279
07-09 12:10:17.202 23046-23107/com.partyturtle.app.debug:service V/Mission: Got next message tick
07-09 12:10:17.203 23046-23107/com.partyturtle.app.debug:service V/Mission: Got next bullseye
07-09 12:10:17.203 23046-23107/com.partyturtle.app.debug:service V/Mission: Got next bullseye sequence
07-09 12:10:17.206 23046-23107/com.partyturtle.app.debug:service D/Mission: **UDP message sent**
07-09 12:10:17.207 23046-23102/com.partyturtle.app.debug:service V/Mission: Got next location
07-09 12:10:17.655 3702-4251/? D/libgps: OnGpsExtensionMessage: message_id(1), data(0x768b230044), size(2728)
07-09 12:10:17.656 3702-4251/? D/libgps: GpsiHook: API: gpsLocationCb(GpsiHookStateGps: e,c,G)
07-09 12:10:17.656 3702-4251/? D/libgps: proxy__gnss_sv_status_cb: called. num_svs(9)
07-09 12:10:17.656 3702-4251/? D/GnssLocationProvider_ex: SV Count : 9(7) / TOP5(v) : 23 21 19 19 15  / TOP5(u) : 23 21 19 19 15 
07-09 12:10:17.659 4240-4240/? D/DriftDetector_FLP: TCXO drift, list is full(2), Max = 435.0 / min = 435.0 / Drift = 0.0 / prevDrift = 435.0
07-09 12:10:17.666 3702-6269/? D/SamsungAlarmManager: Cancel Alarm calling from uid:10028 pid :31419 / listener:android.app.IAlarmListener$Stub$Proxy@8d8b0de
07-09 12:10:17.668 3702-6269/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121102, SetElapsed=1558302194, nowELAPSED=1558257302
07-09 12:10:17.674 3702-4256/? I/LocationManagerService: remove 79e2d8c
07-09 12:10:17.674 3702-4256/? I/LocationManagerService: removeUpdates, receiver.requestedID = 79e2d8c
07-09 12:10:17.675 4240-4240/? E/RequestManager_FLP: [LocationManagerService] Location remove 79e2d8c from android
07-09 12:10:17.677 3702-5071/? D/SamsungAlarmManager: setExact Listener (T:3/F:1/AC:false) 20180709T121024 - CU:10028/CP:31419
07-09 12:10:17.680 3702-5071/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121024, SetElapsed=1558264293, nowELAPSED=1558257314
07-09 12:10:18.672 3702-15001/? D/SamsungAlarmManager: Cancel Alarm calling from uid:10028 pid :31419 / listener:android.app.IAlarmListener$Stub$Proxy@5bafcea
07-09 12:10:18.675 3702-15001/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121102, SetElapsed=1558302195, nowELAPSED=1558258309
07-09 12:10:18.683 3702-17869/? D/SamsungAlarmManager: setExact Listener (T:3/F:1/AC:false) 20180709T121025 - CU:10028/CP:31419
07-09 12:10:18.683 3702-17869/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121025, SetElapsed=1558265299, nowELAPSED=1558258317
07-09 12:10:19.666 3702-6269/? D/SamsungAlarmManager: Cancel Alarm calling from uid:10028 pid :31419 / listener:android.app.IAlarmListener$Stub$Proxy@4c3fdb6
07-09 12:10:19.668 3702-6269/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121102, SetElapsed=1558302194, nowELAPSED=1558259302
07-09 12:10:19.678 3702-4211/? D/SamsungAlarmManager: setExact Listener (T:3/F:1/AC:false) 20180709T121026 - CU:10028/CP:31419
07-09 12:10:19.679 3702-4211/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121026, SetElapsed=1558266296, nowELAPSED=1558259313
07-09 12:10:20.518 3702-5522/? D/SSRM:y: SIOP:: AP = 270, PST = 270 (W:15), CP = 266, CUR = -92, LCD = 0
07-09 12:10:20.529 3702-5522/? D/SSRM:c: ssrm_camera_info is null
07-09 12:10:20.550 3702-5522/? D/SSRM:b: ATC: power = AP = 84, LCD = -1, WIFI = 0, Camera = 0(Sensor:0, Comp:0), 
07-09 12:10:20.550 3702-5522/? D/SSRM:b: ATC: current = AP = 21, LCD = 56, WIFI = 0, Camera = 0(Sensor:0, Comp:0), 
07-09 12:10:20.551 3702-5522/? D/SSRM:b: ATC: Ambient Temperature = 26.00, Skin temperature = 26.00
07-09 12:10:20.668 3702-6311/? D/SamsungAlarmManager: Cancel Alarm calling from uid:10028 pid :31419 / listener:android.app.IAlarmListener$Stub$Proxy@5c6318d
07-09 12:10:20.671 3702-6311/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121102, SetElapsed=1558302194, nowELAPSED=1558260306
07-09 12:10:20.676 3702-17869/? D/SamsungAlarmManager: setExact Listener (T:3/F:1/AC:false) 20180709T121027 - CU:10028/CP:31419
07-09 12:10:20.676 3702-17869/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121027, SetElapsed=1558267301, nowELAPSED=1558260311
07-09 12:10:20.836 4631-4631/? D/io_stats: !@   8,0 r 73156 4780028 w 484061 9282820 d 40894 3164868 f 180123 195118 iot 475564 265007 th 458488 0 0 pt 0 inp 0 0 159689.171
07-09 12:10:21.666 3702-4205/? D/SamsungAlarmManager: Cancel Alarm calling from uid:10028 pid :31419 / listener:android.app.IAlarmListener$Stub$Proxy@a61bc90
07-09 12:10:21.668 3702-4205/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121102, SetElapsed=1558302194, nowELAPSED=1558261302
07-09 12:10:21.682 3702-4336/? D/SamsungAlarmManager: setExact Listener (T:3/F:1/AC:false) 20180709T121028 - CU:10028/CP:31419
07-09 12:10:21.683 3702-4336/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121028, SetElapsed=1558268304, nowELAPSED=1558261317
07-09 12:10:22.685 3702-9512/? D/SamsungAlarmManager: Cancel Alarm calling from uid:10028 pid :31419 / listener:android.app.IAlarmListener$Stub$Proxy@ece11bc
07-09 12:10:22.687 3702-9512/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121102, SetElapsed=1558302195, nowELAPSED=1558262321
07-09 12:10:22.695 3702-4044/? D/SamsungAlarmManager: setExact Listener (T:3/F:1/AC:false) 20180709T121029 - CU:10028/CP:31419
07-09 12:10:22.695 3702-4044/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121029, SetElapsed=1558269299, nowELAPSED=1558262329
07-09 12:10:23.668 3702-17869/? D/SamsungAlarmManager: Cancel Alarm calling from uid:10028 pid :31419 / listener:android.app.IAlarmListener$Stub$Proxy@c88c1cb
07-09 12:10:23.672 3702-17869/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121102, SetElapsed=1558302194, nowELAPSED=1558263306
07-09 12:10:23.677 3702-4348/? D/SamsungAlarmManager: setExact Listener (T:3/F:1/AC:false) 20180709T121030 - CU:10028/CP:31419
07-09 12:10:23.677 3702-4348/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121030, SetElapsed=1558270300, nowELAPSED=1558263311
07-09 12:10:24.671 3702-4211/? D/SamsungAlarmManager: Cancel Alarm calling from uid:10028 pid :31419 / listener:android.app.IAlarmListener$Stub$Proxy@85fafa7
07-09 12:10:24.673 3702-4211/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121102, SetElapsed=1558302195, nowELAPSED=1558264307
07-09 12:10:24.682 3702-31336/? D/SamsungAlarmManager: setExact Listener (T:3/F:1/AC:false) 20180709T121031 - CU:10028/CP:31419
07-09 12:10:24.682 3702-31336/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121031, SetElapsed=1558271303, nowELAPSED=1558264316
07-09 12:10:25.655 3702-4339/? D/SamsungAlarmManager: Cancel Alarm calling from uid:10028 pid :31419 / listener:android.app.IAlarmListener$Stub$Proxy@ccd9f43
07-09 12:10:25.657 3702-4339/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121102, SetElapsed=1558302194, nowELAPSED=1558265291
07-09 12:10:25.667 3702-4205/? D/SamsungAlarmManager: setExact Listener (T:3/F:1/AC:false) 20180709T121032 - CU:10028/CP:31419
07-09 12:10:25.667 3702-4205/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121032, SetElapsed=1558272288, nowELAPSED=1558265301
07-09 12:10:25.840 4631-4631/? D/io_stats: !@   8,0 r 73156 4780028 w 484073 9282924 d 40895 3164872 f 180124 195119 iot 475572 265010 th 458572 0 0 pt 0 inp 0 0 159694.176
07-09 12:10:26.669 3702-3796/? D/SamsungAlarmManager: Cancel Alarm calling from uid:10028 pid :31419 / listener:android.app.IAlarmListener$Stub$Proxy@911f63e
07-09 12:10:26.671 3702-3796/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121102, SetElapsed=1558302194, nowELAPSED=1558266305
07-09 12:10:26.676 3702-30541/? D/SamsungAlarmManager: setExact Listener (T:3/F:1/AC:false) 20180709T121033 - CU:10028/CP:31419
07-09 12:10:26.676 3702-30541/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121033, SetElapsed=1558273300, nowELAPSED=1558266311
07-09 12:10:27.673 3702-4839/? D/SamsungAlarmManager: Cancel Alarm calling from uid:10028 pid :31419 / listener:android.app.IAlarmListener$Stub$Proxy@dd2c9b5
07-09 12:10:27.674 3702-4839/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121102, SetElapsed=1558302194, nowELAPSED=1558267309
07-09 12:10:27.682 3702-4211/? D/SamsungAlarmManager: setExact Listener (T:3/F:1/AC:false) 20180709T121034 - CU:10028/CP:31419
07-09 12:10:27.683 3702-4211/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121034, SetElapsed=1558274303, nowELAPSED=1558267317
07-09 12:10:27.764 3702-4213/? E/Watchdog: !@Sync 5320 [09_Jul_12_10_27.764]
07-09 12:10:28.662 3702-14279/? D/SamsungAlarmManager: Cancel Alarm calling from uid:10028 pid :31419 / listener:android.app.IAlarmListener$Stub$Proxy@3b34c31
07-09 12:10:28.664 3702-14279/? I/SamsungAlarmManager: setLocked to kernel - T:3 / 20180709T121102, SetElapsed=1558302194, nowELAPSED=1558268299
07-09 12:10:28.674 3702-3974/? D/SamsungAlarmManager: setExact Listener

My main questions are:

  • Is there a reason why I would have see no issues while testing for doze/standby while debugging with ADB but see issues and behavior changes after unplugging?
  • This app functions correctly, with all background network activity persisting for a Nexus 5X with Nougat. Is there a reason the app wouldn't be working on an S8 with Nougat when it does function as intended on the Nexus 5X?
  • Is there a clear definition for Samsung Galaxy S8 app management somewhere that might describe the behavior I'm seeing? Maybe it's possible that the "Samsung Experience" doesn't actually kill services but it does do some other magic like simply snuff the network activity whenever it wants. If this is the case then I don't know about it.

Thanks for taking the time to read and for any help! If I can provide any other specifics let me know in a comment.

ThePartyTurtle
  • 2,276
  • 2
  • 18
  • 32
  • 1
    Galaxy devices have given me a lot of problems with this sort of stuff. Even if you turn off all of the battery management stuff it seems to put your app to sleep anyway. – BShaps Jul 09 '18 at 18:27
  • @BShaps yea this is exactly what I'm experiencing right now. Feels good to hear a similar experience. Do you know if there is any definitive description/documentation of this behavior? – ThePartyTurtle Jul 09 '18 at 18:29
  • For anyone experiencing this problem still, I ended up having to ignore battery optimizations, implement my service as a foreground service, AND secure a CPU wakelock, which as far as I had read, shouldn't have been necessary but it did turn out to be the case. – ThePartyTurtle Jul 17 '18 at 15:48
  • did you find a solution, i'm having the same issue with a samsung phone? – 124697 Jul 23 '20 at 15:49
  • @code511788465541441 I actually sort of addressed my own issue in the comment above. You just reminded me of this open question though, so I'm going to submit that comment as an answer and accept, for the sake of anyone else that cruises by this post. – ThePartyTurtle Jul 24 '20 at 19:52

2 Answers2

0

Go to Device Maintainance in Settings then tap Battery, If you haven't already added your app in ''unmonitored apps, then add it.


Alternatively, Tap the 3-dots menu and Turn off App Power monitor. Maybe that puts your app to sleep.

0

I posted this in a comment sometime ago, and a recent commenter reminded me that this question is open and I figured I should post and accept as an answer what worked for me:

To solve my issue, I ended up having to ignore battery optimizations, AND implement my service as a foreground service, AND secure a CPU wakelock.

ThePartyTurtle
  • 2,276
  • 2
  • 18
  • 32