diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/Message.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/Message.java index 49faa3db4b82ba..c194ffb44f9ee1 100644 --- a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/Message.java +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/Message.java @@ -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; + } } diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessageResponseOption.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessageResponseOption.java index 750f57907b6eb0..5d8e77d1e91389 100644 --- a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessageResponseOption.java +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessageResponseOption.java @@ -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; } +} diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessagesManager.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessagesManager.java index 30ab402feea57a..0a5680866714c6 100644 --- a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessagesManager.java +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessagesManager.java @@ -1,4 +1,4 @@ - /* +/* * Copyright (c) 2024 Project CHIP Authors * All rights reserved. * @@ -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 responseOptions); - - boolean cancelMessage(String messageId); + boolean presentMessages( + String messageId, + int priority, + int messageControl, + long startTime, + int duration, + String messageText, + HashMap responseOptions); + + boolean cancelMessage(String messageId); } diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessagesManagerStub.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessagesManagerStub.java index 0ccb0e0d322e0b..63fef69d35c936 100644 --- a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessagesManagerStub.java +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/MessagesManagerStub.java @@ -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 messages = new HashMap(); + private Map messages = new HashMap(); public MessagesManagerStub(int endpoint) { this.endpoint = endpoint; Log.d(TAG, "MessagesManagerStub: at " + this.endpoint); - HashMap responseOptions = new HashMap(); + HashMap responseOptions = new HashMap(); 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"); } @@ -54,39 +47,36 @@ public Message[] getMessages() { } @Override - public boolean presentMessages(String messageId, - int priority, - int messageControl, - long startTime, - int duration, - String messageText, - HashMap 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 responseOptions) { + Log.d( + TAG, "presentMessages: at " + this.endpoint + " id:" + messageId + " text:" + messageText); + MessageResponseOption[] options = new MessageResponseOption[responseOptions.size()]; + int i = 0; - for (Map.Entry 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 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 } - }