com.crashlytics.java_1.6.1.201405061826

16:34:20.829 INFO  jd.cli.Main - Decompiling com.crashlytics.java_1.6.1.201405061826.jar
package com.crashlytics.java;

final class ByteString$CodedBuilder
{
  private final CodedOutputStream output;
  private final byte[] buffer;
  
  private ByteString$CodedBuilder(int size)
  {
    buffer = new byte[size];
    output = CodedOutputStream.newInstance(buffer);
  }
  
  public ByteString build()
  {
    output.checkNoSpaceLeft();
    
    return new ByteString(buffer, null);
  }
  
  public CodedOutputStream getCodedOutput()
  {
    return output;
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.java.ByteString.CodedBuilder
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.java;

import java.io.ByteArrayOutputStream;
import java.io.FilterOutputStream;

final class ByteString$Output
  extends FilterOutputStream
{
  private final ByteArrayOutputStream bout;
  
  private ByteString$Output(ByteArrayOutputStream bout)
  {
    super(bout);
    this.bout = bout;
  }
  
  public ByteString toByteString()
  {
    byte[] byteArray = bout.toByteArray();
    return new ByteString(byteArray, null);
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.java.ByteString.Output
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.java;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FilterOutputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.util.List;

final class ByteString
{
  private final byte[] bytes;
  
  private ByteString(byte[] bytes)
  {
    this.bytes = bytes;
  }
  
  public byte byteAt(int index)
  {
    return bytes[index];
  }
  
  public int size()
  {
    return bytes.length;
  }
  
  public boolean isEmpty()
  {
    return bytes.length == 0;
  }
  
  public static final ByteString EMPTY = new ByteString(new byte[0]);
  
  public static ByteString copyFrom(byte[] bytes, int offset, int size)
  {
    byte[] copy = new byte[size];
    System.arraycopy(bytes, offset, copy, 0, size);
    return new ByteString(copy);
  }
  
  public static ByteString copyFrom(byte[] bytes)
  {
    return copyFrom(bytes, 0, bytes.length);
  }
  
  public static ByteString copyFrom(ByteBuffer bytes, int size)
  {
    byte[] copy = new byte[size];
    bytes.get(copy);
    return new ByteString(copy);
  }
  
  public static ByteString copyFrom(ByteBuffer bytes)
  {
    return copyFrom(bytes, bytes.remaining());
  }
  
  public static ByteString copyFrom(String text, String charsetName)
    throws UnsupportedEncodingException
  {
    return new ByteString(text.getBytes(charsetName));
  }
  
  public static ByteString copyFromUtf8(String text)
  {
    try
    {
      return new ByteString(text.getBytes("UTF-8"));
    }
    catch (UnsupportedEncodingException e)
    {
      throw new RuntimeException("UTF-8 not supported?", e);
    }
  }
  
  public static ByteString copyFrom(List<ByteString> list)
  {
    if (list.size() == 0) {
      return EMPTY;
    }
    if (list.size() == 1) {
      return (ByteString)list.get(0);
    }
    int size = 0;
    for (ByteString str : list) {
      size += str.size();
    }
    byte[] bytes = new byte[size];
    int pos = 0;
    for (ByteString str : list)
    {
      System.arraycopy(bytes, 0, bytes, pos, str.size());
      pos += str.size();
    }
    return new ByteString(bytes);
  }
  
  public void copyTo(byte[] target, int offset)
  {
    System.arraycopy(bytes, 0, target, offset, bytes.length);
  }
  
  public void copyTo(byte[] target, int sourceOffset, int targetOffset, int size)
  {
    System.arraycopy(bytes, sourceOffset, target, targetOffset, size);
  }
  
  public void copyTo(ByteBuffer target)
  {
    target.put(bytes, 0, bytes.length);
  }
  
  public byte[] toByteArray()
  {
    int size = bytes.length;
    byte[] copy = new byte[size];
    System.arraycopy(bytes, 0, copy, 0, size);
    return copy;
  }
  
  public ByteBuffer asReadOnlyByteBuffer()
  {
    ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
    return byteBuffer.asReadOnlyBuffer();
  }
  
  public String toString(String charsetName)
    throws UnsupportedEncodingException
  {
    return new String(bytes, charsetName);
  }
  
  public String toStringUtf8()
  {
    try
    {
      return new String(bytes, "UTF-8");
    }
    catch (UnsupportedEncodingException e)
    {
      throw new RuntimeException("UTF-8 not supported?", e);
    }
  }
  
  public boolean equals(Object o)
  {
    if (o == this) {
      return true;
    }
    if (!(o instanceof ByteString)) {
      return false;
    }
    ByteString other = (ByteString)o;
    int size = bytes.length;
    if (size != bytes.length) {
      return false;
    }
    byte[] thisBytes = bytes;
    byte[] otherBytes = bytes;
    for (int i = 0; i < size; i++) {
      if (thisBytes[i] != otherBytes[i]) {
        return false;
      }
    }
    return true;
  }
  
  private volatile int hash = 0;
  
  public int hashCode()
  {
    int h = hash;
    if (h == 0)
    {
      byte[] thisBytes = bytes;
      int size = bytes.length;
      
      h = size;
      for (int i = 0; i < size; i++) {
        h = h * 31 + thisBytes[i];
      }
      if (h == 0) {
        h = 1;
      }
      hash = h;
    }
    return h;
  }
  
  public InputStream newInput()
  {
    return new ByteArrayInputStream(bytes);
  }
  
  public static Output newOutput(int initialCapacity)
  {
    return new Output(new ByteArrayOutputStream(initialCapacity), null);
  }
  
  public static Output newOutput()
  {
    return newOutput(32);
  }
  
  static final class Output
    extends FilterOutputStream
  {
    private final ByteArrayOutputStream bout;
    
    private Output(ByteArrayOutputStream bout)
    {
      super();
      this.bout = bout;
    }
    
    public ByteString toByteString()
    {
      byte[] byteArray = bout.toByteArray();
      return new ByteString(byteArray, null);
    }
  }
  
  static CodedBuilder newCodedBuilder(int size)
  {
    return new CodedBuilder(size, null);
  }
  
  static final class CodedBuilder
  {
    private final CodedOutputStream output;
    private final byte[] buffer;
    
    private CodedBuilder(int size)
    {
      buffer = new byte[size];
      output = CodedOutputStream.newInstance(buffer);
    }
    
    public ByteString build()
    {
      output.checkNoSpaceLeft();
      
      return new ByteString(buffer, null);
    }
    
    public CodedOutputStream getCodedOutput()
    {
      return output;
    }
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.java.ByteString
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.java;

import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Date;

class CLSUUID
{
  static int _sequenceNumber = 0;
  private byte[] _bytes;
  
  public CLSUUID()
  {
    _bytes = new byte[16];
    
    populateTime(_bytes);
    populateSequenceNumber(_bytes);
    populatePID(_bytes);
    populateMacAddress(_bytes);
  }
  
  private synchronized void populateTime(byte[] bytes)
  {
    Date date = new Date();
    long time = date.getTime();
    long tvSec = time / 1000L;
    long tvUsec = time % 1000L;
    byte[] timeBytes = convertLongToFourByteBuffer(tvSec);
    bytes[0] = timeBytes[0];
    bytes[1] = timeBytes[1];
    bytes[2] = timeBytes[2];
    bytes[3] = timeBytes[3];
    
    byte[] msecsBytes = convertLongToTwoByteBuffer(tvUsec);
    bytes[4] = msecsBytes[0];
    bytes[5] = msecsBytes[1];
  }
  
  private synchronized void populateSequenceNumber(byte[] bytes)
  {
    Long sequence = new Long(++_sequenceNumber);
    byte[] sequenceBytes = convertLongToTwoByteBuffer(sequence.shortValue());
    bytes[6] = sequenceBytes[0];
    bytes[7] = sequenceBytes[1];
  }
  
  private void populatePID(byte[] bytes)
  {
    Integer pid = new Integer(Utils.getPid());
    byte[] pidBytes = convertLongToTwoByteBuffer(pid.shortValue());
    bytes[8] = pidBytes[0];
    bytes[9] = pidBytes[1];
  }
  
  private void populateMacAddress(byte[] bytes)
  {
    String macAddress = Utils.getMacAddress();
    if ((macAddress == null) || (macAddress.isEmpty())) {
      macAddress = "0";
    }
    BigInteger deviceIdBig = new BigInteger(macAddress.replaceAll("-", ""), 16);
    
    byte[] deviceIdBigBytes = convertLongToFourByteBuffer(deviceIdBig.longValue());
    bytes[10] = deviceIdBigBytes[0];
    bytes[11] = deviceIdBigBytes[1];
    bytes[12] = deviceIdBigBytes[2];
    bytes[13] = deviceIdBigBytes[3];
    
    deviceIdBigBytes = convertLongToTwoByteBuffer(deviceIdBig.shortValue());
    bytes[14] = deviceIdBigBytes[0];
    bytes[15] = deviceIdBigBytes[1];
  }
  
  private byte[] convertLongToFourByteBuffer(long value)
  {
    ByteBuffer buf = ByteBuffer.allocate(4);
    buf.putInt((int)value);
    buf.order(ByteOrder.BIG_ENDIAN);
    buf.position(0);
    
    return buf.array();
  }
  
  private byte[] convertLongToTwoByteBuffer(long value)
  {
    ByteBuffer buf = ByteBuffer.allocate(2);
    buf.putShort((short)(int)value);
    buf.order(ByteOrder.BIG_ENDIAN);
    buf.position(0);
    
    return buf.array();
  }
  
  public String toString()
  {
    String hex = "0123456789ABCDEF";
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < _bytes.length; i++)
    {
      byte b = _bytes[i];
      buf.append(hex.charAt((b & 0xF0) >> 4));
      buf.append(hex.charAt(b & 0xF));
      if ((i == 5) || (i == 7) || (i == 9)) {
        buf.append("-");
      }
    }
    return buf.toString();
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.java.CLSUUID
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.java;

import java.io.IOException;

class CodedOutputStream$OutOfSpaceException
  extends IOException
{
  private static final long serialVersionUID = -6947486886997889499L;
  
  CodedOutputStream$OutOfSpaceException()
  {
    super("CodedOutputStream was writing to a flat byte array and ran out of space.");
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.java.CodedOutputStream.OutOfSpaceException
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.java;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;

final class CodedOutputStream
{
  private final byte[] buffer;
  private final int limit;
  private int position;
  private final OutputStream output;
  public static final int DEFAULT_BUFFER_SIZE = 4096;
  public static final int LITTLE_ENDIAN_32_SIZE = 4;
  public static final int LITTLE_ENDIAN_64_SIZE = 8;
  
  static int computePreferredBufferSize(int dataLength)
  {
    if (dataLength > 4096) {
      return 4096;
    }
    return dataLength;
  }
  
  private CodedOutputStream(byte[] buffer, int offset, int length)
  {
    output = null;
    this.buffer = buffer;
    position = offset;
    limit = (offset + length);
  }
  
  private CodedOutputStream(OutputStream output, byte[] buffer)
  {
    this.output = output;
    this.buffer = buffer;
    position = 0;
    limit = buffer.length;
  }
  
  public static CodedOutputStream newInstance(OutputStream output)
  {
    return newInstance(output, 4096);
  }
  
  public static CodedOutputStream newInstance(OutputStream output, int bufferSize)
  {
    return new CodedOutputStream(output, new byte[bufferSize]);
  }
  
  public static CodedOutputStream newInstance(byte[] flatArray)
  {
    return newInstance(flatArray, 0, flatArray.length);
  }
  
  public static CodedOutputStream newInstance(byte[] flatArray, int offset, int length)
  {
    return new CodedOutputStream(flatArray, offset, length);
  }
  
  public void writeDouble(int fieldNumber, double value)
    throws IOException
  {
    writeTag(fieldNumber, 1);
    writeDoubleNoTag(value);
  }
  
  public void writeFloat(int fieldNumber, float value)
    throws IOException
  {
    writeTag(fieldNumber, 5);
    writeFloatNoTag(value);
  }
  
  public void writeUInt64(int fieldNumber, long value)
    throws IOException
  {
    writeTag(fieldNumber, 0);
    writeUInt64NoTag(value);
  }
  
  public void writeInt64(int fieldNumber, long value)
    throws IOException
  {
    writeTag(fieldNumber, 0);
    writeInt64NoTag(value);
  }
  
  public void writeInt32(int fieldNumber, int value)
    throws IOException
  {
    writeTag(fieldNumber, 0);
    writeInt32NoTag(value);
  }
  
  public void writeFixed64(int fieldNumber, long value)
    throws IOException
  {
    writeTag(fieldNumber, 1);
    writeFixed64NoTag(value);
  }
  
  public void writeFixed32(int fieldNumber, int value)
    throws IOException
  {
    writeTag(fieldNumber, 5);
    writeFixed32NoTag(value);
  }
  
  public void writeBool(int fieldNumber, boolean value)
    throws IOException
  {
    writeTag(fieldNumber, 0);
    writeBoolNoTag(value);
  }
  
  public void writeString(int fieldNumber, String value)
    throws IOException
  {
    writeTag(fieldNumber, 2);
    writeStringNoTag(value);
  }
  
  public void writeBytes(int fieldNumber, ByteString value)
    throws IOException
  {
    writeTag(fieldNumber, 2);
    writeBytesNoTag(value);
  }
  
  public void writeUInt32(int fieldNumber, int value)
    throws IOException
  {
    writeTag(fieldNumber, 0);
    writeUInt32NoTag(value);
  }
  
  public void writeEnum(int fieldNumber, int value)
    throws IOException
  {
    writeTag(fieldNumber, 0);
    writeEnumNoTag(value);
  }
  
  public void writeSFixed32(int fieldNumber, int value)
    throws IOException
  {
    writeTag(fieldNumber, 5);
    writeSFixed32NoTag(value);
  }
  
  public void writeSFixed64(int fieldNumber, long value)
    throws IOException
  {
    writeTag(fieldNumber, 1);
    writeSFixed64NoTag(value);
  }
  
  public void writeSInt32(int fieldNumber, int value)
    throws IOException
  {
    writeTag(fieldNumber, 0);
    writeSInt32NoTag(value);
  }
  
  public void writeSInt64(int fieldNumber, long value)
    throws IOException
  {
    writeTag(fieldNumber, 0);
    writeSInt64NoTag(value);
  }
  
  public void writeRawMessageSetExtension(int fieldNumber, ByteString value)
    throws IOException
  {
    writeTag(1, 3);
    writeUInt32(2, fieldNumber);
    writeBytes(3, value);
    writeTag(1, 4);
  }
  
  public void writeDoubleNoTag(double value)
    throws IOException
  {
    writeRawLittleEndian64(Double.doubleToRawLongBits(value));
  }
  
  public void writeFloatNoTag(float value)
    throws IOException
  {
    writeRawLittleEndian32(Float.floatToRawIntBits(value));
  }
  
  public void writeUInt64NoTag(long value)
    throws IOException
  {
    writeRawVarint64(value);
  }
  
  public void writeInt64NoTag(long value)
    throws IOException
  {
    writeRawVarint64(value);
  }
  
  public void writeInt32NoTag(int value)
    throws IOException
  {
    if (value >= 0) {
      writeRawVarint32(value);
    } else {
      writeRawVarint64(value);
    }
  }
  
  public void writeFixed64NoTag(long value)
    throws IOException
  {
    writeRawLittleEndian64(value);
  }
  
  public void writeFixed32NoTag(int value)
    throws IOException
  {
    writeRawLittleEndian32(value);
  }
  
  public void writeBoolNoTag(boolean value)
    throws IOException
  {
    writeRawByte(value ? 1 : 0);
  }
  
  public void writeStringNoTag(String value)
    throws IOException
  {
    byte[] bytes = value.getBytes("UTF-8");
    writeRawVarint32(bytes.length);
    writeRawBytes(bytes);
  }
  
  public void writeBytesNoTag(ByteString value)
    throws IOException
  {
    writeRawVarint32(value.size());
    writeRawBytes(value);
  }
  
  public void writeUInt32NoTag(int value)
    throws IOException
  {
    writeRawVarint32(value);
  }
  
  public void writeEnumNoTag(int value)
    throws IOException
  {
    writeInt32NoTag(value);
  }
  
  public void writeSFixed32NoTag(int value)
    throws IOException
  {
    writeRawLittleEndian32(value);
  }
  
  public void writeSFixed64NoTag(long value)
    throws IOException
  {
    writeRawLittleEndian64(value);
  }
  
  public void writeSInt32NoTag(int value)
    throws IOException
  {
    writeRawVarint32(encodeZigZag32(value));
  }
  
  public void writeSInt64NoTag(long value)
    throws IOException
  {
    writeRawVarint64(encodeZigZag64(value));
  }
  
  public static int computeDoubleSize(int fieldNumber, double value)
  {
    return computeTagSize(fieldNumber) + computeDoubleSizeNoTag(value);
  }
  
  public static int computeFloatSize(int fieldNumber, float value)
  {
    return computeTagSize(fieldNumber) + computeFloatSizeNoTag(value);
  }
  
  public static int computeUInt64Size(int fieldNumber, long value)
  {
    return computeTagSize(fieldNumber) + computeUInt64SizeNoTag(value);
  }
  
  public static int computeInt64Size(int fieldNumber, long value)
  {
    return computeTagSize(fieldNumber) + computeInt64SizeNoTag(value);
  }
  
  public static int computeInt32Size(int fieldNumber, int value)
  {
    return computeTagSize(fieldNumber) + computeInt32SizeNoTag(value);
  }
  
  public static int computeFixed64Size(int fieldNumber, long value)
  {
    return computeTagSize(fieldNumber) + computeFixed64SizeNoTag(value);
  }
  
  public static int computeFixed32Size(int fieldNumber, int value)
  {
    return computeTagSize(fieldNumber) + computeFixed32SizeNoTag(value);
  }
  
  public static int computeBoolSize(int fieldNumber, boolean value)
  {
    return computeTagSize(fieldNumber) + computeBoolSizeNoTag(value);
  }
  
  public static int computeStringSize(int fieldNumber, String value)
  {
    return computeTagSize(fieldNumber) + computeStringSizeNoTag(value);
  }
  
  public static int computeBytesSize(int fieldNumber, ByteString value)
  {
    return computeTagSize(fieldNumber) + computeBytesSizeNoTag(value);
  }
  
  public static int computeUInt32Size(int fieldNumber, int value)
  {
    return computeTagSize(fieldNumber) + computeUInt32SizeNoTag(value);
  }
  
  public static int computeEnumSize(int fieldNumber, int value)
  {
    return computeTagSize(fieldNumber) + computeEnumSizeNoTag(value);
  }
  
  public static int computeSFixed32Size(int fieldNumber, int value)
  {
    return computeTagSize(fieldNumber) + computeSFixed32SizeNoTag(value);
  }
  
  public static int computeSFixed64Size(int fieldNumber, long value)
  {
    return computeTagSize(fieldNumber) + computeSFixed64SizeNoTag(value);
  }
  
  public static int computeSInt32Size(int fieldNumber, int value)
  {
    return computeTagSize(fieldNumber) + computeSInt32SizeNoTag(value);
  }
  
  public static int computeSInt64Size(int fieldNumber, long value)
  {
    return computeTagSize(fieldNumber) + computeSInt64SizeNoTag(value);
  }
  
  public static int computeRawMessageSetExtensionSize(int fieldNumber, ByteString value)
  {
    return computeTagSize(1) * 2 + 
      computeUInt32Size(2, fieldNumber) + 
      computeBytesSize(3, value);
  }
  
  public static int computeDoubleSizeNoTag(double value)
  {
    return 8;
  }
  
  public static int computeFloatSizeNoTag(float value)
  {
    return 4;
  }
  
  public static int computeUInt64SizeNoTag(long value)
  {
    return computeRawVarint64Size(value);
  }
  
  public static int computeInt64SizeNoTag(long value)
  {
    return computeRawVarint64Size(value);
  }
  
  public static int computeInt32SizeNoTag(int value)
  {
    if (value >= 0) {
      return computeRawVarint32Size(value);
    }
    return 10;
  }
  
  public static int computeFixed64SizeNoTag(long value)
  {
    return 8;
  }
  
  public static int computeFixed32SizeNoTag(int value)
  {
    return 4;
  }
  
  public static int computeBoolSizeNoTag(boolean value)
  {
    return 1;
  }
  
  public static int computeStringSizeNoTag(String value)
  {
    try
    {
      byte[] bytes = value.getBytes("UTF-8");
      return computeRawVarint32Size(bytes.length) + 
        bytes.length;
    }
    catch (UnsupportedEncodingException e)
    {
      throw new RuntimeException("UTF-8 not supported.", e);
    }
  }
  
  public static int computeBytesSizeNoTag(ByteString value)
  {
    return computeRawVarint32Size(value.size()) + 
      value.size();
  }
  
  public static int computeUInt32SizeNoTag(int value)
  {
    return computeRawVarint32Size(value);
  }
  
  public static int computeEnumSizeNoTag(int value)
  {
    return computeInt32SizeNoTag(value);
  }
  
  public static int computeSFixed32SizeNoTag(int value)
  {
    return 4;
  }
  
  public static int computeSFixed64SizeNoTag(long value)
  {
    return 8;
  }
  
  public static int computeSInt32SizeNoTag(int value)
  {
    return computeRawVarint32Size(encodeZigZag32(value));
  }
  
  public static int computeSInt64SizeNoTag(long value)
  {
    return computeRawVarint64Size(encodeZigZag64(value));
  }
  
  private void refreshBuffer()
    throws IOException
  {
    if (output == null) {
      throw new OutOfSpaceException();
    }
    output.write(buffer, 0, position);
    position = 0;
  }
  
  public void flush()
    throws IOException
  {
    if (output != null) {
      refreshBuffer();
    }
  }
  
  public int spaceLeft()
  {
    if (output == null) {
      return limit - position;
    }
    throw new UnsupportedOperationException(
      "spaceLeft() can only be called on CodedOutputStreams that are writing to a flat array.");
  }
  
  public void checkNoSpaceLeft()
  {
    if (spaceLeft() != 0) {
      throw new IllegalStateException(
        "Did not write as much data as expected.");
    }
  }
  
  static class OutOfSpaceException
    extends IOException
  {
    private static final long serialVersionUID = -6947486886997889499L;
    
    OutOfSpaceException()
    {
      super();
    }
  }
  
  public void writeRawByte(byte value)
    throws IOException
  {
    if (position == limit) {
      refreshBuffer();
    }
    buffer[(position++)] = value;
  }
  
  public void writeRawByte(int value)
    throws IOException
  {
    writeRawByte((byte)value);
  }
  
  public void writeRawBytes(ByteString value)
    throws IOException
  {
    writeRawBytes(value, 0, value.size());
  }
  
  public void writeRawBytes(byte[] value)
    throws IOException
  {
    writeRawBytes(value, 0, value.length);
  }
  
  public void writeRawBytes(byte[] value, int offset, int length)
    throws IOException
  {
    if (limit - position >= length)
    {
      System.arraycopy(value, offset, buffer, position, length);
      position += length;
    }
    else
    {
      int bytesWritten = limit - position;
      System.arraycopy(value, offset, buffer, position, bytesWritten);
      offset += bytesWritten;
      length -= bytesWritten;
      position = limit;
      refreshBuffer();
      if (length <= limit)
      {
        System.arraycopy(value, offset, buffer, 0, length);
        position = length;
      }
      else
      {
        output.write(value, offset, length);
      }
    }
  }
  
  public void writeRawBytes(ByteString value, int offset, int length)
    throws IOException
  {
    if (limit - position >= length)
    {
      value.copyTo(buffer, offset, position, length);
      position += length;
    }
    else
    {
      int bytesWritten = limit - position;
      value.copyTo(buffer, offset, position, bytesWritten);
      offset += bytesWritten;
      length -= bytesWritten;
      position = limit;
      refreshBuffer();
      if (length <= limit)
      {
        value.copyTo(buffer, offset, 0, length);
        position = length;
      }
      else
      {
        InputStream inputStreamFrom = value.newInput();
        if (offset != inputStreamFrom.skip(offset)) {
          throw new IllegalStateException("Skip failed? Should never happen.");
        }
        while (length > 0)
        {
          int bytesToRead = Math.min(length, limit);
          int bytesRead = inputStreamFrom.read(buffer, 0, bytesToRead);
          if (bytesRead != bytesToRead) {
            throw new IllegalStateException("Read failed? Should never happen");
          }
          output.write(buffer, 0, bytesRead);
          length -= bytesRead;
        }
      }
    }
  }
  
  public void writeTag(int fieldNumber, int wireType)
    throws IOException
  {
    writeRawVarint32(WireFormat.makeTag(fieldNumber, wireType));
  }
  
  public static int computeTagSize(int fieldNumber)
  {
    return computeRawVarint32Size(WireFormat.makeTag(fieldNumber, 0));
  }
  
  public void writeRawVarint32(int value)
    throws IOException
  {
    for (;;)
    {
      if ((value & 0xFFFFFF80) == 0)
      {
        writeRawByte(value);
        return;
      }
      writeRawByte(value & 0x7F | 0x80);
      value >>>= 7;
    }
  }
  
  public static int computeRawVarint32Size(int value)
  {
    if ((value & 0xFFFFFF80) == 0) {
      return 1;
    }
    if ((value & 0xC000) == 0) {
      return 2;
    }
    if ((value & 0xFFE00000) == 0) {
      return 3;
    }
    if ((value & 0xF0000000) == 0) {
      return 4;
    }
    return 5;
  }
  
  public void writeRawVarint64(long value)
    throws IOException
  {
    for (;;)
    {
      if ((value & 0xFFFFFFFFFFFFFF80) == 0L)
      {
        writeRawByte((int)value);
        return;
      }
      writeRawByte((int)value & 0x7F | 0x80);
      value >>>= 7;
    }
  }
  
  public static int computeRawVarint64Size(long value)
  {
    if ((value & 0xFFFFFFFFFFFFFF80) == 0L) {
      return 1;
    }
    if ((value & 0xFFFFFFFFFFFFC000) == 0L) {
      return 2;
    }
    if ((value & 0xFFFFFFFFFFE00000) == 0L) {
      return 3;
    }
    if ((value & 0xFFFFFFFFF0000000) == 0L) {
      return 4;
    }
    if ((value & 0xFFFFFFF800000000) == 0L) {
      return 5;
    }
    if ((value & 0xFFFFFC0000000000) == 0L) {
      return 6;
    }
    if ((value & 0xFFFE000000000000) == 0L) {
      return 7;
    }
    if ((value & 0xFF00000000000000) == 0L) {
      return 8;
    }
    if ((value & 0x8000000000000000) == 0L) {
      return 9;
    }
    return 10;
  }
  
  public void writeRawLittleEndian32(int value)
    throws IOException
  {
    writeRawByte(value & 0xFF);
    writeRawByte(value >> 8 & 0xFF);
    writeRawByte(value >> 16 & 0xFF);
    writeRawByte(value >> 24 & 0xFF);
  }
  
  public void writeRawLittleEndian64(long value)
    throws IOException
  {
    writeRawByte((int)value & 0xFF);
    writeRawByte((int)(value >> 8) & 0xFF);
    writeRawByte((int)(value >> 16) & 0xFF);
    writeRawByte((int)(value >> 24) & 0xFF);
    writeRawByte((int)(value >> 32) & 0xFF);
    writeRawByte((int)(value >> 40) & 0xFF);
    writeRawByte((int)(value >> 48) & 0xFF);
    writeRawByte((int)(value >> 56) & 0xFF);
  }
  
  public static int encodeZigZag32(int n)
  {
    return n << 1 ^ n >> 31;
  }
  
  public static long encodeZigZag64(long n)
  {
    return n << 1 ^ n >> 63;
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.java.CodedOutputStream
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.java;

import java.io.File;
import java.io.FilenameFilter;

class Crashlytics$1
  implements FilenameFilter
{
  public boolean accept(File dir, String filename)
  {
    if (filename.endsWith(".cls")) {
      return true;
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.java.Crashlytics.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.java;

class Crashlytics$2
  implements Runnable
{
  Crashlytics$2(Exception paramException) {}
  
  public void run()
  {
    Crashlytics.access$1(Crashlytics.access$0()).logException(Thread.currentThread(), val$exception);
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.java.Crashlytics.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.java;

class Crashlytics$3
  implements Runnable
{
  Crashlytics$3(long paramLong, String paramString) {}
  
  public void run()
  {
    Crashlytics.access$1(Crashlytics.access$0()).writeToLog(val$timestamp, val$msg);
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.java.Crashlytics.3
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.java;

import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;

class Crashlytics$4
  implements Runnable
{
  Crashlytics$4(Crashlytics paramCrashlytics, float paramFloat) {}
  
  public void run()
  {
    boolean success = false;
    try
    {
      HttpParams connectionParams = new BasicHttpParams();
      
      HttpConnectionParams.setConnectionTimeout(connectionParams, 10000);
      HttpConnectionParams.setSoTimeout(connectionParams, 10000);
      
      DefaultHttpClient client = new DefaultHttpClient(connectionParams);
      if (Crashlytics.access$2(this$0).load(client))
      {
        success = true;
        if (Crashlytics.access$2(this$0).getShouldReportCrashes()) {
          this$0.detectAndSendCrashReports(val$delay);
        } else {
          Utils.log("Crash reporting disabled");
        }
      }
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
    if (!success) {
      Utils.log("Crash report collection disabled.");
    }
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.java.Crashlytics.4
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.java;

import java.util.Set;

class Crashlytics$5
  implements Runnable
{
  Crashlytics$5(Crashlytics paramCrashlytics, float paramFloat) {}
  
  public void run()
  {
    Utils.log("Starting report processing in " + val$delay + " second(s)...");
    if (val$delay > 0.0F) {
      try
      {
        Thread.sleep((val$delay * 1000.0F));
      }
      catch (InterruptedException localInterruptedException)
      {
        Thread.currentThread().interrupt();
        return;
      }
    }
    Set<Report> reports = Crashlytics.findReports();
    Crashlytics.access$3(this$0, reports);
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.java.Crashlytics.5
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.java;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Set;

class Crashlytics$6
  implements Runnable
{
  Crashlytics$6(Crashlytics paramCrashlytics, Set paramSet) {}
  
  public void run()
  {
    String submissionURLString = null;
    try
    {
      submissionURLString = Crashlytics.access$2(this$0).getCrashSubmissionURL();
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
    if ((submissionURLString != null) && (!submissionURLString.equals("")))
    {
      URL submissionURL = null;
      try
      {
        submissionURL = new URL(submissionURLString);
      }
      catch (MalformedURLException e)
      {
        Utils.logError("Crash submission URL is malformed, Aborting.", e);
      }
      boolean sent = Crashlytics.access$4(this$0, val$reports, submissionURL);
      int retryCount = 0;
      while (!sent)
      {
        long interval = Crashlytics.access$5()[Math.min(retryCount, Crashlytics.access$5().length - 1)];
        Utils.log("Report submisson: scheduling delayed retry in " + interval + " seconds");
        try
        {
          Thread.sleep(interval * 1000L);
        }
        catch (InterruptedException localInterruptedException)
        {
          Thread.currentThread().interrupt();
          return;
        }
        sent = Crashlytics.access$4(this$0, val$reports, submissionURL);
        retryCount++;
      }
    }
    else
    {
      Utils.log("Crash submission URL is null or empty, Aborting.");
    }
  }
}

/* Location:
 * Qualified Name:     com.crashlytics.java.Crashlytics.6
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.crashlytics.java;

import com.crashlytics.tools.eclipse.workbench.WorkbenchPlugin;
import java.io.File;
import java.io.FilenameFilter;
import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;

public final class Crashlytics
{
  private static Crashlytics _clsInstance = null;
  private static final float CLS_DEFAULT_PROCESS_DELAY = 1.0F;
  private static final String CLS_FILE_EXT = ".cls";
  private static final String BASE_SETTINGS_URL = "https://settings.crashlytics.com";
  private static final short[] RETRY_INTERVALS = { 10, 20, 30, 60, 120, 300 };
  private static final int MAX_ATTRIBUTES = 64;
  private static final int MAX_ATTRIBUTE_SIZE = 1024;
  private Settings _settings;
  private CrashlyticsListener _listener;
  private CrashlyticsUncaughtExceptionHandler _handler;
  private final long _startTime;
  private final ConcurrentHashMap<String, String> _attributes;
  static File _crashlyticsDir;
  static String _packageName;
  static String _activityLabel;
  static String _versionCode;
  static String _versionName;
  static String _apiKey;
  static boolean _clsDebugMode = false;
  private static String _webApiUrl;
  
  private Crashlytics()
  {
    _attributes = new ConcurrentHashMap();
    _startTime = System.currentTimeMillis();
  }
  
  public static void startWithAPIKey(String apiKey, String webApiUrl, File crashlyticsDirectory, Object main, String version, float delay)
  {
    if (apiKey == null) {
      throw new IllegalArgumentException("apiKey cannot be null.");
    }
    if (crashlyticsDirectory == null) {
      throw new IllegalArgumentException("crashlyticsDirectory cannot be null.");
    }
    getInstance().initializeWithAPIKey(apiKey, webApiUrl, crashlyticsDirectory, main, version, delay);
  }
  
  public static void startWithAPIKey(String apiKey, String webApiURL, File crashlyticsDirectory, Object main, String version)
  {
    startWithAPIKey(apiKey, webApiURL, crashlyticsDirectory, main, version, 1.0F);
  }
  
  public static synchronized void stopCrashlytics()
  {
    if (_clsInstance != null)
    {
      if (WorkbenchPlugin.getDefault() != null) {
        WorkbenchPlugin.getDefault().setStatusHandlerDelegate(null);
      }
      if ((_clsInstance_handler != null) && (_clsInstance_handler.getDefaultHandler() != null)) {
        Thread.setDefaultUncaughtExceptionHandler(_clsInstance_handler.getDefaultHandler());
      } else {
        Thread.setDefaultUncaughtExceptionHandler(null);
      }
      Utils.log("Uninstalling Crashlytics from this runtime instance.");
    }
  }
  
  public static synchronized Crashlytics getInstance()
  {
    if (_clsInstance == null) {
      _clsInstance = new Crashlytics();
    }
    return _clsInstance;
  }
  
  public static void logException(Exception exception)
  {
    if ((_clsInstance == null) || (_clsInstance_handler == null))
    {
      Utils.logError("Crashlytics must be initialized by calling Crashlytics.startWithAPIKey prior to logging exceptions.", 
        null);
      return;
    }
    new Thread(new Runnable()
    {
      public void run()
      {
        _clsInstance_handler.logException(Thread.currentThread(), Crashlytics.this);
      }
    }, "Crashlytics Exception Handler").start();
  }
  
  public static void log(String msg)
  {
    if ((_clsInstance == null) || (_clsInstance_handler == null))
    {
      Utils.logError("Crashlytics must be initialized by calling Crashlytics.startWithAPIKey prior to logging messages.", 
        null);
      return;
    }
    long timestamp = System.currentTimeMillis() - _clsInstance_startTime;
    
    new Thread(new Runnable()
    {
      public void run()
      {
        _clsInstance_handler.writeToLog(val$timestamp, val$msg);
      }
    })
    
      .start();
  }
  
  public static void log(String tag, String msg)
  {
    log(msg);
    Log.d(tag, msg);
  }
  
  public static void setString(String key, String value)
  {
    if (getInstance_attributes.size() < 64)
    {
      if (key.length() > 1024) {
        key = key.substring(0, 1024);
      }
      if (value == null) {
        value = "";
      } else if (value.length() > 1024) {
        value = value.substring(0, 1024);
      }
      _clsInstance_attributes.put(key.trim(), value.trim());
    }
  }
  
  public static void setBool(String key, boolean value)
  {
    setString(key, Boolean.toString(value));
  }
  
  public static void setDouble(String key, double value)
  {
    setString(key, Double.toString(value));
  }
  
  public static void setFloat(String key, float value)
  {
    setString(key, Float.toString(value));
  }
  
  public static void setInt(String key, int value)
  {
    setString(key, Integer.toString(value));
  }
  
  public static void setLong(String key, long value)
  {
    setString(key, Long.toString(value));
  }
  
  Map<String, String> getAttributes()
  {
    return Collections.unmodifiableMap(_attributes);
  }
  
  public void setListener(CrashlyticsListener listener)
  {
    _listener = listener;
  }
  
  public void setDebugMode(boolean bool)
  {
    _clsDebugMode = bool;
  }
  
  public boolean getDebugMode()
  {
    return _clsDebugMode;
  }
  
  public String getVersion()
  {
    return _versionName;
  }
  
  String getAPIKey()
  {
    return _apiKey;
  }
  
  public void crash()
  {
    CrashTest ct = new CrashTest();
    ct.indexOutOfBounds();
  }
  
  static String getSettingsEndpoint()
  {
    String devHostId = _webApiUrl;
    if ((devHostId != null) && (devHostId.length() > 0)) {
      return devHostId;
    }
    return "https://settings.crashlytics.com";
  }
  
  private void initializeWithAPIKey(String apiKey, String webApiUrl, File crashlyticsDirectory, Object main, String version, float delay)
  {
    Utils.log("Welcome to Crashlytics " + version);
    
    _apiKey = apiKey;
    _webApiUrl = webApiUrl;
    _crashlyticsDir = crashlyticsDirectory;
    try
    {
      _packageName = main.getClass().getPackage().toString();
      if (_packageName.startsWith("package ")) {
        _packageName = _packageName.substring(8);
      }
      _versionCode = version;
      _versionName = version;
      _activityLabel = main.getClass().getSimpleName();
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
    startCrashDetector(delay);
  }
  
  Thread.UncaughtExceptionHandler getHandler()
  {
    return _handler;
  }
  
  private void startCrashDetector(final float delay)
  {
    _settings = new Settings(_apiKey, _packageName, _versionCode, _versionName);
    
    Utils.log("Starting crash detector...");
    _handler = new CrashlyticsUncaughtExceptionHandler(Thread.getDefaultUncaughtExceptionHandler(), _listener);
    Thread.setDefaultUncaughtExceptionHandler(_handler);
    
    WorkbenchPlugin.getDefault().setStatusHandlerDelegate(new CrashlyticsStatusHandler());
    
    Utils.log("Successfully started crash detector.");
    System.out.println("About to make connection " + Thread.currentThread().toString());
    Thread t = new Thread(new Runnable()
    {
      public void run()
      {
        boolean success = false;
        try
        {
          HttpParams connectionParams = new BasicHttpParams();
          
          HttpConnectionParams.setConnectionTimeout(connectionParams, 10000);
          HttpConnectionParams.setSoTimeout(connectionParams, 10000);
          
          DefaultHttpClient client = new DefaultHttpClient(connectionParams);
          if (_settings.load(client))
          {
            success = true;
            if (_settings.getShouldReportCrashes()) {
              detectAndSendCrashReports(delay);
            } else {
              Utils.log("Crash reporting disabled");
            }
          }
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
        if (!s
1 2 3 4

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd