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

Commit 48328dd8 authored by Peng Xu's avatar Peng Xu
Browse files

Support custom permission, slight adjust of dumpsys print

Test: tested permission positive and negative case
Test: dumpsys print as expected
Change-Id: I916222fe4cd05ac5268b190fc250e8d51943114d
parent 18c2d051
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -30,7 +30,7 @@ Sensor::Sensor(const char * name) :
        mName(name), mHandle(0), mType(0),
        mName(name), mHandle(0), mType(0),
        mMinValue(0), mMaxValue(0), mResolution(0),
        mMinValue(0), mMaxValue(0), mResolution(0),
        mPower(0), mMinDelay(0), mVersion(0), mFifoReservedEventCount(0),
        mPower(0), mMinDelay(0), mVersion(0), mFifoReservedEventCount(0),
        mFifoMaxEventCount(0), mRequiredAppOp(0),
        mFifoMaxEventCount(0), mRequiredAppOp(-1),
        mMaxDelay(0), mFlags(0) {
        mMaxDelay(0), mFlags(0) {
}
}


@@ -412,6 +412,10 @@ bool Sensor::isDynamicSensor() const {
    return (mFlags & SENSOR_FLAG_DYNAMIC_SENSOR) != 0;
    return (mFlags & SENSOR_FLAG_DYNAMIC_SENSOR) != 0;
}
}


bool Sensor::isDataInjectionSupported() const {
    return (mFlags & SENSOR_FLAG_DATA_INJECTION) != 0;
}

bool Sensor::hasAdditionalInfo() const {
bool Sensor::hasAdditionalInfo() const {
    return (mFlags & SENSOR_FLAG_ADDITIONAL_INFO) != 0;
    return (mFlags & SENSOR_FLAG_ADDITIONAL_INFO) != 0;
}
}
+1 −0
Original line number Original line Diff line number Diff line
@@ -90,6 +90,7 @@ public:
    uint32_t getFlags() const;
    uint32_t getFlags() const;
    bool isWakeUpSensor() const;
    bool isWakeUpSensor() const;
    bool isDynamicSensor() const;
    bool isDynamicSensor() const;
    bool isDataInjectionSupported() const;
    bool hasAdditionalInfo() const;
    bool hasAdditionalInfo() const;
    int32_t getHighestDirectReportRateLevel() const;
    int32_t getHighestDirectReportRateLevel() const;
    bool isDirectChannelTypeSupported(int32_t sharedMemType) const;
    bool isDirectChannelTypeSupported(int32_t sharedMemType) const;
+8 −3
Original line number Original line Diff line number Diff line
@@ -124,14 +124,15 @@ std::string SensorList::dump() const {
    forEachSensor([&result] (const Sensor& s) -> bool {
    forEachSensor([&result] (const Sensor& s) -> bool {
            result.appendFormat(
            result.appendFormat(
                    "%#010x) %-25s | %-15s | ver: %" PRId32 " | type: %20s(%" PRId32
                    "%#010x) %-25s | %-15s | ver: %" PRId32 " | type: %20s(%" PRId32
                        ") | perm: %s\n",
                        ") | perm: %s | flags: 0x%08x\n",
                    s.getHandle(),
                    s.getHandle(),
                    s.getName().string(),
                    s.getName().string(),
                    s.getVendor().string(),
                    s.getVendor().string(),
                    s.getVersion(),
                    s.getVersion(),
                    s.getStringType().string(),
                    s.getStringType().string(),
                    s.getType(),
                    s.getType(),
                    s.getRequiredPermission().size() ? s.getRequiredPermission().string() : "n/a");
                    s.getRequiredPermission().size() ? s.getRequiredPermission().string() : "n/a",
                    static_cast<int>(s.getFlags()));


            result.append("\t");
            result.append("\t");
            const int reportingMode = s.getReportingMode();
            const int reportingMode = s.getReportingMode();
@@ -173,9 +174,14 @@ std::string SensorList::dump() const {
                result.appendFormat("non-wakeUp | ");
                result.appendFormat("non-wakeUp | ");
            }
            }


            if (s.isDataInjectionSupported()) {
                result.appendFormat("data-injection, ");
            }

            if (s.isDynamicSensor()) {
            if (s.isDynamicSensor()) {
                result.appendFormat("dynamic, ");
                result.appendFormat("dynamic, ");
            }
            }

            if (s.hasAdditionalInfo()) {
            if (s.hasAdditionalInfo()) {
                result.appendFormat("has-additional-info, ");
                result.appendFormat("has-additional-info, ");
            }
            }
@@ -190,7 +196,6 @@ std::string SensorList::dump() const {
                if (s.isDirectChannelTypeSupported(SENSOR_DIRECT_MEM_TYPE_GRALLOC)) {
                if (s.isDirectChannelTypeSupported(SENSOR_DIRECT_MEM_TYPE_GRALLOC)) {
                    result.append("gralloc, ");
                    result.append("gralloc, ");
                }
                }
                result.appendFormat("flag =0x%08x", static_cast<int>(s.getFlags()));
                result.append("\n");
                result.append("\n");
            }
            }
            return true;
            return true;