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

Community
  • 1
  • 1
georgewhr
  • 174
  • 1
  • 12
  • `service list` doesn't show the current state of a service as oppose to `dumpsys `. 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 ` and `stop `. – Onik Oct 28 '16 at 21:22
  • What `Activity` are you trying to start? Is it your app's `Activity` or one of the system app's? – Onik Oct 28 '16 at 21:52
  • Hi Onik, thanks for the input. **service list** does not show and not even . I just did 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. – georgewhr Oct 28 '16 at 22:37
  • _"I just did "_ 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`. – Onik Oct 28 '16 at 22:44
  • **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 *.rc – georgewhr Oct 28 '16 at 23:21

1 Answers1

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.

Onik
  • 19,396
  • 14
  • 68
  • 91
  • Hi Onik, for 1st problem, as you see I've attached the output of **ps** and **service list**, the zygote is indeed running background. – georgewhr Oct 28 '16 at 22:48
  • 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. – georgewhr Oct 30 '16 at 18:09
  • 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? – georgewhr Oct 30 '16 at 18:36
  • @georgewhr _"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. – Onik Oct 30 '16 at 18:55
  • 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 up – georgewhr Oct 30 '16 at 19:02
  • It's a customised kernel based on 3.14.43 vanilla kernel, I have actually enabled all android patch on there. – georgewhr Oct 31 '16 at 19:00
  • 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_server – georgewhr Oct 31 '16 at 19:12
  • 1
    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. – georgewhr Nov 01 '16 at 23:31
  • How did you disabled dsplayservice ? @georgewhr – Vijeth PO May 31 '21 at 14:27