// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: braces fieldsfirst space lnc package com.olio.communication.messages; import android.os.Parcel; import android.os.Parcelable; import android.os.SystemClock; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.olio.communication.messages.files.FileChunk; import com.olio.communication.notifications.Utilities; import com.olio.util.ALog; import java.io.IOException; import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.text.SimpleDateFormat; import java.util.Random; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; // Referenced classes of package com.olio.communication.messages: // JsonSuperPackAPI, MessagePayload, MessageBuilder public class Message implements Parcelable, Serializable { public static final class Action extends Enum { private static final Action $VALUES[]; public static final Action APPEND; public static final Action CREATE_OR_UPDATE; public static final Action DELETE; public static Action valueOf(String s) { return (Action)Enum.valueOf(com/olio/communication/messages/Message$Action, s); } public static Action[] values() { return (Action[])$VALUES.clone(); } static { CREATE_OR_UPDATE = new Action("CREATE_OR_UPDATE", 0); DELETE = new Action("DELETE", 1); APPEND = new Action("APPEND", 2); $VALUES = (new Action[] { CREATE_OR_UPDATE, DELETE, APPEND }); } private Action(String s, int i) { super(s, i); } } public static final android.os.Parcelable.Creator CREATOR = new android.os.Parcelable.Creator() { public Message createFromParcel(Parcel parcel) { return Message.unpackParcel(parcel); } public volatile Object createFromParcel(Parcel parcel) { return createFromParcel(parcel); } public Message[] newArray(int i) { return new Message[i]; } public volatile Object[] newArray(int i) { return newArray(i); } }; public static final byte FILE_CHUNK_ENCODED_MESSAGE = 1; public static final byte JSON_ENCODED_MESSAGE = 0; public static final String PHONE = "phone"; public static final String WATCH = "watch"; public static final String WEB = "web"; public static JsonSuperPackAPI jsonPack = new JsonSuperPackAPI(); static Random randomForBleEncoding = new Random(0x98580b121L); private static final long serialVersionUID = 1L; Action mAction; String mDestination; MessagePayload mPayload; String mSource; public Message() { mPayload = null; mAction = null; } public static Message decodeFromBle(String s, byte byte0, byte abyte0[]) { if (byte0 == 0) { return jsonDecode(abyte0); } if (byte0 == 1) { return FileChunk.decodeChunk(s, abyte0); } else { ALog.e("Received an unknown message type on the BLE channel", new Object[0]); return null; } } public static Message decodeFromSerialization(byte abyte0[]) { long l = SystemClock.elapsedRealtime(); abyte0 = (Message)Utilities.decode(abyte0); if (abyte0 != null && abyte0.getPayload() != null) { ALog.d("Analytics_new,major,serializationDecode,minor,%s,time,%d", new Object[] { abyte0.getPayload().getClass().getSimpleName(), Long.valueOf(SystemClock.elapsedRealtime() - l) }); } return abyte0; } public static Message jsonDecode(String s) { long l; l = SystemClock.elapsedRealtime(); ALog.d("Message Decode: \n %s", new Object[] { s }); s = (Message)objectMapper().readValue(s, com/olio/communication/messages/Message); if (s == null) { break MISSING_BLOCK_LABEL_74; } if (s.getPayload() != null) { ALog.d("Analytics_new, major,jsonDecode,minor,%s,time,%d", new Object[] { s.getPayload().getClass().getSimpleName(), Long.valueOf(SystemClock.elapsedRealtime() - l) }); } return s; s; ALog.e("Error Decoding Notification JSON", new Object[0]); _L2: return null; s; ALog.e("Error decoding message JSON", s, new Object[0]); continue; /* Loop/switch isn't completed */ s; ALog.e("Error decoding message JSON", s, new Object[0]); continue; /* Loop/switch isn't completed */ s; ALog.e("Error decoding message JSON", s, new Object[0]); if (true) goto _L2; else goto _L1 _L1: } public static Message jsonDecode(byte abyte0[]) { long l = SystemClock.elapsedRealtime(); if (!jsonPack.isSuperPack(abyte0)) goto _L2; else goto _L1 _L1: ALog.d("MESSAGE: isSuperPack: True", new Object[0]); abyte0 = jsonPack.toJson(abyte0, true); _L6: ALog.d("MESSAGE: returned JSON string: %s", new Object[] { abyte0 }); abyte0 = (Message)objectMapper().readValue(abyte0, com/olio/communication/messages/Message); if (abyte0 == null) goto _L4; else goto _L3 _L3: if (abyte0.getPayload() == null) goto _L4; else goto _L5 _L5: ALog.d("Analytics_new, major,jsonDecode,minor,%s,time,%d", new Object[] { abyte0.getPayload().getClass().getSimpleName(), Long.valueOf(SystemClock.elapsedRealtime() - l) }); return abyte0; _L2: ALog.d("MESSAGE: isSuperPack: False", new Object[0]); abyte0 = new String(abyte0, "UTF-8"); goto _L6 abyte0; ALog.e("Error Decoding Notification JSON", new Object[0]); _L7: return null; abyte0; ALog.e("Error decoding Notification JSON", new Object[0]); if (true) goto _L7; else goto _L4 _L4: return abyte0; } public static ObjectMapper objectMapper() { SimpleDateFormat simpledateformat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); ObjectMapper objectmapper = new ObjectMapper(); objectmapper.setDateFormat(simpledateformat); objectmapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); return objectmapper; } public static Message unpackParcel(Parcel parcel) { MessagePayload messagepayload = (MessagePayload)parcel.readParcelable(com/olio/communication/messages/Message.getClassLoader()); Action action = (Action)parcel.readSerializable(); String s = parcel.readString(); parcel = parcel.readString(); return (new MessageBuilder()).setSource(s).setDestination(parcel).setPayload(messagepayload).setAction(action).build(); } public int describeContents() { return 0; } public byte[] encodeForBle() { Object obj; Object obj1; byte abyte0[]; byte abyte1[]; ByteBuffer bytebuffer; abyte1 = jsonEncode(); bytebuffer = ByteBuffer.allocate(abyte1.length + 4 + 4 + 20); bytebuffer.order(ByteOrder.LITTLE_ENDIAN); bytebuffer.putInt(randomForBleEncoding.nextInt()); bytebuffer.putInt(abyte1.length); abyte0 = new byte[20]; obj = abyte0; obj1 = abyte0; MessageDigest messagedigest = MessageDigest.getInstance("SHA-1"); obj = abyte0; obj1 = abyte0; messagedigest.update(abyte1); obj = abyte0; obj1 = abyte0; abyte0 = messagedigest.digest(); obj = abyte0; obj1 = abyte0; new String(abyte0, "UTF-8"); obj = abyte0; _L2: bytebuffer.put(((byte []) (obj))); bytebuffer.put(abyte1); return bytebuffer.array(); obj1; ALog.e("Unable to perform SHA-1", new Object[0]); continue; /* Loop/switch isn't completed */ UnsupportedEncodingException unsupportedencodingexception; unsupportedencodingexception; ALog.e("Unable to find UTF-8 encoding", new Object[0]); unsupportedencodingexception = ((UnsupportedEncodingException) (obj1)); if (true) goto _L2; else goto _L1 _L1: } public byte[] encodeWithSerialization() { long l = SystemClock.elapsedRealtime(); byte abyte0[] = Utilities.encodeWithSerialization(this); if (getPayload() != null) { ALog.d("Analytics_new,major,serializationEncode,minor,%s,time,%d", new Object[] { getPayload().getClass().getSimpleName(), Long.valueOf(SystemClock.elapsedRealtime() - l) }); } return abyte0; } public boolean equals(Object obj) { if (obj != null) { if (obj == this) { return true; } if (obj.getClass() == getClass()) { obj = (Message)obj; return (new EqualsBuilder()).append(mPayload, ((Message) (obj)).getPayload()).append(mAction, ((Message) (obj)).getAction()).isEquals(); } } return false; } public Action getAction() { return mAction; } public String getDestination() { return mDestination; } public MessagePayload getPayload() { return mPayload; } public String getSource() { return mSource; } public int hashCode() { return (new HashCodeBuilder(53, 29)).append(mPayload).append(mAction).toHashCode(); } public byte[] jsonEncode() { long l; l = SystemClock.elapsedRealtime(); ALog.d("JsonEncode(): %s", new Object[] { getPayload().getClass().getName() }); String s; byte abyte0[]; s = objectMapper().writeValueAsString(this); abyte0 = jsonPack.fromJson(s, true); if (abyte0 != null) { break MISSING_BLOCK_LABEL_96; } if (getPayload() != null) { ALog.d("Analytics_new,major,jsonEncode,minor,%s,time,%d", new Object[] { getPayload().getClass().getSimpleName(), Long.valueOf(SystemClock.elapsedRealtime() - l) }); } return s.getBytes("UTF-8"); if (getPayload() == null) goto _L2; else goto _L1 _L1: ALog.d("Analytics_new,major,jsonEncode,minor,%s,time,%d", new Object[] { getPayload().getClass().getSimpleName(), Long.valueOf(SystemClock.elapsedRealtime() - l) }); return abyte0; Object obj; obj; ALog.e("Error Decoding Notification JSON", ((Throwable) (obj)), new Object[0]); _L3: return null; obj; ALog.e("Error Decoding notification JSON", ((Throwable) (obj)), new Object[0]); if (true) goto _L3; else goto _L2 _L2: return abyte0; } public void setAction(Action action) { mAction = action; } public void setDestination(String s) { mDestination = s; } public void setPayload(MessagePayload messagepayload) { mPayload = messagepayload; } public void setSource(String s) { mSource = s; } public String toString() { return (new StringBuilder()).append("Message{mAction=").append(mAction).append(", mPayload=").append(mPayload).append(", mSource='").append(mSource).append('\'').append(", mDestination='").append(mDestination).append('\'').append(", randomForBleEncoding=").append(randomForBleEncoding).append('}').toString(); } public void writeToParcel(Parcel parcel, int i) { parcel.writeParcelable(mPayload, 0); parcel.writeSerializable(mAction); parcel.writeString(mSource); parcel.writeString(mDestination); } }