Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 501c4671 authored by Jeff Brown's avatar Jeff Brown Committed by Android (Google) Code Review
Browse files

Merge "Eliminate single-process mode. Bug: 5010576"

parents 9b40a61c 10e89712
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -14392,7 +14392,7 @@ package android.os {
    method public static final void sendSignal(int, int);
    method public static final void setThreadPriority(int, int) throws java.lang.IllegalArgumentException, java.lang.SecurityException;
    method public static final void setThreadPriority(int) throws java.lang.IllegalArgumentException, java.lang.SecurityException;
    method public static final boolean supportsProcesses();
    method public static final deprecated boolean supportsProcesses();
    field public static final int BLUETOOTH_GID = 2000; // 0x7d0
    field public static final int FIRST_APPLICATION_UID = 10000; // 0x2710
    field public static final int LAST_APPLICATION_UID = 99999; // 0x1869f
+6 −14
Original line number Diff line number Diff line
@@ -82,36 +82,28 @@ public:
    virtual void onStarted()
    {
        sp<ProcessState> proc = ProcessState::self();
        if (proc->supportsProcesses()) {
        LOGV("App process: starting thread pool.\n");
        proc->startThreadPool();
        }

        AndroidRuntime* ar = AndroidRuntime::getRuntime();
        ar->callMain(mClassName, mClass, mArgC, mArgV);

        if (ProcessState::self()->supportsProcesses()) {
        IPCThreadState::self()->stopProcess();
    }
    }

    virtual void onZygoteInit()
    {
        sp<ProcessState> proc = ProcessState::self();
        if (proc->supportsProcesses()) {
        LOGV("App process: starting thread pool.\n");
        proc->startThreadPool();
    }
    }

    virtual void onExit(int code)
    {
        if (mClassName == NULL) {
            // if zygote
            if (ProcessState::self()->supportsProcesses()) {
            IPCThreadState::self()->stopProcess();
        }
        }

        AndroidRuntime::onExit(code);
    }
+22 −65
Original line number Diff line number Diff line
@@ -93,12 +93,11 @@ extern void QuickTests();
static void usage(const char* argv0)
{
    fprintf(stderr,
        "Usage: runtime [-g gamma] [-l logfile] [-n] [-s]\n"
        "Usage: runtime [-g gamma] [-l logfile] [-n]\n"
        "               [-j app-component] [-v app-verb] [-d app-data]\n"
        "\n"
        "-l: File to send log messages to\n"
        "-n: Don't print to stdout/stderr\n"
        "-s: Force single-process mode\n"
        "-j: Custom home app component name\n"
        "-v: Custom home app intent verb\n"
        "-d: Custom home app intent data\n"
@@ -145,7 +144,6 @@ static int run(sp<ProcessState>& proc)
LOGI("run() sending FIRST_CALL_TRANSACTION to activity manager");
    am->transact(IBinder::FIRST_CALL_TRANSACTION, data, &reply);

    if (proc->supportsProcesses()) {
    // Now we link to the Activity Manager waiting for it to die. If it does kill ourself.
    // initd will restart this process and bring the system back up.
    sp<GrimReaper> grim = new GrimReaper();
@@ -154,12 +152,6 @@ LOGI("run() sending FIRST_CALL_TRANSACTION to activity manager");
    // Now join the thread pool. Note this is needed so that the message enqueued in the driver
    // for the linkToDeath gets processed.
    IPCThreadState::self()->joinThreadPool();
    } else {
        // Keep this thread running forever...
        while (1) {
            usleep(100000);
        }
    }
    return 1;
}

@@ -179,15 +171,8 @@ LOGI("run() sending FIRST_CALL_TRANSACTION to activity manager");
 */
static void finish_system_init(sp<ProcessState>& proc)
{
    // If we are running multiprocess, we now need to have the
    // thread pool started here.  We don't do this in boot_init()
    // because when running single process we need to start the
    // thread pool after the Android runtime has been started (so
    // the pool uses Dalvik threads).
    if (proc->supportsProcesses()) {
    proc->startThreadPool();
}
}


// This function can be used to enforce security to different
@@ -214,11 +199,7 @@ static void boot_init()
    LOGD("ProcessState: %p\n", proc.get());
    proc->becomeContextManager(contextChecker, NULL);

    if (proc->supportsProcesses()) {
        LOGI("Binder driver opened.  Multiprocess enabled.\n");
    } else {
        LOGI("Binder driver not found.  Processes not supported.\n");
    }
    LOGI("Binder driver opened.\n");

    sp<BServiceManager> sm = new BServiceManager;
    proc->setContextObject(sm);
@@ -340,7 +321,6 @@ static status_t start_process(const char* name)
extern "C"
int main(int argc, char* const argv[])
{
    bool singleProcess = false;
    const char* logFile = NULL;
    int ic;
    int result = 1;
@@ -359,7 +339,7 @@ int main(int argc, char* const argv[])
#endif

    while (1) {
        ic = getopt(argc, argv, "g:j:v:d:l:ns");
        ic = getopt(argc, argv, "g:j:v:d:l:n");
        if (ic < 0)
            break;

@@ -381,9 +361,6 @@ int main(int argc, char* const argv[])
        case 'n':
            redirectStdFds();
            break;
        case 's':
            singleProcess = true;
            break;
        case '?':
        default:
            LOGE("runtime: unrecognized flag -%c\n", ic);
@@ -396,10 +373,6 @@ int main(int argc, char* const argv[])
        usage(argv[0]);
    }

    if (singleProcess) {
        ProcessState::setSingleProcess(true);
    }

    if (logFile != NULL) {
        android_logToFile(NULL, logFile);
    }
@@ -475,11 +448,7 @@ int main(int argc, char* const argv[])

    boot_init();

    /* If we are in multiprocess mode, have zygote spawn the system
     * server process and call system_init(). If we are running in
     * single process mode just call system_init() directly.
     */
    if (proc->supportsProcesses()) {
    // Have zygote spawn the system server process and call system_init().
    // If stdio logging is on, system_server should not inherit our stdio
    // The dalvikvm instance will copy stdio to the log on its own
    char propBuf[PROPERTY_VALUE_MAX];
@@ -491,18 +460,6 @@ int main(int argc, char* const argv[])
            sizeof(ZYGOTE_ARGV) / sizeof(ZYGOTE_ARGV[0]),
            ZYGOTE_ARGV);

        //start_process("/system/bin/mediaserver");

    } else {
#ifndef HAVE_ANDROID_OS
        QuickRuntime* runt = new QuickRuntime();
        runt->start("com/android/server/SystemServer",
                    "" /* spontaneously fork system server from zygote */);
#endif
    }

    //printf("+++ post-zygote\n");

    finish_system_init(proc);
    run(proc);

+5 −26
Original line number Diff line number Diff line
@@ -76,23 +76,6 @@ extern "C" status_t system_init()
        SensorService::instantiate();
    }

    // On the simulator, audioflinger et al don't get started the
    // same way as on the device, and we need to start them here
    if (!proc->supportsProcesses()) {

        // Start the AudioFlinger
        AudioFlinger::instantiate();

        // Start the media playback service
        MediaPlayerService::instantiate();

        // Start the camera service
        CameraService::instantiate();

        // Start the audio policy service
        AudioPolicyService::instantiate();
    }

    // And now start the Android runtime.  We have to do this bit
    // of nastiness because the Android runtime initialization requires
    // some of the core system services to already be started.
@@ -117,14 +100,10 @@ extern "C" status_t system_init()
    }
    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.
    if (proc->supportsProcesses()) {
    LOGI("System server: entering thread pool.\n");
    ProcessState::self()->startThreadPool();
    IPCThreadState::self()->joinThreadPool();
    LOGI("System server: exiting thread pool.\n");
    }

    return NO_ERROR;
}
+3 −17
Original line number Diff line number Diff line
@@ -4093,11 +4093,6 @@ public final class ActivityThread {
        });
    }

    private final void detach()
    {
        sThreadLocal.set(null);
    }

    public static final ActivityThread systemMain() {
        HardwareRenderer.disable();
        ActivityThread thread = new ActivityThread();
@@ -4105,10 +4100,9 @@ public final class ActivityThread {
        return thread;
    }

    public final void installSystemProviders(List providers) {
    public final void installSystemProviders(List<ProviderInfo> providers) {
        if (providers != null) {
            installContentProviders(mInitialApplication,
                                    (List<ProviderInfo>)providers);
            installContentProviders(mInitialApplication, providers);
        }
    }

@@ -4147,14 +4141,6 @@ public final class ActivityThread {

        Looper.loop();

        if (Process.supportsProcesses()) {
        throw new RuntimeException("Main thread loop unexpectedly exited");
    }

        thread.detach();
        String name = (thread.mInitialApplication != null)
            ? thread.mInitialApplication.getPackageName()
            : "<unknown>";
        Slog.i(TAG, "Main thread of " + name + " is now exiting");
    }
}
Loading