diff options
author | Elliott Hughes <enh@google.com> | 2011-04-13 15:39:37 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2011-04-13 16:43:15 -0700 |
commit | d195e5ab401432ddac659791640a2927fc668699 (patch) | |
tree | 61169b923b4d530a097ac8ff9e3029dfe468b7cd /cmds/system_server/library/system_init.cpp | |
parent | 966f9e558d714d9d41189e989b21e6d5fec35047 (diff) |
Replace a custom AndroidRuntime::findClass with a more targeted fix.
This seems simpler and more contained, and I think the comment explaining
why hoop-jumping is necessary is a bit clearer now.
Change-Id: Ief4afd7cbb42188ed835fce23e497520bdb753a8
Diffstat (limited to 'cmds/system_server/library/system_init.cpp')
-rw-r--r-- | cmds/system_server/library/system_init.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/cmds/system_server/library/system_init.cpp b/cmds/system_server/library/system_init.cpp index a29ba733a0f0..b615764c029f 100644 --- a/cmds/system_server/library/system_init.cpp +++ b/cmds/system_server/library/system_init.cpp @@ -37,7 +37,7 @@ namespace android { * This class is used to kill this process when the runtime dies. */ class GrimReaper : public IBinder::DeathRecipient { -public: +public: GrimReaper() { } virtual void binderDied(const wp<IBinder>& who) @@ -54,15 +54,15 @@ public: extern "C" status_t system_init() { LOGI("Entered system_init()"); - + sp<ProcessState> proc(ProcessState::self()); - + sp<IServiceManager> sm = defaultServiceManager(); LOGI("ServiceManager: %p\n", sm.get()); - + sp<GrimReaper> grim = new GrimReaper(); sm->asBinder()->linkToDeath(grim, grim.get(), 0); - + char propBuf[PROPERTY_VALUE_MAX]; property_get("system_init.startsurfaceflinger", propBuf, "1"); if (strcmp(propBuf, "1") == 0) { @@ -97,12 +97,23 @@ extern "C" status_t system_init() // the beginning of their processes's main(), before calling // the init function. LOGI("System server: starting Android runtime.\n"); - AndroidRuntime* runtime = AndroidRuntime::getRuntime(); LOGI("System server: starting Android services.\n"); - runtime->callStatic("com/android/server/SystemServer", "init2"); - + JNIEnv* env = runtime->getJNIEnv(); + if (env == NULL) { + return UNKNOWN_ERROR; + } + jclass clazz = env->FindClass("com/android/server/SystemServer"); + if (clazz == NULL) { + return UNKNOWN_ERROR; + } + jmethodID methodId = env->GetStaticMethodID(clazz, "init2", "()V"); + if (methodId == NULL) { + return UNKNOWN_ERROR; + } + env->CallStaticVoidMethod(clazz, methodId); + // If running in our own process, just go into the thread // pool. Otherwise, call the initialization finished // func to let this process continue its initilization. @@ -114,4 +125,3 @@ extern "C" status_t system_init() } return NO_ERROR; } - |