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

Commit 788e1c41 authored by Yunfan Chen's avatar Yunfan Chen
Browse files

Reduce the polling interval in getService() to 100ms

The 1 second polling interval is too long and 100ms interval can reduce
the boot time, especially for ARC++. The test results can be found in
b/30892329.

This CL also adds some ALOGs to show the service start failure as well
as to avoid spam.

Bug: 38432898
Test: Services can still start. Test cheets_PerfBootServer for ARC++.
Change-Id: I9c0da9ef8a18a0e1432c39d98a34377bb66c5d85
parent de1de879
Loading
Loading
Loading
Loading
+26 −10
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <binder/IPermissionController.h>
#endif
#include <binder/Parcel.h>
#include <cutils/properties.h>
#include <utils/String8.h>
#include <utils/SystemClock.h>
#include <utils/CallStack.h>
@@ -142,20 +143,35 @@ public:

    virtual sp<IBinder> getService(const String16& name) const
    {
        unsigned n;
        for (n = 0; n < 5; n++){
            if (n > 0) {
                if (!strcmp(ProcessState::self()->getDriverName().c_str(), "/dev/vndbinder")) {
        sp<IBinder> svc = checkService(name);
        if (svc != NULL) return svc;

        const bool isVendorService =
            strcmp(ProcessState::self()->getDriverName().c_str(), "/dev/vndbinder") == 0;
        const long timeout = uptimeMillis() + 5000;
        if (!gSystemBootCompleted) {
            char bootCompleted[PROPERTY_VALUE_MAX];
            property_get("sys.boot_completed", bootCompleted, "0");
            gSystemBootCompleted = strcmp(bootCompleted, "1") == 0 ? true : false;
        }
        // retry interval in millisecond.
        const long sleepTime = gSystemBootCompleted ? 1000 : 100;

        int n = 0;
        while (uptimeMillis() < timeout) {
            n++;
            if (isVendorService) {
                ALOGI("Waiting for vendor service %s...", String8(name).string());
                CallStack stack(LOG_TAG);
                } else {
            } else if (n%10 == 0) {
                ALOGI("Waiting for service %s...", String8(name).string());
            }
                sleep(1);
            }
            usleep(1000*sleepTime);

            sp<IBinder> svc = checkService(name);
            if (svc != NULL) return svc;
        }
        ALOGW("Service %s didn't start. Returning NULL", String8(name).string());
        return NULL;
    }

+1 −0
Original line number Diff line number Diff line
@@ -97,5 +97,6 @@ sp<IServiceManager> gDefaultServiceManager;
#ifndef __ANDROID_VNDK__
sp<IPermissionController> gPermissionController;
#endif
bool gSystemBootCompleted = false;

}   // namespace android
+1 −0
Original line number Diff line number Diff line
@@ -41,5 +41,6 @@ extern sp<IServiceManager> gDefaultServiceManager;
#ifndef __ANDROID_VNDK__
extern sp<IPermissionController> gPermissionController;
#endif
extern bool gSystemBootCompleted;

}   // namespace android