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

Commit 9c1867ee authored by Brian Stack's avatar Brian Stack
Browse files

Update member variables to use mNamingConvention

Bug: 115969174
Test: Builds
Change-Id: Id4334d9060a3110d13debcfaf1bebc9dddd321c5
parent 40525b14
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -94,9 +94,9 @@ bool SensorsHidlEnvironmentV1_0::resetHal() {
}

void SensorsHidlEnvironmentV1_0::startPollingThread() {
    stopThread = false;
    pollThread = std::thread(pollingThread, this, std::ref(stopThread));
    events.reserve(128);
    mStopThread = false;
    mPollThread = std::thread(pollingThread, this, std::ref(mStopThread));
    mEvents.reserve(128);
}

void SensorsHidlEnvironmentV1_0::pollingThread(SensorsHidlEnvironmentV1_0* env,
+6 −6
Original line number Diff line number Diff line
@@ -95,19 +95,19 @@ bool SensorsHidlEnvironmentV2_0::resetHal() {
}

void SensorsHidlEnvironmentV2_0::HidlTearDown() {
    stopThread = true;
    mStopThread = true;

    // Wake up the event queue so the poll thread can exit
    mEventQueueFlag->wake(asBaseType(EventQueueFlagBits::READ_AND_PROCESS));
    pollThread.join();
    mPollThread.join();

    EventFlag::deleteEventFlag(&mEventQueueFlag);
}

void SensorsHidlEnvironmentV2_0::startPollingThread() {
    stopThread = false;
    pollThread = std::thread(pollingThread, this);
    events.reserve(MAX_RECEIVE_BUFFER_EVENT_COUNT);
    mStopThread = false;
    mPollThread = std::thread(pollingThread, this);
    mEvents.reserve(MAX_RECEIVE_BUFFER_EVENT_COUNT);
}

void SensorsHidlEnvironmentV2_0::readEvents() {
@@ -133,7 +133,7 @@ void SensorsHidlEnvironmentV2_0::readEvents() {
void SensorsHidlEnvironmentV2_0::pollingThread(SensorsHidlEnvironmentV2_0* env) {
    ALOGD("polling thread start");

    while (!env->stopThread.load()) {
    while (!env->mStopThread.load()) {
        env->readEvents();
    }

+13 −13
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@
void SensorsHidlEnvironmentBase::HidlSetUp() {
    ASSERT_TRUE(resetHal()) << "could not get hidl service";

    collectionEnabled = false;
    mCollectionEnabled = false;
    startPollingThread();

    // In case framework just stopped for test and there is sensor events in the pipe,
@@ -28,27 +28,27 @@ void SensorsHidlEnvironmentBase::HidlSetUp() {
}

void SensorsHidlEnvironmentBase::HidlTearDown() {
    stopThread = true;
    pollThread.detach();
    mStopThread = true;
    mPollThread.detach();
}

void SensorsHidlEnvironmentBase::catEvents(std::vector<Event>* output) {
    std::lock_guard<std::mutex> lock(events_mutex);
    std::lock_guard<std::mutex> lock(mEventsMutex);
    if (output) {
        output->insert(output->end(), events.begin(), events.end());
        output->insert(output->end(), mEvents.begin(), mEvents.end());
    }
    events.clear();
    mEvents.clear();
}

void SensorsHidlEnvironmentBase::setCollection(bool enable) {
    std::lock_guard<std::mutex> lock(events_mutex);
    collectionEnabled = enable;
    std::lock_guard<std::mutex> lock(mEventsMutex);
    mCollectionEnabled = enable;
}

void SensorsHidlEnvironmentBase::addEvent(const Event& ev) {
    std::lock_guard<std::mutex> lock(events_mutex);
    if (collectionEnabled) {
        events.push_back(ev);
    std::lock_guard<std::mutex> lock(mEventsMutex);
    if (mCollectionEnabled) {
        mEvents.push_back(ev);
    }

    if (mCallback != nullptr) {
@@ -57,11 +57,11 @@ void SensorsHidlEnvironmentBase::addEvent(const Event& ev) {
}

void SensorsHidlEnvironmentBase::registerCallback(IEventCallback* callback) {
    std::lock_guard<std::mutex> lock(events_mutex);
    std::lock_guard<std::mutex> lock(mEventsMutex);
    mCallback = callback;
}

void SensorsHidlEnvironmentBase::unregisterCallback() {
    std::lock_guard<std::mutex> lock(events_mutex);
    std::lock_guard<std::mutex> lock(mEventsMutex);
    mCallback = nullptr;
}
 No newline at end of file
+6 −6
Original line number Diff line number Diff line
@@ -50,18 +50,18 @@ class SensorsHidlEnvironmentBase : public ::testing::VtsHalHidlTargetTestEnvBase
    void unregisterCallback();

   protected:
    SensorsHidlEnvironmentBase() : collectionEnabled(false), mCallback(nullptr) {}
    SensorsHidlEnvironmentBase() : mCollectionEnabled(false), mCallback(nullptr) {}

    void addEvent(const Event& ev);

    virtual void startPollingThread() = 0;
    virtual bool resetHal() = 0;

    bool collectionEnabled;
    std::atomic_bool stopThread;
    std::thread pollThread;
    std::vector<Event> events;
    std::mutex events_mutex;
    bool mCollectionEnabled;
    std::atomic_bool mStopThread;
    std::thread mPollThread;
    std::vector<Event> mEvents;
    std::mutex mEventsMutex;

    IEventCallback* mCallback;