1

In android 4.4 and below, who loads a native application (/system/bin/*) at startup, I think that the file init.rc is responsible, it is correct?

Then if a native application crashes (for example /system/bin/mediaserver) it restart automatically, then the question is: who is responsible for the application restart? there is a file?

Shridutt Kothari
  • 7,326
  • 3
  • 41
  • 61
Livio
  • 205
  • 1
  • 3
  • 9

1 Answers1

0

ActivityManagerService restarts the native apps.

There's usually some chatter in logcat when an app is restarted by the activity manager service, in the normal log and/or event log

(logcat -b events).

More Info:

If you see the code of ActivityManagerService.finishForceStopPackageLocked() method, this method fires an Intent with action Intent.ACTION_PACKAGE_RESTARTED.

And it is called from various methods like:
ActivityManagerService.forceStopPackage()
IPackageDataObserveronRemoveCompleted.onRemoveCompleted()

So internally there's an PackageDataObserver implemented in ActivityManagerService, which observes if any package is removed, and if it's need to be restarted, an intent is fired with the action Intent.ACTION_PACKAGE_RESTARTED

And every package is forced closed using ActivityManagerService.forceStopPackage(), it knows which package to restart.

Hope it clears the doubt.

Shridutt Kothari
  • 7,326
  • 3
  • 41
  • 61
  • Sorry, I see nothing from logcat, I see only a crash of /system/bin/mediaserver, but I don't see the restart of mediaserver with another pid – Livio Aug 31 '16 at 08:39