Improve ActivityManagerInternal.startIsolatedProcess.

The processes created by ActivityManagerInternal.startIsolatedProcess
were not being tracked by ActivityManager after creation (other than to
handle crashes), but they still had ProcessRecords created for them.
This meant that if a second process was started with the same name, a
WTF would be triggered due to the old ProcessRecord still existing.

To resolve this, we change the way that these special isolated processes
start up: instead of directly executing the main() of the requested
class after forking, the process first runs ActivityThread as with
ordinary processes. When the process attaches to ActivityManagerService,
it is given the name and parameters of the entry point class to execute
instead of being given an ApplicationInfo to bind. We also reinstate the
previously-disabled process start timeout, since the process is now
expected to attach as normal.

This means that ActivityManagerService can observe the process's death
via Binder as usual and clean up the ProcessRecord, as well as making
this process less of a special case. To ensure the process is still
treated as important, we set a minimum OOM adjustment of
PERSISTENT_SERVICE_ADJ (which is accurate as the system server is
depending on the process even though it does not directly bind to it as
a service), and exclude processes of this type from being killed due to
being empty isolated processes. The process will exit voluntarily after
the entry point function returns instead.

Bug: 19061358
Test: Upgrade the current WebView implementation APK and check for WTFs
Change-Id: Ide4f89d308851bb591194a8d59e6d581e9d59b50
4 files changed