Skip to content

Commit

Permalink
Fixes #24034 (#24037)
Browse files Browse the repository at this point in the history
* Fixes #24034

* Restyled by google-java-format

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Oct 12, 2023
1 parent 7395547 commit c4eb51a
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import com.matter.tv.app.api.MatterIntentConstants;
import com.matter.tv.server.model.ContentApp;
import com.matter.tv.server.receivers.ContentAppDiscoveryService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

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

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

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

0 comments on commit c4eb51a

Please sign in to comment.