Skip to content

Commit b333cee

Browse files
committed
Updated live logging codes to include the new sniffer obtained data
1 parent 19b08fe commit b333cee

File tree

13 files changed

+89
-57
lines changed

13 files changed

+89
-57
lines changed

app/build.gradle

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ def getDateTimestamp() {
1111

1212
android {
1313

14-
compileSdkVersion 25
14+
compileSdkVersion 28
1515
defaultConfig {
1616
applicationId "com.maxieds.chameleonminilivedebugger"
17-
minSdkVersion 21
18-
targetSdkVersion 27
19-
versionCode 53
20-
versionName "0.5.3"
17+
minSdkVersion 26
18+
targetSdkVersion 28
19+
versionCode 54
20+
versionName "0.5.4"
2121
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
2222
multiDexEnabled true
2323
}
@@ -27,30 +27,25 @@ android {
2727
shrinkResources false
2828
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
2929
crunchPngs false
30-
//enableCrashlytics = true
31-
//alwaysUpdateBuildId false
3230
}
3331
debug {
3432
minifyEnabled false
3533
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
3634
crunchPngs false
37-
//enableCrashlytics = true
38-
//alwaysUpdateBuildId true
3935
}
4036
}
41-
buildToolsVersion '27.0.3'
37+
buildToolsVersion '28.0.2'
4238

4339
flavorDimensions "mode"
4440
def configBuildTimeStamp = getDateTimestamp()
4541
applicationVariants.all { variant ->
4642
variant.outputs.each { output ->
4743
def directoryPath = "all-builds/"
4844
def apkName = "ChameleonMiniLiveDebugger-${variant.name}-vc${variant.versionCode}-v${variant.versionName}-${configBuildTimeStamp}.apk"
49-
//output.outputFile = new File(directoryPath + apkName)
5045
}
5146
}
5247
productFlavors {
53-
main {
48+
free {
5449
versionNameSuffix "-free"
5550
dimension "mode"
5651
buildConfigField "boolean", "PAID_APP_VERSION", "false"
@@ -86,23 +81,20 @@ android {
8681
implementation fileTree(include: ['*.jar'], dir: 'libs')
8782
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
8883
testImplementation 'junit:junit:4.12'
89-
androidTestImplementation 'com.android.support.test:runner:1.0.1'
84+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
9085
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
91-
implementation 'com.android.support:support-v4:25.4.0'
92-
implementation 'com.android.support:appcompat-v7:25.4.0'
93-
implementation 'com.android.support:design:25.4.0'
94-
implementation 'com.github.felHR85:UsbSerial:4.5'
86+
implementation 'com.android.support:support-v4:28.0.0'
87+
implementation 'com.android.support:appcompat-v7:28.0.0'
88+
implementation 'com.android.support:design:28.0.0'
89+
implementation 'com.github.felHR85:UsbSerial:4.5.2'
9590
implementation 'com.shawnlin:number-picker:2.4.4'
96-
//classpath 'io.fabric.tools:gradle:1.+'
97-
//compile('com.crashlytics.sdk.android:crashlytics:2.8.0@aar') { transitive = true; }
9891
}
9992

10093
repositories {
10194
jcenter()
10295
google()
10396
maven { url "https://maven.google.com" }
10497
maven { url "https://jitpack.io" }
105-
//maven { url "https://maven.fabric.io/public" }
10698
}
10799

108-
}
100+
}
2.46 MB
Binary file not shown.

app/free/release/output.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":54,"versionName":"0.5.4-free","enabled":true,"outputFile":"app-free-release.apk","fullName":"freeRelease","baseName":"free-release"},"path":"app-free-release.apk","properties":{}}]
271 KB
Binary file not shown.

app/paid/release/output.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":53,"versionName":"0.5.3-paid","enabled":true,"outputFile":"app-paid-release.apk","fullName":"paidRelease","baseName":"paid-release"},"path":"app-paid-release.apk","properties":{}}]
1+
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":54,"versionName":"0.5.4-paid","enabled":true,"outputFile":"app-paid-release.apk","fullName":"paidRelease","baseName":"paid-release"},"path":"app-paid-release.apk","properties":{}}]

app/src/main/java/com/maxieds/chameleonminilivedebugger/LiveLoggerActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import android.support.v4.view.ViewPager;
2828
import android.support.v7.app.AlertDialog;
2929
import android.support.v7.app.AppCompatActivity;
30-
import android.support.v7.app.NotificationCompat;
30+
import android.support.v4.app.NotificationCompat;
3131
import android.util.Log;
3232
import android.view.LayoutInflater;
3333
import android.view.MenuItem;

app/src/main/java/com/maxieds/chameleonminilivedebugger/LogEntryUI.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.maxieds.chameleonminilivedebugger;
22

33
import android.content.Context;
4+
import android.support.annotation.DrawableRes;
45
import android.util.Log;
56
import android.view.LayoutInflater;
67
import android.view.View;
@@ -49,6 +50,7 @@ public class LogEntryUI extends LogEntryBase {
4950
private int logType;
5051
private String logLabel;
5152
private byte[] entryData;
53+
private int dataDirection;
5254

5355
/**
5456
* Effective constructor for the class.
@@ -80,7 +82,7 @@ public static LogEntryUI newInstance(byte[] rawLogBytes, String logLabel) {
8082
else
8183
System.arraycopy(rawLogBytes, 4, payloadBytes, 0, payloadBytes.length);
8284
LogEntryUI newLogDataEntry = new LogEntryUI();
83-
return newLogDataEntry.configureLogEntry(LiveLoggerActivity.defaultContext, logLabel, diffTimeMs, logCode, payloadBytes);
85+
return newLogDataEntry.configureLogEntry(LiveLoggerActivity.defaultContext, logLabel, diffTimeMs, LogUtils.getDataDirection(logCode), logCode, payloadBytes);
8486
}
8587

8688
/**
@@ -93,13 +95,13 @@ public static LogEntryUI newInstance(byte[] rawLogBytes, String logLabel) {
9395
* @return LogEntryUI the configured log entry
9496
* @url http://rawgit.com/emsec/ChameleonMini/master/Doc/Doxygen/html/Page_Log.html
9597
*/
96-
public LogEntryUI configureLogEntry(Context context, String label, int diffTimeMs, int ltype, byte[] edata) {
98+
public LogEntryUI configureLogEntry(Context context, String label, int diffTimeMs, int dataDir, int ltype, byte[] edata) {
9799
numBytes = edata.length;
98100
diffTimeMillis = diffTimeMs;
101+
dataDirection = dataDir;
99102
logType = ltype;
100103
logLabel = label;
101104
entryData = edata;
102-
//LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
103105
LayoutInflater inflater = LiveLoggerActivity.defaultInflater;
104106
mainEntryContainer = (LinearLayout) inflater.inflate(R.layout.log_entry_ui, null);
105107
configureLayout(mainEntryContainer);
@@ -152,6 +154,7 @@ public void configureLayout(LinearLayout mainContainerRef) {
152154
mainEntryContainer = mainContainerRef;
153155
entrySelect = (CheckBox) mainContainerRef.findViewById(R.id.entrySelect);
154156
inoutDirIndicator = (ImageView) mainContainerRef.findViewById(R.id.inputDirIndicatorImg);
157+
inoutDirIndicator.setImageDrawable(LiveLoggerActivity.runningActivity.getResources().getDrawable(getDataDirectionMarker()));
155158
apduParseStatus = (ImageView) mainContainerRef.findViewById(R.id.apduParseStatusImg);
156159
tvLabel = (TextView) mainContainerRef.findViewById(R.id.text_label);
157160
recordID = ++LiveLoggerActivity.RECORDID;
@@ -279,6 +282,15 @@ public String getPayloadDataString(boolean byteString) {
279282
}
280283
}
281284

285+
public int getDataDirectionMarker() {
286+
if(dataDirection == LogUtils.DATADIR_INCOMING)
287+
return R.drawable.incoming_arrow16;
288+
else if(dataDirection == LogUtils.DATADIR_OUTGOING)
289+
return R.drawable.outgoing_arrow16;
290+
else
291+
return R.drawable.xfer16;
292+
}
293+
282294
/**
283295
* Returns the layout container (LinearLayout object) associated with this log entry.
284296
* @return (LinearLayout) View

app/src/main/java/com/maxieds/chameleonminilivedebugger/LogUtils.java

Lines changed: 54 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,46 @@
1818
*/
1919
public class LogUtils {
2020

21+
public static final int DATADIR_INCOMING = 0;
22+
public static final int DATADIR_OUTGOING = 1;
23+
public static final int DATADIR_BIDIRECTIONAL = 2;
24+
2125
public enum LogCode {
2226
/* Generic */
23-
LOG_INFO_GENERIC(0x10, "Unspecific log entry."),
24-
LOG_INFO_CONFIG_SET(0x11, "Configuration change."),
25-
LOG_INFO_SETTING_SET(0x12, "Setting change."),
26-
LOG_INFO_UID_SET(0x13, "UID change."),
27-
LOG_INFO_RESET_APP(0x20, "Application reset."),
27+
LOG_INFO_GENERIC(0x10, DATADIR_BIDIRECTIONAL, "Unspecific log entry."),
28+
LOG_INFO_CONFIG_SET(0x11, DATADIR_BIDIRECTIONAL, "Configuration change."),
29+
LOG_INFO_SETTING_SET(0x12, DATADIR_BIDIRECTIONAL, "Setting change."),
30+
LOG_INFO_UID_SET(0x13, DATADIR_BIDIRECTIONAL, "UID change."),
31+
LOG_INFO_RESET_APP(0x20, DATADIR_BIDIRECTIONAL, "Application reset."),
2832
/* Codec */
29-
LOG_INFO_CODEC_RX_DATA(0x40, "Currently active codec received data."),
30-
LOG_INFO_CODEC_TX_DATA(0x41, "Currently active codec sent data."),
31-
LOG_INFO_CODEC_RX_DATA_W_PARITY(0x42, "Currently active codec received data."),
32-
LOG_INFO_CODEC_TX_DATA_W_PARITY(0x43, "Currently active codec sent data."),
33+
LOG_INFO_CODEC_RX_DATA(0x40, DATADIR_OUTGOING, "Currently active codec received data."),
34+
LOG_INFO_CODEC_TX_DATA(0x41, DATADIR_OUTGOING, "Currently active codec sent data."),
35+
LOG_INFO_CODEC_RX_DATA_W_PARITY(0x42, DATADIR_OUTGOING, "Currently active codec received data."),
36+
LOG_INFO_CODEC_TX_DATA_W_PARITY(0x43, DATADIR_OUTGOING, "Currently active codec sent data."),
37+
LOG_INFO_CODEC_SNI_READER_DATA(0x44, DATADIR_INCOMING, "Sniffing codec receive data from reader."),
38+
LOG_INFO_CODEC_SNI_READER_DATA_W_PARITY(0x44, DATADIR_INCOMING, "Sniffing codec receive data from reader"),
39+
LOG_INFO_CODEC_SNI_CARD_DATA(0x46, DATADIR_INCOMING, "Sniffing codec receive data from card."),
40+
LOG_INFO_CODEC_SNI_CARD_DATA_W_PARITY(0x47, DATADIR_INCOMING, "Sniffing codec receive data from card."),
3341
/* App */
34-
LOG_INFO_APP_CMD_READ(0x80, "Application processed read command."),
35-
LOG_INFO_APP_CMD_WRITE(0x81, "Application processed write command."),
36-
LOG_INFO_APP_CMD_INC(0x84, "Application processed increment command."),
37-
LOG_INFO_APP_CMD_DEC(0x85, "Application processed decrement command."),
38-
LOG_INFO_APP_CMD_TRANSFER(0x86, "Application processed transfer command."),
39-
LOG_INFO_APP_CMD_RESTORE(0x87, "Application processed restore command."),
40-
LOG_INFO_APP_CMD_AUTH(0x90, "Application processed authentication command."),
41-
LOG_INFO_APP_CMD_HALT(0x91, "Application processed halt command."),
42-
LOG_INFO_APP_CMD_UNKNOWN(0x92, "Application processed an unknown command."),
43-
LOG_INFO_APP_AUTHING(0xA0, "Application is in `authing` state."),
44-
LOG_INFO_APP_AUTHED(0xA1, "Application is in `auth` state."),
42+
LOG_INFO_APP_CMD_READ(0x80, DATADIR_BIDIRECTIONAL, "Application processed read command."),
43+
LOG_INFO_APP_CMD_WRITE(0x81, DATADIR_BIDIRECTIONAL, "Application processed write command."),
44+
LOG_INFO_APP_CMD_INC(0x84, DATADIR_BIDIRECTIONAL, "Application processed increment command."),
45+
LOG_INFO_APP_CMD_DEC(0x85, DATADIR_BIDIRECTIONAL, "Application processed decrement command."),
46+
LOG_INFO_APP_CMD_TRANSFER(0x86, DATADIR_BIDIRECTIONAL, "Application processed transfer command."),
47+
LOG_INFO_APP_CMD_RESTORE(0x87, DATADIR_BIDIRECTIONAL, "Application processed restore command."),
48+
LOG_INFO_APP_CMD_AUTH(0x90, DATADIR_BIDIRECTIONAL, "Application processed authentication command."),
49+
LOG_INFO_APP_CMD_HALT(0x91, DATADIR_BIDIRECTIONAL, "Application processed halt command."),
50+
LOG_INFO_APP_CMD_UNKNOWN(0x92, DATADIR_BIDIRECTIONAL, "Application processed an unknown command."),
51+
LOG_INFO_APP_AUTHING(0xA0, DATADIR_BIDIRECTIONAL, "Application is in `authing` state."),
52+
LOG_INFO_APP_AUTHED(0xA1, DATADIR_BIDIRECTIONAL, "Application is in `auth` state."),
4553
/* Log errors */
46-
LOG_ERR_APP_AUTH_FAIL(0xC0, "Application authentication failed."),
47-
LOG_ERR_APP_CHECKSUM_FAIL(0xC1, "Application had a checksum fail."),
48-
LOG_ERR_APP_NOT_AUTHED(0xC2, "Application is not authenticated."),
54+
LOG_ERR_APP_AUTH_FAIL(0xC0, DATADIR_BIDIRECTIONAL, "Application authentication failed."),
55+
LOG_ERR_APP_CHECKSUM_FAIL(0xC1, DATADIR_BIDIRECTIONAL, "Application had a checksum fail."),
56+
LOG_ERR_APP_NOT_AUTHED(0xC2, DATADIR_BIDIRECTIONAL, "Application is not authenticated."),
4957
/* Other Chameleon-specific */
50-
LOG_INFO_SYSTEM_BOOT(0xFF, "Chameleon boots"),
51-
LOG_EMPTY(0x00, "Empty Log Entry. This is not followed by a length byte nor the two systick bytes nor any data."),
52-
LOG_CODE_DNE(0xff, "This is a dummy log code entry for matching where the input code does not exist.");
58+
LOG_INFO_SYSTEM_BOOT(0xFF, DATADIR_BIDIRECTIONAL, "Chameleon boots"),
59+
LOG_EMPTY(0x00, DATADIR_BIDIRECTIONAL, "Empty Log Entry. This is not followed by a length byte nor the two systick bytes nor any data."),
60+
LOG_CODE_DNE(0xff, DATADIR_BIDIRECTIONAL, "This is a dummy log code entry for matching where the input code does not exist.");
5361

5462
/**
5563
* Stores a mapping of the log codes to their enum values.
@@ -67,15 +75,17 @@ public enum LogCode {
6775
* Local data stored by the class.
6876
*/
6977
private int logCode;
78+
private int logDataDirection;
7079
private String logDesc;
7180

7281
/**
7382
* Constructor.
7483
* @param lcode
7584
* @param ldesc
7685
*/
77-
private LogCode(int lcode, String ldesc) {
86+
private LogCode(int lcode, int ldd, String ldesc) {
7887
logCode = lcode;
88+
logDataDirection = ldd;
7989
logDesc = ldesc;
8090
}
8191

@@ -86,6 +96,7 @@ private LogCode(int lcode, String ldesc) {
8696
public int toInteger() {
8797
return logCode;
8898
}
99+
public int getDataDirection() { return logDataDirection; }
89100
public String getDesc() { return logDesc; }
90101

91102
/**
@@ -108,6 +119,9 @@ public static LogCode lookupByLogCode(int lcode) {
108119
*/
109120
public static String getShortCodeName(int lcode) {
110121
LogCode lc = lookupByLogCode(lcode);
122+
if(lc == null) {
123+
return "UNKNOWN_LOG_CODE";
124+
}
111125
String longName = lc.name();
112126
longName = longName.replace("LOG_INFO_", "");
113127
longName = longName.replace("LOG_INFO_CODEC_", "");
@@ -118,4 +132,17 @@ public static String getShortCodeName(int lcode) {
118132

119133
}
120134

135+
/**
136+
* Returns the data transfer direction based on the logging code.
137+
* Note that this bidirectional sniffing output from the Chameleon Rev. G
138+
* boards is fairly recent as of (9-10/2018).
139+
*/
140+
public static int getDataDirection(int lcode) {
141+
LogCode lc = LogCode.lookupByLogCode(lcode);
142+
if(lc == null) {
143+
return DATADIR_BIDIRECTIONAL;
144+
}
145+
return lc.getDataDirection();
146+
}
147+
121148
}
385 Bytes
Loading
382 Bytes
Loading

0 commit comments

Comments
 (0)