summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Devin Moore <devinmoore@google.com> 2023-08-29 23:06:23 +0000
committer Devin Moore <devinmoore@google.com> 2023-08-30 22:39:20 +0000
commit872973c13bb9735a0f1b2584fe81382b70d127f0 (patch)
treed673d7f82349f3fafdaf395edf37fe44ced18878
parent4d32277443f893d837f07160692d7acbd4e10662 (diff)
SensorManager: Don't try to attach looper thread without JVM
The fuzzer isn't currently running inside a JVM so we don't have access to JNIEnv when creating SensorManager. Test: m Bug: 295558387 Change-Id: Ie6d3b8f0c4871b4b84bb9eb02a1cd6240652de60
-rw-r--r--services/sensorservice/aidl/SensorManager.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/services/sensorservice/aidl/SensorManager.cpp b/services/sensorservice/aidl/SensorManager.cpp
index 9b0334443b..ee4c5f819c 100644
--- a/services/sensorservice/aidl/SensorManager.cpp
+++ b/services/sensorservice/aidl/SensorManager.cpp
@@ -197,6 +197,11 @@ ndk::ScopedAStatus SensorManagerAidl::getSensorList(std::vector<SensorInfo>* _ai
sp<Looper> SensorManagerAidl::getLooper() {
std::lock_guard<std::mutex> lock(mThreadMutex);
+ if (!mJavaVm) {
+ LOG(ERROR) << "No Java VM. This must be running in a test or fuzzer.";
+ return mLooper;
+ }
+
if (!mPollThread.joinable()) {
// if thread not initialized, start thread
mStopThread = false;