Skip to content

Commit 4632e1f

Browse files
committed
1 parent 71da650 commit 4632e1f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

+9-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
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+
19+
import java.util.concurrent.ExecutorService;
20+
import java.util.concurrent.Executors;
1821
import java.util.concurrent.TimeUnit;
1922

2023
public class ContentAppAgentService extends Service {
@@ -38,6 +41,7 @@ public class ContentAppAgentService extends Service {
3841
private static final int ATTRIBUTE_TIMEOUT = 2; // seconds
3942

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

4246
private final IBinder appAgentBinder =
4347
new IMatterAppAgent.Stub() {
@@ -76,8 +80,11 @@ 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(()->{AppPlatformService.get()
87+
.reportAttributeChange(contentApp.getEndpointId(), clusterId, attributeId);});
8188
return true;
8289
}
8390
Log.e(TAG, "No matter content app found for package " + pkg);

0 commit comments

Comments
 (0)