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

Commit 93be444a authored by Anh Pham's avatar Anh Pham Committed by Android (Google) Code Review
Browse files

Merge changes from topic "sensor_sampling_rate_throttling-sc-dev" into sc-dev

* changes:
  Update sensor get methods related to sampling rate
  Resample sensor events for non-direct connections.
  Subscribe to the microphone toggle state.
  Throttle sensor sampling rates at 200Hz.
  Add support for retrieving the Debuggable flag.
parents 92f808f0 4e291338
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -108,4 +108,10 @@ interface IPackageManagerNative {
     * has been set to {@link PackageManager#CERT_INPUT_SHA256}.
     */
    boolean hasSha256SigningCertificate(in @utf8InCpp String packageName, in byte[] certificate);

    /**
     * Returns the debug flag for the given package.
     * Unknown packages will cause the call to fail.
     */
     boolean isPackageDebuggable(in String packageName);
}
+13 −0
Original line number Diff line number Diff line
@@ -468,6 +468,19 @@ void Sensor::setId(int32_t id) {
    mUuid.i64[1] = 0;
}

void Sensor::capMinDelayMicros(int32_t cappedMinDelay) {
    if (mMinDelay < cappedMinDelay) {
        mMinDelay = cappedMinDelay;
    }
}

void Sensor::capHighestDirectReportRateLevel(int32_t cappedRateLevel) {
    if (cappedRateLevel < getHighestDirectReportRateLevel()) {
        mFlags &= ~SENSOR_FLAG_MASK_DIRECT_REPORT;
        mFlags |= cappedRateLevel << SENSOR_FLAG_SHIFT_DIRECT_REPORT;
    }
}

int32_t Sensor::getId() const {
    return int32_t(mUuid.i64[0]);
}
+3 −0
Original line number Diff line number Diff line
@@ -104,6 +104,9 @@ public:
    int32_t getId() const;
    void setId(int32_t id);

    void capMinDelayMicros(int32_t cappedMinDelay);
    void capHighestDirectReportRateLevel(int32_t cappedRateLevel);

    // LightFlattenable protocol
    inline bool isFixedSize() const { return false; }
    size_t getFlattenedSize() const;
+15 −0
Original line number Diff line number Diff line
@@ -914,6 +914,21 @@ bool SensorDevice::isSensorActive(int handle) const {
    return mActivationCount.valueAt(activationIndex).numActiveClients() > 0;
}

void SensorDevice::onMicSensorAccessChanged(void* ident, int handle, nsecs_t samplingPeriodNs) {
    Mutex::Autolock _l(mLock);
    ssize_t activationIndex = mActivationCount.indexOfKey(handle);
    if (activationIndex < 0) {
        ALOGW("Handle %d cannot be found in activation record", handle);
        return;
    }
    Info& info(mActivationCount.editValueAt(activationIndex));
    if (info.hasBatchParamsForIdent(ident)) {
        ssize_t index = info.batchParams.indexOfKey(ident);
        BatchParams& params = info.batchParams.editValueAt(index);
        params.mTSample = samplingPeriodNs;
    }
}

void SensorDevice::enableAllSensors() {
    if (mSensors == nullptr) return;
    Mutex::Autolock _l(mLock);
+4 −0
Original line number Diff line number Diff line
@@ -125,6 +125,10 @@ public:

    bool isSensorActive(int handle) const;

    // To update the BatchParams of a SensorEventConnection when the mic toggle changes its state
    // while the Sensors Off toggle is on.
    void onMicSensorAccessChanged(void* ident, int handle, nsecs_t samplingPeriodNs);

    // Dumpable
    virtual std::string dump() const override;
    virtual void dump(util::ProtoOutputStream* proto) const override;
Loading