I want to know whether media player service (registers with media.player when device boots up) is running or not using adb shell. Is it possible?
I tried running ps command but no success.
As mentioned already, adb shell service list will only list system services.
As explained in Android Emulator: How can I get a list of services that are running, you can look for services created by apps by using
// List all services
adb shell dumpsys activity services
// List all services containing "myservice" in its name
adb shell dumpsys activity services myservice
If it returns something, it means the service is installed. To know if the service is currently started or stopped, look for app=ProcessRecord(...) or app=null respectively.
You can also do it Linux style with a simple
ps | grep myservice
while inside of your shell.
Try the command line
adb shell service list
I get a list of service names and their package names as well.
To simply check whether a specific service is running, use:
adb shell service check <service>
For example, adb shell service check media.player gives Service media.player: found if it's running and Service media.player: not found otherwise.
If you need more detail, try dumpsys <service>. For example, adb shell dumpsys media.player returns information about media.player's clients, open files, etc.
Finally, if you really need serious detail for debugging, try adb shell dumpsys activity services which shows what's going on from ActivityManager's point of view. This includes information about intents, create times, last activity time, bindings, etc., etc. You can redirect the output if you want to store it for later viewing/searching. It's typically rather lengthy.
For Android 10, list all currently running services:
adb shell dumpsys activity services | grep "ServiceRecord" | awk '{print $4}' | sed 's/.$//' | sort
To know whether an app process is running or not (background or foreground):
adb shell pidof <package.name>
It'll return empty string if process is not running else its pid.
Related
Does anyone know if there is a way to fire up a specific test from the GFXBench suite directly from adb shell?
I have seen references on the net about a very similar command:
adb shell am broadcast -a net.kishonti.testfw.ACTION_RUN_TESTS -n net.kishonti.gfxbench.vulkan.v50000.corporate/net.kishonti.benchui.corporate.CommandLineSession -e test_ids "gl_manhattan" --ei raw_config.single_frame 56400 --ei raw_config.max_rendered_frames 1 --es -screenshot_frames 0
but this does not seem to work with the current GFXBench application.
Maybe because you need to start the main activity first.
Have you tried
am start net.kishonti.gfxbench.vulkan.v50000.corporate/net.kishonti.app.MainActivity
Then sleep for a second to let the activity start, and then fire up the braodcast command
Have joined a new company and am new to android ui. What is the best way to see which activity in code relates to ui which am seeing in emulator or device?
Run the app on a device and make sure the device is connected to your machine. In your terminal, run:
adb shell dumpsys activity | grep -i 'resumedactivity\|focusedactivity'
This will output the name of the activity that is currently being displayed
Did anyone tried Android multiple display feature which is new in Android O
Following steps which is not working for me
1.connect hdmi cable to mobile(not sure can use USB as well)
2.make device in root and give following command (expect app is installed)
and not seen that app is launching on secondary(Multiple display feature
) it's just reflecting mobile display as it is because connected hdmi cable
adb shell am start com.Chrome.Canary --display 1
Please suggest any other way or any command to make it work?
Android in general do mirroring when two displays are connected. Right now google has not enabled support for touch and display mapping on the two displays. But if you want to launch any activity on any of the two displays then the command adb shell am start "your_activity" --display display_id will launch your activity on that particular display id. If the above command doesn't launch your activity then you can use adb shell am stack start display_id "your activity". This will also work. But regarding touch, it will be mapped to the primary display (display id 0). As per google you can enable the mapping of touch in EventHub.cpp of Android source code but till now I haven't found it useful. Hope my answer helps you.
Ran using below procedure passed with dell monitor:
ADB shell can be used to call Activity Manager(am) for starting any system actions (or an activity).
The syntax:
adb shell am start [-n (component)] [-a (action)] [-t (mime type)] [-d (data_URL)]
examples:
1. For starting ‘Settings app’:
adb shell am start -n com.android.settings/.Settings
In the above-mentioned command, we set component(-n) to be settings in a specific format.
For starting ‘Gallery app’:
adb shell am start -t image/* -a android.intent.action.VIEW
In the above-mentioned command, we are setting action(-a) for opening the default app for gallery with mime type(-t) to be image/*
In general, for external display the ‘display_id’ starts from ‘1’ in an increasing order, final command to do multi display operation is
adb shell am start -n com.android.settings/.Settings --display 1
The above command will display ‘Settings’ app only in external display with display_id = 1. The primary display will be in the same mode as before executing the command.
Question
What do adb shell start and adb shell stop actually do?
Description
I think they call /system/bin/start and /system/bin/stop. But these two executables don't give any clue about what they do. When tested on a real device, I found the zygote process is started and stopped. So these two commands seem to control the Android runtime (which corresponds to the yellow and blue parts in the figure below).
But what exact processes/services are started/stopped with these two commands?
Basically, all your Android services are restarted; those that are created and registered in SystemServer.java. This is called within the "Context of Zygote". So yes, Zygote is stopped.
All your services registered with ServiceManager in Android will get removed within ServiceManager. To restart them, do adb shell start.
Also note that SystemServer is started by Zygote, so init.rc tells that if Zygote is stopped, then even SystemServer must be stopped. Even SurfaceFlinger dies, since it's started from SystemServer but natively.
Run this on your device
grep ^service /init*rc
I have been wondering what "stop" does on Android too. Learned from someone that "stop" stops AP being rendered by SurfaceFlinger.
Had a try with the command like below. Execute the command, wait for a few seconds and then execute "stop" on Android. The command keeps printing increased number and creating .txt files. So maybe it only stops the Android part while the Linux part remains active. Just FYI.
busybox sh -c 'i=0;while [ $i -ne 100 ]; do echo $i >> count.txt; sleep 1; i=$(($i + 1)); echo $i; touch "$i.txt"; done;'
adb shell "start --help"
usage: start [SERVICE...]
Starts the given system service, or netd/surfaceflinger/zygotes.
adb shell "stop --help"
usage: stop [SERVICE...]
Stops the given system service, or netd/surfaceflinger/zygotes.
Well, I have searched a lot. People say that I need to close the window of emulator to close it. However, I need to reboot the emulator to catch ACTION_BOOT_COMPLETED by my BroadcastReceiver.
How can I do that?
You can use the following command from adb:
adb shell am activity/service/broadcast -a ACTION -c CATEGORY -n NAME
for example:
adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -c android.intent.category.HOME -n package_name/class_name
Note that class name and package names need to be as defined in the Manifest.
This will generate the Intent you want , directed only to the component you want (otherwise you system will go crazy with BOOT_COMPLETED sent...)
Or another way (also from the command line):
adb shell stop
adb shell start
First, make sure that USB Debugging is enabled from within the emulator:
click:
the Home icon
Menu icon
'Settings'
'Applications'
'Development'
make sure that the box next to 'USB debugging' contains a check mark
from a command-line:
adb -e reboot
EDIT:
This definitely doesn't work... very strange. I tested it and could not make the emulator reboot. It just hangs.
To emulate a broadcast action, you can connect via adb to the emulator/device and open a shell:
adb shell
Then, you can broadcast the action you want to test:
am broadcast -a android.intent.action.BOOT_COMPLETED
Please note that, in the latest Android versions, broadcasting the *android.intent.action.BOOT_COMPLETED* action will actually reboot your emulator/device.
While using tubemate on android tab, I was not successful in downloading video with the error:host interupped etc. I used the following commands:
adb shell stop
adb shell start
and the application started downloading videos.
emulators have on/off button - just click it
and another way:
If you start your emulator, and select the "wipe user data" checkbox, you will also receive that notification when boot is completed.