I have a package, androidx.test.services
(download link for APK), and within the package, there is a service called the androidx.test.services.speakeasy.server.SpeakEasyService
that is exported. I would like to start this service as a foreground service via adb
such that when I run adb shell pm dump androidx.test.services
, the DUMP OF SERVICE usagestats
section contains the following lines under the Last 24 hour events
.
time="2023-07-10 14:26:11" type=STANDBY_BUCKET_CHANGED package=androidx.test.services standbyBucket=10 reason=u-si flags=0x0
time="2023-07-10 14:26:11" type=FOREGROUND_SERVICE_START package=androidx.test.services class=androidx.test.services.speakeasy.server.SpeakEasyService flags=0x0
time="2023-07-10 14:26:11" type=NOTIFICATION_INTERRUPTION package=androidx.test.services channelId=test_services_channel_id flags=0x0
time="2023-07-10 14:26:20" type=FOREGROUND_SERVICE_STOP package=androidx.test.services class=androidx.test.services.speakeasy.server.SpeakEasyService flags=0x0
Would anybody happen to know what actions to take to reproduce these log lines? Below is the procedure that I have done so far which has not successfuly started the a service.
- Install the
androidx.test.services
APK with$ adb install <apk path>
- Change the standby bucket of the app from 50 to 10 with
$ adb shell am set-standby-bucket androidx.test.services 10
(this makes it active and creates the first line in the log with theSTANDBY_BUCKET_CHANGED
event type). - Attempt to start the only service that is exported from the APK which is this
androidx.test.services.speakeasy.server.SpeakEasyService
service. I attempted to start this with$ adb shell am startservice androidx.test.services/.speakeasy.server.SpeakEasyService
. However, I get an error stating thatapp is in background uid null
. To fix that, I ran it as a foreground service instead according to that SO post. - As a result, I ran
adb shell am start-foreground-service androidx.test.services/.speakeasy.server.SpeakEasyService
. This command appears to work fine where it just outputs the following text
Starting service: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=androidx.test.services/.speakeasy.server.SpeakEasyService }
However, when I check the DUMP OF SERVICE usagestats
section, I find that there is no line that states that the FOREGROUND_SERVICE_START
event, despite the output saying that the intent was started. I was wondering if anybody would happen to know what might be causing this issue with the foreground service not starting or being recorded in the log.
I'm new to Android, so I might be missing a conceptual understanding of how this works. If there is any information that I can provide, please let me know. Thanks!