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

Commit 605ee5e4 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Improve Sensor Service's dumpsys when restricted"

parents 3a18962e bce04d71
Loading
Loading
Loading
Loading
+10 −1
Original line number Original line Diff line number Diff line
@@ -359,7 +359,7 @@ std::string SensorDevice::dump() const {
    for (const auto & s : mSensorList) {
    for (const auto & s : mSensorList) {
        int32_t handle = s.handle;
        int32_t handle = s.handle;
        const Info& info = mActivationCount.valueFor(handle);
        const Info& info = mActivationCount.valueFor(handle);
        if (info.batchParams.isEmpty()) continue;
        if (info.numActiveClients() == 0) continue;


        result.appendFormat("0x%08x) active-count = %zu; ", handle, info.batchParams.size());
        result.appendFormat("0x%08x) active-count = %zu; ", handle, info.batchParams.size());


@@ -730,6 +730,15 @@ bool SensorDevice::isClientDisabledLocked(void* ident) {
    return mDisabledClients.indexOf(ident) >= 0;
    return mDisabledClients.indexOf(ident) >= 0;
}
}


bool SensorDevice::isSensorActive(int handle) const {
    Mutex::Autolock _l(mLock);
    ssize_t activationIndex = mActivationCount.indexOfKey(handle);
    if (activationIndex < 0) {
        return false;
    }
    return mActivationCount.valueAt(activationIndex).numActiveClients() > 0;
}

void SensorDevice::enableAllSensors() {
void SensorDevice::enableAllSensors() {
    if (mSensors == nullptr) return;
    if (mSensors == nullptr) return;
    Mutex::Autolock _l(mLock);
    Mutex::Autolock _l(mLock);
+2 −0
Original line number Original line Diff line number Diff line
@@ -120,6 +120,8 @@ public:
        return mReconnecting;
        return mReconnecting;
    }
    }


    bool isSensorActive(int handle) const;

    // Dumpable
    // Dumpable
    virtual std::string dump() const;
    virtual std::string dump() const;
private:
private:
+8 −1
Original line number Original line Diff line number Diff line
@@ -78,7 +78,14 @@ void SensorService::SensorEventConnection::resetWakeLockRefCount() {


void SensorService::SensorEventConnection::dump(String8& result) {
void SensorService::SensorEventConnection::dump(String8& result) {
    Mutex::Autolock _l(mConnectionLock);
    Mutex::Autolock _l(mConnectionLock);
    result.appendFormat("\tOperating Mode: %s\n",mDataInjectionMode ? "DATA_INJECTION" : "NORMAL");
    result.appendFormat("\tOperating Mode: ");
    if (!mService->isWhiteListedPackage(getPackageName())) {
        result.append("RESTRICTED\n");
    } else if (mDataInjectionMode) {
        result.append("DATA_INJECTION\n");
    } else {
        result.append("NORMAL\n");
    }
    result.appendFormat("\t %s | WakeLockRefCount %d | uid %d | cache size %d | "
    result.appendFormat("\t %s | WakeLockRefCount %d | uid %d | cache size %d | "
            "max cache size %d\n", mPackageName.string(), mWakeLockRefCount, mUid, mCacheSize,
            "max cache size %d\n", mPackageName.string(), mWakeLockRefCount, mUid, mCacheSize,
            mMaxCacheSize);
            mMaxCacheSize);
+7 −4
Original line number Original line Diff line number Diff line
@@ -441,13 +441,16 @@ status_t SensorService::dump(int fd, const Vector<String16>& args) {
            }
            }


            result.append("Active sensors:\n");
            result.append("Active sensors:\n");
            SensorDevice& dev = SensorDevice::getInstance();
            for (size_t i=0 ; i<mActiveSensors.size() ; i++) {
            for (size_t i=0 ; i<mActiveSensors.size() ; i++) {
                int handle = mActiveSensors.keyAt(i);
                int handle = mActiveSensors.keyAt(i);
                if (dev.isSensorActive(handle)) {
                    result.appendFormat("%s (handle=0x%08x, connections=%zu)\n",
                    result.appendFormat("%s (handle=0x%08x, connections=%zu)\n",
                            getSensorName(handle).string(),
                            getSensorName(handle).string(),
                            handle,
                            handle,
                            mActiveSensors.valueAt(i)->getNumConnections());
                            mActiveSensors.valueAt(i)->getNumConnections());
                }
                }
            }


            result.appendFormat("Socket Buffer size = %zd events\n",
            result.appendFormat("Socket Buffer size = %zd events\n",
                                mSocketBufferSize/sizeof(sensors_event_t));
                                mSocketBufferSize/sizeof(sensors_event_t));