Skip to content

Commit 410ac76

Browse files
authored
Merge pull request #16 from cslrfid/release-1.22.0
Updates for Android 10
2 parents f832d01 + c789717 commit 410ac76

File tree

79 files changed

+2635
-691
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+2635
-691
lines changed

.idea/caches/build_file_checksums.ser

0 Bytes
Binary file not shown.

.idea/compiler.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 28
4+
compileSdkVersion 29
55
defaultConfig {
66
applicationId "com.csl.cs108ademoapp"
77
minSdkVersion 19
8-
targetSdkVersion 28
9-
versionCode 25
10-
versionName "1.20.0"
8+
targetSdkVersion 29
9+
versionCode 27
10+
versionName "1.22.0"
1111
}
1212
compileOptions {
1313
sourceCompatibility JavaVersion.VERSION_1_7
@@ -18,5 +18,5 @@ android {
1818
dependencies {
1919
implementation fileTree(include: ['*.jar'], dir: 'libs')
2020
implementation project(':cs108library4a')
21-
implementation 'com.android.support:design:28.0.0'
21+
implementation 'com.google.android.material:material:1.0.0'
2222
}

app/release/output-metadata.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": 2,
3+
"artifactType": {
4+
"type": "APK",
5+
"kind": "Directory"
6+
},
7+
"applicationId": "com.csl.cs108ademoapp",
8+
"variantName": "processReleaseResources",
9+
"elements": [
10+
{
11+
"type": "SINGLE",
12+
"filters": [],
13+
"versionCode": 27,
14+
"versionName": "1.22.0",
15+
"outputFile": "app-release.apk"
16+
}
17+
]
18+
}

app/release/output.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"version": 1,
3+
"artifactType": {
4+
"type": "APK",
5+
"kind": "Directory"
6+
},
7+
"applicationId": "com.csl.cs108ademoapp",
8+
"variantName": "release",
9+
"elements": [
10+
{
11+
"type": "SINGLE",
12+
"filters": [],
13+
"properties": [],
14+
"versionCode": 26,
15+
"versionName": "26",
16+
"enabled": true,
17+
"outputFile": "app-release.apk"
18+
}
19+
]
20+
}

app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<uses-permission android:name="android.permission.INTERNET" />
77
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
88
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
9+
<uses-permission android:name="android.permission.NFC" />
910

1011
<application
1112
android:allowBackup="true"
@@ -30,7 +31,12 @@
3031
<action android:name="android.intent.action.MAIN" />
3132
<category android:name="android.intent.category.LAUNCHER" />
3233
</intent-filter>
34+
35+
<intent-filter>
36+
<action android:name="android.nfc.action.ACTION_TAG_DISCOVERED" />
37+
<category android:name="android.intent.category.DEFAULT" />
38+
<data android:mimeType="text/plain" />
39+
</intent-filter>
3340
</activity>
3441
</application>
35-
3642
</manifest>

app/src/main/java/com/csl/cs108ademoapp/AccessTask.java

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

33
import android.os.AsyncTask;
4+
import android.os.Handler;
45
import android.widget.Button;
56
import android.widget.TextView;
67
import android.widget.Toast;
@@ -13,10 +14,12 @@ public class AccessTask extends AsyncTask<Void, String, String> {
1314
final boolean DEBUG = true;
1415
final boolean skipSelect = false;
1516
public enum TaskCancelRReason {
16-
NULL, INVALD_REQUEST, DESTORY, STOP, BUTTON_RELEASE, TIMEOUT
17+
NULL, INVALD_REQUEST, DESTORY, STOP, BUTTON_RELEASE, ERROR, TIMEOUT
1718
}
1819
public TaskCancelRReason taskCancelReason;
1920
public String accessResult;
21+
Handler mHandler = new Handler();
22+
Runnable updateRunnable = null;
2023

2124
Button button; String buttonText;
2225
TextView registerRunTime, registerTagGot, registerVoltageLevel;
@@ -46,7 +49,8 @@ public enum TaskCancelRReason {
4649

4750
public AccessTask(Button button, boolean invalidRequest,
4851
String selectMask, int selectBank, int selectOffset,
49-
String strPassword, int powerLevel, Cs108Connector.HostCommands hostCommand, boolean bEnableErrorPopWindow) {
52+
String strPassword, int powerLevel, Cs108Connector.HostCommands hostCommand,
53+
boolean bEnableErrorPopWindow, Runnable updateRunnable) {
5054
this.button = button;
5155
this.registerTagGot = registerTagGot;
5256
this.registerVoltageLevel = registerVoltageLevel;
@@ -59,6 +63,7 @@ public AccessTask(Button button, boolean invalidRequest,
5963
this.powerLevel = powerLevel;
6064
this.hostCommand = hostCommand;
6165
this.bEnableErrorPopWindow = bEnableErrorPopWindow;
66+
this.updateRunnable = updateRunnable;
6267
if (true) {
6368
total = 0;
6469
tagList.clear();
@@ -95,6 +100,9 @@ public AccessTask(Button button, TextView textViewWriteCount, boolean invalidReq
95100
}
96101
preExecute();
97102
}
103+
public void setRunnable(Runnable updateRunnable) {
104+
this.updateRunnable = updateRunnable;
105+
}
98106

99107
void preExecute() {
100108
accessResult = null;
@@ -106,13 +114,14 @@ void preExecute() {
106114
String buttonText1 = null; String strLastChar = buttonText.substring(buttonText.length()-1);
107115
if (strLastChar.toUpperCase().matches("E")) {
108116
buttonText1 = buttonText.substring(0, buttonText.length()-1);
109-
if (strLastChar.matches("E")) buttonText1 += "ING";
110-
else buttonText1 += "ing";
111-
}
117+
} else if (buttonText.toUpperCase().matches("STOP")) {
118+
buttonText1 = buttonText; buttonText1 += buttonText1.substring(buttonText.length()-1);
119+
} else buttonText1 = buttonText;
112120
if (repeat || buttonText.length() == 0) button.setText("Stop");
113-
else if (buttonText1 != null) button.setText(buttonText1);
114-
else if (Character.isUpperCase(strLastChar.charAt(0))) button.setText(buttonText + "ING");
115-
else button.setText(buttonText + "ing");
121+
else {
122+
if (Character.isUpperCase(strLastChar.charAt(0))) button.setText(buttonText1 + "ING");
123+
else button.setText(buttonText1 + "ing");
124+
}
116125
if (registerYield != null && tagList.size()==0) registerYield.setText("");
117126
if (registerTotal != null && total == 0) registerTotal.setText("");
118127

@@ -163,6 +172,7 @@ else if (MainActivity.mCs108Library4a.setSelectedTag(selectMask, selectBank, sel
163172
@Override
164173
protected String doInBackground(Void... a) {
165174
boolean ending = false;
175+
int iTimeOut = 5000;
166176

167177
while (MainActivity.mCs108Library4a.isBleConnected() && isCancelled() == false && ending == false) {
168178
int batteryCount = MainActivity.mCs108Library4a.getBatteryCount();
@@ -174,6 +184,7 @@ protected String doInBackground(Void... a) {
174184
runTimeMillis = System.currentTimeMillis();
175185
publishProgress("WW");
176186
}
187+
byte[] notificationData = MainActivity.mCs108Library4a.onNotificationEvent();
177188
Cs108Connector.Rx000pkgData rx000pkgData = MainActivity.mCs108Library4a.onRFIDEvent();
178189
if (MainActivity.mCs108Library4a.mrfidToWriteSize() != 0) timeMillis = System.currentTimeMillis();
179190
else if (rx000pkgData != null) {
@@ -182,11 +193,19 @@ else if (rx000pkgData != null) {
182193
} else if (rx000pkgData.responseType == Cs108Connector.HostCmdResponseTypes.TYPE_18K6C_TAG_ACCESS) {
183194
if (true) {
184195
if (rx000pkgData.decodedError == null) {
185-
if (done == false) { accessResult = rx000pkgData.decodedResult; MainActivity.mCs108Library4a.appendToLog("HelloA, accResult=" + accessResult);}
196+
if (done == false) {
197+
accessResult = rx000pkgData.decodedResult;
198+
MainActivity.mCs108Library4a.appendToLog("StreamOut, accResult=" + accessResult);
199+
if (updateRunnable != null) {
200+
MainActivity.mCs108Library4a.appendToLog("StreamOut: start updateRunnable");
201+
mHandler.post(updateRunnable);
202+
}
203+
}
186204
done = true;
187205
publishProgress(null, rx000pkgData.decodedResult);
188206
}
189207
else publishProgress(rx000pkgData.decodedError);
208+
iTimeOut = 500;
190209
}
191210
} else if (rx000pkgData.responseType == Cs108Connector.HostCmdResponseTypes.TYPE_COMMAND_END) {
192211
if (rx000pkgData.decodedError != null) { endingMessaage = rx000pkgData.decodedError; ending = true; }
@@ -204,11 +223,20 @@ else if (repeat && (nextNew == false || resultError.length() != 0)) {
204223
}
205224
timeMillis = System.currentTimeMillis();
206225
}
207-
if (System.currentTimeMillis() - timeMillis > 5000) {
208-
cancel(true);
226+
else if (notificationData != null) {
227+
MainActivity.mCs108Library4a.appendToLog("resultError=" + MainActivity.mCs108Library4a.byteArrayToString(notificationData));
228+
publishProgress("Received notification uplink event 0xA101 with error code=" + MainActivity.mCs108Library4a.byteArrayToString(notificationData));
229+
timeMillis = System.currentTimeMillis();
230+
iTimeOut = 500;
231+
}
232+
if (System.currentTimeMillis() - timeMillis > iTimeOut) {
233+
MainActivity.mCs108Library4a.appendToLog("endingMessage: iTimeout = " + iTimeOut);
209234
taskCancelReason = TaskCancelRReason.TIMEOUT;
210235
}
211-
if (taskCancelReason != TaskCancelRReason.NULL) cancel(true);
236+
if (taskCancelReason != TaskCancelRReason.NULL) {
237+
MainActivity.mCs108Library4a.appendToLog("taskCancelReason=" + TaskCancelRReason.values());
238+
cancel(true);
239+
}
212240
}
213241
return "End of Asynctask():" + ending;
214242
}
@@ -244,6 +272,7 @@ else if (output[0] != null) {
244272
resultError += output[0];
245273
if (true)
246274
MainActivity.mCs108Library4a.appendToLog("output[0]: " + output[0] + ", resultError = " + resultError);
275+
taskCancelReason = TaskCancelRReason.ERROR;
247276
}
248277
} else {
249278
if (registerYield != null) {
@@ -260,8 +289,8 @@ else if (output[0] != null) {
260289
@Override
261290
protected void onCancelled() {
262291
super.onCancelled();
263-
if (DEBUG) MainActivity.mCs108Library4a.appendToLog("AccessSecurityLockFragment.InventoryRfidTask.onCancelled()");
264-
292+
if (DEBUG) MainActivity.mCs108Library4a.appendToLog("endingMesssage: taskCancelReason = " + taskCancelReason);
293+
//if (taskCancelReason != TaskCancelRReason.NULL) MainActivity.mCs108Library4a.abortOperation1(); else
265294
MainActivity.mCs108Library4a.abortOperation();
266295
if (taskCancelReason == TaskCancelRReason.NULL) taskCancelReason = TaskCancelRReason.DESTORY;
267296
DeviceConnectTask4RegisterEnding();
@@ -339,6 +368,9 @@ void DeviceConnectTask4RegisterEnding() {
339368
case BUTTON_RELEASE:
340369
strErrorMessage += "Finish as BUTTON is released. ";
341370
break;
371+
case ERROR:
372+
strErrorMessage += "Finish due to error received.";
373+
break;
342374
case TIMEOUT:
343375
strErrorMessage += "TIMEOUT without COMMAND_END. ";
344376
break;
@@ -354,7 +386,7 @@ void DeviceConnectTask4RegisterEnding() {
354386
if (strErrorMessage.length() != 0) endingMessaage = strErrorMessage;
355387
button.setText(buttonText);
356388
if (endingMessaage != null) {
357-
if (endingMessaage.length() != 0 || true) {
389+
if (endingMessaage.length() != 0) {
358390
MainActivity.mCs108Library4a.appendToLog("endingMessage=" + endingMessaage);
359391
if (bEnableErrorPopWindow) {
360392
CustomPopupWindow customPopupWindow = new CustomPopupWindow(MainActivity.mContext);

app/src/main/java/com/csl/cs108ademoapp/AccessTask1.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ public class AccessTask1 {
1616
String strPassword;
1717
int powerLevel;
1818
Cs108Connector.HostCommands hostCommand;
19+
Runnable updateRunnable = null;
1920

2021
AccessTask accessTask;
2122
public AccessTask1(Button button, boolean invalidRequest,
2223
int accBank, int accOffset, int accSize, int accBlockCount, String accWriteData,
2324
String selectMask, int selectBank, int selectOffset,
24-
String strPassword, int powerLevel, Cs108Connector.HostCommands hostCommand) {
25+
String strPassword, int powerLevel, Cs108Connector.HostCommands hostCommand, Runnable updateRunnable) {
2526
this.button = button;
2627
this.invalidRequest = invalidRequest;
2728
MainActivity.mCs108Library4a.appendToLog("HelloK: invalidRequest=" + invalidRequest);
@@ -51,6 +52,7 @@ public AccessTask1(Button button, boolean invalidRequest,
5152
this.strPassword = strPassword;
5253
this.powerLevel = powerLevel;
5354
this.hostCommand = hostCommand;
55+
this.updateRunnable = updateRunnable;
5456
MainActivity.mCs108Library4a.appendToLog("HelloA, AccessTask1");
5557
CustomMediaPlayer playerN = MainActivity.sharedObjects.playerN;
5658
playerN.start();
@@ -187,6 +189,6 @@ void setup() {
187189
MainActivity.mCs108Library4a.appendToLog("HelloK: invalidRequest=" + invalidRequest);
188190
accessTask = new AccessTask(button, invalidRequest,
189191
selectMask, selectBank, selectOffset,
190-
strPassword, powerLevel, hostCommand, tryCount==tryCountMax);
192+
strPassword, powerLevel, hostCommand, tryCount==tryCountMax, updateRunnable);
191193
}
192194
}

app/src/main/java/com/csl/cs108ademoapp/CustomMediaPlayer.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@
44
import android.content.res.AssetFileDescriptor;
55
import android.media.AudioManager;
66
import android.media.MediaPlayer;
7-
import android.support.annotation.Keep;
8-
import android.support.annotation.NonNull;
9-
10-
import com.csl.cs108library4a.ReaderDevice;
7+
import androidx.annotation.Keep;
8+
import androidx.annotation.NonNull;
119

1210
import java.io.IOException;
13-
import java.util.ArrayList;
1411

1512
public class CustomMediaPlayer {
1613
final boolean DEBUG = false;

app/src/main/java/com/csl/cs108ademoapp/DrawerListContent.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public enum DrawerPositions {
2020
ABOUT, CONNECT,
2121
INVENTORY, SEARCH, MULTIBANK,
2222
SETTING, FILTER, READWRITE, SECURITY,
23-
COLDCHAIN, AXZON, RFMICRON, CTESIUS,
23+
COLDCHAIN, AXZON, RFMICRON, CTESIUS, FDMICRO,
2424
UCODE, UCODE8,
2525
BAPCARD, IMPINVENTORY, AURASENSE,
2626
REGISTER, READWRITEUSER, WEDGE, BLANK;
@@ -40,14 +40,15 @@ public static DrawerPositions toDrawerPosition(int x) {
4040
case 10: return AXZON;
4141
case 11: return RFMICRON;
4242
case 12: return CTESIUS;
43-
case 13: return UCODE;
44-
case 14: return UCODE8;
45-
case 15: return BAPCARD;
46-
case 16: return IMPINVENTORY;
47-
case 17: return AURASENSE;
48-
case 18: return REGISTER;
49-
case 19: return READWRITEUSER;
50-
case 20: return WEDGE;
43+
case 13: return FDMICRO;
44+
case 14: return UCODE;
45+
case 15: return UCODE8;
46+
case 16: return BAPCARD;
47+
case 17: return IMPINVENTORY;
48+
case 18: return AURASENSE;
49+
case 19: return REGISTER;
50+
case 20: return READWRITEUSER;
51+
case 21: return WEDGE;
5152
}
5253
return null;
5354
}

0 commit comments

Comments
 (0)