summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2025-01-09 11:55:56 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2025-01-09 11:55:56 -0800
commitc616d8f49e533a71b6e2db4de4c89be3d5d1b3ed (patch)
tree2b9a5322ed9bd06bb6a9587c0bf426be23751354
parent48e2bba0a8c10db6c2883c8b5177a2e6eca3bffb (diff)
parent2746db0cab3fb7c0de15cf3c32e44746e9909f64 (diff)
Merge "Release all pending wakelocks on endpoint unregistration" into main
-rw-r--r--services/core/java/com/android/server/location/contexthub/ContextHubEndpointBroker.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/location/contexthub/ContextHubEndpointBroker.java b/services/core/java/com/android/server/location/contexthub/ContextHubEndpointBroker.java
index 3018cfdd0f67..1e54beeb2d64 100644
--- a/services/core/java/com/android/server/location/contexthub/ContextHubEndpointBroker.java
+++ b/services/core/java/com/android/server/location/contexthub/ContextHubEndpointBroker.java
@@ -248,6 +248,7 @@ public class ContextHubEndpointBroker extends IContextHubEndpoint.Stub
}
}
mEndpointManager.unregisterEndpoint(mEndpointInfo.getIdentifier().getEndpoint());
+ releaseWakeLockOnExit();
}
@Override
@@ -559,6 +560,23 @@ public class ContextHubEndpointBroker extends IContextHubEndpoint.Stub
});
}
+ private void releaseWakeLockOnExit() {
+ Binder.withCleanCallingIdentity(
+ () -> {
+ while (mWakeLock.isHeld()) {
+ try {
+ mWakeLock.release();
+ } catch (RuntimeException e) {
+ Log.e(
+ TAG,
+ "Releasing the wakelock for all acquisitions fails - ",
+ e);
+ break;
+ }
+ }
+ });
+ }
+
/**
* Invokes a callback and acquires a wakelock.
*