@@ -561,8 +561,9 @@ sp<IBinder> CppBackendShim::getService(const String16& name) const {
561561 sp<IBinder> svc = checkService (name);
562562 if (svc != nullptr ) return svc;
563563
564+ sp<ProcessState> self = ProcessState::selfOrNull ();
564565 const bool isVendorService =
565- strcmp (ProcessState:: self() ->getDriverName ().c_str (), " /dev/vndbinder" ) == 0 ;
566+ self && strcmp (self->getDriverName ().c_str (), " /dev/vndbinder" ) == 0 ;
566567 constexpr auto timeout = 5s;
567568 const auto startTime = std::chrono::steady_clock::now ();
568569 // Vendor code can't access system properties
@@ -579,7 +580,7 @@ sp<IBinder> CppBackendShim::getService(const String16& name) const {
579580 const useconds_t sleepTime = gSystemBootCompleted ? 1000 : 100 ;
580581
581582 ALOGI (" Waiting for service '%s' on '%s'..." , String8 (name).c_str (),
582- ProcessState:: self() ->getDriverName ().c_str ());
583+ self ? self ->getDriverName ().c_str () : " RPC accessors only " );
583584
584585 int n = 0 ;
585586 while (std::chrono::steady_clock::now () - startTime < timeout) {
@@ -661,7 +662,8 @@ sp<IBinder> CppBackendShim::waitForService(const String16& name16) {
661662 if (Status status = realGetService (name, &out); !status.isOk ()) {
662663 ALOGW (" Failed to getService in waitForService for %s: %s" , name.c_str (),
663664 status.toString8 ().c_str ());
664- if (0 == ProcessState::self ()->getThreadPoolMaxTotalThreadCount ()) {
665+ sp<ProcessState> self = ProcessState::selfOrNull ();
666+ if (self && 0 == self->getThreadPoolMaxTotalThreadCount ()) {
665667 ALOGW (" Got service, but may be racey because we could not wait efficiently for it. "
666668 " Threadpool has 0 guaranteed threads. "
667669 " Is the threadpool configured properly? "
@@ -695,9 +697,10 @@ sp<IBinder> CppBackendShim::waitForService(const String16& name16) {
695697 if (waiter->mBinder != nullptr ) return waiter->mBinder ;
696698 }
697699
700+ sp<ProcessState> self = ProcessState::selfOrNull ();
698701 ALOGW (" Waited one second for %s (is service started? Number of threads started in the "
699702 " threadpool: %zu. Are binder threads started and available?)" ,
700- name.c_str (), ProcessState:: self() ->getThreadPoolMaxTotalThreadCount ());
703+ name.c_str (), self ? self ->getThreadPoolMaxTotalThreadCount () : 0 );
701704
702705 // Handle race condition for lazy services. Here is what can happen:
703706 // - the service dies (not processed by init yet).
0 commit comments