Move thread creation to setCallback() from start()
This change only modifies the Cuttlefish emulator behavior.
Creating a new thread is a heavy operation. Doing so in start() slows
down the request handling. In a stress test like
testVariedRatesRepetitive, 100+ requests are received in a short time,
which results in accumulated requests waiting to be handled, and thus
breaks the subsequent tests.
This change moves creating a new thread from start() to setCallback()
to avoid thread creation for each new request.
Bug: 400325468
Test: atest CtsLocationGnssTestCases
Test: atest GtsLocationTestCases
Test: atest VtsHalGnssTargetTest
Change-Id: I6bf89989c572b0e7b1b9ba9339b922363ef26ce4
diff --git a/gnss/aidl/default/Gnss.h b/gnss/aidl/default/Gnss.h
index 56fe399..aea9eb9 100644
--- a/gnss/aidl/default/Gnss.h
+++ b/gnss/aidl/default/Gnss.h
@@ -110,10 +110,12 @@
std::atomic<long> mMinIntervalMs;
std::atomic<long> mGnssMeasurementIntervalMs;
std::atomic<bool> mIsActive;
+ std::atomic<bool> mIsInitialized;
std::atomic<bool> mIsSvStatusActive;
std::atomic<bool> mIsNmeaActive;
std::atomic<bool> mFirstFixReceived;
std::atomic<bool> mGnssMeasurementEnabled;
+ std::atomic<int> mReportedLocationCount;
std::shared_ptr<GnssLocation> mLastLocation;
std::thread mThread;
::android::hardware::gnss::common::ThreadBlocker mThreadBlocker;