-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix-pw-config-file
- Loading branch information
Showing
26 changed files
with
685 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
...roid/App/common-api/src/main/aidl/com/matter/tv/app/api/ReportAttributeChangeRequest.aidl
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
examples/tv-app/android/App/common-api/src/main/java/com/matter/tv/app/api/Clusters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.matter.tv.app.api; | ||
|
||
public class Clusters { | ||
// Clusters | ||
public static class MediaPlayback { | ||
public static final int Id = 1286; | ||
|
||
public static class Attributes { | ||
public static final int CurrentState = 0; | ||
} | ||
|
||
public static class PlaybackStateEnum { | ||
public static final int Playing = 0; | ||
public static final int Paused = 1; | ||
public static final int NotPlaying = 2; | ||
public static final int Buffering = 3; | ||
} | ||
} | ||
|
||
public static class ContentLauncher { | ||
public static final int Id = 1290; | ||
|
||
public static class Attributes { | ||
public static final int AcceptHeader = 0; | ||
public static final int SupportedStreamingProtocols = 1; | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
.../tv-app/android/App/content-app/src/main/java/com/example/contentapp/AttributeHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.example.contentapp; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** Class to hold attribute values to help test attribute read and subscribe use cases. */ | ||
public class AttributeHolder { | ||
private static AttributeHolder instance = new AttributeHolder(); | ||
private Map<Long, Map<Long, Object>> attributeValues = new HashMap<>(); | ||
|
||
private AttributeHolder() {}; | ||
|
||
public static AttributeHolder getInstance() { | ||
return instance; | ||
} | ||
|
||
public void setAttributeValue(long clusterId, long attributeId, Object value) { | ||
Map<Long, Object> attributes = attributeValues.get(clusterId); | ||
if (attributes == null) { | ||
attributes = new HashMap<>(); | ||
attributeValues.put(clusterId, attributes); | ||
} | ||
attributes.put(attributeId, value); | ||
} | ||
|
||
public Object getAttributeValue(long clusterId, long attributeId) { | ||
Map<Long, Object> attributes = attributeValues.get(clusterId); | ||
return attributes.get(attributeId); | ||
} | ||
} |
104 changes: 102 additions & 2 deletions
104
...les/tv-app/android/App/content-app/src/main/java/com/example/contentapp/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,121 @@ | ||
package com.example.contentapp; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.Button; | ||
import android.widget.Spinner; | ||
import android.widget.TextView; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
import com.example.contentapp.matter.MatterAgentClient; | ||
import com.matter.tv.app.api.Clusters; | ||
import com.matter.tv.app.api.MatterIntentConstants; | ||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Executors; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
private static final String TAG = "ContentAppMainActivity"; | ||
private static final String ATTR_PS_PLAYING = "Playback State : PLAYING"; | ||
private static final String ATTR_PS_PAUSED = "Playback State : PAUSED"; | ||
private static final String ATTR_PS_NOT_PLAYING = "Playback State : NOT_PLAYING"; | ||
private static final String ATTR_PS_BUFFERING = "Playback State : BUFFERING"; | ||
private final ExecutorService executorService = Executors.newSingleThreadExecutor(); | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
MatterAgentClient.initialize(getApplicationContext()); | ||
|
||
setContentView(R.layout.activity_main); | ||
MatterAgentClient matterAgentClient = MatterAgentClient.getInstance(getApplicationContext()); | ||
final ExecutorService executorService = Executors.newSingleThreadExecutor(); | ||
|
||
Intent intent = getIntent(); | ||
String command = intent.getStringExtra(MatterIntentConstants.EXTRA_COMMAND_PAYLOAD); | ||
|
||
// use the text in a TextView | ||
TextView textView = (TextView) findViewById(R.id.commandTextView); | ||
textView.setText("Command Payload : " + command); | ||
|
||
Button sendMessageButton = findViewById(R.id.sendMessageButton); | ||
|
||
sendMessageButton.setOnClickListener( | ||
view -> { | ||
Spinner dropdown = findViewById(R.id.spinnerAttribute); | ||
String attribute = (String) dropdown.getSelectedItem(); | ||
switch (attribute) { | ||
case ATTR_PS_PLAYING: | ||
AttributeHolder.getInstance() | ||
.setAttributeValue( | ||
Clusters.MediaPlayback.Id, | ||
Clusters.MediaPlayback.Attributes.CurrentState, | ||
Clusters.MediaPlayback.PlaybackStateEnum.Playing); | ||
reportAttributeChange( | ||
Clusters.MediaPlayback.Id, Clusters.MediaPlayback.Attributes.CurrentState); | ||
break; | ||
case ATTR_PS_PAUSED: | ||
AttributeHolder.getInstance() | ||
.setAttributeValue( | ||
Clusters.MediaPlayback.Id, | ||
Clusters.MediaPlayback.Attributes.CurrentState, | ||
Clusters.MediaPlayback.PlaybackStateEnum.Paused); | ||
reportAttributeChange( | ||
Clusters.MediaPlayback.Id, Clusters.MediaPlayback.Attributes.CurrentState); | ||
break; | ||
case ATTR_PS_BUFFERING: | ||
AttributeHolder.getInstance() | ||
.setAttributeValue( | ||
Clusters.MediaPlayback.Id, | ||
Clusters.MediaPlayback.Attributes.CurrentState, | ||
Clusters.MediaPlayback.PlaybackStateEnum.Buffering); | ||
reportAttributeChange( | ||
Clusters.MediaPlayback.Id, Clusters.MediaPlayback.Attributes.CurrentState); | ||
break; | ||
case ATTR_PS_NOT_PLAYING: | ||
AttributeHolder.getInstance() | ||
.setAttributeValue( | ||
Clusters.MediaPlayback.Id, | ||
Clusters.MediaPlayback.Attributes.CurrentState, | ||
Clusters.MediaPlayback.PlaybackStateEnum.NotPlaying); | ||
reportAttributeChange( | ||
Clusters.MediaPlayback.Id, Clusters.MediaPlayback.Attributes.CurrentState); | ||
break; | ||
} | ||
}); | ||
Spinner dropdown = findViewById(R.id.spinnerAttribute); | ||
String[] items = | ||
new String[] {ATTR_PS_PLAYING, ATTR_PS_PAUSED, ATTR_PS_NOT_PLAYING, ATTR_PS_BUFFERING}; | ||
ArrayAdapter<String> adapter = | ||
new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, items); | ||
dropdown.setAdapter(adapter); | ||
|
||
MatterAgentClient matterAgentClient = MatterAgentClient.getInstance(); | ||
executorService.execute(matterAgentClient::reportClusters); | ||
|
||
// Setting up attribute defaults | ||
AttributeHolder.getInstance() | ||
.setAttributeValue( | ||
Clusters.ContentLauncher.Id, | ||
Clusters.ContentLauncher.Attributes.AcceptHeader, | ||
"[\"video/mp4\", \"application/x-mpegURL\", \"application/dash+xml\"]"); | ||
AttributeHolder.getInstance() | ||
.setAttributeValue( | ||
Clusters.ContentLauncher.Id, | ||
Clusters.ContentLauncher.Attributes.SupportedStreamingProtocols, | ||
3); | ||
AttributeHolder.getInstance() | ||
.setAttributeValue( | ||
Clusters.MediaPlayback.Id, Clusters.MediaPlayback.Attributes.CurrentState, 2); | ||
} | ||
|
||
private void reportAttributeChange(final int clusterId, final int attributeId) { | ||
executorService.execute( | ||
new Runnable() { | ||
@Override | ||
public void run() { | ||
MatterAgentClient client = MatterAgentClient.getInstance(); | ||
client.reportAttributeChange(clusterId, attributeId); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.