Merge "Eliminate single-process mode. Bug: 5010576"
This commit is contained in:
commit
e145dffb1d
@ -93,12 +93,11 @@ extern void QuickTests();
|
|||||||
static void usage(const char* argv0)
|
static void usage(const char* argv0)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
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"
|
" [-j app-component] [-v app-verb] [-d app-data]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"-l: File to send log messages to\n"
|
"-l: File to send log messages to\n"
|
||||||
"-n: Don't print to stdout/stderr\n"
|
"-n: Don't print to stdout/stderr\n"
|
||||||
"-s: Force single-process mode\n"
|
|
||||||
"-j: Custom home app component name\n"
|
"-j: Custom home app component name\n"
|
||||||
"-v: Custom home app intent verb\n"
|
"-v: Custom home app intent verb\n"
|
||||||
"-d: Custom home app intent data\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");
|
LOGI("run() sending FIRST_CALL_TRANSACTION to activity manager");
|
||||||
am->transact(IBinder::FIRST_CALL_TRANSACTION, data, &reply);
|
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.
|
// 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.
|
// initd will restart this process and bring the system back up.
|
||||||
sp<GrimReaper> grim = new GrimReaper();
|
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
|
// Now join the thread pool. Note this is needed so that the message enqueued in the driver
|
||||||
// for the linkToDeath gets processed.
|
// for the linkToDeath gets processed.
|
||||||
IPCThreadState::self()->joinThreadPool();
|
IPCThreadState::self()->joinThreadPool();
|
||||||
} else {
|
|
||||||
// Keep this thread running forever...
|
|
||||||
while (1) {
|
|
||||||
usleep(100000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,14 +171,7 @@ LOGI("run() sending FIRST_CALL_TRANSACTION to activity manager");
|
|||||||
*/
|
*/
|
||||||
static void finish_system_init(sp<ProcessState>& proc)
|
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();
|
proc->startThreadPool();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -214,11 +199,7 @@ static void boot_init()
|
|||||||
LOGD("ProcessState: %p\n", proc.get());
|
LOGD("ProcessState: %p\n", proc.get());
|
||||||
proc->becomeContextManager(contextChecker, NULL);
|
proc->becomeContextManager(contextChecker, NULL);
|
||||||
|
|
||||||
if (proc->supportsProcesses()) {
|
LOGI("Binder driver opened.\n");
|
||||||
LOGI("Binder driver opened. Multiprocess enabled.\n");
|
|
||||||
} else {
|
|
||||||
LOGI("Binder driver not found. Processes not supported.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
sp<BServiceManager> sm = new BServiceManager;
|
sp<BServiceManager> sm = new BServiceManager;
|
||||||
proc->setContextObject(sm);
|
proc->setContextObject(sm);
|
||||||
@ -340,7 +321,6 @@ static status_t start_process(const char* name)
|
|||||||
extern "C"
|
extern "C"
|
||||||
int main(int argc, char* const argv[])
|
int main(int argc, char* const argv[])
|
||||||
{
|
{
|
||||||
bool singleProcess = false;
|
|
||||||
const char* logFile = NULL;
|
const char* logFile = NULL;
|
||||||
int ic;
|
int ic;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
@ -359,7 +339,7 @@ int main(int argc, char* const argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (1) {
|
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)
|
if (ic < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -381,9 +361,6 @@ int main(int argc, char* const argv[])
|
|||||||
case 'n':
|
case 'n':
|
||||||
redirectStdFds();
|
redirectStdFds();
|
||||||
break;
|
break;
|
||||||
case 's':
|
|
||||||
singleProcess = true;
|
|
||||||
break;
|
|
||||||
case '?':
|
case '?':
|
||||||
default:
|
default:
|
||||||
LOGE("runtime: unrecognized flag -%c\n", ic);
|
LOGE("runtime: unrecognized flag -%c\n", ic);
|
||||||
@ -396,10 +373,6 @@ int main(int argc, char* const argv[])
|
|||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (singleProcess) {
|
|
||||||
ProcessState::setSingleProcess(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (logFile != NULL) {
|
if (logFile != NULL) {
|
||||||
android_logToFile(NULL, logFile);
|
android_logToFile(NULL, logFile);
|
||||||
}
|
}
|
||||||
@ -475,11 +448,7 @@ int main(int argc, char* const argv[])
|
|||||||
|
|
||||||
boot_init();
|
boot_init();
|
||||||
|
|
||||||
/* If we are in multiprocess mode, have zygote spawn the system
|
// Have zygote spawn the system server process and call system_init().
|
||||||
* server process and call system_init(). If we are running in
|
|
||||||
* single process mode just call system_init() directly.
|
|
||||||
*/
|
|
||||||
if (proc->supportsProcesses()) {
|
|
||||||
// If stdio logging is on, system_server should not inherit our stdio
|
// If stdio logging is on, system_server should not inherit our stdio
|
||||||
// The dalvikvm instance will copy stdio to the log on its own
|
// The dalvikvm instance will copy stdio to the log on its own
|
||||||
char propBuf[PROPERTY_VALUE_MAX];
|
char propBuf[PROPERTY_VALUE_MAX];
|
||||||
@ -491,18 +460,6 @@ int main(int argc, char* const argv[])
|
|||||||
sizeof(ZYGOTE_ARGV) / sizeof(ZYGOTE_ARGV[0]),
|
sizeof(ZYGOTE_ARGV) / sizeof(ZYGOTE_ARGV[0]),
|
||||||
ZYGOTE_ARGV);
|
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);
|
finish_system_init(proc);
|
||||||
run(proc);
|
run(proc);
|
||||||
|
|
||||||
|
@ -39,8 +39,6 @@ class ProcessState : public virtual RefBase
|
|||||||
public:
|
public:
|
||||||
static sp<ProcessState> self();
|
static sp<ProcessState> self();
|
||||||
|
|
||||||
static void setSingleProcess(bool singleProcess);
|
|
||||||
|
|
||||||
void setContextObject(const sp<IBinder>& object);
|
void setContextObject(const sp<IBinder>& object);
|
||||||
sp<IBinder> getContextObject(const sp<IBinder>& caller);
|
sp<IBinder> getContextObject(const sp<IBinder>& caller);
|
||||||
|
|
||||||
@ -49,8 +47,6 @@ public:
|
|||||||
sp<IBinder> getContextObject(const String16& name,
|
sp<IBinder> getContextObject(const String16& name,
|
||||||
const sp<IBinder>& caller);
|
const sp<IBinder>& caller);
|
||||||
|
|
||||||
bool supportsProcesses() const;
|
|
||||||
|
|
||||||
void startThreadPool();
|
void startThreadPool();
|
||||||
|
|
||||||
typedef bool (*context_check_func)(const String16& name,
|
typedef bool (*context_check_func)(const String16& name,
|
||||||
|
@ -43,8 +43,6 @@
|
|||||||
|
|
||||||
#define BINDER_VM_SIZE ((1*1024*1024) - (4096 *2))
|
#define BINDER_VM_SIZE ((1*1024*1024) - (4096 *2))
|
||||||
|
|
||||||
static bool gSingleProcess = false;
|
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -82,12 +80,6 @@ sp<ProcessState> ProcessState::self()
|
|||||||
return gProcess;
|
return gProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessState::setSingleProcess(bool singleProcess)
|
|
||||||
{
|
|
||||||
gSingleProcess = singleProcess;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ProcessState::setContextObject(const sp<IBinder>& object)
|
void ProcessState::setContextObject(const sp<IBinder>& object)
|
||||||
{
|
{
|
||||||
setContextObject(object, String16("default"));
|
setContextObject(object, String16("default"));
|
||||||
@ -95,11 +87,7 @@ void ProcessState::setContextObject(const sp<IBinder>& object)
|
|||||||
|
|
||||||
sp<IBinder> ProcessState::getContextObject(const sp<IBinder>& caller)
|
sp<IBinder> ProcessState::getContextObject(const sp<IBinder>& caller)
|
||||||
{
|
{
|
||||||
if (supportsProcesses()) {
|
|
||||||
return getStrongProxyForHandle(0);
|
return getStrongProxyForHandle(0);
|
||||||
} else {
|
|
||||||
return getContextObject(String16("default"), caller);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessState::setContextObject(const sp<IBinder>& object, const String16& name)
|
void ProcessState::setContextObject(const sp<IBinder>& object, const String16& name)
|
||||||
@ -144,11 +132,6 @@ sp<IBinder> ProcessState::getContextObject(const String16& name, const sp<IBinde
|
|||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProcessState::supportsProcesses() const
|
|
||||||
{
|
|
||||||
return mDriverFD >= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProcessState::startThreadPool()
|
void ProcessState::startThreadPool()
|
||||||
{
|
{
|
||||||
AutoMutex _l(mLock);
|
AutoMutex _l(mLock);
|
||||||
@ -169,7 +152,7 @@ bool ProcessState::becomeContextManager(context_check_func checkFunc, void* user
|
|||||||
AutoMutex _l(mLock);
|
AutoMutex _l(mLock);
|
||||||
mBinderContextCheckFunc = checkFunc;
|
mBinderContextCheckFunc = checkFunc;
|
||||||
mBinderContextUserData = userData;
|
mBinderContextUserData = userData;
|
||||||
if (mDriverFD >= 0) {
|
|
||||||
int dummy = 0;
|
int dummy = 0;
|
||||||
#if defined(HAVE_ANDROID_OS)
|
#if defined(HAVE_ANDROID_OS)
|
||||||
status_t result = ioctl(mDriverFD, BINDER_SET_CONTEXT_MGR, &dummy);
|
status_t result = ioctl(mDriverFD, BINDER_SET_CONTEXT_MGR, &dummy);
|
||||||
@ -183,11 +166,6 @@ bool ProcessState::becomeContextManager(context_check_func checkFunc, void* user
|
|||||||
mBinderContextUserData = NULL;
|
mBinderContextUserData = NULL;
|
||||||
LOGE("Binder ioctl to become context manager failed: %s\n", strerror(errno));
|
LOGE("Binder ioctl to become context manager failed: %s\n", strerror(errno));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// If there is no driver, our only world is the local
|
|
||||||
// process so we can always become the context manager there.
|
|
||||||
mManagesContexts = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return mManagesContexts;
|
return mManagesContexts;
|
||||||
}
|
}
|
||||||
@ -322,10 +300,6 @@ void ProcessState::spawnPooledThread(bool isMain)
|
|||||||
|
|
||||||
static int open_driver()
|
static int open_driver()
|
||||||
{
|
{
|
||||||
if (gSingleProcess) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int fd = open("/dev/binder", O_RDWR);
|
int fd = open("/dev/binder", O_RDWR);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||||
@ -386,9 +360,8 @@ ProcessState::ProcessState()
|
|||||||
mDriverFD = -1;
|
mDriverFD = -1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (mDriverFD < 0) {
|
|
||||||
// Need to run without the driver, starting our own thread pool.
|
LOG_ALWAYS_FATAL_IF(mDriverFD < 0, "Binder driver could not be opened. Terminating.");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessState::~ProcessState()
|
ProcessState::~ProcessState()
|
||||||
|
Loading…
Reference in New Issue
Block a user