AOSP ActivityManager not running
Asked Answered
B

1

4

I'm trying to port Android 7.0 into a customized HW platform and have zygote running background. But when I tried to start an app by using am start <>, it gives error "Can't connect to activity manager; is system running?". After that I did service list and found out that the activity:[android.app.IActivityManager] is not running (I don't know why). I'm actually kinda new to AOSP, but how could I start the AM service by typing a single shell command? I have attached the error message and logcat prints.

From the source code the ActivityManagerNative tries to getDefault() of ActivityManagerService, which is not available, so how to start ActivityManagerService or which process actually trigger it?

am start error log and logcat prints

enter image description here

enter image description here enter image description here

enter image description here

Battlefield answered 28/10, 2016 at 20:33 Comment(5)
service list doesn't show the current state of a service as oppose to dumpsys <servicename>. Does it output activity:[android.app.IActivityManager] or activity:[] or anything else? How do you know it's not running? The commands to control services are: start <servicename> and stop <servicename>.Community
What Activity are you trying to start? Is it your app's Activity or one of the system app's?Community
Hi Onik, thanks for the input. service list does not show <activity:[android.app.IActivityManager]> and not even <activity:[]>. I just did <start android.app.IActivityManager> but it shows <75518.022603] init: no such service 'android.app.IActivityManager'>; This is system app such as phone, music, and I cannot even start them.Battlefield
"I just did <start android.app.IActivityManager>" The service name is activity, so the command would be start activity. Note that not all services work as expected (or work at all) with start/stop.Community
start activity will gives error msg * init: no such service 'activity'*; Is this supposed in the *.rc script? I didn't see any activity related strings in *.rcBattlefield
C
3

AndroidException: Can't connect to activity manager; is the system running? means ActivityManagerService is not running as well as other core system services as reflected in the list of running services.

The cause of the problem is SystemServer. Started by zygote the system_server process acts like a host process for most of the system services to run in. It tries to start the services and dies in case of failure.

How to start ActivityManagerService or which process actually trigger it?

You can't do it manually. SystemServer is responsible for starting the service.

So maybe I need to disable both DisplayManagerS and Battery Service?

Despite the fact that you can effect the startup behavior of SystemServer by modifying the ro.factorytest and ro.headless system properties, for disabling these particular services you should edit SystemServer.java manually by commenting out the corresponding lines of code.

Community answered 28/10, 2016 at 22:42 Comment(9)
Hi Onik, for 1st problem, as you see I've attached the output of ps and service list, the zygote is indeed running background.Battlefield
My code is based on anroid-7.0.0_r14, I have not pushed to AOSP yet; I have attached the log: Left side is the error message from my customized platform, right side is the right behavior from an official android platform, both of them are based on same system.img. As you can see the log, I didn't see any AM failure message prints out, but somehow after ART WTF error in the left side, no other services prints anything. I'm tracing the code to see whats going on there.Battlefield
I didn't see zygote got any exit error and also zygote is actually running background. I'm guessing the DisplayManagerService somehow blocking the threads(as you see from the right side the display service prints out after ART), because there is no display in my customized HW and I actually did disable surfaceflinger during init, so is there any way for zygote(systemserver) to skip the display service during it starts up?Battlefield
@Battlefield "zygote is actually running background" I doubt you'd be so lucky to catch when zygote isn't running with ps - in case of failure its restart happens fast (what's why I asked to use the filter). Anyways, the problem is with HW. From what I see it's rather BatteryStatsService than DisplayManagerService. Have you tried to start the system with zygote disabled? If not try it by adding disabled at the end of init.zigote[32/64].rc. Doing this avoid starting zygote followed by SystemServer on boot.Community
both left and right side are DC power HW and they dont have any battery on board. So maybe I need to disable both DisplayManagerS and Battery Service? With zygote disabled, my system can boot upBattlefield
It's a customised kernel based on 3.14.43 vanilla kernel, I have actually enabled all android patch on there.Battlefield
I've attached the screenshot of ADM DDMS of andorid studio. As you can see 'uto' is my device name and it only shows one thread so far, The BatteryStas_wakepRason is the last thread it was kicked off by system_serverBattlefield
AM is up and running. I skip the display related methods in SystemServer. Since my platform does not have any display HW, so I will just bypass them.Battlefield
How did you disabled dsplayservice ? @BattlefieldPretypify

© 2022 - 2024 — McMap. All rights reserved.