Fix nondeterminism in LMS
When provider properties are set asynchronously, there is a race
condition with getProviderProperties on whether those properties are
immediately visible or not. Fix this, and make mock providers disabled
by default (as CTS tests appear to expect).
Bug: 122898923
Test: Manual + CTS
Change-Id: I731b6b12f13f3dce6d4ccaf7d24abe3712a5f3f2
diff --git a/services/core/java/com/android/server/LocationManagerService.java b/services/core/java/com/android/server/LocationManagerService.java
index 869d564..312b83c 100644
--- a/services/core/java/com/android/server/LocationManagerService.java
+++ b/services/core/java/com/android/server/LocationManagerService.java
@@ -1041,12 +1041,13 @@
@Override
public void onSetProperties(ProviderProperties properties) {
- // move calls coming from below LMS onto a different thread to avoid deadlock
- runInternal(() -> {
- synchronized (mLock) {
- mProperties = properties;
- }
- });
+ // because this does not invoke any other methods which might result in calling back
+ // into the location provider, it is safe to run this on the calling thread. it is also
+ // currently necessary to run this on the calling thread to ensure that property changes
+ // are publicly visibly immediately, ie for mock providers which are created.
+ synchronized (mLock) {
+ mProperties = properties;
+ }
}
@GuardedBy("mLock")