NativeCrashWriter.java
20.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
package com.crashlytics.android.core;
import com.crashlytics.android.core.internal.models.BinaryImageData;
import com.crashlytics.android.core.internal.models.CustomAttributeData;
import com.crashlytics.android.core.internal.models.DeviceData;
import com.crashlytics.android.core.internal.models.SessionEventData;
import com.crashlytics.android.core.internal.models.SignalData;
import com.crashlytics.android.core.internal.models.ThreadData;
import com.crashlytics.android.core.internal.models.ThreadData.FrameData;
import io.fabric.sdk.android.Fabric;
import io.fabric.sdk.android.Logger;
import java.io.IOException;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
class NativeCrashWriter
{
private static final SignalData DEFAULT_SIGNAL = new SignalData("", "", 0L);
private static final BinaryImageMessage[] EMPTY_BINARY_IMAGE_MESSAGES = new BinaryImageMessage[0];
private static final ProtobufMessage[] EMPTY_CHILDREN = new ProtobufMessage[0];
private static final CustomAttributeMessage[] EMPTY_CUSTOM_ATTRIBUTE_MESSAGES = new CustomAttributeMessage[0];
private static final FrameMessage[] EMPTY_FRAME_MESSAGES;
private static final ThreadMessage[] EMPTY_THREAD_MESSAGES = new ThreadMessage[0];
static final String NDK_CRASH_TYPE = "ndk-crash";
static
{
EMPTY_FRAME_MESSAGES = new FrameMessage[0];
}
private static RepeatedMessage createBinaryImagesMessage(BinaryImageData[] paramArrayOfBinaryImageData)
{
if (paramArrayOfBinaryImageData != null) {}
for (BinaryImageMessage[] arrayOfBinaryImageMessage = new BinaryImageMessage[paramArrayOfBinaryImageData.length];; arrayOfBinaryImageMessage = EMPTY_BINARY_IMAGE_MESSAGES)
{
int i = 0;
while (i < arrayOfBinaryImageMessage.length)
{
arrayOfBinaryImageMessage[i] = new BinaryImageMessage(paramArrayOfBinaryImageData[i]);
i += 1;
}
}
return new RepeatedMessage(arrayOfBinaryImageMessage);
}
private static RepeatedMessage createCustomAttributesMessage(CustomAttributeData[] paramArrayOfCustomAttributeData)
{
if (paramArrayOfCustomAttributeData != null) {}
for (CustomAttributeMessage[] arrayOfCustomAttributeMessage = new CustomAttributeMessage[paramArrayOfCustomAttributeData.length];; arrayOfCustomAttributeMessage = EMPTY_CUSTOM_ATTRIBUTE_MESSAGES)
{
int i = 0;
while (i < arrayOfCustomAttributeMessage.length)
{
arrayOfCustomAttributeMessage[i] = new CustomAttributeMessage(paramArrayOfCustomAttributeData[i]);
i += 1;
}
}
return new RepeatedMessage(arrayOfCustomAttributeMessage);
}
private static ProtobufMessage createDeviceMessage(DeviceData paramDeviceData)
{
if (paramDeviceData == null) {
return new NullMessage();
}
return new DeviceMessage(paramDeviceData.batteryCapacity / 100.0F, paramDeviceData.batteryVelocity, paramDeviceData.proximity, paramDeviceData.orientation, paramDeviceData.totalPhysicalMemory - paramDeviceData.availablePhysicalMemory, paramDeviceData.totalInternalStorage - paramDeviceData.availableInternalStorage);
}
private static EventMessage createEventMessage(SessionEventData paramSessionEventData, LogFileManager paramLogFileManager, Map<String, String> paramMap)
throws IOException
{
Object localObject;
ByteString localByteString;
if (paramSessionEventData.signal != null)
{
localObject = paramSessionEventData.signal;
paramMap = new ApplicationMessage(new ExecutionMessage(new SignalMessage((SignalData)localObject), createThreadsMessage(paramSessionEventData.threads), createBinaryImagesMessage(paramSessionEventData.binaryImages)), createCustomAttributesMessage(mergeCustomAttributes(paramSessionEventData.customAttributes, paramMap)));
localObject = createDeviceMessage(paramSessionEventData.deviceData);
localByteString = paramLogFileManager.getByteStringForLog();
if (localByteString == null) {
Fabric.getLogger().d("CrashlyticsCore", "No log data to include with this event.");
}
paramLogFileManager.clearLog();
if (localByteString == null) {
break label147;
}
}
label147:
for (paramLogFileManager = new LogMessage(localByteString);; paramLogFileManager = new NullMessage())
{
return new EventMessage(paramSessionEventData.timestamp, "ndk-crash", new ProtobufMessage[] { paramMap, localObject, paramLogFileManager });
localObject = DEFAULT_SIGNAL;
break;
}
}
private static RepeatedMessage createFramesMessage(ThreadData.FrameData[] paramArrayOfFrameData)
{
if (paramArrayOfFrameData != null) {}
for (FrameMessage[] arrayOfFrameMessage = new FrameMessage[paramArrayOfFrameData.length];; arrayOfFrameMessage = EMPTY_FRAME_MESSAGES)
{
int i = 0;
while (i < arrayOfFrameMessage.length)
{
arrayOfFrameMessage[i] = new FrameMessage(paramArrayOfFrameData[i]);
i += 1;
}
}
return new RepeatedMessage(arrayOfFrameMessage);
}
private static RepeatedMessage createThreadsMessage(ThreadData[] paramArrayOfThreadData)
{
if (paramArrayOfThreadData != null) {}
for (ThreadMessage[] arrayOfThreadMessage = new ThreadMessage[paramArrayOfThreadData.length];; arrayOfThreadMessage = EMPTY_THREAD_MESSAGES)
{
int i = 0;
while (i < arrayOfThreadMessage.length)
{
ThreadData localThreadData = paramArrayOfThreadData[i];
arrayOfThreadMessage[i] = new ThreadMessage(localThreadData, createFramesMessage(localThreadData.frames));
i += 1;
}
}
return new RepeatedMessage(arrayOfThreadMessage);
}
private static CustomAttributeData[] mergeCustomAttributes(CustomAttributeData[] paramArrayOfCustomAttributeData, Map<String, String> paramMap)
{
paramMap = new TreeMap(paramMap);
if (paramArrayOfCustomAttributeData != null)
{
int j = paramArrayOfCustomAttributeData.length;
i = 0;
while (i < j)
{
CustomAttributeData localCustomAttributeData = paramArrayOfCustomAttributeData[i];
paramMap.put(localCustomAttributeData.key, localCustomAttributeData.value);
i += 1;
}
}
paramArrayOfCustomAttributeData = (Map.Entry[])paramMap.entrySet().toArray(new Map.Entry[paramMap.size()]);
paramMap = new CustomAttributeData[paramArrayOfCustomAttributeData.length];
int i = 0;
while (i < paramMap.length)
{
paramMap[i] = new CustomAttributeData((String)paramArrayOfCustomAttributeData[i].getKey(), (String)paramArrayOfCustomAttributeData[i].getValue());
i += 1;
}
return paramMap;
}
public static void writeNativeCrash(SessionEventData paramSessionEventData, LogFileManager paramLogFileManager, Map<String, String> paramMap, CodedOutputStream paramCodedOutputStream)
throws IOException
{
createEventMessage(paramSessionEventData, paramLogFileManager, paramMap).write(paramCodedOutputStream);
}
static final class ApplicationMessage
extends NativeCrashWriter.ProtobufMessage
{
private static final int PROTOBUF_TAG = 3;
public ApplicationMessage(NativeCrashWriter.ExecutionMessage paramExecutionMessage, NativeCrashWriter.RepeatedMessage paramRepeatedMessage)
{
super(new NativeCrashWriter.ProtobufMessage[] { paramExecutionMessage, paramRepeatedMessage });
}
}
static final class BinaryImageMessage
extends NativeCrashWriter.ProtobufMessage
{
private static final int PROTOBUF_TAG = 4;
private final long baseAddr;
private final String filePath;
private final long imageSize;
private final String uuid;
public BinaryImageMessage(BinaryImageData paramBinaryImageData)
{
super(new NativeCrashWriter.ProtobufMessage[0]);
this.baseAddr = paramBinaryImageData.baseAddress;
this.imageSize = paramBinaryImageData.size;
this.filePath = paramBinaryImageData.path;
this.uuid = paramBinaryImageData.id;
}
public final int getPropertiesSize()
{
int i = CodedOutputStream.computeUInt64Size(1, this.baseAddr);
int j = CodedOutputStream.computeUInt64Size(2, this.imageSize);
return i + CodedOutputStream.computeBytesSize(3, ByteString.copyFromUtf8(this.filePath)) + j + CodedOutputStream.computeBytesSize(4, ByteString.copyFromUtf8(this.uuid));
}
public final void writeProperties(CodedOutputStream paramCodedOutputStream)
throws IOException
{
paramCodedOutputStream.writeUInt64(1, this.baseAddr);
paramCodedOutputStream.writeUInt64(2, this.imageSize);
paramCodedOutputStream.writeBytes(3, ByteString.copyFromUtf8(this.filePath));
paramCodedOutputStream.writeBytes(4, ByteString.copyFromUtf8(this.uuid));
}
}
static final class CustomAttributeMessage
extends NativeCrashWriter.ProtobufMessage
{
private static final int PROTOBUF_TAG = 2;
private final String key;
private final String value;
public CustomAttributeMessage(CustomAttributeData paramCustomAttributeData)
{
super(new NativeCrashWriter.ProtobufMessage[0]);
this.key = paramCustomAttributeData.key;
this.value = paramCustomAttributeData.value;
}
public final int getPropertiesSize()
{
int i = CodedOutputStream.computeBytesSize(1, ByteString.copyFromUtf8(this.key));
if (this.value == null) {}
for (String str = "";; str = this.value) {
return CodedOutputStream.computeBytesSize(2, ByteString.copyFromUtf8(str)) + i;
}
}
public final void writeProperties(CodedOutputStream paramCodedOutputStream)
throws IOException
{
paramCodedOutputStream.writeBytes(1, ByteString.copyFromUtf8(this.key));
if (this.value == null) {}
for (String str = "";; str = this.value)
{
paramCodedOutputStream.writeBytes(2, ByteString.copyFromUtf8(str));
return;
}
}
}
static final class DeviceMessage
extends NativeCrashWriter.ProtobufMessage
{
private static final int PROTOBUF_TAG = 5;
private final float batteryLevel;
private final int batteryVelocity;
private final long diskUsed;
private final int orientation;
private final boolean proximityOn;
private final long ramUsed;
public DeviceMessage(float paramFloat, int paramInt1, boolean paramBoolean, int paramInt2, long paramLong1, long paramLong2)
{
super(new NativeCrashWriter.ProtobufMessage[0]);
this.batteryLevel = paramFloat;
this.batteryVelocity = paramInt1;
this.proximityOn = paramBoolean;
this.orientation = paramInt2;
this.ramUsed = paramLong1;
this.diskUsed = paramLong2;
}
public final int getPropertiesSize()
{
return CodedOutputStream.computeFloatSize(1, this.batteryLevel) + 0 + CodedOutputStream.computeSInt32Size(2, this.batteryVelocity) + CodedOutputStream.computeBoolSize(3, this.proximityOn) + CodedOutputStream.computeUInt32Size(4, this.orientation) + CodedOutputStream.computeUInt64Size(5, this.ramUsed) + CodedOutputStream.computeUInt64Size(6, this.diskUsed);
}
public final void writeProperties(CodedOutputStream paramCodedOutputStream)
throws IOException
{
paramCodedOutputStream.writeFloat(1, this.batteryLevel);
paramCodedOutputStream.writeSInt32(2, this.batteryVelocity);
paramCodedOutputStream.writeBool(3, this.proximityOn);
paramCodedOutputStream.writeUInt32(4, this.orientation);
paramCodedOutputStream.writeUInt64(5, this.ramUsed);
paramCodedOutputStream.writeUInt64(6, this.diskUsed);
}
}
static final class EventMessage
extends NativeCrashWriter.ProtobufMessage
{
private static final int PROTOBUF_TAG = 10;
private final String crashType;
private final long time;
public EventMessage(long paramLong, String paramString, NativeCrashWriter.ProtobufMessage... paramVarArgs)
{
super(paramVarArgs);
this.time = paramLong;
this.crashType = paramString;
}
public final int getPropertiesSize()
{
return CodedOutputStream.computeUInt64Size(1, this.time) + CodedOutputStream.computeBytesSize(2, ByteString.copyFromUtf8(this.crashType));
}
public final void writeProperties(CodedOutputStream paramCodedOutputStream)
throws IOException
{
paramCodedOutputStream.writeUInt64(1, this.time);
paramCodedOutputStream.writeBytes(2, ByteString.copyFromUtf8(this.crashType));
}
}
static final class ExecutionMessage
extends NativeCrashWriter.ProtobufMessage
{
private static final int PROTOBUF_TAG = 1;
public ExecutionMessage(NativeCrashWriter.SignalMessage paramSignalMessage, NativeCrashWriter.RepeatedMessage paramRepeatedMessage1, NativeCrashWriter.RepeatedMessage paramRepeatedMessage2)
{
super(new NativeCrashWriter.ProtobufMessage[] { paramRepeatedMessage1, paramSignalMessage, paramRepeatedMessage2 });
}
}
static final class FrameMessage
extends NativeCrashWriter.ProtobufMessage
{
private static final int PROTOBUF_TAG = 3;
private final long address;
private final String file;
private final int importance;
private final long offset;
private final String symbol;
public FrameMessage(ThreadData.FrameData paramFrameData)
{
super(new NativeCrashWriter.ProtobufMessage[0]);
this.address = paramFrameData.address;
this.symbol = paramFrameData.symbol;
this.file = paramFrameData.file;
this.offset = paramFrameData.offset;
this.importance = paramFrameData.importance;
}
public final int getPropertiesSize()
{
return CodedOutputStream.computeUInt64Size(1, this.address) + CodedOutputStream.computeBytesSize(2, ByteString.copyFromUtf8(this.symbol)) + CodedOutputStream.computeBytesSize(3, ByteString.copyFromUtf8(this.file)) + CodedOutputStream.computeUInt64Size(4, this.offset) + CodedOutputStream.computeUInt32Size(5, this.importance);
}
public final void writeProperties(CodedOutputStream paramCodedOutputStream)
throws IOException
{
paramCodedOutputStream.writeUInt64(1, this.address);
paramCodedOutputStream.writeBytes(2, ByteString.copyFromUtf8(this.symbol));
paramCodedOutputStream.writeBytes(3, ByteString.copyFromUtf8(this.file));
paramCodedOutputStream.writeUInt64(4, this.offset);
paramCodedOutputStream.writeUInt32(5, this.importance);
}
}
static final class LogMessage
extends NativeCrashWriter.ProtobufMessage
{
private static final int PROTOBUF_TAG = 6;
ByteString logBytes;
public LogMessage(ByteString paramByteString)
{
super(new NativeCrashWriter.ProtobufMessage[0]);
this.logBytes = paramByteString;
}
public final int getPropertiesSize()
{
return CodedOutputStream.computeBytesSize(1, this.logBytes);
}
public final void writeProperties(CodedOutputStream paramCodedOutputStream)
throws IOException
{
paramCodedOutputStream.writeBytes(1, this.logBytes);
}
}
static final class NullMessage
extends NativeCrashWriter.ProtobufMessage
{
public NullMessage()
{
super(new NativeCrashWriter.ProtobufMessage[0]);
}
public final int getSize()
{
return 0;
}
public final void write(CodedOutputStream paramCodedOutputStream)
throws IOException
{}
}
static abstract class ProtobufMessage
{
private final ProtobufMessage[] children;
private final int tag;
public ProtobufMessage(int paramInt, ProtobufMessage... paramVarArgs)
{
this.tag = paramInt;
if (paramVarArgs != null) {}
for (;;)
{
this.children = paramVarArgs;
return;
paramVarArgs = NativeCrashWriter.EMPTY_CHILDREN;
}
}
public int getPropertiesSize()
{
return 0;
}
public int getSize()
{
int i = getSizeNoTag();
return i + CodedOutputStream.computeRawVarint32Size(i) + CodedOutputStream.computeTagSize(this.tag);
}
public int getSizeNoTag()
{
int j = getPropertiesSize();
ProtobufMessage[] arrayOfProtobufMessage = this.children;
int k = arrayOfProtobufMessage.length;
int i = 0;
while (i < k)
{
j += arrayOfProtobufMessage[i].getSize();
i += 1;
}
return j;
}
public void write(CodedOutputStream paramCodedOutputStream)
throws IOException
{
paramCodedOutputStream.writeTag(this.tag, 2);
paramCodedOutputStream.writeRawVarint32(getSizeNoTag());
writeProperties(paramCodedOutputStream);
ProtobufMessage[] arrayOfProtobufMessage = this.children;
int j = arrayOfProtobufMessage.length;
int i = 0;
while (i < j)
{
arrayOfProtobufMessage[i].write(paramCodedOutputStream);
i += 1;
}
}
public void writeProperties(CodedOutputStream paramCodedOutputStream)
throws IOException
{}
}
static final class RepeatedMessage
extends NativeCrashWriter.ProtobufMessage
{
private final NativeCrashWriter.ProtobufMessage[] messages;
public RepeatedMessage(NativeCrashWriter.ProtobufMessage... paramVarArgs)
{
super(new NativeCrashWriter.ProtobufMessage[0]);
this.messages = paramVarArgs;
}
public final int getSize()
{
int i = 0;
NativeCrashWriter.ProtobufMessage[] arrayOfProtobufMessage = this.messages;
int k = arrayOfProtobufMessage.length;
int j = 0;
while (i < k)
{
j += arrayOfProtobufMessage[i].getSize();
i += 1;
}
return j;
}
public final void write(CodedOutputStream paramCodedOutputStream)
throws IOException
{
NativeCrashWriter.ProtobufMessage[] arrayOfProtobufMessage = this.messages;
int j = arrayOfProtobufMessage.length;
int i = 0;
while (i < j)
{
arrayOfProtobufMessage[i].write(paramCodedOutputStream);
i += 1;
}
}
}
static final class SignalMessage
extends NativeCrashWriter.ProtobufMessage
{
private static final int PROTOBUF_TAG = 3;
private final long sigAddr;
private final String sigCode;
private final String sigName;
public SignalMessage(SignalData paramSignalData)
{
super(new NativeCrashWriter.ProtobufMessage[0]);
this.sigName = paramSignalData.name;
this.sigCode = paramSignalData.code;
this.sigAddr = paramSignalData.faultAddress;
}
public final int getPropertiesSize()
{
return CodedOutputStream.computeBytesSize(1, ByteString.copyFromUtf8(this.sigName)) + CodedOutputStream.computeBytesSize(2, ByteString.copyFromUtf8(this.sigCode)) + CodedOutputStream.computeUInt64Size(3, this.sigAddr);
}
public final void writeProperties(CodedOutputStream paramCodedOutputStream)
throws IOException
{
paramCodedOutputStream.writeBytes(1, ByteString.copyFromUtf8(this.sigName));
paramCodedOutputStream.writeBytes(2, ByteString.copyFromUtf8(this.sigCode));
paramCodedOutputStream.writeUInt64(3, this.sigAddr);
}
}
static final class ThreadMessage
extends NativeCrashWriter.ProtobufMessage
{
private static final int PROTOBUF_TAG = 1;
private final int importance;
private final String name;
public ThreadMessage(ThreadData paramThreadData, NativeCrashWriter.RepeatedMessage paramRepeatedMessage)
{
super(new NativeCrashWriter.ProtobufMessage[] { paramRepeatedMessage });
this.name = paramThreadData.name;
this.importance = paramThreadData.importance;
}
private boolean hasName()
{
return (this.name != null) && (this.name.length() > 0);
}
public final int getPropertiesSize()
{
if (hasName()) {}
for (int i = CodedOutputStream.computeBytesSize(1, ByteString.copyFromUtf8(this.name));; i = 0) {
return i + CodedOutputStream.computeUInt32Size(2, this.importance);
}
}
public final void writeProperties(CodedOutputStream paramCodedOutputStream)
throws IOException
{
if (hasName()) {
paramCodedOutputStream.writeBytes(1, ByteString.copyFromUtf8(this.name));
}
paramCodedOutputStream.writeUInt32(2, this.importance);
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/crashlytics/android/core/NativeCrashWriter.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/