Skip to content

Commit

Permalink
Merge branch 'tv2-7' of github.com:project-chip/connectedhomeip into …
Browse files Browse the repository at this point in the history
…tv2-7
  • Loading branch information
chrisdecenzo committed Feb 20, 2024
2 parents e00fbf1 + 8a82ad3 commit 96e072a
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,30 @@
*/
package com.matter.tv.server.tvapp;

import java.util.Vector;

public class Message {

public String messageId;
public int priority;
public int messageControl;
public long startTime;
public int duration;
public String messageText;
public MessageResponseOption responseOptions[];
public String messageId;
public int priority;
public int messageControl;
public long startTime;
public int duration;
public String messageText;
public MessageResponseOption responseOptions[];

public Message(String messageId,
int priority,
int messageControl,
long startTime,
int duration,
String messageText,
MessageResponseOption responseOptions[])
{
this.messageId = messageId;
this.priority = priority;
this.messageControl = messageControl;
this.startTime = startTime;
this.duration = duration;
this.messageText = messageText;
this.responseOptions = responseOptions;
}
public Message(
String messageId,
int priority,
int messageControl,
long startTime,
int duration,
String messageText,
MessageResponseOption responseOptions[]) {
this.messageId = messageId;
this.priority = priority;
this.messageControl = messageControl;
this.startTime = startTime;
this.duration = duration;
this.messageText = messageText;
this.responseOptions = responseOptions;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@
package com.matter.tv.server.tvapp;

public class MessageResponseOption {
public long id = -1;
public String label = "na";
public long id = -1;
public String label = "na";

public MessageResponseOption(
long id,
String label) {
this.id = id;
this.label = label;
}
public MessageResponseOption(long id, String label) {
this.id = id;
this.label = label;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
Expand All @@ -21,15 +21,16 @@

public interface MessagesManager {

Message[] getMessages();
Message[] getMessages();

boolean presentMessages(String messageId,
int priority,
int messageControl,
long startTime,
int duration,
String messageText,
HashMap<Long,String> responseOptions);

boolean cancelMessage(String messageId);
boolean presentMessages(
String messageId,
int priority,
int messageControl,
long startTime,
int duration,
String messageText,
HashMap<Long, String> responseOptions);

boolean cancelMessage(String messageId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,23 @@
import android.util.Log;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Vector;

public class MessagesManagerStub implements MessagesManager {
private static final String TAG = MessagesManagerStub.class.getSimpleName();

private int endpoint = -1;

private Map<String,Message> messages = new HashMap<String,Message>();
private Map<String, Message> messages = new HashMap<String, Message>();

public MessagesManagerStub(int endpoint) {
this.endpoint = endpoint;
Log.d(TAG, "MessagesManagerStub: at " + this.endpoint);

HashMap<Long,String> responseOptions = new HashMap<Long,String>();
HashMap<Long, String> responseOptions = new HashMap<Long, String>();
responseOptions.put(new Long(1), "Yes");
responseOptions.put(new Long(2), "No");
presentMessages("31323334353637383930313233343536",
1,
1,
30,
60,
"TestMessage",
responseOptions);
presentMessages(
"31323334353637383930313233343536", 1, 1, 30, 60, "TestMessage", responseOptions);
Log.d(TAG, "MessagesManagerStub: added dummy message");
}

Expand All @@ -54,39 +47,36 @@ public Message[] getMessages() {
}

@Override
public boolean presentMessages(String messageId,
int priority,
int messageControl,
long startTime,
int duration,
String messageText,
HashMap<Long,String> responseOptions) {
Log.d(TAG, "presentMessages: at " + this.endpoint + " id:" + messageId+ " text:"+messageText);
MessageResponseOption[] options = new MessageResponseOption[responseOptions.size()];
int i=0;
public boolean presentMessages(
String messageId,
int priority,
int messageControl,
long startTime,
int duration,
String messageText,
HashMap<Long, String> responseOptions) {
Log.d(
TAG, "presentMessages: at " + this.endpoint + " id:" + messageId + " text:" + messageText);
MessageResponseOption[] options = new MessageResponseOption[responseOptions.size()];
int i = 0;

for (Map.Entry<Long,String> set : responseOptions.entrySet()) {
Log.d(TAG, "presentMessages option: key:"+set.getKey()+" value:"+set.getValue());
options[i] = new MessageResponseOption(set.getKey().longValue(), set.getValue());
i++;
}

messages.put(messageId, new Message(messageId,
priority,
messageControl,
startTime,
duration,
messageText,
options));
return true;
for (Map.Entry<Long, String> set : responseOptions.entrySet()) {
Log.d(TAG, "presentMessages option: key:" + set.getKey() + " value:" + set.getValue());
options[i] = new MessageResponseOption(set.getKey().longValue(), set.getValue());
i++;
}


messages.put(
messageId,
new Message(
messageId, priority, messageControl, startTime, duration, messageText, options));
return true;
}

@Override
public boolean cancelMessage(String messageId)
{
Log.d(TAG, "cancelMessage: at " + this.endpoint + " messageId:"+messageId);
public boolean cancelMessage(String messageId) {
Log.d(TAG, "cancelMessage: at " + this.endpoint + " messageId:" + messageId);
messages.remove(messageId);
return true; // per spec, succeed unless error
}

}

0 comments on commit 96e072a

Please sign in to comment.