2

I create simple android application which contains one activity and service. The service is defined by aidl file and can receive calls from the activity via Binder. Everything works as expected.

Now I deploy the application on device (also I've tried an emulator) and I want to send message to the service via adb:

$ adb shell service call \
    com.example.gluttton.dummyandroid/.DummyService 0 STR "Bingo!"

and got message that such service doesn't exist:

service: Service com.example.gluttton.dummyandroid/.DummyService does not exist

I try to check is my service launched:

$ adb shell service list

or

$ adb shell service check com.example.gluttton.dummyandroid/.DummyService

and got similar result.

But at the same time I cat see my service using dumpsys:

$ adb shell dumpsys activity services Dummy
ACTIVITY MANAGER SERVICES (dumpsys activity services)
  User 0 active services:
  * ServiceRecord{a1627b5 u0 com.example.gluttton.dummyandroid/.DummyService}
    intent={act=android.intent.action.MAIN     cat=[android.intent.category.LAUNCHER]     cmp=com.example.gluttton.dummyandroid/.DummyService}
    packageName=com.example.gluttton.dummyandroid
    processName=com.example.gluttton.dummyandroid
    baseDir=/data/app/com.example.gluttton.dummyandroid-1/base.apk
    dataDir=/data/data/com.example.gluttton.dummyandroid
    app=ProcessRecord{114da04c 20168:com.example.gluttton.dummyandroid/u0a126}
    createTime=-21m40s817ms startingBgTimeout=--
    lastActivity=-21m40s816ms restartTime=-21m40s816ms createdFromFg=true
    startRequested=true delayedStop=false stopIfKilled=false callStart=true lastStartId=1

Also I can start my service:

$ adb shell am startservice com.example.gluttton.dummyandroid/.DummyService
Starting service: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.gluttton.dummyandroid/.DummyService }

and stop it:

$ adb shell am stopservice com.example.gluttton.dummyandroid/.DummyService
Stopping service: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.gluttton.dummyandroid/.DummyService }
Service stopped

So my question is where is my mistake and how to send message to my service via adb?

3
  • seems its for system services only: stackoverflow.com/questions/12157442/…, i couldnt find my service as well using service list Commented May 14, 2017 at 18:04
  • and if adb shell am startservice works then use it to pass the message to your service Commented May 14, 2017 at 18:18
  • @pskink, can you show how to pass the message using startservice? Commented May 14, 2017 at 18:31

2 Answers 2

1

I think system/bin/service is only for working with android system services. If you do a adb -s emulator-5554 shell service list for example you will see only a list of services such as

Found 100 services:
0   carrier_config: [com.android.internal.telephony.ICarrierConfigLoader]
1   phone: [com.android.internal.telephony.ITelephony]
2   isms: [com.android.internal.telephony.ISms]
3   iphonesubinfo: [com.android.internal.telephony.IPhoneSubInfo]

If you wish to send a message to your service you can do so via

adb shell am startservice [options] intent

Start the Service specified by intent. See the Specification for intent arguments.

Options are:

--user user_id | current: Specify which user to run as; if not specified, then run as the current user.

see this link for how to set up the intent as an argument

Sign up to request clarification or add additional context in comments.

Comments

0

adb shell am start-foreground-service --user 0 -n com.varun.services/.wifiservice --ei "op" 1

there is a service inside the app wifiservice which will take input like 1 and then perform the operations by verifying the data

Service code is below

enter image description here

Might be this will helpful

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.