@SystemApi
@Deprecated
public class ContextHubMessage {
+ private static final int DEBUG_LOG_NUM_BYTES = 16;
private int mType;
private int mVersion;
private byte[]mData;
- private static final String TAG = "ContextHubMessage";
-
/**
* Get the message type
*
return new ContextHubMessage[size];
}
};
+
+ @Override
+ public String toString() {
+ int length = mData.length;
+
+ String ret =
+ "ContextHubMessage[type = " + mType + ", length = " + mData.length + " bytes](";
+ if (length > 0) {
+ ret += "data = 0x";
+ }
+ for (int i = 0; i < Math.min(length, DEBUG_LOG_NUM_BYTES); i++) {
+ ret += Byte.toHexString(mData[i], true /* upperCase */);
+
+ if ((i + 1) % 4 == 0) {
+ ret += " ";
+ }
+ }
+ if (length > DEBUG_LOG_NUM_BYTES) {
+ ret += "...";
+ }
+ ret += ")";
+
+ return ret;
+ }
}
*/
@SystemApi
public final class NanoAppMessage implements Parcelable {
+ private static final int DEBUG_LOG_NUM_BYTES = 16;
private long mNanoAppId;
private int mMessageType;
private byte[] mMessageBody;
return new NanoAppMessage[size];
}
};
+
+ @Override
+ public String toString() {
+ int length = mMessageBody.length;
+
+ String ret = "NanoAppMessage[type = " + mMessageType + ", length = " + mMessageBody.length
+ + " bytes, " + (mIsBroadcasted ? "broadcast" : "unicast") + ", nanoapp = 0x"
+ + Long.toHexString(mNanoAppId) + "](";
+ if (length > 0) {
+ ret += "data = 0x";
+ }
+ for (int i = 0; i < Math.min(length, DEBUG_LOG_NUM_BYTES); i++) {
+ ret += Byte.toHexString(mMessageBody[i], true /* upperCase */);
+
+ if ((i + 1) % 4 == 0) {
+ ret += " ";
+ }
+ }
+ if (length > DEBUG_LOG_NUM_BYTES) {
+ ret += "...";
+ }
+ ret += ")";
+
+ return ret;
+ }
}
NanoAppMessage clientMessage = ContextHubServiceUtil.createNanoAppMessage(message);
if (DEBUG_LOG_ENABLED) {
- String targetAudience = clientMessage.isBroadcastMessage() ? "broadcast" : "unicast";
- Log.v(TAG, "Received a " + targetAudience + " message from nanoapp 0x"
- + Long.toHexString(clientMessage.getNanoAppId()));
+ Log.v(TAG, "Received " + clientMessage);
}
if (clientMessage.isBroadcastMessage()) {