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

Commit 285aac19 authored by Mike Ma's avatar Mike Ma
Browse files

Skip dump proto when initCheck fails

Sometimes sensorservice is not initialized when calling dumpProto. Add
this check to prevent NPE, which aligns with what text dump does.

Fixes: 149019631
Test: Manual
Change-Id: Id8c2dcd242b04e2bf3ef948690d88760f3bd08c8
parent 144cb00a
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -520,6 +520,10 @@ status_t SensorService::dump(int fd, const Vector<String16>& args) {
status_t SensorService::dumpProtoLocked(int fd, ConnectionSafeAutolock* connLock) const {
    using namespace service::SensorServiceProto;
    util::ProtoOutputStream proto;
    proto.write(INIT_STATUS, int(SensorDevice::getInstance().initCheck()));
    if (!mSensors.hasAnySensor()) {
        return proto.flush(fd) ? OK : UNKNOWN_ERROR;
    }
    const bool privileged = IPCThreadState::self()->getCallingUid() == 0;

    timespec curTime;