Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
amitnj committed Dec 12, 2022
1 parent 71da650 commit 4632e1f
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
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 +41,7 @@ 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,11 @@ 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 4632e1f

Please sign in to comment.