Skip to content

Commit ef3e743

Browse files
Fixes #24034 (#24037)
* Fixes #24034 * Restyled by google-java-format Co-authored-by: Restyled.io <commits@restyled.io>
1 parent edd2863 commit ef3e743

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

examples/tv-app/android/App/platform-app/src/main/java/com/matter/tv/server/service/ContentAppAgentService.java

+12-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import com.matter.tv.app.api.MatterIntentConstants;
1616
import com.matter.tv.server.model.ContentApp;
1717
import com.matter.tv.server.receivers.ContentAppDiscoveryService;
18+
import java.util.concurrent.ExecutorService;
19+
import java.util.concurrent.Executors;
1820
import java.util.concurrent.TimeUnit;
1921

2022
public class ContentAppAgentService extends Service {
@@ -38,6 +40,8 @@ public class ContentAppAgentService extends Service {
3840
private static final int ATTRIBUTE_TIMEOUT = 2; // seconds
3941

4042
private static ResponseRegistry responseRegistry = new ResponseRegistry();
43+
private static ExecutorService executorService =
44+
Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
4145

4246
private final IBinder appAgentBinder =
4347
new IMatterAppAgent.Stub() {
@@ -76,8 +80,14 @@ public boolean reportAttributeChange(int clusterId, int attributeId)
7680
ContentApp contentApp =
7781
ContentAppDiscoveryService.getReceiverInstance().getDiscoveredContentApp(pkg);
7882
if (contentApp != null && contentApp.getEndpointId() != ContentApp.INVALID_ENDPOINTID) {
79-
AppPlatformService.get()
80-
.reportAttributeChange(contentApp.getEndpointId(), clusterId, attributeId);
83+
// Make this call async so that even if the content apps make this call during command
84+
// processing and synchronously, the command processing thread will not block for the
85+
// chip stack lock.
86+
executorService.execute(
87+
() -> {
88+
AppPlatformService.get()
89+
.reportAttributeChange(contentApp.getEndpointId(), clusterId, attributeId);
90+
});
8191
return true;
8292
}
8393
Log.e(TAG, "No matter content app found for package " + pkg);

0 commit comments

Comments
 (0)