Browse Source

证通-易加POS工程初始上传

suxinghua 4 years ago
commit
2c88c53b0a
100 changed files with 7757 additions and 0 deletions
  1. 15 0
      ZTHandPOS/.gitignore
  2. 3 0
      ZTHandPOS/.idea/.gitignore
  3. 6 0
      ZTHandPOS/.idea/compiler.xml
  4. 7 0
      ZTHandPOS/.idea/encodings.xml
  5. 21 0
      ZTHandPOS/.idea/gradle.xml
  6. 25 0
      ZTHandPOS/.idea/jarRepositories.xml
  7. 14 0
      ZTHandPOS/.idea/misc.xml
  8. 1 0
      ZTHandPOS/app/.gitignore
  9. 40 0
      ZTHandPOS/app/build.gradle
  10. BIN
      ZTHandPOS/app/libs/android-support-v4.jar
  11. BIN
      ZTHandPOS/app/libs/szztdevicesdk.jar
  12. 21 0
      ZTHandPOS/app/proguard-rules.pro
  13. 26 0
      ZTHandPOS/app/src/androidTest/java/com/yijia/zthandpos/ExampleInstrumentedTest.java
  14. 82 0
      ZTHandPOS/app/src/main/AndroidManifest.xml
  15. 579 0
      ZTHandPOS/app/src/main/assets/CardActivity.java
  16. 146 0
      ZTHandPOS/app/src/main/assets/MainActivity.java
  17. BIN
      ZTHandPOS/app/src/main/assets/image/a.jpg
  18. BIN
      ZTHandPOS/app/src/main/assets/image/b.png
  19. BIN
      ZTHandPOS/app/src/main/assets/image/sb.png
  20. 29 0
      ZTHandPOS/app/src/main/java/com/yijia/zthandpos/MainAdapter.java
  21. 62 0
      ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/BaseActivity.java
  22. 257 0
      ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/MainApplication.java
  23. 237 0
      ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/NewMainActivity.java
  24. 617 0
      ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/test/EMVActivity.java
  25. 357 0
      ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/test/ICCardActivity.java
  26. 205 0
      ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/test/MagCardActivity.java
  27. 277 0
      ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/test/PinPadActivity.java
  28. 262 0
      ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/test/PrinterActivity.java
  29. 213 0
      ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/test/PsamCardActivity.java
  30. 287 0
      ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/test/RFCardActivity.java
  31. 454 0
      ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/test/ReadCardActivity.java
  32. 123 0
      ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/test/ScanActivity.java
  33. 157 0
      ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/test/SystemManagerActivity.java
  34. 291 0
      ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/test/WaveFileReader.java
  35. 30 0
      ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/utils/FileUtils.java
  36. 346 0
      ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/utils/HexDump.java
  37. 106 0
      ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/utils/MessageManager.java
  38. 17 0
      ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/utils/Shower.java
  39. 563 0
      ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/utils/StringUtil.java
  40. 140 0
      ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/utils/StringUtility.java
  41. 216 0
      ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/utils/UTF8Util.java
  42. 10 0
      ZTHandPOS/app/src/main/res/anim/anmitation.xml
  43. 5 0
      ZTHandPOS/app/src/main/res/anim/cycle_interpolator.xml
  44. 30 0
      ZTHandPOS/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
  45. BIN
      ZTHandPOS/app/src/main/res/drawable-xxhdpi/cantact.png
  46. BIN
      ZTHandPOS/app/src/main/res/drawable-xxhdpi/cantactless.png
  47. BIN
      ZTHandPOS/app/src/main/res/drawable-xxhdpi/card.png
  48. BIN
      ZTHandPOS/app/src/main/res/drawable-xxhdpi/emv.png
  49. BIN
      ZTHandPOS/app/src/main/res/drawable-xxhdpi/exit.png
  50. BIN
      ZTHandPOS/app/src/main/res/drawable-xxhdpi/mag.png
  51. BIN
      ZTHandPOS/app/src/main/res/drawable-xxhdpi/pinpad.png
  52. BIN
      ZTHandPOS/app/src/main/res/drawable-xxhdpi/print.png
  53. BIN
      ZTHandPOS/app/src/main/res/drawable-xxhdpi/sx.png
  54. BIN
      ZTHandPOS/app/src/main/res/drawable/a_side.jpg
  55. BIN
      ZTHandPOS/app/src/main/res/drawable/app_launcher.png
  56. 21 0
      ZTHandPOS/app/src/main/res/drawable/btn_round_solid_blue.xml
  57. 21 0
      ZTHandPOS/app/src/main/res/drawable/btn_round_solid_blue_2.xml
  58. 21 0
      ZTHandPOS/app/src/main/res/drawable/btn_round_solid_green.xml
  59. 12 0
      ZTHandPOS/app/src/main/res/drawable/btn_style.xml
  60. 23 0
      ZTHandPOS/app/src/main/res/drawable/btn_styleblue.xml
  61. 18 0
      ZTHandPOS/app/src/main/res/drawable/btnstyle.xml
  62. BIN
      ZTHandPOS/app/src/main/res/drawable/luncher.jpg
  63. 18 0
      ZTHandPOS/app/src/main/res/drawable/shape.xml
  64. BIN
      ZTHandPOS/app/src/main/res/drawable/side.jpg
  65. BIN
      ZTHandPOS/app/src/main/res/drawable/szzt.bmp
  66. 53 0
      ZTHandPOS/app/src/main/res/layout/activity_card.xml
  67. 79 0
      ZTHandPOS/app/src/main/res/layout/activity_emv.xml
  68. 95 0
      ZTHandPOS/app/src/main/res/layout/activity_hw_security.xml
  69. 74 0
      ZTHandPOS/app/src/main/res/layout/activity_id_card.xml
  70. 134 0
      ZTHandPOS/app/src/main/res/layout/activity_idc.xml
  71. 18 0
      ZTHandPOS/app/src/main/res/layout/activity_main.xml
  72. 319 0
      ZTHandPOS/app/src/main/res/layout/activity_new_main.xml
  73. 93 0
      ZTHandPOS/app/src/main/res/layout/activity_pinpad.xml
  74. 73 0
      ZTHandPOS/app/src/main/res/layout/activity_printer.xml
  75. 55 0
      ZTHandPOS/app/src/main/res/layout/activity_psamcard.xml
  76. 55 0
      ZTHandPOS/app/src/main/res/layout/activity_scan.xml
  77. 65 0
      ZTHandPOS/app/src/main/res/layout/activity_serial.xml
  78. 88 0
      ZTHandPOS/app/src/main/res/layout/activity_system.xml
  79. 21 0
      ZTHandPOS/app/src/main/res/layout/list_item.xml
  80. 44 0
      ZTHandPOS/app/src/main/res/layout/progress.xml
  81. 9 0
      ZTHandPOS/app/src/main/res/menu/all_card.xml
  82. 9 0
      ZTHandPOS/app/src/main/res/menu/main.xml
  83. 5 0
      ZTHandPOS/app/src/main/res/menu/menu_main.xml
  84. 9 0
      ZTHandPOS/app/src/main/res/menu/new_main.xml
  85. 9 0
      ZTHandPOS/app/src/main/res/menu/read_card.xml
  86. 5 0
      ZTHandPOS/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
  87. 5 0
      ZTHandPOS/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
  88. BIN
      ZTHandPOS/app/src/main/res/mipmap-hdpi/ic_launcher.png
  89. BIN
      ZTHandPOS/app/src/main/res/mipmap-mdpi/ic_launcher.png
  90. BIN
      ZTHandPOS/app/src/main/res/mipmap-xhdpi/ic_launcher.png
  91. BIN
      ZTHandPOS/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
  92. BIN
      ZTHandPOS/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
  93. BIN
      ZTHandPOS/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
  94. BIN
      ZTHandPOS/app/src/main/res/raw/alert_tone.wav
  95. BIN
      ZTHandPOS/app/src/main/res/raw/app_test
  96. BIN
      ZTHandPOS/app/src/main/res/raw/err.wav
  97. 21 0
      ZTHandPOS/app/src/main/res/raw/params
  98. 8 0
      ZTHandPOS/app/src/main/res/raw/params_ms
  99. BIN
      ZTHandPOS/app/src/main/res/raw/plsswca.wav
  100. BIN
      ZTHandPOS/app/src/main/res/raw/selftest_affirm.wav

+ 15 - 0
ZTHandPOS/.gitignore

@@ -0,0 +1,15 @@
+*.iml
+.gradle
+/local.properties
+/.idea/caches
+/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
+.DS_Store
+/build
+/captures
+.externalNativeBuild
+.cxx
+local.properties

+ 3 - 0
ZTHandPOS/.idea/.gitignore

@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml

+ 6 - 0
ZTHandPOS/.idea/compiler.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CompilerConfiguration">
+    <bytecodeTargetLevel target="1.8" />
+  </component>
+</project>

+ 7 - 0
ZTHandPOS/.idea/encodings.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding">
+    <file url="file://$PROJECT_DIR$/app/src/main/java/com/yijia/zthandpos/pos/MainApplication.java" charset="GB2312" />
+    <file url="file://$PROJECT_DIR$/app/src/main/java/com/yijia/zthandpos/pos/NewMainActivity.java" charset="GB2312" />
+  </component>
+</project>

+ 21 - 0
ZTHandPOS/.idea/gradle.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="GradleMigrationSettings" migrationVersion="1" />
+  <component name="GradleSettings">
+    <option name="linkedExternalProjectsSettings">
+      <GradleProjectSettings>
+        <option name="testRunner" value="PLATFORM" />
+        <option name="distributionType" value="DEFAULT_WRAPPED" />
+        <option name="externalProjectPath" value="$PROJECT_DIR$" />
+        <option name="modules">
+          <set>
+            <option value="$PROJECT_DIR$" />
+            <option value="$PROJECT_DIR$/app" />
+          </set>
+        </option>
+        <option name="resolveModulePerSourceSet" value="false" />
+        <option name="useQualifiedModuleNames" value="true" />
+      </GradleProjectSettings>
+    </option>
+  </component>
+</project>

+ 25 - 0
ZTHandPOS/.idea/jarRepositories.xml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="RemoteRepositoriesConfiguration">
+    <remote-repository>
+      <option name="id" value="central" />
+      <option name="name" value="Maven Central repository" />
+      <option name="url" value="https://repo1.maven.org/maven2" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="jboss.community" />
+      <option name="name" value="JBoss Community repository" />
+      <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="BintrayJCenter" />
+      <option name="name" value="BintrayJCenter" />
+      <option name="url" value="https://jcenter.bintray.com/" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="Google" />
+      <option name="name" value="Google" />
+      <option name="url" value="https://dl.google.com/dl/android/maven2/" />
+    </remote-repository>
+  </component>
+</project>

+ 14 - 0
ZTHandPOS/.idea/misc.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CMakeSettings">
+    <configurations>
+      <configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
+    </configurations>
+  </component>
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/build/classes" />
+  </component>
+  <component name="ProjectType">
+    <option name="id" value="Android" />
+  </component>
+</project>

+ 1 - 0
ZTHandPOS/app/.gitignore

@@ -0,0 +1 @@
+/build

+ 40 - 0
ZTHandPOS/app/build.gradle

@@ -0,0 +1,40 @@
+plugins {
+    id 'com.android.application'
+}
+
+android {
+    compileSdkVersion 29
+    buildToolsVersion "30.0.3"
+
+    defaultConfig {
+        applicationId "com.yijia.zthandpos"
+        minSdkVersion 14
+        targetSdkVersion 29
+        versionCode 1
+        versionName "1.0"
+
+        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+    }
+
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+        }
+    }
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
+    }
+}
+
+dependencies {
+
+    implementation 'androidx.appcompat:appcompat:1.1.0'
+    implementation 'com.google.android.material:material:1.1.0'
+    implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
+    implementation files('libs/szztdevicesdk.jar')
+    testImplementation 'junit:junit:4.11'
+    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
+    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
+}

BIN
ZTHandPOS/app/libs/android-support-v4.jar


BIN
ZTHandPOS/app/libs/szztdevicesdk.jar


+ 21 - 0
ZTHandPOS/app/proguard-rules.pro

@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile

+ 26 - 0
ZTHandPOS/app/src/androidTest/java/com/yijia/zthandpos/ExampleInstrumentedTest.java

@@ -0,0 +1,26 @@
+package com.yijia.zthandpos;
+
+import android.content.Context;
+
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+    @Test
+    public void useAppContext() {
+        // Context of the app under test.
+        Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+        assertEquals("com.yijia.zthandpos", appContext.getPackageName());
+    }
+}

+ 82 - 0
ZTHandPOS/app/src/main/AndroidManifest.xml

@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.yijia.zthandpos.pos"
+    android:versionCode="1"
+    android:versionName="V1.0.1" >
+
+    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
+    <uses-permission android:name="android.permission.IDC" />
+    <uses-permission android:name="android.permission.ACCESS_CPOSSYSTEM" />
+    <uses-permission android:name="android.permission.ACCESS_HWSECURITYMANAGER" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORKMANAGER" />
+    <uses-permission android:name="android.permission.CLOUDPOS_SHUTDOWN" />
+    <uses-permission android:name="android.permission.CLOUDPOS_SLEEP" />
+    <uses-permission android:name="android.permission.CLOUDPOS_INSTALL_SILENCE" />
+    <uses-permission android:name="android.permission.CLOUDPOS_UNINSTALL_SILENCE" />
+    <uses-permission android:name="android.permission.CLOUDPOS_REBOOT" />
+    <uses-permission android:name="android.permission.CLOUDPOS_SYSTEM_DISABLE_HARDWARE" />
+    <uses-permission android:name="android.permission.ADMIN_PWD_MODIFY" />
+    <uses-permission android:name="android.permission.ADMIN_PWD_RESET" />
+    <uses-permission android:name="android.permission.ADMIN_PWD" />
+    <uses-permission android:name="android.permission.CLOUDPOS_SYSTEM_SETTIME" />
+    <uses-permission android:name="android.permission.CLOUDPOS_SYSTEM_GETCPOSDEVICEINFO" />
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.WIZARPOS_SAFE_MODULE_READONLY" />
+    <uses-permission android:name="android.permission.CLOUDPOS_SAFE_MODULE_READONLY" />
+    <uses-permission android:name="android.permission.CLOUDPOS_MSR" />
+    <uses-permission android:name="android.permission.CLOUDPOS_PRINTER" />
+    <uses-permission android:name="android.permission.CLOUDPOS_CONTACTLESS_CARD" />
+    <uses-permission android:name="android.permission.CLOUDPOS_SMARTCARD" />
+    <uses-permission android:name="android.permission.CLOUDPOS_SERIAL" />
+    <uses-permission android:name="android.permission.CLOUDPOS_PIN_GET_PIN_BLOCK" />
+    <uses-permission android:name="android.permission.CLOUDPOS_PIN_MAC" />
+    <uses-permission android:name="android.permission.CLOUDPOS_PIN_ENCRYPT_DATA" />
+    <uses-permission android:name="android.permission.CLOUDPOS_PIN_UPDATA_USER_KEY" />
+    <uses-permission android:name="android.permission.CLOUDPOS_PIN_UPDATE_MASTER_KEY" />
+    <uses-permission android:name="android.permission.CLOUDPOS_PIN_UPDATE_USER_KEY" />
+    <uses-permission android:name="android.permission.CAMERA" />
+    <uses-permission android:name="android.permission.FLASHLIGHT" />
+
+    <uses-feature android:name="android.hardware.camera" />
+    <uses-feature android:name="android.hardware.camera.autofocus" />
+
+    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+    <uses-permission android:name="android.permission.CLOUDPOS_CUSTOMER_DISPLAY" />
+    <uses-permission android:name="android.permission.WIZARPOS_CUSTOMER_DISPLAY" />
+    <uses-permission android:name="android.permission.KOOLCLOUD_CUSTOMER_DISPLAY" />
+    <!-- 条码 -->
+    <uses-permission android:name="android.permission.CLOUDPOS_BARCODE" />
+	<!-- 身份证识别权限 -->
+	<uses-permission android:name="android.permission.CLOUDPOS_IDCARD" />
+	
+	<uses-permission android:name="android.permission.CLOUDPOS_GET_DEVICE_INFO" />
+    <application
+        android:name=".MainApplication"
+        android:allowBackup="true"
+        android:icon="@drawable/app_launcher"
+        android:label="@string/app_name"
+        android:theme="@style/AppTheme" >
+        <activity
+            android:name=".NewMainActivity"
+            android:label="@string/app_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+       
+        <activity android:name="com.yijia.zthandpos.pos.test.PinPadActivity" />
+        <activity android:name="com.yijia.zthandpos.pos.test.PrinterActivity" />
+        <activity android:name="com.yijia.zthandpos.pos.test.EMVActivity" />
+        <activity android:name="com.yijia.zthandpos.pos.test.ScanActivity" />
+        <activity android:name="com.yijia.zthandpos.pos.test.ReadCardActivity" />
+        <activity android:name="com.yijia.zthandpos.pos.test.MagCardActivity" />
+        <activity android:name="com.yijia.zthandpos.pos.test.PsamCardActivity" />
+        <activity android:name="com.yijia.zthandpos.pos.test.ICCardActivity" /> >
+        <activity android:name="com.yijia.zthandpos.pos.test.RFCardActivity"/>
+        <activity android:name="com.yijia.zthandpos.pos.test.SystemManagerActivity" />
+    </application>
+
+</manifest>

+ 579 - 0
ZTHandPOS/app/src/main/assets/CardActivity.java

@@ -0,0 +1,579 @@
+package cn.zt.pos.test;
+
+import android.content.Intent;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.Looper;
+import android.os.Message;
+import android.text.method.ScrollingMovementMethod;
+import android.util.Log;
+import android.view.View;
+import android.view.Window;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.szzt.sdk.device.Constants;
+import com.szzt.sdk.device.Constants.Error;
+
+import com.szzt.sdk.device.Device;
+import com.szzt.sdk.device.card.ContactlessCardReader;
+import com.szzt.sdk.device.card.MagneticStripeCardReader;
+import com.szzt.sdk.device.card.SmartCardReader;
+
+
+import cn.zt.pos.BaseActivity;
+import cn.zt.pos.R;
+import cn.zt.pos.utils.MessageManager;
+import cn.zt.pos.utils.Shower;
+import cn.zt.pos.utils.StringUtility;
+
+public class CardActivity extends BaseActivity{
+    private MagneticStripeCardReader mMagneticStripeCardReader;
+    private SmartCardReader mSmartCardReader;
+    private ContactlessCardReader mContactlessCardReader;
+    private Button mOpenButton;
+    private Button mClearButton;
+    private Button mCloseButton;
+    private TextView mTextViewResult;
+    MessageManager messageManager;
+    HandlerThread mWaitForCardHandlerThread;
+    int mTestDeviceType = Device.TYPE_UNKNOWN;
+    private static final int  MSG_WAIT_FOR_CARD  = 0;
+    private static final int  MSG_SMARTCARD_REMOVED = 1;
+    private Shower shower ;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        requestWindowFeature(Window.FEATURE_NO_TITLE); 
+        setContentView(R.layout.activity_card);
+        shower = new Shower(this) ;
+        boolean isConnected = mainApplication.isDeviceManagerConnetcted();
+        Intent intent = getIntent();
+        if (intent != null && intent.hasExtra("device-type")) {
+            mTestDeviceType = intent
+                    .getIntExtra("device-type", mTestDeviceType);
+        }
+        init(isConnected);
+    }
+
+    @Override
+    protected void onDestroy() {
+        if (mMagneticStripeCardReader != null
+                && mMagneticStripeCardReader.getStatus() != Device.STATUS_CLOSED) {
+            mMagneticStripeCardReader.close();
+        } else if (mSmartCardReader != null
+                && mSmartCardReader.getStatus() != Device.STATUS_CLOSED) {
+            mSmartCardReader.close();
+        } else if (mContactlessCardReader != null
+                && mContactlessCardReader.getStatus() != Device.STATUS_CLOSED) {
+            mContactlessCardReader.close();
+        }
+
+        try {
+            myHandler.removeMessages(MSG_SMARTCARD_REMOVED);
+            myHandler.removeMessages(MSG_WAIT_FOR_CARD);
+            myHandler.getLooper().quit();
+            myHandler = null;
+            mWaitForCardHandlerThread = null;
+        } catch (Exception e) {
+        	e.printStackTrace();
+        }
+        super.onDestroy();
+    }
+
+    @Override
+    protected void onResume() {
+        if (messageManager != null) {
+            if (mTestDeviceType == Device.TYPE_MAGSTRIPECARDREADER)
+                messageManager
+                        .AppendInfoMessage(R.string.test_magstripecardreader);
+            else if (mTestDeviceType == Device.TYPE_SMARTCARDREADER)
+                messageManager
+                        .AppendInfoMessage(R.string.test_smartcardreader);
+            else if (mTestDeviceType == Device.TYPE_CONTACTLESSCARDREADER)
+                messageManager
+                        .AppendInfoMessage(R.string.test_contacltesscardreader);
+        }
+        if (mWaitForCardHandlerThread == null) {
+            mWaitForCardHandlerThread = new HandlerThread("wait_for_card");
+        }
+        mWaitForCardHandlerThread.start();
+        myHandler = new MyHandler(mWaitForCardHandlerThread.getLooper());
+        super.onResume();
+    }
+
+    @Override
+    public void onServiceConnected() {
+        super.onServiceConnected();
+        init(true);
+    }
+
+    @Override
+    public void onServiceDisconnected() {
+        super.onServiceDisconnected();
+        init(false);
+    }
+
+    private void init(boolean isConnected) {
+        if (mCloseButton == null) {
+            mTextViewResult = (TextView) findViewById(R.id.mag_text);
+            mTextViewResult.setMovementMethod(ScrollingMovementMethod
+                    .getInstance());
+            messageManager = new MessageManager(this, mTextViewResult);
+            mOpenButton = (Button) findViewById(R.id.mag_open);
+            mOpenButton.setOnClickListener(listener);
+
+            mClearButton = (Button) findViewById(R.id.mag_clear);
+            mClearButton.setOnClickListener(listener);
+            mCloseButton = (Button) findViewById(R.id.mag_close);
+            mCloseButton.setOnClickListener(listener);
+        }
+        mTextViewResult.setEnabled(isConnected);
+        mOpenButton.setEnabled(isConnected);
+        mClearButton.setEnabled(isConnected);
+        mCloseButton.setEnabled(isConnected);
+        if (isConnected) {
+            if (mTestDeviceType == Device.TYPE_MAGSTRIPECARDREADER)
+                mMagneticStripeCardReader = mainApplication
+                        .getMagneticStripeCardReader();
+            else if (mTestDeviceType == Device.TYPE_SMARTCARDREADER)
+                mSmartCardReader = mainApplication.getSmartCardReader();
+            else if (mTestDeviceType == Device.TYPE_CONTACTLESSCARDREADER)
+                mContactlessCardReader = mainApplication
+                        .getContactlessCardReader();
+        } else {
+            mMagneticStripeCardReader = null;
+            mSmartCardReader = null;
+            mContactlessCardReader = null;
+        }
+    }
+
+    void testMagStripeCardReader() {
+        int result = mMagneticStripeCardReader.waitForCard(100000);
+        if (result == 0) {
+            byte[] data1 = mMagneticStripeCardReader
+                    .getTrackData(MagneticStripeCardReader.TRACK_INDEX_1);
+            byte[] data2 = mMagneticStripeCardReader
+                    .getTrackData(MagneticStripeCardReader.TRACK_INDEX_2);
+            byte[] data3 = mMagneticStripeCardReader
+                    .getTrackData(MagneticStripeCardReader.TRACK_INDEX_3);
+            if (data1 == null && data2 == null && data3 == null) {
+                messageManager.AppendInfoMessageInUiThread(
+                        shower.getString(R.string.msg_card_read_error), Color.RED);
+            } else {
+                messageManager.AppendInfoMessageInUiThread(
+                        shower.getString(R.string.msg_card_read_succ), Color.RED);
+
+                String strTrack1 = trackFormat(data1);
+                String strTrack2 = trackFormat(data2);
+                String strTrack3 = trackFormat(data3);
+
+                messageManager
+                        .AppendInfoMessageInUiThread("Data of Track 1 (len "
+                                + strTrack1.length() + "):");
+                messageManager.AppendInfoMessageInUiThread(strTrack1);
+                messageManager
+                        .AppendInfoMessageInUiThread("Data of Track 2 (len "
+                                + strTrack2.length() + "):");
+                messageManager.AppendInfoMessageInUiThread(strTrack2);
+                messageManager
+                        .AppendInfoMessageInUiThread("Data of Track 3 (len "
+                                + strTrack3.length() + "):");
+                messageManager.AppendInfoMessageInUiThread(strTrack3);
+                //messageManager.AppendInfoMessageInUiThread("Data of Track 1:"+trackFormat(data1));
+                //messageManager.AppendInfoMessageInUiThread("Data of Track 2:"+trackFormat(data2));
+                //messageManager.AppendInfoMessageInUiThread("Data of Track 3:"+trackFormat(data3));
+            }
+//            messageManager.AppendInfoMessageInUiThread(
+//                    R.string.info_action_continue_or_close_device, Color.GREEN);
+        } else if (result == Error.TIMEOUT) {
+            messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.msg_card_time_out), Color.RED);
+        } else if (result == Error.DEVICE_FORCE_CLOSED) {
+            messageManager.AppendInfoMessageInUiThread(
+                    shower.getString(R.string.msg_card_close_succ), Color.RED);
+        } else {
+            messageManager.AppendInfoMessageInUiThread(
+                    shower.getString(R.string.msg_card_read_error), Color.RED);
+        }
+    }
+
+    void testSmartCardReader() {
+        int result = mSmartCardReader.waitForCard(0, Constants.WAIT_INFINITE);
+        if (result == 0) {
+        	byte[] data=new byte[256];
+        	result=mSmartCardReader.powerOn(0, data);
+            messageManager.AppendInfoMessageInUiThread("Power On ATR:" + (result>0?StringUtility.ByteArrayToString(data, result):""));
+
+//            messageManager.AppendInfoMessageInUiThread(
+//                    R.string.info_action_test_io, Color.GREEN);
+            testSmartCardReaderIO();
+        } else if (result == Error.TIMEOUT) {
+            messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.msg_card_time_out),
+                    Color.RED);
+        } else if (result == Error.DEVICE_FORCE_CLOSED) {
+            messageManager.AppendInfoMessageInUiThread(
+                    shower.getString(R.string.msg_card_close_succ), Color.RED);
+        } else {
+            messageManager.AppendInfoMessageInUiThread(
+                    shower.getString(R.string.msg_card_read_error), Color.RED);
+        }
+    }
+
+    void testContactlessCardReader() {
+        int result = mContactlessCardReader.waitForCard(60000);
+        if (result == 0) {
+            byte[] data=new byte[256];
+            result=mContactlessCardReader.powerOn(data);            
+            messageManager.AppendInfoMessageInUiThread("Power On ATR:" +( result>0?StringUtility.ByteArrayToString(data, result):""));
+            int cardType = mContactlessCardReader.getCardType();
+
+            switch (cardType) {
+                case 0x0000:
+                    messageManager
+                            .AppendInfoMessageInUiThread("Get Card Type: A_CPU");
+                    break;
+                case 0x0100:
+                    messageManager
+                            .AppendInfoMessageInUiThread("Get Card Type: B_CPU");
+                    break;
+                case 0x0001:
+                    messageManager
+                            .AppendInfoMessageInUiThread("Get Card Type: CLASSIC_MINI");
+                    break;
+                case 0x0002:
+                    messageManager
+                            .AppendInfoMessageInUiThread("Get Card Type: CLASSIC_1K");
+                    break;
+                case 0x0003:
+                    messageManager
+                            .AppendInfoMessageInUiThread("Get Card Type: CLASSIC_4K");
+                    break;
+                case 0x0004:
+                    messageManager
+                            .AppendInfoMessageInUiThread("Get Card Type: UL_64");
+                    break;
+                case 0x0005:
+                    messageManager
+                            .AppendInfoMessageInUiThread("Get Card Type: UL_192");
+                    break;
+                case 0x0006:
+                    messageManager
+                            .AppendInfoMessageInUiThread("Get Card Type: MP_2K_SL1");
+                    break;
+                case 0x0007:
+                    messageManager
+                            .AppendInfoMessageInUiThread("Get Card Type: MP_4K_SL1");
+                    break;
+                case 0x0008:
+                    messageManager
+                            .AppendInfoMessageInUiThread("Get Card Type: MP_2K_SL2");
+                    break;
+                case 0x0009:
+                    messageManager
+                            .AppendInfoMessageInUiThread("Get Card Type: MP_4K_SL2");
+                    break;
+//                default:
+//                    messageManager.AppendInfoMessageInUiThread(
+//                            "Get Card Type: UNKNOW", Color.RED);
+                default:
+                    messageManager.AppendInfoMessageInUiThread(
+                            "Get Card Type: A_CPU", Color.BLACK);
+                    break;
+            }
+
+            ContactlessCardReader.CardInfo cardInfo = mContactlessCardReader.getCardInfo();
+            if (cardInfo != null) {
+                messageManager.AppendInfoMessageInUiThread("CardInfo of UID:"
+                        + StringUtility.getStringFormat(cardInfo.uid));
+            }
+
+            if (cardType == 0x0000 || cardType == 0x0100) {
+                testContactlessCardReaderIOApdu();
+            } else if (cardType == 0x0002 || cardType == 0x0003) {
+                testContactlessCardReaderIO_M1();
+            } else {
+                testContactlessCardReaderIOApdu();
+//                messageManager.AppendInfoMessageInUiThread("读写测试功能未完善",
+//                        Color.RED);
+            }
+        } else if (result == Error.TIMEOUT) {
+            messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.msg_card_time_out),
+                    Color.RED);
+        } else if (result == Error.DEVICE_FORCE_CLOSED) {
+            messageManager.AppendInfoMessageInUiThread(
+                    shower.getString(R.string.msg_card_close_succ), Color.RED);
+        } else {
+            messageManager.AppendInfoMessageInUiThread(
+                    shower.getString(R.string.msg_card_read_error), Color.RED);
+        }
+    }
+
+    void testContactlessCardReaderIO_M1() {
+        int iSecIdx = 0x02; //扇区02
+        int iBlkIdx = 0x02; //块02
+        byte[] pin = new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+                (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
+
+        int iRet = mContactlessCardReader.verifyPinMifare(iSecIdx, 0x0A, pin);
+        if (iRet >= 0) {
+            messageManager.AppendInfoMessageInUiThread("Sector " + iSecIdx
+                    + shower.getString(R.string.msg_card_verify_pass_succ), Color.GREEN);
+
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+
+            byte[] inData = new byte[] { (byte) 0x01, (byte) 0x02, (byte) 0x03,
+                    (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
+                    (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x0B,
+                    (byte) 0x0C, (byte) 0xA1, (byte) 0xB2, (byte) 0xC3,
+                    (byte) 0xD4 };
+
+            iRet = mContactlessCardReader.writeMifare(iSecIdx, iBlkIdx, inData);
+            if (iRet >= 0) {
+                messageManager.AppendInfoMessageInUiThread("Write [" + iSecIdx
+                        + ", " + iBlkIdx + "]:"
+                        + StringUtility.ByteArrayToString(inData, 16));
+            } else {
+                messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.msg_card_write_op_error), Color.RED);
+            }
+
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+
+            byte[] outBuf = new byte[16];
+
+            iRet = mContactlessCardReader.readMifare(iSecIdx, iBlkIdx, outBuf);
+            if (iRet >= 0) {
+                messageManager.AppendInfoMessageInUiThread("Read [" + iSecIdx
+                        + ", " + iBlkIdx + "]:"
+                        + StringUtility.ByteArrayToString(outBuf, iRet));
+            } else {
+                messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.msg_card_read_op_error), Color.RED);
+            }
+        } else {
+            messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.msg_card_verify_pass_error), Color.RED);
+        }
+    }
+
+    void testContactlessCardReaderIOApdu() {
+        // 00 A4 04 00 0E 2PAY.SYS.DDF01
+        byte[] apdu = new byte[] { (byte) 0x00, (byte) 0xA4, (byte) 0x04,
+                (byte) 0x00, (byte) 0x0E, 0x32, 0x50, 0x41, 0x59, 0x2E, 0x53,
+                0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31 };
+        byte[] ret = new byte[255];
+        int len = mContactlessCardReader.transmit(apdu, ret);
+        if (len >= 0) {
+            if (len >= 2 && ret[len - 2] == 97) {
+                apdu = new byte[] { 0x00, (byte) 0xC0, 0x00, 0x00,
+                        (byte) (ret[len - 1] & 0xFF) };
+                ret = new byte[255];
+                len = mContactlessCardReader.transmit(apdu, ret);
+            }
+        }
+        if (len >= 0) {
+            messageManager.AppendInfoMessageInUiThread("APDU:"
+                    + StringUtility.ByteArrayToString(ret, len));
+        } else {
+            messageManager.AppendInfoMessageInUiThread(
+                    shower.getString(R.string.msg_card_exe_apdu_error), Color.RED);
+        }
+    }
+
+    void testSmartCardReaderIO() {
+        // 00 A4 04 00 0E 1PAY.SYS.DDF01
+        byte[] apdu = new byte[] { (byte) 0x00, (byte) 0xA4, (byte) 0x04,
+                (byte) 0x00, (byte) 0x0E, 0x31, 0x50, 0x41, 0x59, 0x2E, 0x53,
+                0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31,0x00,0x00};
+        byte[] ret = new byte[255];
+        int len = mSmartCardReader.transmit(0, apdu, ret);
+        if (len >= 0) {
+            if (len >= 2 && ret[len - 2] == 97) {
+                apdu = new byte[] { 0x00, (byte) 0xC0, 0x00, 0x00,
+                        (byte) (ret[len - 1] & 0xFF) };
+                ret = new byte[255];
+                len = mSmartCardReader.transmit(0, apdu, ret);
+            }
+        }
+        if (len >= 0) {
+            messageManager.AppendInfoMessageInUiThread("APDU:"
+                    + StringUtility.ByteArrayToString(ret, len));
+        } else {
+            messageManager.AppendInfoMessageInUiThread(
+                    shower.getString(R.string.msg_card_exe_apdu_error), Color.RED);
+        }
+    }
+
+    private class MyHandler extends Handler {
+        public MyHandler(Looper looper) {
+            super(looper);
+        }
+
+        public void handleMessage(Message m) {
+            int what = m.what;
+            if (what == MSG_WAIT_FOR_CARD) {
+                if (mTestDeviceType == Device.TYPE_MAGSTRIPECARDREADER)
+                    testMagStripeCardReader();
+                else if (mTestDeviceType == Device.TYPE_SMARTCARDREADER) {
+                    testSmartCardReader();
+                } else if (mTestDeviceType == Device.TYPE_CONTACTLESSCARDREADER) {
+                    testContactlessCardReader();
+                }
+            } else if (what == MSG_SMARTCARD_REMOVED) {
+                messageManager.AppendInfoMessageInUiThread(
+                        shower.getString(R.string.msg_card_unplug_card), Color.RED);
+            }
+        }
+    }
+
+    private MyHandler myHandler;
+
+    private String trackFormat(byte[] data) {
+        if (data == null) {
+            return "no track info";
+        } else {
+            return new String(trackTrim(data));
+        }
+    }
+
+    private byte[] trackTrim(byte[] data) {
+        if (data == null) {
+            return null;
+        } else {
+            int end = 0;
+            for (int i = data.length - 1; i >= 0; i--) {
+                if (data[i] != 0) {
+                    end = i;
+                    break;
+                }
+            }
+            byte[] d = new byte[end + 1];
+            System.arraycopy(data, 0, d, 0, end + 1);
+            return d;
+        }
+    }
+
+    private final View.OnClickListener listener = new View.OnClickListener() {
+        @Override
+        public void onClick(View v) {
+            switch (v.getId()) {
+                case R.id.mag_open: {
+                    int nret = -1;
+                    if (mTestDeviceType == Device.TYPE_MAGSTRIPECARDREADER) {
+                        nret = mMagneticStripeCardReader
+                                .open();
+
+                    } else if (mTestDeviceType == Device.TYPE_SMARTCARDREADER) {
+                        nret = mSmartCardReader
+                                .open(0,
+                                        new SmartCardReader.SCReaderListener(){
+                                            @Override
+                                            public void notify(
+                                                    int nSlotIndex,
+                                                    int nEvent) {
+                                                if (nEvent == SmartCardReader.EVENT_SMARTCARD_NOT_READY) {
+                                                    myHandler
+                                                            .sendEmptyMessage(MSG_SMARTCARD_REMOVED);
+                                                }
+                                            }
+                                        });
+                    } else if (mTestDeviceType == Device.TYPE_CONTACTLESSCARDREADER) {
+                        nret = mContactlessCardReader
+                                .open();
+                    }
+                    if (nret >= 0) {
+                        messageManager
+                                .AppendInfoMessage(shower.getString(R.string.msg_card_open_success));
+                        messageManager
+                                .AppendInfoMessage(
+                                        shower.getString(R.string.msg_card_wait_for_card),
+                                        Color.GREEN);
+                        myHandler
+                                .sendEmptyMessage(MSG_WAIT_FOR_CARD);
+                    } else {
+                        messageManager
+                                .AppendInfoMessage(shower.getString(R.string.msg_card_open_error));
+                    }
+                }
+                break;
+                case R.id.mag_clear:
+                    messageManager.clear();
+                    break;
+                case R.id.mag_close: {
+                    int ret = -1;
+                    if (mTestDeviceType == Device.TYPE_MAGSTRIPECARDREADER) {
+                        ret = mMagneticStripeCardReader
+                                .close();
+                    } else if (mTestDeviceType == Device.TYPE_SMARTCARDREADER) {
+                        ret = mSmartCardReader
+                                .close();
+                    } else if (mTestDeviceType == Device.TYPE_CONTACTLESSCARDREADER) {
+                        ret = mContactlessCardReader
+                                .close();
+                    }
+                    if (ret >= 0) {
+                        messageManager
+                                .AppendInfoMessage(shower.getString(R.string.msg_card_close_succ));
+                    } else {
+                        messageManager
+                                .AppendInfoMessage(
+                                        shower.getString(R.string.msg_card_close_succ),
+                                        Color.RED);
+                    }
+                }
+
+                break;
+//            case R.id.mag_read: {
+//
+//                if (myHandler
+//                        .hasMessages(MSG_WAIT_FOR_CARD)) {
+//                    messageManager
+//                    .AppendInfoMessage(
+//                            R.string.info_wait_for_card_already,
+//                            Color.RED);
+//                } else {
+//                    int status = Device.STATUS_IDLE;
+//                    if (mTestDeviceType == Device.TYPE_MAGSTRIPECARDREADER) {
+//                        status = mMagneticStripeCardReader
+//                                .getStatus();
+//                    } else if (mTestDeviceType == Device.TYPE_SMARTCARDREADER) {
+//                        status = mSmartCardReader
+//                                .getStatus();
+//                    } else if (mTestDeviceType == Device.TYPE_CONTACTLESSCARDREADER) {
+//                        status = mContactlessCardReader
+//                                .getStatus();
+//                    }
+//
+//                    if (status == Device.STATUS_IN_ACTION) {
+//                        messageManager
+//                        .AppendInfoMessage(
+//                                R.string.info_wait_for_card_already,
+//                                Color.GREEN);
+//                    } else {
+//                        messageManager
+//                        .AppendInfoMessage(
+//                                R.string.info_wait_for_card,
+//                                Color.RED);
+//                        myHandler
+//                        .sendEmptyMessage(MSG_WAIT_FOR_CARD);
+//                    }
+//
+//                }
+//            }
+//            break;
+                default:
+                    break;
+            }
+        }
+    };
+}

+ 146 - 0
ZTHandPOS/app/src/main/assets/MainActivity.java

@@ -0,0 +1,146 @@
+package cn.zt.pos;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.AdapterView;
+import android.widget.ListView;
+import android.widget.SimpleAdapter;
+import cn.zt.pos.test.EMVActivity;
+import cn.zt.pos.test.PinPadActivity;
+import cn.zt.pos.test.PrinterActivity;
+import cn.zt.pos.test.ScanActivity;
+
+import com.szzt.sdk.device.Device;
+
+public class MainActivity extends BaseActivity {
+
+	private ListView mListView = null;
+	private final List<Map<String, Object>> data_list = new ArrayList<Map<String, Object>>();
+	@SuppressLint("NewApi")
+	@Override
+	protected void onCreate(Bundle savedInstanceState) {
+		super.onCreate(savedInstanceState);
+		requestWindowFeature(Window.FEATURE_NO_TITLE); 
+		setContentView(R.layout.activity_main);
+		MainApplication mainApplication = (MainApplication) getApplication();
+		mListView = (ListView) findViewById(R.id.listview);
+		mListView.setAdapter(getAdapter());
+		boolean isConnected = mainApplication.isDeviceManagerConnetcted();
+		mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+			@Override
+			public void onItemClick(AdapterView<?> parent, View view,
+					int position, long id) {
+				onClick(position);
+			}
+		});
+		init(isConnected);
+	}
+
+	public SimpleAdapter getAdapter() {
+		String[] arrays = getResources().getStringArray(R.array.test);
+		String[] from = { "text" };
+		int[] to = { R.id.listview_text };
+		for (int i = 0; i < arrays.length; i++) {
+			Map<String, Object> map = new HashMap<String, Object>();
+			map.put("text", arrays[i]);
+			data_list.add(map);
+		}
+		return new SimpleAdapter(this, data_list, R.layout.list_item, from, to);
+	}
+
+	@Override
+	public void onServiceConnected() {
+		init(true);
+		super.onServiceConnected();
+	}
+
+	@Override
+	public void onServiceDisconnected() {
+		init(false);
+		super.onServiceDisconnected();
+	}
+
+	private void init(boolean isConnected) {
+		mListView.setEnabled(isConnected);
+	}
+
+	public void onClick(int position) {
+		Intent intent = null;
+		switch (position) {
+		case 0:
+		case 1:
+		case 2: {
+			intent = new Intent();
+			intent.setClass(getApplicationContext(), CardActivity.class);
+			int type = Device.TYPE_UNKNOWN;
+			if (position == 0)
+				type = Device.TYPE_MAGSTRIPECARDREADER;
+			else if (position == 1)
+				type = Device.TYPE_CONTACTLESSCARDREADER;
+			else if (position == 2)
+				type = Device.TYPE_SMARTCARDREADER;
+			intent.putExtra("device-type", type);
+		}
+			break;
+		case 3:
+			intent = new Intent();
+			intent.setClass(getApplicationContext(), PinPadActivity.class);
+			break;
+		case 4:
+			intent = new Intent();
+			intent.setClass(getApplicationContext(), PrinterActivity.class);
+			break;
+		case 5:
+			intent = new Intent();
+			intent.setClass(getApplicationContext(), EMVActivity.class);
+			break;
+		case 6:
+			intent = new Intent();
+			intent.setClass(getApplicationContext(), ScanActivity.class);
+			break;
+		case 7:
+			System.exit(0);
+			System.gc();
+			break;
+		default:
+			break;
+		}
+		if (intent != null) {
+			startActivity(intent);
+		}
+	}
+
+	@Override
+	public boolean onCreateOptionsMenu(Menu menu) {
+		// Inflate the menu; this adds items to the action bar if it is present.
+		getMenuInflater().inflate(R.menu.menu_main, menu);
+		return true;
+	}
+
+	@Override
+	public boolean onOptionsItemSelected(MenuItem item) {
+		// Handle action bar item clicks here. The action bar will
+		// automatically handle clicks on the Home/Up button, so long
+		// as you specify a parent activity in AndroidManifest.xml.
+		int id = item.getItemId();
+
+		// noinspection SimplifiableIfStatement
+		if (id == R.id.action_settings) {
+			return true;
+		}
+
+		return super.onOptionsItemSelected(item);
+	}
+}

BIN
ZTHandPOS/app/src/main/assets/image/a.jpg


BIN
ZTHandPOS/app/src/main/assets/image/b.png


BIN
ZTHandPOS/app/src/main/assets/image/sb.png


+ 29 - 0
ZTHandPOS/app/src/main/java/com/yijia/zthandpos/MainAdapter.java

@@ -0,0 +1,29 @@
+package com.yijia.zthandpos;
+
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+
+public class MainAdapter extends BaseAdapter {
+
+	@Override
+	public int getCount() {
+		return 0;
+	}
+
+	@Override
+	public Object getItem(int arg0) {
+		return null;
+	}
+
+	@Override
+	public long getItemId(int arg0) {
+		return 0;
+	}
+
+	@Override
+	public View getView(int arg0, View arg1, ViewGroup arg2) {
+		return null;
+	}
+
+}

+ 62 - 0
ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/BaseActivity.java

@@ -0,0 +1,62 @@
+package com.yijia.zthandpos.pos;
+
+import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+
+import androidx.localbroadcastmanager.content.LocalBroadcastManager;
+
+public class BaseActivity extends Activity{
+    public MainApplication  mainApplication;
+    private LocalBroadcastManager mLocalBroadcastManager;
+    private ServiceEventBroadcastReceiver mBroadcastReceiver;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mainApplication = (MainApplication) getApplication();
+        mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);
+        mBroadcastReceiver = new ServiceEventBroadcastReceiver();
+    }
+
+    public void onServiceConnected() {
+
+    }
+
+    public void onServiceDisconnected() {
+
+    }
+
+    private class ServiceEventBroadcastReceiver extends BroadcastReceiver {
+
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            String action = intent.getAction();
+            if (action.equals(MainApplication.ACTION_SERVICE_CONNECTED)) {
+                BaseActivity.this.onServiceConnected();
+            } else if (action
+                    .equals(MainApplication.ACTION_SERVICE_DISCONNECTED)) {
+                BaseActivity.this.onServiceDisconnected();
+            }
+        }
+    }
+
+    @Override
+    protected void onResume() {
+        IntentFilter ifIntentFilter = new IntentFilter();
+        ifIntentFilter.addAction(MainApplication.ACTION_SERVICE_CONNECTED);
+        ifIntentFilter.addAction(MainApplication.ACTION_SERVICE_DISCONNECTED);
+        mLocalBroadcastManager.registerReceiver(mBroadcastReceiver,
+                ifIntentFilter);
+        super.onResume();
+    }
+
+    @Override
+    protected void onStop() {
+        mLocalBroadcastManager.unregisterReceiver(mBroadcastReceiver);
+        super.onStop();
+    }
+}

+ 257 - 0
ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/MainApplication.java

@@ -0,0 +1,257 @@
+package com.yijia.zthandpos.pos;
+
+import android.app.Application;
+import android.content.Intent;
+import android.media.AudioFormat;
+import android.media.AudioTrack;
+import android.os.Handler;
+import android.widget.Toast;
+
+import com.szzt.android.util.SzztDebug;
+import com.szzt.sdk.device.Device;
+import com.szzt.sdk.device.DeviceManager;
+import com.szzt.sdk.device.DeviceManager.DeviceManagerListener;
+import com.szzt.sdk.device.FileSystem;
+import com.szzt.sdk.device.barcode.Barcode;
+import com.szzt.sdk.device.barcode.CameraScan;
+import com.szzt.sdk.device.card.ContactlessCardReader;
+import com.szzt.sdk.device.card.IDCardReader;
+import com.szzt.sdk.device.card.MagneticStripeCardReader;
+import com.szzt.sdk.device.card.SmartCardReader;
+import com.szzt.sdk.device.emv.EmvInterface;
+import com.szzt.sdk.device.led.Led;
+import com.szzt.sdk.device.pinpad.PinPad;
+import com.szzt.sdk.device.port.SerialPort;
+import com.szzt.sdk.device.printer.Printer;
+import com.szzt.sdk.system.HwSecurityManager;
+import com.szzt.sdk.system.SystemManager;
+import com.szzt.sdk.system.net.NetManager;
+import com.yijia.zthandpos.pos.test.WaveFileReader;
+
+import java.io.InputStream;
+
+import androidx.localbroadcastmanager.content.LocalBroadcastManager;
+
+
+public class MainApplication extends Application {
+    private DeviceManager mDeviceManager;
+    private SystemManager mSystemManager;
+    private boolean isConnect = false;
+    LocalBroadcastManager mLocalBroadcastManager;
+    public static String  ACTION_SERVICE_CONNECTED    = "DEVICEMANAGER_SERVICE_CONNECTED";
+    public static String  ACTION_SERVICE_DISCONNECTED = "DEVICEMANAGER_SERVICE_DISCONNECTED";
+    Intent mServiceConnectedIntent = new Intent(ACTION_SERVICE_CONNECTED);
+    Intent mServiceDisConnectedIntent  = new Intent(ACTION_SERVICE_DISCONNECTED);
+    public static int printIndex = 0;
+
+    @Override
+    public void onCreate() {
+        // TODO Auto-generated method stub
+        mDeviceManager = DeviceManager.createInstance(this);
+        mDeviceManager.start(deviceManagerListener);
+        mDeviceManager.getSystemManager();
+        mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);
+        super.onCreate();
+    }
+    
+    public SerialPort getSerialPortWrapperImpl(){
+    	Device[] pinPads = mDeviceManager.getDeviceByType(Device.TYPE_SERIALPORT);
+        if (pinPads != null)
+            return (SerialPort) pinPads[0];
+        return null;
+    }
+    
+   /* public Android getAndroid(){
+    	Device[] android = mDeviceManager.getDeviceByType(Device.TYPE_ANDROID);
+    	if(android!=null){
+    		return (Android) android[0];
+    	}return null ;
+    }*/
+    
+    /*public Identifier getIdentifier(){
+    	Device[] identify = mDeviceManager.getDeviceByType(Device.TYPE_IDC);
+    	if(identify!=null){
+    		return (Identifier)identify[0];
+    	}return null ;
+    }*/
+    
+    public Led getLedWrapperImpl(){
+    	Device[] pinPads = mDeviceManager.getDeviceByType(Device.TYPE_LED);
+        if (pinPads != null)
+            return (Led) pinPads[0];
+        return null;
+    }
+    public FileSystem getFileSystemWrapperImpl(){
+    	Device[] pinPads = mDeviceManager.getDeviceByType(Device.TYPE_FILESYSTEM);
+        if (pinPads != null)
+            return (FileSystem) pinPads[0];
+        return null;
+    }
+   /* public Net getNetWrapperImpl(){
+    	Device[] pinPads = mDeviceManager.getDeviceByType(Device.TYPE_NET);
+        if (pinPads != null)
+            return (Net) pinPads[0];
+        return null;
+    }*/
+
+    public SmartCardReader getSmartCardReader() {
+        Device[] smartCardReaders = mDeviceManager.getDeviceByType(Device.TYPE_SMARTCARDREADER);
+        if (smartCardReaders != null)
+            return (SmartCardReader) smartCardReaders[0];
+        return null;
+    }
+
+    public PinPad getPinPad() {
+        Device[] pinPads = mDeviceManager.getDeviceByType(Device.TYPE_PINPAD);
+        if (pinPads != null)
+            return (PinPad) pinPads[0];
+        return null;
+    }
+    
+   /* public D5000Printer getD5000P() {
+        Device[] pinPads = mDeviceManager.getDeviceByType(Device.TYPE_D5000);
+        if (pinPads != null)
+            return (D5000Printer) pinPads[0];
+        return null;
+    }*/
+
+    public EmvInterface getEmvInterface() {
+        return mDeviceManager.getEmvInterface();
+    }    
+    AudioTrack at;
+	public synchronized int wavePlay( byte[]value, final float volume) {
+		if (at != null){
+			at.stop();
+			at.release();
+			at = null;
+		}
+		byte[] buffer=value;
+		int pcmlen= value.length;
+		int channel = 1;
+		at = new AudioTrack(7, 8000,   
+				channel,
+				AudioFormat.ENCODING_PCM_8BIT,   
+				pcmlen,   
+				AudioTrack.MODE_STATIC); 
+		at.write(buffer, 0, pcmlen);
+		at.play();
+		return 0;
+	}
+	private final Handler mHandler=new Handler();
+    public void playWav(final int mId,int delayTime){
+    	SzztDebug.d("MainApplication", "playWav");
+    	mHandler.postDelayed(new Runnable() {
+			
+			@Override
+			public void run() {
+				InputStream is =getResources().openRawResource(mId);        
+				WaveFileReader read = new WaveFileReader(is);
+				byte [] data = read.getPcmData();
+				wavePlay(data,80);
+			}
+		}, delayTime);
+	}
+    public Printer getPrinter() {
+        Device[] printers = mDeviceManager.getDeviceByType(Device.TYPE_PRINTER);
+        if (printers != null)
+            return (Printer) printers[0];
+        return null;
+    }
+
+    public ContactlessCardReader getContactlessCardReader() {
+        Device[] contactlessCards = mDeviceManager
+                .getDeviceByType(Device.TYPE_CONTACTLESSCARDREADER);
+        if (contactlessCards != null)
+            return (ContactlessCardReader) contactlessCards[0];
+        return null;
+    }
+
+    public MagneticStripeCardReader getMagneticStripeCardReader() {
+        Device[] magStripCards = mDeviceManager
+                .getDeviceByType(Device.TYPE_MAGSTRIPECARDREADER);
+        if (magStripCards != null)
+            return (MagneticStripeCardReader) magStripCards[0];
+
+        return null;
+    }
+    public IDCardReader getIDCardReader(){
+   	 Device[] idCards = mDeviceManager.getDeviceByType(Device.TYPE_IDCARDREADER);
+     if (idCards != null)
+         return (IDCardReader) idCards[0];
+         return null;
+    }
+
+
+    public SystemManager getSystemManager() {
+        if (mSystemManager == null) {
+            mSystemManager =SystemManager.getInstance(this);
+        }
+        return mSystemManager;
+    }
+
+    public HwSecurityManager getHwSecurityManager() {
+        getSystemManager();
+//        SzztDebug.e("getHwSecurityManager", "mSystemManager=="+mSystemManager);
+        if(mSystemManager!=null){
+//        	SzztDebug.e("HwSecurityManager", "HwSecurityManager=="+mSystemManager.getHwSecurityManager());
+        	return mSystemManager.getHwSecurityManager();
+        }else return null;
+    }
+
+    public NetManager getNetworkManager() {
+        getSystemManager();
+        return mSystemManager.getNetManager();
+    }
+
+    public boolean isDeviceManagerConnetcted() {
+        return isConnect;
+    }
+
+    @Override
+    public void onTerminate() {
+        mDeviceManager.stop();
+        DeviceManager.destroy();
+        mDeviceManager = null;
+        super.onTerminate();
+    }
+    public CameraScan getCameraScanImpl(){
+    	Device[] barcode = mDeviceManager.getDeviceByType(Device.TYPE_CAMERA_SCAN);
+        if (barcode != null)
+            return (CameraScan) barcode[0];
+
+        return null;
+    }
+    public Barcode getBarcodeImpl(){
+    	Device[] barcode = mDeviceManager.getDeviceByType(Device.TYPE_BARCODE);
+    	if (barcode != null)
+    		return (Barcode) barcode[0];
+    	
+    	return null;
+    }
+
+    DeviceManagerListener deviceManagerListener = new DeviceManagerListener() {
+        @Override
+        public int serviceEventNotify(
+                int event) {
+            if (event == EVENT_SERVICE_CONNECTED) {
+                isConnect = true;
+                mLocalBroadcastManager.sendBroadcast(mServiceConnectedIntent);
+            } else if (event == EVENT_SERVICE_VERSION_NOT_COMPATABLE) {
+                Toast.makeText(MainApplication.this,"SDK Version is not compatable!!!",Toast.LENGTH_SHORT).show();
+            } else if (event == EVENT_SERVICE_DISCONNECTED) {
+                isConnect = false;
+                mDeviceManager.start(deviceManagerListener);
+                mLocalBroadcastManager.sendBroadcast(mServiceDisConnectedIntent);
+            }
+            return 0;
+        }
+
+        @Override
+        public int deviceEventNotify(
+                Device device,
+                int event) {
+            // TODO Auto-generated method stub
+            return 0;
+        }
+    };
+}

+ 237 - 0
ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/NewMainActivity.java

@@ -0,0 +1,237 @@
+package com.yijia.zthandpos.pos;
+
+import android.annotation.SuppressLint;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.graphics.Color;
+import android.graphics.drawable.GradientDrawable;
+import android.os.Bundle;
+import android.os.SystemClock;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.Window;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+
+import com.yijia.zthandpos.pos.test.EMVActivity;
+import com.yijia.zthandpos.pos.test.ICCardActivity;
+import com.yijia.zthandpos.pos.test.MagCardActivity;
+import com.yijia.zthandpos.pos.test.PinPadActivity;
+import com.yijia.zthandpos.pos.test.PrinterActivity;
+import com.yijia.zthandpos.pos.test.PsamCardActivity;
+import com.yijia.zthandpos.pos.test.RFCardActivity;
+import com.yijia.zthandpos.pos.test.ScanActivity;
+import com.yijia.zthandpos.pos.test.SystemManagerActivity;
+
+
+public class NewMainActivity extends BaseActivity {
+	private LinearLayout lin_citiao,lin_psam,lin_pinpad,
+			lin_printer, lin_emv, lin_camera, lin_exit, lin_all,
+			lin_cantact,lin_cantactless,lin_idcard,lin_serial,lin_SystemManager,lin_HWsecurity;
+	private ImageView img_touch;
+	@Override
+	protected void onCreate(Bundle savedInstanceState) {
+		super.onCreate(savedInstanceState);
+		requestWindowFeature(Window.FEATURE_NO_TITLE);
+		setContentView(R.layout.activity_new_main);
+		MainApplication mainApplication = (MainApplication) getApplication();
+		boolean isConnected = mainApplication.isDeviceManagerConnetcted();
+		initView(isConnected);
+	}
+
+	private void initView(boolean isConnect) {
+		lin_all = (LinearLayout) findViewById(R.id.lin_all);
+		lin_all.setEnabled(isConnect);
+
+		lin_citiao = (LinearLayout) findViewById(R.id.lin_citiao);
+		setBackShapeNo(lin_citiao, "#6495ED");
+		lin_citiao.setOnClickListener(mClick);
+		
+		lin_psam = (LinearLayout) findViewById(R.id.lin_psam);
+		setBackShapeNo(lin_psam, "#6495ED");
+		lin_psam.setOnClickListener(mClick);
+		
+		lin_cantact = (LinearLayout) findViewById(R.id.lin_cantact);
+		setBackShapeNo(lin_cantact, "#63B8FF");
+		lin_cantact.setOnClickListener(mClick);
+
+		lin_cantactless = (LinearLayout) findViewById(R.id.lin_cantactless);
+		setBackShapeNo(lin_cantactless, "#63B8FF");
+		lin_cantactless.setOnClickListener(mClick);
+
+		lin_pinpad = (LinearLayout) findViewById(R.id.lin_pinpad);
+		setBackShapeNo(lin_pinpad, "#6495ED");
+		lin_pinpad.setOnClickListener(mClick);
+
+		lin_printer = (LinearLayout) findViewById(R.id.lin_printer);
+		setBackShapeNo(lin_printer, "#6495ED");
+		lin_printer.setOnClickListener(mClick);
+
+		lin_emv = (LinearLayout) findViewById(R.id.lin_emv);
+		setBackShapeNo(lin_emv, "#63B8FF");
+		lin_emv.setOnClickListener(mClick);
+
+		lin_camera = (LinearLayout) findViewById(R.id.lin_camera);
+		setBackShapeNo(lin_camera, "#63B8FF");
+		lin_camera.setOnClickListener(mClick);
+		
+		lin_SystemManager = (LinearLayout) findViewById(R.id.lin_SystemManager);
+		setBackShapeNo(lin_SystemManager, "#63B8FF");
+		lin_SystemManager.setOnClickListener(mClick);
+
+		
+		lin_exit = (LinearLayout) findViewById(R.id.lin_exit);
+		setBackShapeNo(lin_exit, "#9370DB");
+		lin_exit.setOnClickListener(mClick);
+		
+		img_touch = (ImageView) findViewById(R.id.img_touch);
+		img_touch.setOnClickListener(mfullClick);
+	}
+
+	/**
+	 *
+	 */
+	private EditText editText;
+	private final android.view.View.OnClickListener mfullClick = new View.OnClickListener() {
+		final long[] mHints = new long[6];
+		@Override
+		public void onClick(View arg0) {
+			System.arraycopy(mHints, 1, mHints, 0, mHints.length - 1);
+			mHints[mHints.length - 1] = SystemClock.uptimeMillis();
+			if (SystemClock.uptimeMillis() - mHints[0] <= 2000) {
+				AlertDialog.Builder builder = new AlertDialog.Builder(
+						NewMainActivity.this);
+				builder.setTitle(getString(R.string.chooice_config_item));
+				builder.setItems(R.array.touchConfig, new DialogInterface.OnClickListener() {
+					
+					@Override
+					public void onClick(DialogInterface arg0, int which) {
+						arg0.dismiss();
+	            		switch (which) {
+						case 0:
+							printerConfig();
+							break;
+
+						default:
+							break;
+						}
+					}
+				});
+				builder.setNegativeButton(getString(R.string.input_loop_index_cancel),
+						new DialogInterface.OnClickListener() {
+
+							@Override
+							public void onClick(DialogInterface dialog, int arg1) {
+								dialog.cancel();
+							}
+						});
+				AlertDialog dialog = builder.create();
+				dialog.setCanceledOnTouchOutside(false);
+				dialog.show();
+			}
+
+		}
+	};
+	/**
+	 * print config
+	 */
+	private void printerConfig() {
+		editText  = new EditText(NewMainActivity.this);
+    	AlertDialog.Builder builder = new AlertDialog.Builder(NewMainActivity.this);
+    	builder.setTitle(getString(R.string.input_loop_index));
+    	builder.setView(editText);
+    	builder.setNegativeButton(getString(R.string.input_loop_index_cancel), new DialogInterface.OnClickListener() {
+			
+			@Override
+			public void onClick(DialogInterface arg0, int arg1) {
+				arg0.dismiss();
+			}
+		});
+    	builder.setPositiveButton(getString(R.string.input_loop_index_submit), new DialogInterface.OnClickListener() {
+			
+			@Override
+			public void onClick(DialogInterface arg0, int arg1) {
+				MainApplication.printIndex = Integer.valueOf(editText.getText().toString().trim());
+				arg0.dismiss();
+			}
+		});
+    	AlertDialog alertDialog = builder.create();
+    	alertDialog.show();
+	}
+	private final OnClickListener mClick = new OnClickListener() {
+
+		@Override
+		public void onClick(View v) {
+			Intent intent = null;
+			switch (v.getId()) {
+			case R.id.lin_citiao:
+				intent = new Intent();
+				intent.setClass(getApplicationContext(), MagCardActivity.class);
+				break;
+			case R.id.lin_psam:
+				intent = new Intent();
+				intent.setClass(getApplicationContext(), PsamCardActivity.class);
+				break;
+			case R.id.lin_pinpad:
+				intent = new Intent();
+				intent.setClass(getApplicationContext(), PinPadActivity.class);
+				break;
+			case R.id.lin_printer:
+				intent = new Intent();
+				intent.setClass(getApplicationContext(), PrinterActivity.class);
+				break;
+			case R.id.lin_emv:
+				intent = new Intent();
+				intent.setClass(getApplicationContext(), EMVActivity.class);
+				break;
+			case R.id.lin_camera:
+				intent = new Intent();
+				intent.setClass(getApplicationContext(), ScanActivity.class);
+				break;
+			case R.id.lin_cantact:
+				intent = new Intent();
+				intent.setClass(getApplicationContext(), ICCardActivity.class);
+				break;
+			case R.id.lin_cantactless:
+				intent = new Intent();
+				intent.setClass(getApplicationContext(), RFCardActivity.class);
+				break;
+			case R.id.lin_SystemManager:
+				intent = new Intent();
+				intent.setClass(getApplicationContext(), SystemManagerActivity.class);
+				break;
+			case R.id.lin_exit:
+				System.exit(0);
+				System.gc();
+				break;
+			}
+			if (intent != null) {
+				startActivity(intent);
+			}
+		}
+	};
+	@SuppressLint("NewApi")
+	private static void setBackShapeNo(View view, String color) {
+		int roundRadius = 6; 
+		int fillColor = Color.parseColor(color); 
+		GradientDrawable gd = new GradientDrawable(); 
+		gd.setColor(fillColor);
+		gd.setCornerRadius(roundRadius);
+		view.setBackground(gd);
+	}
+
+	@Override
+	public void onServiceConnected() {
+		initView(true);
+		super.onServiceConnected();
+	}
+
+	@Override
+	public void onServiceDisconnected() {
+		initView(false);
+		super.onServiceDisconnected();
+	}
+
+}

+ 617 - 0
ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/test/EMVActivity.java

@@ -0,0 +1,617 @@
+package com.yijia.zthandpos.pos.test;
+
+import android.graphics.Color;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.Looper;
+import android.os.Message;
+import android.text.method.ScrollingMovementMethod;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.Window;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.szzt.sdk.device.Constants;
+import com.szzt.sdk.device.card.ContactlessCardReader;
+import com.szzt.sdk.device.card.SmartCardReader;
+import com.szzt.sdk.device.emv.EMV_STATUS;
+import com.szzt.sdk.device.emv.EmvInterface;
+import com.szzt.sdk.device.pinpad.PinPad;
+import com.szzt.sdk.device.pinpad.PinPad.OnSendKeyListerner;
+import com.yijia.zthandpos.pos.BaseActivity;
+import com.yijia.zthandpos.pos.R;
+import com.yijia.zthandpos.pos.utils.HexDump;
+import com.yijia.zthandpos.pos.utils.MessageManager;
+import com.yijia.zthandpos.pos.utils.Shower;
+import com.yijia.zthandpos.pos.utils.StringUtil;
+import com.yijia.zthandpos.pos.utils.StringUtility;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+
+public class EMVActivity extends BaseActivity {
+	private static final int MSG_WAIT_FOR_CARD = 0;
+	private MessageManager messageManager;
+    private EmvInterface emvInterface;
+    private PinPad pinPad;
+    private Button  mClearButton;
+    private Button  mEmvStart;
+    private Button  mEmvClose;
+    private Button  mEmvElectronic;
+    private Button  mElectronicCashInquiry;
+    private Button  mEmvSetParam;
+    private HandlerThread            mWaitForCardHandlerThread;
+    volatile boolean         mIsWaitingForCard = false;
+    volatile boolean         mHasCard          = false;
+    private MyHandler        myHandler;
+    private static ArrayList<byte[]> mAIDParams;
+    private static ArrayList<byte[]> mCAPKParams;
+
+    private static ArrayList<String> mAIDParamInString;
+    private static ArrayList<String> mCAPKParamInString;
+    
+    private static String  mTermInfo;
+    private Shower shower ;
+    private byte mTransType=EmvInterface.TRANS_GOODS_SERVICE;
+    private static final int EMV_WAIT_CARD = 113;
+    private static final int EMV_ELECTRO_CASH_WAIT_CARD = 114;
+    private static final int EMV_ELECT_TRANS_WAIT_CARD = 115;
+    private class MyHandler extends Handler {
+        public MyHandler(Looper looper) {
+            super(looper);
+        }
+        public void handleMessage(Message m) {
+            int what = m.what;
+            if(what == EmvInterface.EMV_PROCESS_MSG){
+                int status = m.arg1;
+                int retcode = m.arg2;
+                EmvTest(status,retcode);
+            }else if(what == EmvInterface.EMV_CARD_MSG){
+                int removed = m.arg1;
+                if(removed == EmvInterface.CARD_REMOVED){
+                    
+                }
+            }else if (what == MSG_WAIT_FOR_CARD) {
+            }else if (what == EMV_WAIT_CARD) {
+				messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.msg_emv_wait_card),
+	                     Color.GREEN);
+			}else if(what == EMV_ELECTRO_CASH_WAIT_CARD)
+			{
+				messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.info_get_electro_cash),
+	                     Color.GREEN);
+			}else if(what == EMV_ELECT_TRANS_WAIT_CARD)
+			{
+				messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.info_emv_elect_trans_wait_card),
+	                     Color.GREEN);
+			}
+        }
+    }
+    private final Handler handler=new Handler(Looper.getMainLooper());
+    //接触卡 isEmvInit:true 电子现金 ; false:联机交易
+    private void smart_emv(boolean isEmvInit){
+    	if (!mIsWaitingForCard) {
+            mIsWaitingForCard = true;
+            int result = smartCardReader.waitForCard(0, Constants.WAIT_INFINITE);
+	          if (result < 0) {
+	        	  messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.info_card_contact)+shower.getString(R.string.msg_card_read_error));
+	          } else {
+	        	  contactlessCardReader.close();
+	        	  messageManager.AppendInfoMessageInUiThread("Contact card");
+	        	  byte[] data=new byte[256];
+	        	  int ret=smartCardReader.powerOn(0, data);
+	        	  if(ret>0){
+	        		  if(!isEmvInit)
+	        		  {
+	        			  smart();
+	        		  }else{
+	        			  EmvInit(data, EmvInterface.READER_TYPE_CONTACT_CARD);
+	        		  }
+	        	  }
+	              	
+	          }
+	          mIsWaitingForCard = false;
+        }
+    }
+    
+    private void smart(){
+    	emvInterface.setForceOnline(1);
+		emvInterface.initialize(myHandler);
+	    byte[] term = HexDump.hexStringToByteArray("9F660436800080");
+		emvInterface.setTerminalParam(term);
+		emvInterface.preprocess(1);
+		emvInterface.setCardType( EmvInterface.READER_TYPE_CONTACT_CARD);
+        emvInterface.setTransAmount(1);		             
+        emvInterface.setTransType(EmvInterface.TRANS_GOODS_SERVICE);        
+        emvInterface.process();
+    }
+    private void EmvInit(byte[] atr,int result) {
+    	emvInterface.initialize(myHandler);
+    	emvInterface.preprocess(0);
+    	emvInterface.setTransAmount(1);
+    	emvInterface.setCardType(result);
+        emvInterface.setTransType(mTransType);        
+        emvInterface.process();		
+	}
+    //非接卡 isEmvInit:false电子现金 ;true:联机交易
+    volatile boolean mIsWaitingForCard2 = false;
+    private void contact_emv(boolean isEmvInit){
+    	if (!mIsWaitingForCard2) {
+    		mIsWaitingForCard2 = true;
+            int result = contactlessCardReader.waitForCard(Constants.WAIT_INFINITE);
+	          if (result < 0) {
+	        	  messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.info_card_contactless)+shower.getString(R.string.msg_card_read_error));
+
+	          } else {
+	        	  smartCardReader.close();
+	        	  handler.post(new Runnable() {
+						@Override
+						public void run() {
+							 messageManager.AppendInfoMessage("Contactless card");
+						}
+					});
+	        	  byte[] data=new byte[256];
+	        	  int ret=contactlessCardReader.powerOn( data);
+	        	  if(ret>0){
+	        		  if(!isEmvInit)
+	        		  {
+		        		  emvInterface.setForceOnline(1);
+		        		  emvInterface.initialize(myHandler);
+		        		  byte[] term = HexDump.hexStringToByteArray("9F660436800080");
+		  				  emvInterface.setTerminalParam(term);
+		        		  emvInterface.preprocess(1);
+		        		  emvInterface.setCardType( EmvInterface.READER_TYPE_CONTACTLESS_CARD);
+			              emvInterface.setTransAmount(1);		              
+			              emvInterface.setTransType(EmvInterface.TRANS_GOODS_SERVICE);        
+			              emvInterface.process();	  
+	        		  }else{
+	        			  EmvInit(data, EmvInterface.READER_TYPE_CONTACTLESS_CARD);
+	        		  }
+	        	  }
+	          }
+	          mIsWaitingForCard2 = false;
+        }
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        requestWindowFeature(Window.FEATURE_NO_TITLE); 
+        setContentView(R.layout.activity_emv);
+        shower = new Shower(this);
+        boolean isConnected = mainApplication.isDeviceManagerConnetcted();
+        init(isConnected);
+        loadEmvParam();
+    }
+    
+    @Override
+    public void onResume() {
+        messageManager.AppendInfoMessage(shower.getString(R.string.test_emv));
+        if (mWaitForCardHandlerThread == null) {
+            mWaitForCardHandlerThread = new HandlerThread("wait_for_card");
+        }
+        mWaitForCardHandlerThread.start();
+        myHandler = new MyHandler(mWaitForCardHandlerThread.getLooper());
+        super.onResume();
+    }
+    
+    @Override
+    public void onDestroy() {
+        emvInterface.processExit();
+        myHandler.removeMessages(MSG_WAIT_FOR_CARD);
+        myHandler.getLooper().quit();
+        myHandler = null;
+        mWaitForCardHandlerThread = null;
+        mIsWaitingForCard = false;
+        mIsWaitingForCard2 = false ;
+        pinPad.close();
+        super.onDestroy();
+    }
+
+    private SmartCardReader smartCardReader = null ;
+    private ContactlessCardReader contactlessCardReader = null ;
+    private void init(boolean isConnected) {
+        if (messageManager == null) {
+            TextView text = (TextView) findViewById(R.id.emv_text);
+            text.setMovementMethod(ScrollingMovementMethod.getInstance());
+            messageManager = new MessageManager(this, text);
+            mClearButton = (Button) findViewById(R.id.emv_clear);
+            mClearButton.setOnClickListener(listener);
+            mEmvStart = (Button) findViewById(R.id.emv_start);
+            mEmvStart.setOnClickListener(listener);
+            mEmvClose = (Button) findViewById(R.id.emv_stop);
+            mEmvClose.setOnClickListener(listener);
+            mEmvElectronic = (Button) findViewById(R.id.emv_electronic_cash);
+            mEmvElectronic.setOnClickListener(listener);
+            mElectronicCashInquiry = (Button) findViewById(R.id.emv_electronic_cash_inquiry);
+            mElectronicCashInquiry.setOnClickListener(listener);
+            mEmvSetParam = (Button) findViewById(R.id.emv_set_param);
+            mEmvSetParam.setOnClickListener(listener);
+            emvInterface = mainApplication.getEmvInterface();
+            smartCardReader = mainApplication.getSmartCardReader();
+            contactlessCardReader = mainApplication.getContactlessCardReader();
+            pinPad = mainApplication.getPinPad();
+        }
+        mClearButton.setEnabled(isConnected);
+        mEmvStart.setEnabled(isConnected);
+        mEmvClose.setEnabled(isConnected);
+    }
+
+    private final OnClickListener listener = new OnClickListener() {
+
+        @Override
+        public void onClick(View v) {
+            switch (v.getId()) {
+            case R.id.emv_clear:
+                messageManager.clear();
+                break;
+            //联机交易
+            case R.id.emv_start:
+           	 	myHandler.sendEmptyMessage(EMV_WAIT_CARD);
+           	 	mTransType=EmvInterface.TRANS_GOODS_SERVICE;
+			    openCardRead(false);
+            	break;
+            //电子现金查询
+            case R.id.emv_electronic_cash_inquiry:
+            	myHandler.sendEmptyMessage(EMV_ELECTRO_CASH_WAIT_CARD);
+            	mTransType = (byte) 0xF4;
+            	openCardRead(true);
+            	break;
+            //电子现金交易
+            case R.id.emv_electronic_cash:
+            	myHandler.sendEmptyMessage(EMV_ELECT_TRANS_WAIT_CARD);
+            	mTransType=EmvInterface.TRANS_GOODS_SERVICE;
+            	openCardRead(true);
+            	break;
+            //设置参数
+            case R.id.emv_set_param:
+            	emvSetParam();
+            	break;
+            //停止测试
+            case R.id.emv_stop:
+            	closeReader();
+            	break;
+            default:
+                break;
+            }
+        }
+    };
+    
+    //非接卡、接触卡
+    private void openCardRead(final boolean isEmvInit){
+    	 int res = smartCardReader.open(0, new SmartCardReader.SCReaderListener() {
+				
+				@Override
+				public void notify(int nSlotIndex, int nEvent) {
+					
+				}
+			});
+		    if(res>=0){
+		    	new Thread(){
+		    		public void run(){
+		    			smart_emv(isEmvInit);
+		    		}
+		    	}.start();
+		    }
+     	
+     	int res2 = contactlessCardReader.open();
+		    if(res2>=0){
+		    	new Thread(){
+		    		public void run(){
+		    			contact_emv(isEmvInit);
+		    		}
+		    	}.start();
+		 }
+    }
+    
+    //设置参数
+    private void emvSetParam(){
+    	new Thread(new Runnable() {
+			
+			@Override
+			public void run() {
+				loadEmvParam();
+				setEmvParam();
+			}
+		}).start();
+    }
+    private void loadEmvParam(){
+        if(mAIDParams == null){
+            mAIDParams = new ArrayList<byte[]>();
+            mCAPKParams = new ArrayList<byte[]>();
+            mAIDParamInString = new ArrayList<String>();
+            mCAPKParamInString = new ArrayList<String>();
+        }
+        if(mAIDParams.size() != 0 || mCAPKParams.size() != 0){
+            return;
+        }
+        try {
+            InputStreamReader inputReader = new InputStreamReader(
+                    getResources().openRawResource(R.raw.params));
+            BufferedReader bufferedReader = new BufferedReader(inputReader);
+            ArrayList<byte[]> activeList = null;
+            ArrayList<String> stringList = null;
+            while(true){
+                String line = bufferedReader.readLine();
+                if(line == null)
+                    break;
+                if(line.startsWith("AID=")){
+                    activeList = mAIDParams;
+                    stringList = mAIDParamInString;
+                    continue;
+                }else if(line.startsWith("CAPK=")){
+                    activeList = mCAPKParams;
+                    stringList = mCAPKParamInString;
+                    continue;
+                }else if(line.startsWith("TERM=")){
+                    line = bufferedReader.readLine();
+                    mTermInfo = line;
+                    continue;
+                }
+                stringList.add(line);
+                byte[] data = StringUtil.hexString2bytes(line);
+                activeList.add(data);
+            }
+            bufferedReader.close();
+            inputReader.close();
+        } catch (Exception e) {
+            messageManager.AppendInfoMessageInUiThread(
+                    shower.getString(R.string.msg_emv_load_para_error) + e.getMessage());
+        }
+    }
+    
+    private void setEmvParam() {
+        int index = 0;
+        for(byte[] param:mAIDParams){
+            int nret = emvInterface.updateAidParam(1, param);
+            messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.msg_emv_init_aid) + (index)
+                    +"]=" + mAIDParamInString.get(index++) + " = " + nret);
+        }
+        index = 0;
+        for(byte[] param:mCAPKParams){
+            int nret = emvInterface.updateCAPKParam(1, param);
+            messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.msg_emv_init_capk) + (index)
+                    +"]=" + mCAPKParamInString.get(index++) + " = " + nret);
+        }
+        if(mTermInfo != null){
+            int nret = emvInterface.setTerminalParam(StringUtil.hexString2bytes(mTermInfo));
+            messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.msg_emv_init_teminal)+nret);
+        }
+    }
+
+    private void EmvTest(int status,int retcode) {
+    	Log.e("EmvTest", "status:"+status+" retcode:"+retcode);
+        if(status == EmvInterface.STATUS_CONTINUE){
+            switch(retcode){
+            //请求选择候选应用列表
+            case EMV_STATUS.EMV_REQ_SEL_CANDIDATES:
+            //请求再次选择候选列表
+            case EMV_STATUS.EMV_REQ_SEL_CANDIDATES_AGAIN:
+                byte[] candidateList = new byte[300];
+                int length = emvInterface.getCardCandidateList(candidateList);
+                if(length <= 0){
+                    emvInterface.process();
+                    return;
+                }
+                int nret = emvInterface.setCardCandidateListResult(10);
+                messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.msg_emv_sum_up)+length +
+                        shower.getString(R.string.msg_emv_apps) + shower.getString(R.string.msg_emv_chose_app)
+                        + nret);
+                emvInterface.process();
+                break;
+             //请求持卡人输入联机pin   
+            case EMV_STATUS.EMV_REQ_ONLINE_PIN:
+            	//输入联机pin
+            	onlinePinPad();
+            	break;
+            //请求联机交易
+            case EMV_STATUS.EMV_REQ_GO_ONLINE:
+            	byte[] data=new byte[256];
+            	byte[] recvFiled55=new byte[256];            	
+            	int index=0;
+            	int[] tag=new int[]{0x82,0x84,0x95,0x9F26,0x9F27,0x9F10,0x9F37,0x9F36,0x9A,0x9C,0x9F02,0x5F2A,0x9F1A,0x9F03,0x9F33,0x9F34,0x9F35,0x9F1E,0x9F09,0x9F41};
+            	for(int i=0;i<tag.length;i++){
+            		int len=emvInterface.getTagData(tag[i], data);
+                	if(len>0){
+                		Log.e("tag", tag[i]+"-->"+StringUtility.ByteArrayToString(data, len));
+                		int tagIndex;
+                		if(tag[i]>0xFF){
+                		    Log.e("status", "status-->"+(tag[i]>>8)+"-->"+(tag[i]<<8));
+                			tagIndex=recvFiled55[index++]=(byte)(tag[i]/0xff);
+                		}
+                		recvFiled55[index++]=(byte)(tag[i]&0xff);
+                		recvFiled55[index++]=(byte) len;
+                		System.arraycopy(data, 0, recvFiled55, index, len);
+                		index+=len;
+                	}
+            	}
+            	byte[] filed55=new byte[index];
+            	System.arraycopy(recvFiled55, 0, filed55, 0, index);
+            	emvInterface.setOnlineResult(2, filed55, filed55.length);
+            	emvInterface.process();
+            	break;
+            //得到卡号
+            case EMV_STATUS.EMV_REQ_CARD_CONFIRM:
+                byte[] tagData = new byte[100];
+                int tagDataLength = emvInterface.getTagData(0x57, tagData);
+                cardNumber = StringUtility.getStringFormat(tagData, tagDataLength);
+                messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.msg_emv_card_num)
+                        + cardNumber);
+                emvInterface.process();
+                break;
+            default:
+            	emvInterface.process();
+                break;
+            }
+        }
+        //完成状态
+        else if(status == EmvInterface.STATUS_COMPLETION){
+        	messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.msg_emv_trade_over));
+        	//电子现金余额查询
+        	if ((mTransType & 0xFF) == 0xF4) {
+				if (retcode == 100) {
+					byte[] temp = new byte[32];
+					String amount = "0.00";
+					emvInterface.getICCTagData(0x9F79, temp);
+					int ret = emvInterface.getTagData(0x9F79, temp);
+					if (ret >= 0) {
+						amount = HexDump.decBytesToHex(temp, ret);
+					}
+					messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.info_emv_elect_cash_balance)
+							+ String.format("%.2f",
+									Integer.parseInt(amount) * 1.0 / 100));
+				}
+			}else if ((mTransType & 0xFF) == 0xF0){
+				if (retcode == 100){
+					byte[] sum = new byte[1];
+					emvInterface.getTransLog(0x101, sum);
+					System.out.println("sum:" + sum[0]);		
+					byte[] fmt_dol = new byte[60];
+					byte[] rec_val = new byte[256];
+					for (int i=1; i<=sum[0]; i++){
+						int index = 0;
+						
+						int len = emvInterface.getTransLog(0x102, fmt_dol);
+						System.out.println("fmt_dol:" + HexDump.decBytesToHex(fmt_dol));
+						
+						len = emvInterface.getTransLog(i, rec_val);
+						System.out.println("rec_val:" + HexDump.decBytesToHex(rec_val, len));
+						
+			            StringBuffer stringBuffer = new StringBuffer();
+
+			            index = 0;
+			            stringBuffer.append("9A03");
+			            stringBuffer.append(HexDump.toHexString(rec_val, index, 3));
+			            index += 3;
+			            stringBuffer.append("9F2103");
+			            stringBuffer.append(HexDump.toHexString(rec_val, index, 3));
+			            index += 3;
+			            stringBuffer.append("9F0206");
+			            stringBuffer.append(HexDump.toHexString(rec_val, index, 6));
+			            index += 6;
+			            index += 6;
+			            stringBuffer.append("9F1A02");
+			            stringBuffer.append(HexDump.toHexString(rec_val, index, 2));
+			            index += 2;
+			            stringBuffer.append("5F2A02");
+			            stringBuffer.append(HexDump.toHexString(rec_val, index, 2));
+
+			            index += 2;
+			            stringBuffer.append("9F4E14");
+			            stringBuffer.append(HexDump.toHexString(rec_val, index, 20));
+			            index += 20;
+			            stringBuffer.append("9C01");
+			            stringBuffer.append(HexDump.toHexString(rec_val, index, 1));
+			            index += 1;
+			            stringBuffer.append("9F3602");
+			            stringBuffer.append(HexDump.toHexString(rec_val, index, 2));
+			            
+			            messageManager.AppendInfoMessageInUiThread(stringBuffer.toString());
+					}
+				}
+			}else if ((mTransType & 0xFF) == 0xF2){
+				if (retcode == 100){
+					String cardSN = "0" + HexDump.decBytesToHex(getTag(0x5F34));
+					System.out.println("cardSN:" + cardSN);
+					String cardNO = HexDump.decBytesToHex(getTag(0x5A));
+					System.out.println("cardNO:" + cardNO);
+				}
+			}
+        	byte[] data=new byte[1024];
+        	emvInterface.getTransLog(0, data);
+        }else if(status == EmvInterface.STATUS_ERROR){
+        	messageManager.AppendInfoMessageInUiThread("Ic error");
+        }
+    }
+    //获取交易日志
+    private byte[] getTag(int tagInt){
+        byte[] temp = new byte[256];
+        byte[] result = null;
+        int ret = emvInterface.getTagData(tagInt, temp);
+        if (ret <= 0) {
+            return null;
+        }
+        result = new byte[ret];
+        System.arraycopy(temp, 0, result, 0, ret);
+        return result;
+    }
+    private String cardNumber = "";
+    private final int mainKey = 2;
+    //密码键盘
+    private void onlinePinPad() {
+    	int ret = pinPad.open(new OnSendKeyListerner() {
+			
+			@Override
+			public void onSendKey(int keyCode) {
+				messageManager.AppendInfoMessageInUiThread("keyCode-->"+keyCode);
+			}
+		});
+    	if(ret >=0)
+    	{
+    		updateMainKey();
+    	}
+	}
+    //下载主密钥
+	private void updateMainKey() {
+		byte[] oldKey = HexDump.hexStringToByteArray("701A5B3D7F6E891C56A46A18C1CD5C0A");
+		byte[] newkey = HexDump.hexStringToByteArray("701A5B3D7F6E891C56A46A18C1CD5C0A");
+		int ret = pinPad.updateMasterKey(mainKey, oldKey, newkey);
+		if(ret >=0)
+			updateWorkKey();
+		else
+			closePinpad(1);
+	}
+	private void closePinpad(int type){
+		if(type == 1)
+			messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.msg_pinpad_main_key_error));
+		else if(type == 2)
+			messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.msg_pinpad_wk_error));
+		pinPad.close();
+	}
+	//下载工作密钥
+	private void updateWorkKey() {
+		byte[] pinkey = HexDump.hexStringToByteArray("5A7C9B2D21EDF2907ED9F72A5CFB6EC5");
+		int ret = pinPad.updateUserKey(mainKey, 0,mainKey, pinkey);
+		if(ret >=0)
+			pinPadOnline();
+		else
+			closePinpad(2);
+	}
+	//获取联机pin
+	private void pinPadOnline() {
+		int limit = pinPad.setPinLimit(new byte[]{4,6,8});
+		messageManager.AppendInfoMessageInUiThread("setLimit:"+limit);
+		byte[] arryASCIICardNumber = cardNumber.getBytes();
+		int nTimeout_MS = 10000;
+		int nFlagSound = 1;
+		messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.info_emv_input_pwd));
+		pinPad.calculatePinBlock(mainKey, arryASCIICardNumber, nTimeout_MS, nFlagSound,new PinPad.OnInputResultListener() {
+			@Override
+			public void onInputResult(int ret, byte[] result) {
+				if(ret>0){
+					messageManager.AppendInfoMessageInUiThread("result-->"+StringUtility.ByteArrayToString(result, ret));
+					emvInterface.setOnlinePinEntered(0,new byte[]{1,2,3,4,5,6,7,8},8);
+	            	int t = emvInterface.process();
+	            	messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.info_emv_transformation_ret)+t);
+				}else{
+					messageManager.AppendInfoMessageInUiThread("pin"+shower.getString(R.string.btn_pinpad_encrypt)+shower.getString(R.string.info_failed));
+				}
+			}
+		});
+	}
+	
+	private void closeReader(){
+		boolean flag = false;
+    	flag = contactlessCardReader.close() >=0;
+    	flag &= smartCardReader.close()>=0;
+    	if(flag)
+    	{
+    		messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.btn_emv_close)+shower.getString(R.string.info_success));
+    	}else{
+    		messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.btn_emv_close)+shower.getString(R.string.info_failed));
+    	}
+    }
+}

+ 357 - 0
ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/test/ICCardActivity.java

@@ -0,0 +1,357 @@
+package com.yijia.zthandpos.pos.test;
+
+import android.graphics.Color;
+import android.os.Bundle;
+import android.text.method.ScrollingMovementMethod;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.szzt.android.util.HexDump;
+import com.szzt.sdk.device.Constants.Error;
+import com.szzt.sdk.device.card.SmartCardReader;
+import com.yijia.zthandpos.pos.BaseActivity;
+import com.yijia.zthandpos.pos.utils.MessageManager;
+import com.yijia.zthandpos.pos.utils.Shower;
+import com.yijia.zthandpos.pos.utils.StringUtility;
+import com.yijia.zthandpos.pos.R;
+
+public class ICCardActivity extends BaseActivity{
+    private SmartCardReader mSmartCardReader;
+    private Button mOpenButton;
+    private Button mClearButton;
+    private Button mCloseButton;
+    private TextView mTextViewResult;
+    MessageManager messageManager;
+    private Shower shower ;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_card);
+        shower = new Shower(this) ;
+        boolean isConnected = mainApplication.isDeviceManagerConnetcted();
+        init(isConnected);
+    }
+    
+    @Override
+    protected void onStop() {
+    	super.onStop();
+    	if (mSmartCardReader != null){
+    		mSmartCardReader.close(0);
+    	}
+    }
+    
+    private void init(boolean isConnected) {
+        if (mCloseButton == null) {
+            mTextViewResult = (TextView) findViewById(R.id.mag_text);
+            mTextViewResult.setMovementMethod(ScrollingMovementMethod
+                    .getInstance());
+
+            messageManager = new MessageManager(this, mTextViewResult);
+
+            mOpenButton = (Button) findViewById(R.id.mag_open);
+            mOpenButton.setOnClickListener(listener);
+
+            mClearButton = (Button) findViewById(R.id.mag_clear);
+            mClearButton.setOnClickListener(listener);
+
+
+            mCloseButton = (Button) findViewById(R.id.mag_close);
+            mCloseButton.setOnClickListener(listener);
+        }
+        mTextViewResult.setEnabled(isConnected);
+        mOpenButton.setEnabled(isConnected);
+        mClearButton.setEnabled(isConnected);
+        mCloseButton.setEnabled(isConnected);
+        if (isConnected) {
+                mSmartCardReader = mainApplication.getSmartCardReader();
+        } else {
+            mSmartCardReader = null;
+        }
+    }
+    
+    void testSmartCardReader() {
+        int result = mSmartCardReader.waitForCard(0, 60000);
+        if (result == 0) {
+        	byte[] data=new byte[256];
+        	int type = mSmartCardReader.getCardType(0);
+        	System.out.println("type:" + type);
+        	if (type == SmartCardReader.CONTACT_CARD_TYPE_A_CPU){
+        		result=mSmartCardReader.powerOn(0, data);
+                messageManager.AppendInfoMessageInUiThread("Power On ATR:" + (result>0?StringUtility.ByteArrayToString(data, result):""));
+                testSmartCardReaderIO();
+        	}else if (type == SmartCardReader.CONTACT_CARD_TYPE_4442){
+        		result=mSmartCardReader.powerOn(0, data);
+                messageManager.AppendInfoMessageInUiThread("Power On ATR:" + (result>0?StringUtility.ByteArrayToString(data, result):""));
+                messageManager.AppendInfoMessageInUiThread("type:4442");
+                testMemoryCard();
+        	}else if (type == SmartCardReader.CONTACT_CARD_TYPE_4428){
+        		result=mSmartCardReader.powerOn(0, data);
+                messageManager.AppendInfoMessageInUiThread("Power On ATR:" + (result>0?StringUtility.ByteArrayToString(data, result):""));
+                messageManager.AppendInfoMessageInUiThread("type:4428");
+                testMemoryCard();
+        	}else if (type == SmartCardReader.CONTACT_CARD_TYPE_AT24C02){
+        		result=mSmartCardReader.powerOn(0, data);
+                messageManager.AppendInfoMessageInUiThread("Power On ATR:" + (result>0?StringUtility.ByteArrayToString(data, result):""));
+                messageManager.AppendInfoMessageInUiThread("type:AT24C02");
+                //TODO 
+        	}else if (type == SmartCardReader.CONTACT_CARD_TYPE_AT88SC102){
+        		result=mSmartCardReader.powerOn(0, data);
+                messageManager.AppendInfoMessageInUiThread("Power On ATR:" + (result>0?StringUtility.ByteArrayToString(data, result):""));
+                messageManager.AppendInfoMessageInUiThread("type:AT88SC102");
+                //TODO
+        	}else if (type == SmartCardReader.CONTACT_CARD_TYPE_AT88SC1604){
+        		result=mSmartCardReader.powerOn(0, data);
+                messageManager.AppendInfoMessageInUiThread("Power On ATR:" + (result>0?StringUtility.ByteArrayToString(data, result):""));
+                messageManager.AppendInfoMessageInUiThread("type:AT88SC1604");
+                //TODO
+        	}else if (type == SmartCardReader.CONTACT_CARD_TYPE_AT88SC1608){
+        		result=mSmartCardReader.powerOn(0, data);
+                messageManager.AppendInfoMessageInUiThread("Power On ATR:" + (result>0?StringUtility.ByteArrayToString(data, result):""));
+                messageManager.AppendInfoMessageInUiThread("type:AT88SC1608");
+                //TODO
+        	}else{
+        		messageManager.AppendInfoMessageInUiThread("Not support");
+        	}
+        	
+        } else if (result == Error.TIMEOUT) {
+            messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.msg_card_time_out),
+                    Color.RED);
+        } else if (result == Error.DEVICE_FORCE_CLOSED) {
+            messageManager.AppendInfoMessageInUiThread(
+                    shower.getString(R.string.msg_card_force_close), Color.RED);
+        } else {
+            messageManager.AppendInfoMessageInUiThread(
+                    shower.getString(R.string.msg_card_read_error), Color.RED);
+        }
+    }
+    
+    void testMemoryCard(){
+		//�����洢������������
+		byte[] pvalue = new byte[32];
+		int ret = mSmartCardReader.read(0, SmartCardReader.MemoryCardArea.MAIN, 0, pvalue);
+		if (ret > 0){
+			messageManager.AppendInfoMessageInUiThread("read main memory protected:"  + HexDump.toHexString(pvalue));
+		}else{
+			messageManager.AppendInfoMessageInUiThread("read main memory protected faild!");
+		}
+		
+		//�����洢��
+		byte[] data = new byte[16];
+		ret = mSmartCardReader.read(0, SmartCardReader.MemoryCardArea.MAIN, 32, data);
+		if (ret > 0){
+			messageManager.AppendInfoMessageInUiThread("read main memory:"  + HexDump.toHexString(data, 0, ret));
+		}else{
+			 messageManager.AppendInfoMessageInUiThread("read main memory faild!");
+		}
+		//�������洢��
+		byte[] pdata = new byte[8];
+		ret = mSmartCardReader.read(0, SmartCardReader.MemoryCardArea.PROTECTED, 0, pdata);
+		if (ret > 0){
+			 messageManager.AppendInfoMessageInUiThread("read protected memory:"  + HexDump.toHexString(pdata, 0, ret));
+		}else{
+			 messageManager.AppendInfoMessageInUiThread("read protected memory faild!");
+		}
+		
+		int count = getPassCount();
+		if (count >= 0){
+			 messageManager.AppendInfoMessageInUiThread("get pin check times:" + count);
+		}else{
+			 messageManager.AppendInfoMessageInUiThread("get pin check times fail��");
+		}
+		
+		if (count == 1){
+			//���һ��У�鲻������Ƭ�Ͳ�����У���ˡ� У��ʱ���м�ʹ����ȷ����У��
+			messageManager.AppendInfoMessageInUiThread("the last check pin");
+			return;
+		}else if (count == 0){
+			messageManager.AppendInfoMessageInUiThread("the check pin times is over");
+		}
+		
+		//������
+		byte[] key = HexDump.hexStringToByteArray("FFFFFF");
+		ret = mSmartCardReader.verify(0, key, SmartCardReader.KEY_TYPE_A);
+		if (ret == 0){
+			 messageManager.AppendInfoMessageInUiThread("verify succ!");
+			
+			writeData();
+			
+			writeProtectData();
+			
+		}else{
+			 messageManager.AppendInfoMessageInUiThread("verify faild!");
+			return;
+		}
+		
+		ret = mSmartCardReader.read(0, SmartCardReader.MemoryCardArea.MAIN, 32, data);
+		if (ret > 0){
+			 messageManager.AppendInfoMessageInUiThread("read main memory:" +  HexDump.toHexString(data, 0, ret));
+		}else{
+			 messageManager.AppendInfoMessageInUiThread("read main memory faild!");
+		}
+		
+		//�޸�����  ����Ϊ3���ֽ�
+		byte[] pass = HexDump.hexStringToByteArray("FFFFFF");
+		ret = mSmartCardReader.write(0, SmartCardReader.MemoryCardArea.SECURITY, 1, pass);
+		if (ret >= 0){
+			messageManager.AppendInfoMessageInUiThread("write pass succ!");
+		}else{
+			messageManager.AppendInfoMessageInUiThread("write pass faild!");
+		}
+    }
+    
+	
+	/**
+	 * ��ȡʣ������У�����
+	 * @param data
+	 * @return
+	 */
+	private int getPassCount() {
+		int ret;
+		byte[] count = new byte[1];
+		ret = mSmartCardReader.read(0, SmartCardReader.MemoryCardArea.SECURITY, 0, count);
+		if (ret > 0){
+			System.out.println("read:" + HexDump.toHexString(count));
+			if ((count[0] & 0x07) == 0x07){
+				return 3;
+			}else if ((count[0] & 0x03) == 0x03){
+				return 2;
+			}else if ((count[0] & 0x01) == 0x01){
+				return 1;
+			}else{
+				return 0;
+			}
+		}else{
+			messageManager.AppendInfoMessageInUiThread("read faild!");
+		}
+		return -1;
+	}
+
+	/**
+	 * д���洢��
+	 */
+	private void writeData() {
+		int ret;
+		String msg = "hello:" + System.currentTimeMillis();
+		//д���ݵ���������
+		ret = mSmartCardReader.write(0, SmartCardReader.MemoryCardArea.MAIN, 32, msg.getBytes());
+		if (ret >= 0){
+			messageManager.AppendInfoMessageInUiThread("write succ!");
+		}else{
+			messageManager.AppendInfoMessageInUiThread("write faild!");
+		}
+	}
+
+	/**
+	 * �̻����������ݣ��ȶ�ȡ���룬Ȼ��д�룬д������ݾͲ����ٱ��޸�
+	 */
+	private void writeProtectData() {
+		int ret;
+		//д�̻�����������
+		byte[] ppp = new byte[1];
+		ret = mSmartCardReader.read(0, SmartCardReader.MemoryCardArea.MAIN, 5, ppp);
+		if (ret > 0){
+			messageManager.AppendInfoMessageInUiThread("�����洢��:"  + HexDump.toHexString(ppp));
+		}else{
+			messageManager.AppendInfoMessageInUiThread("�����洢��ʧ��!");
+		}
+		
+		ret = mSmartCardReader.write(0, SmartCardReader.MemoryCardArea.PROTECTED, 5, ppp);
+		if (ret >= 0){
+			messageManager.AppendInfoMessageInUiThread("д�������ɹ�!");
+		}else{
+			messageManager.AppendInfoMessageInUiThread("д������ʧ��!");
+		}
+	}
+    
+    void testSmartCardReaderIO() {
+        // 00 A4 04 00 0E 1PAY.SYS.DDF01
+        byte[] apdu = new byte[] { (byte) 0x00, (byte) 0xA4, (byte) 0x04,
+                (byte) 0x00, (byte) 0x0E, 0x31, 0x50, 0x41, 0x59, 0x2E, 0x53,
+                0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31,0x00,0x00};
+        byte[] ret = new byte[255];
+        int len = mSmartCardReader.transmit(0, apdu, ret);
+        if (len >= 0) {
+            if (len >= 2 && ret[len - 2] == 97) {
+                apdu = new byte[] { 0x00, (byte) 0xC0, 0x00, 0x00,
+                        (byte) (ret[len - 1] & 0xFF) };
+                ret = new byte[255];
+                len = mSmartCardReader.transmit(0, apdu, ret);
+            }
+        }
+        if (len >= 0) {
+            messageManager.AppendInfoMessageInUiThread("APDU:"
+                    + StringUtility.ByteArrayToString(ret, len));
+        } else {
+            messageManager.AppendInfoMessageInUiThread(
+                    shower.getString(R.string.msg_card_exe_apdu_error), Color.RED);
+        }
+    }
+    
+    private final View.OnClickListener listener = new View.OnClickListener() {
+        @Override
+        public void onClick(View v) {
+            switch (v.getId()) {
+                case R.id.mag_open: {
+                	// if don't want to get card remove notice can using mSmartCardReader.open(0, null);
+                    int nret = mSmartCardReader.open(0,
+                                        new SmartCardReader.SCReaderListener(){
+                                            @Override
+                                            public void notify(
+                                                    int nSlotIndex,
+                                                    int nEvent) {
+                                                if (nEvent == SmartCardReader.EVENT_SMARTCARD_NOT_READY) {
+                                                    messageManager.AppendInfoMessageInUiThread(
+                                                            shower.getString(R.string.msg_card_unplug_card), Color.RED);
+                                                }else if (nEvent == SmartCardReader.EVENT_SMARTCARD_READY){
+                                                	
+                                                }
+                                            }
+                                        });
+	                    if (nret >= 0) {
+	                        messageManager
+	                                .AppendInfoMessage(shower.getString(R.string.msg_card_open_success));
+	                        messageManager
+	                                .AppendInfoMessage(
+	                                        shower.getString(R.string.msg_card_wait_for_card),
+	                                        Color.GREEN);
+	                        new Thread(){
+	                        	@Override
+	                        	public void run() {
+	                        		testSmartCardReader();
+	                        	}
+                            }.start();
+	                    } else {
+	                        messageManager
+	                                .AppendInfoMessage(shower.getString(R.string.msg_card_open_error));
+	                    }
+	                }
+                	break;
+                
+                case R.id.mag_clear:
+                    messageManager.clear();
+                    break;
+                    
+                case R.id.mag_close: {
+                    int ret = mSmartCardReader
+                                .close();
+                    if (ret >= 0) {
+                        messageManager
+                                .AppendInfoMessage(shower.getString(R.string.msg_card_close_succ));
+                    } else {
+                        messageManager
+                                .AppendInfoMessage(
+                                        shower.getString(R.string.msg_card_close_succ),
+                                        Color.RED);
+                    }
+                }
+
+                break;
+                default:
+                    break;
+            }
+        }
+    };
+
+}

+ 205 - 0
ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/test/MagCardActivity.java

@@ -0,0 +1,205 @@
+package com.yijia.zthandpos.pos.test;
+
+import android.graphics.Color;
+import android.os.Bundle;
+import android.os.HandlerThread;
+import android.text.method.ScrollingMovementMethod;
+import android.util.Log;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.szzt.sdk.device.Constants.Error;
+import com.szzt.sdk.device.Device;
+import com.szzt.sdk.device.card.MagneticStripeCardReader;
+import com.yijia.zthandpos.pos.BaseActivity;
+import com.yijia.zthandpos.pos.utils.MessageManager;
+import com.yijia.zthandpos.pos.utils.Shower;
+
+import com.yijia.zthandpos.pos.R;
+
+public class MagCardActivity extends BaseActivity{
+    private MagneticStripeCardReader mMagneticStripeCardReader;
+    private Button mOpenButton;
+    private Button mClearButton;
+    private Button mCloseButton;
+    private TextView mTextViewResult;
+    MessageManager messageManager;
+    HandlerThread mWaitForCardHandlerThread;
+    int mTestDeviceType = Device.TYPE_UNKNOWN;
+    private Shower shower;
+    
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_card);
+        shower = new Shower(this) ;
+        boolean isConnected = mainApplication.isDeviceManagerConnetcted();
+        init(isConnected);
+        if (messageManager != null) {
+            messageManager
+                    .AppendInfoMessage(R.string.button_card_read_test);
+        }
+    }
+    
+    @Override
+    protected void onStop() {
+    	super.onStop();
+    	if (mMagneticStripeCardReader != null){
+    		mMagneticStripeCardReader.close();
+    	}
+    	
+    }
+    
+    private void init(boolean isConnected) {
+        if (mCloseButton == null) {
+            mTextViewResult = (TextView) findViewById(R.id.mag_text);
+            mTextViewResult.setMovementMethod(ScrollingMovementMethod.getInstance());
+
+            messageManager = new MessageManager(this, mTextViewResult);
+
+            mOpenButton = (Button) findViewById(R.id.mag_open);
+            mOpenButton.setOnClickListener(listener);
+
+            mClearButton = (Button) findViewById(R.id.mag_clear);
+            mClearButton.setOnClickListener(listener);
+
+            mCloseButton = (Button) findViewById(R.id.mag_close);
+            mCloseButton.setOnClickListener(listener);
+        }
+        mTextViewResult.setEnabled(isConnected);
+        mOpenButton.setEnabled(isConnected);
+        mClearButton.setEnabled(isConnected);
+        mCloseButton.setEnabled(isConnected);
+        if (isConnected) {
+                mMagneticStripeCardReader = mainApplication
+                        .getMagneticStripeCardReader();
+        } else {
+            mMagneticStripeCardReader = null;
+        }
+    }
+    
+    private String trackFormat(byte[] data) {
+        if (data == null) {
+            return "no track info";
+        } else {
+            return new String(trackTrim(data));
+        }
+    }
+    
+    private byte[] trackTrim(byte[] data) {
+        if (data == null) {
+            return null;
+        } else {
+            int end = 0;
+            for (int i = data.length - 1; i >= 0; i--) {
+                if (data[i] != 0) {
+                    end = i;
+                    break;
+                }
+            }
+            byte[] d = new byte[end + 1];
+            System.arraycopy(data, 0, d, 0, end + 1);
+            return d;
+        }
+    }
+    
+    void testMagStripeCardReader() {
+    	mMagneticStripeCardReader.setCheckLrc(1);
+        int result = mMagneticStripeCardReader.waitForCard(100000);
+        Log.e("waitForCard", "result:" + result);
+        if (result == 0) {
+            byte[] data1 = mMagneticStripeCardReader
+                    .getTrackData(MagneticStripeCardReader.TRACK_INDEX_1);
+            byte[] data2 = mMagneticStripeCardReader
+                    .getTrackData(MagneticStripeCardReader.TRACK_INDEX_2);
+            byte[] data3 = mMagneticStripeCardReader
+                    .getTrackData(MagneticStripeCardReader.TRACK_INDEX_3);
+            byte[] checkFlag = mMagneticStripeCardReader.getTrackData(MagneticStripeCardReader.TRACK_CHECK_FLAG);
+            if (data1 == null && data2 == null && data3 == null) {
+                messageManager.AppendInfoMessageInUiThread(
+                        shower.getString(R.string.msg_card_read_error), Color.RED);
+            } else {
+                messageManager.AppendInfoMessageInUiThread(
+                        shower.getString(R.string.msg_card_read_succ), Color.RED);
+
+                String strTrack1 = trackFormat(data1);
+                String strTrack2 = trackFormat(data2);
+                String strTrack3 = trackFormat(data3);
+
+                messageManager
+                        .AppendInfoMessageInUiThread("Data of Track 1 (len "
+                                + strTrack1.length() + "):");
+                messageManager.AppendInfoMessageInUiThread(strTrack1 + " FLAG:" + checkFlag[0]);
+                messageManager
+                        .AppendInfoMessageInUiThread("Data of Track 2 (len "
+                                + strTrack2.length() + "):");
+                messageManager.AppendInfoMessageInUiThread(strTrack2 + " FLAG:" + checkFlag[1]);
+                messageManager
+                        .AppendInfoMessageInUiThread("Data of Track 3 (len "
+                                + strTrack3.length() + "):");
+                messageManager.AppendInfoMessageInUiThread(strTrack3 + " FLAG:" + checkFlag[2]);
+            }
+        } else if (result == Error.TIMEOUT) {
+            messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.msg_card_time_out), Color.RED);
+        } else if (result == Error.DEVICE_FORCE_CLOSED) {
+            messageManager.AppendInfoMessageInUiThread(
+                    shower.getString(R.string.msg_card_force_close), Color.RED);
+        } else {
+            messageManager.AppendInfoMessageInUiThread(
+                    shower.getString(R.string.msg_card_read_error), Color.RED);
+        }
+
+    }
+    
+
+    
+    private final View.OnClickListener listener = new View.OnClickListener() {
+        @Override
+        public void onClick(View v) {
+            switch (v.getId()) {
+                case R.id.mag_open: {
+                    int nret = mMagneticStripeCardReader.open();
+                    if (nret >= 0) {
+                        messageManager
+                                .AppendInfoMessage(shower.getString(R.string.msg_card_open_success));
+                        messageManager
+                                .AppendInfoMessage(
+                                        shower.getString(R.string.msg_card_wait_for_card),
+                                        Color.GREEN);
+                        new Thread(){
+                        	@Override
+                        	public void run() {
+                                testMagStripeCardReader();
+                        	}
+                        }.start();
+
+                    } else {
+                        messageManager
+                                .AppendInfoMessage(shower.getString(R.string.msg_card_open_error));
+                    }
+                }
+                break;
+                case R.id.mag_clear:
+                    messageManager.clear();
+                    break;
+                case R.id.mag_close: {
+                    int ret = mMagneticStripeCardReader.close();
+                    if (ret >= 0) {
+                        messageManager
+                                .AppendInfoMessage(shower.getString(R.string.msg_card_close_succ));
+                    } else {
+                        messageManager
+                                .AppendInfoMessage(
+                                        shower.getString(R.string.msg_card_close_succ),
+                                        Color.RED);
+                    }
+                }
+
+                break;
+                default:
+                    break;
+            }
+        }
+    };
+}

+ 277 - 0
ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/test/PinPadActivity.java

@@ -0,0 +1,277 @@
+package com.yijia.zthandpos.pos.test;
+
+import android.graphics.Color;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
+import android.text.method.ScrollingMovementMethod;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.Window;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.szzt.sdk.device.pinpad.PinPad;
+import com.yijia.zthandpos.pos.BaseActivity;
+import com.yijia.zthandpos.pos.utils.MessageManager;
+import com.yijia.zthandpos.pos.utils.Shower;
+import com.yijia.zthandpos.pos.utils.StringUtil;
+import com.yijia.zthandpos.pos.utils.StringUtility;
+
+import com.yijia.zthandpos.pos.R;
+
+public class PinPadActivity extends BaseActivity {
+    private MessageManager messageManager;
+    private PinPad mPinpad;
+    private Button mClearButton;
+    private Button mOpenButton;
+    private Button mCloseButton;
+    private Button mShowTextButton;
+    private Button mLoadMasterKeyButton;
+    private Button mUpdateWorkKeyButton;
+    private Button mEncryptDataButton;
+    private Shower shower ;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        requestWindowFeature(Window.FEATURE_NO_TITLE); 
+        setContentView(R.layout.activity_pinpad);
+        shower = new Shower(this);
+        boolean isConnected = mainApplication.isDeviceManagerConnetcted();
+        init(isConnected);
+    }
+    //获取联机pin
+    public void cal_pin(View v){
+    	PinpadCalculatePin();
+    }
+
+    private void init(boolean isConnected) {
+        if (messageManager == null) {
+            TextView text = (TextView) findViewById(R.id.pinpad_text);
+            text.setMovementMethod(ScrollingMovementMethod.getInstance());
+            messageManager = new MessageManager(this, text);
+            mClearButton = (Button) findViewById(R.id.pinpad_clear);
+            mClearButton.setOnClickListener(listener);
+            mOpenButton = (Button) findViewById(R.id.pinpad_open);
+            mOpenButton.setOnClickListener(listener);
+            mCloseButton = (Button) findViewById(R.id.pinpad_close);
+            mCloseButton.setOnClickListener(listener);
+            mShowTextButton = (Button) findViewById(R.id.pinpad_showText);
+            mShowTextButton.setOnClickListener(listener);
+            mLoadMasterKeyButton = (Button) findViewById(R.id.pinpad_loadMasterKey);
+            mLoadMasterKeyButton.setOnClickListener(listener);
+            mUpdateWorkKeyButton = (Button) findViewById(R.id.pinpad_updateWorkKey);
+            mUpdateWorkKeyButton.setOnClickListener(listener);
+            mEncryptDataButton = (Button) findViewById(R.id.pinpad_encryptData);
+            mEncryptDataButton.setOnClickListener(listener);
+            mPinpad = mainApplication.getPinPad();
+
+        }
+        mClearButton.setEnabled(isConnected);
+        mOpenButton.setEnabled(isConnected);
+        mCloseButton.setEnabled(isConnected);
+        mShowTextButton.setEnabled(isConnected);
+        mUpdateWorkKeyButton.setEnabled(isConnected);
+        mUpdateWorkKeyButton.setEnabled(isConnected);
+        mEncryptDataButton.setEnabled(isConnected);
+    }
+
+    private final OnClickListener listener = new OnClickListener() {
+        @Override
+        public void onClick(View v) {
+            switch (v.getId()) {
+            case R.id.pinpad_clear:
+            	PinpadCalculateMac();
+            break;
+            case R.id.pinpad_open:
+                PinpadOpen();
+                break;
+            case R.id.pinpad_close:
+                PinpadClose();
+                break;
+            case R.id.pinpad_showText:
+                PinpadShowText();
+                break;
+            case R.id.pinpad_loadMasterKey:
+                PinpadUpdateMasterKey();
+                break;
+            case R.id.pinpad_updateWorkKey:
+                PinpadUpdateUserKey();
+                break;
+            case R.id.pinpad_encryptData:
+                PinpadEncryptData();
+                break;
+            default:
+                break;
+            }
+        }
+
+    };
+    private final Handler mHandler = new Handler(Looper.getMainLooper()) {
+        public void handleMessage(Message m) {
+            int ret = m.what;
+            if (ret >= 0) {
+                byte[] data = (byte[]) m.obj;
+                messageManager
+                .AppendInfoMessage(shower.getString(R.string.msg_pinpad_pin_result)
+                        + StringUtility
+                        .ByteArrayToString(
+                                data,
+                                ret));
+            } else {
+                messageManager
+                .AppendInfoMessage(
+                        shower.getString(R.string.msg_pinpad_pin_result_error),
+                        Color.RED);
+            }
+        }
+    };
+
+    private void PinpadCalculatePin() {
+    	
+        messageManager.AppendInfoMessage(shower.getString(R.string.msg_pinpad_pin_prompt), Color.GREEN);
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                mPinpad.showText(0, "金额:123.00".getBytes(), true);
+                mPinpad.setPinLimit(new byte[]{0,6});
+                Bundle bundle = new Bundle();
+                bundle.putInt(PinPad.PinStyle.CUSTOM_VIEW_TYPE, 4);
+                mPinpad.setPinViewStyle(bundle);
+                mPinpad.calculatePinBlock(0, "6225776819866784".getBytes(), 60000, 0, new PinPad.OnInputResultListener() {
+					@Override
+					public void onInputResult(int retCode, byte[] data) {
+						Message m = new Message();
+		                m.what = retCode;
+		                m.obj = data;
+		                mHandler.sendMessage(m);
+					}
+				});                
+            }
+        }).start();
+    }
+    //mac计算
+    private void PinpadCalculateMac() {
+        String srcData = "170C020B0361142D8000000000000000170C020B0361142D8000000000000000" +
+        		"170C020B0361142D8000000000000000170C020B0361142D8000000000000000" +
+        		"170C020B0361142D8000000000000000170C020B0361142D8000000000000000" +
+        		"170C020B0361142D8000000000000000170C020B0361142D8000000000000000";
+        byte[] data = new byte[256]; 
+        int ret = mPinpad.calculateMac(1, StringUtil.hexString2bytes(srcData), PinPad.MAC_TYPE_X99, data);
+        if (ret >= 0) {
+            messageManager.AppendInfoMessage(shower.getString(R.string.msg_pinpad_mac_data) + srcData +
+                    shower.getString(R.string.msg_pinpad_mac_result_1)
+                    + StringUtility.ByteArrayToString(data, ret));
+        } else {
+            messageManager.AppendInfoMessage(shower.getString(R.string.msg_pinpad_mac_data) + srcData
+                    + shower.getString(R.string.msg_pinpad_mac_result_2), Color.RED);
+        }       
+    }
+    
+    //加密
+    private void PinpadEncryptData() {
+        String srcData = "12345678";
+        byte[] data = new byte[256];
+        int ret = mPinpad.encryptData(2, srcData.getBytes(), data);
+        if (ret >= 0) {
+            messageManager.AppendInfoMessage(shower.getString(R.string.msg_pinpad_encrypt_data) + srcData +
+                    shower.getString(R.string.msg_pinpad_encrypt_result_1)
+                    + StringUtility.ByteArrayToString(data, ret));
+        } else {
+            messageManager.AppendInfoMessage(
+                    shower.getString(R.string.msg_pinpad_encrypt_data) + srcData +
+                            shower.getString(R.string.msg_pinpad_encrypt_result_1), Color.RED);
+        }
+    }
+    //下载主密钥
+    private void PinpadUpdateMasterKey(){
+        byte[] newKey=new byte[] {  (byte)0x89, (byte)0x40, (byte)0xF7, (byte)0xB3,
+        		 (byte)0xEA, (byte)0xCA, (byte)0x59, (byte)0x39,
+        		 (byte)0x89, (byte)0x40, (byte)0x87, (byte)0xB3,
+        		 (byte)0xEA, (byte)0xCA, (byte)0x89, (byte)0x39};
+        int ret = mPinpad.updateMasterKey(2, newKey, null);
+        if (ret >= 0) {
+            messageManager.AppendInfoMessage(shower.getString(R.string.msg_pinpad_main_key_succ));
+        } else {
+            messageManager.AppendInfoMessage(shower.getString(R.string.msg_pinpad_main_key_error));
+        }
+    }
+
+    //下载工作密钥
+    private void PinpadUpdateUserKey() {
+    	byte[] keys=new byte[] { (byte) 0x38, (byte) 0x38, (byte) 0x38, (byte) 0x38, 
+                (byte) 0x38, (byte) 0x38, (byte) 0x38, (byte) 0x38,
+                (byte) 0x38, (byte) 0x38, (byte) 0x38, (byte) 0x38, 
+                (byte) 0x38, (byte) 0x38, (byte) 0x38, (byte) 0x38};
+    	//下载pin类型密钥
+        int ret =mPinpad.updateUserKey(2, PinPad.KeyType.PIN, 0, keys);
+        if (ret >= 0) {
+            messageManager.AppendInfoMessage(shower.getString(R.string.msg_pinpad_wk_0_succ));
+        } else {
+            messageManager.AppendInfoMessage(shower.getString(R.string.msg_pinpad_wk_0_error), Color.RED);
+        }
+        keys = new byte[] { (byte) 0x99, (byte) 0x4D, (byte) 0x4D,
+                (byte) 0xC1, (byte) 0x57, (byte) 0xB9, (byte) 0x6C,
+                (byte) 0x52, (byte) 0x99, (byte) 0x4D, (byte) 0x4D,
+                (byte) 0xC1, (byte) 0x57, (byte) 0xB9, (byte) 0x6C, (byte) 0x52 };
+        //下载mac类型密钥
+        ret = mPinpad.updateUserKey(2, PinPad.KeyType.MAC, 1, keys);
+        if (ret >= 0) {
+            messageManager.AppendInfoMessage(shower.getString(R.string.msg_pinpad_wk_1_succ));
+        } else {
+            messageManager.AppendInfoMessage(shower.getString(R.string.msg_pinpad_wk_1_error), Color.RED);
+        }
+        keys=new byte[] { (byte) 0x38, (byte) 0x38, (byte) 0x38, (byte) 0x38, 
+                (byte) 0x38, (byte) 0x48, (byte) 0x38, (byte) 0x38,
+                (byte) 0x38, (byte) 0x48, (byte) 0x38, (byte) 0x38, 
+                (byte) 0x38, (byte) 0x48, (byte) 0x38, (byte) 0x38};
+        //下载des类型密钥
+        ret = mPinpad.updateUserKey(2, PinPad.KeyType.TD, 2, keys);
+        if (ret >= 0) {
+            messageManager.AppendInfoMessage(shower.getString(R.string.msg_pinpad_wk_2_succ));
+        } else {
+            messageManager.AppendInfoMessage(shower.getString(R.string.msg_pinpad_wk_2_error), Color.RED);
+        }
+    }
+    private void PinpadClose() {
+        int ret = mPinpad.close();
+        if (ret >= 0) {
+            messageManager.AppendInfoMessage(shower.getString(R.string.msg_pinpad_close_succ));
+        } else {
+            messageManager.AppendInfoMessage(shower.getString(R.string.msg_pinpad_close_error), Color.RED);
+        }
+    }
+    //设置密码键盘显示的字符串
+    private void PinpadShowText() {
+        int ret = mPinpad.showText(0, "PINPAD TEST".getBytes(), true);
+        if (ret >= 0) {
+            messageManager.AppendInfoMessage(shower.getString(R.string.msg_pinpad_show_succ));
+        } else {
+            messageManager.AppendInfoMessage(shower.getString(R.string.msg_pinpad_show_error), Color.RED);
+        }
+    }
+    private final Handler handler=new Handler(Looper.getMainLooper());
+    //打开密码键盘
+    private void PinpadOpen() {
+        int ret = mPinpad.open(new PinPad.OnSendKeyListerner() {
+			@Override
+			public void onSendKey(final int keyCode) {
+				handler.post(new Runnable() {
+					@Override
+					public void run() {
+						messageManager.AppendInfoMessage("keyCode:"+keyCode);
+						
+					}
+				});
+			}
+		});
+        if (ret >= 0) {
+            messageManager.AppendInfoMessage(shower.getString(R.string.msg_pinpad_open_succ));
+        } else {
+            messageManager.AppendInfoMessage(shower.getString(R.string.msg_pinpad_open_error), Color.RED);
+        }
+    }
+    
+}

+ 262 - 0
ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/test/PrinterActivity.java

@@ -0,0 +1,262 @@
+package com.yijia.zthandpos.pos.test;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.RemoteException;
+import android.text.method.ScrollingMovementMethod;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.Window;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.szzt.sdk.device.Device;
+import com.szzt.sdk.device.aidl.IPrinterListener;
+import com.szzt.sdk.device.printer.Printer;
+import com.yijia.zthandpos.pos.BaseActivity;
+import com.yijia.zthandpos.pos.MainApplication;
+import com.yijia.zthandpos.pos.utils.MessageManager;
+import com.yijia.zthandpos.pos.utils.Shower;
+
+import com.yijia.zthandpos.pos.R;
+
+public class PrinterActivity extends BaseActivity {
+    private MessageManager messageManager;
+    private Printer mPrint;
+    private Button  mClearButton;
+    private Button  mOpenButton;
+    private Button mLoopButton;
+    private Button  mPrintDefaultButton;
+    private Button  mCloseButton;
+    private Shower shower ;
+    private static final String mPrintReceive="com.szzt.printer.stat";
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        requestWindowFeature(Window.FEATURE_NO_TITLE); 
+        setContentView(R.layout.activity_printer);
+        shower = new Shower(this);
+        boolean isConnected = mainApplication.isDeviceManagerConnetcted();
+        IntentFilter printerFilter=new IntentFilter(mPrintReceive);
+		PrinterReceiver printReceiver=new PrinterReceiver();
+		registerReceiver(printReceiver, printerFilter);
+        init(isConnected);
+    }
+    public static int mPrintStatus=-9999;
+    class PrinterReceiver extends BroadcastReceiver{
+
+		@Override
+		public void onReceive(Context context, Intent intent) {
+			if(mPrintReceive.equals(intent.getAction())){
+				mPrintStatus=intent.getIntExtra("stat", Printer.STATUS_OK);
+				if(mPrintStatus==Printer.STATUS_OK){
+					if(mIndex>0){
+						PrinterDefaultPurchase();
+					}
+				}
+			}
+		}
+	}
+
+    private void init(boolean isConnected) {
+        if (messageManager == null) {
+            TextView text = (TextView) findViewById(R.id.print_text);
+            text.setMovementMethod(ScrollingMovementMethod.getInstance());
+            messageManager = new MessageManager(this, text);
+            mClearButton = (Button) findViewById(R.id.print_clear);
+            mClearButton.setOnClickListener(listener);
+            mLoopButton=(Button) findViewById(R.id.print_loop);
+            mLoopButton.setOnClickListener(listener);
+            mOpenButton = (Button) findViewById(R.id.print_open);
+            mOpenButton.setOnClickListener(listener);
+            mPrintDefaultButton = (Button) findViewById(R.id.print_print);
+            mPrintDefaultButton.setOnClickListener(listener);
+            mCloseButton = (Button) findViewById(R.id.print_close);
+            mCloseButton.setOnClickListener(listener);
+            mPrint = mainApplication.getPrinter();
+        }
+        mClearButton.setEnabled(isConnected);
+        mOpenButton.setEnabled(isConnected);
+        mPrintDefaultButton.setEnabled(isConnected);
+        mCloseButton.setEnabled(isConnected);
+        mLoopButton.setEnabled(isConnected);
+    }
+    private final OnClickListener listener = new OnClickListener() {
+
+        @Override
+        public void onClick(View v) {
+            switch (v.getId()) {
+            case R.id.print_clear:
+                messageManager.clear();
+                break;
+            case R.id.print_open: {
+                int ret = mPrint.open();
+                if (ret >= 0) {
+                	mPrintStatus=ret = mPrint.getStatus();
+                    if (ret == Printer.STATUS_NO_PAPER) {
+                    	//no paper
+                        messageManager
+                        .AppendInfoMessage("\n"+shower.getString(R.string.msg_printer_lake_paper));
+                    } else if (ret == Printer.STATUS_OK) {
+                    	//ok
+                        messageManager
+                        .AppendInfoMessage("\n"+shower.getString(R.string.msg_printer_has_paper));
+                    } else if (ret == Printer.STATUS_LOWVOL) {
+                    	//low vol
+                        messageManager
+                        .AppendInfoMessage("\n"+shower.getString(R.string.msg_printer_has_paper));
+                    } else if (ret == Printer.STATUS_OVERHEAT) {
+                    	//too heat
+                        messageManager
+                        .AppendInfoMessage("\n"+shower.getString(R.string.msg_printer_has_paper));
+                    } else {
+                        messageManager
+                        .AppendInfoMessage("\n"+shower.getString(R.string.msg_printer_unknow_status));
+                    }
+                } else {
+                    messageManager
+                    .AppendInfoMessage(
+                            shower.getString(R.string.msg_printer_open_error),
+                            Color.RED);
+                }
+            }
+            break;
+            case R.id.print_close: {
+            	mIndex=0;
+                int ret = mPrint.close();
+                if (ret >= 0) {
+                    messageManager
+                    .AppendInfoMessage(shower.getString(R.string.msg_printer_close_succ));
+                } else {
+                    messageManager
+                    .AppendInfoMessage(
+                            shower.getString(R.string.msg_printer_clsoe_error),
+                            Color.RED);
+                }
+            }
+            break;
+            case R.id.print_print:
+                if (mPrint.getStatus() == Printer.STATUS_NO_PAPER) {
+                    messageManager
+                    .AppendInfoMessage(
+                            shower.getString(R.string.msg_printer_lake_paper),
+                            Color.RED);
+                    return;
+                }    
+                if(mIndex<=0){
+                	PrinterDefaultPurchase();
+                    mIndex=1;
+                }                
+                break;
+            case R.id.print_loop:
+            	if (mPrint.getStatus() == Printer.STATUS_NO_PAPER) {
+                    messageManager
+                    .AppendInfoMessage(
+                            shower.getString(R.string.msg_printer_lake_paper),
+                            Color.RED);
+                    return;
+                }
+            	
+            	if(mIndex<=0){ 
+            		PrinterDefaultPurchase();
+            		if(MainApplication.printIndex == 0)
+            		{
+            			mIndex=300;
+            		}else{
+            			mIndex = MainApplication.printIndex;
+            		}
+
+            	}
+            	else{
+            		 messageManager
+                     .AppendInfoMessage(
+                             "mIndex="+mIndex,
+                             Color.RED);
+            	}
+            	
+            	break;
+            default:
+            	
+                break;
+            }
+        }
+    };
+    private int mIndex=0;
+    private void PrinterDefaultPurchase() {
+    	if(mPrintStatus==Printer.STATUS_OK){
+    		mPrint.addStr("交易凭证\n\n", Printer.Font.LARGE, true,Printer.Align.LEFT);
+    		mPrint.addStr("交易流水:{0}\n", Printer.Font.FONT_2, false,Printer.Align.LEFT);
+    		mPrint.addStr("终端编号:{1}\n", Printer.Font.FONT_2, false,Printer.Align.LEFT);
+    		mPrint.addStr("卡号:{2}\n", Printer.Font.FONT_2, false,Printer.Align.LEFT);
+    		mPrint.addStr("交易类型:{3}\n", Printer.Font.FONT_2, false,Printer.Align.LEFT);
+    		mPrint.addStr("批次号:{4}\n", Printer.Font.FONT_2, false,Printer.Align.LEFT);
+    		mPrint.addStr("交易时间:{5}\n", Printer.Font.FONT_2, false,Printer.Align.LEFT);
+    		mPrint.addStr("金额:{6}\n", Printer.Font.FONT_2, false,Printer.Align.LEFT);
+    		mPrint.addStr("交易结果:{7}\n", Printer.Font.FONT_2, false,Printer.Align.LEFT);
+    		mPrint.addStr("-----冠字码-----\n", Printer.Font.FONT_2, true,Printer.Align.LEFT);
+    		mPrint.addStr("{8}本人已确认以上交易,并核对冠字码\n", Printer.Font.FONT_2, false,Printer.Align.LEFT);
+    		mPrint.addStr("无误!\n\n\n", Printer.Font.FONT_2, true,Printer.Align.LEFT);
+    		mPrint.start(new IPrinterListener.Stub() {
+    			
+    			@Override
+    			public void PrinterNotify(final int retCode) throws RemoteException {
+    				mHandler.post(new Runnable() {					
+    					@Override
+    					public void run() {						
+    						if (retCode == 0) {
+    							mIndex--;
+    							if(mIndex>0){
+    								PrinterDefaultPurchase();							
+    							}
+    							else{
+    								messageManager.AppendInfoMessage(shower.getString(R.string.msg_printer_print_succ));
+    							}
+    				        } else {
+    		                	int ret = mPrint.getStatus();
+    		                    if (ret == Printer.STATUS_NO_PAPER) {
+    		                    	//no paper
+    		                        messageManager
+    		                        .AppendInfoMessage("\n"+shower.getString(R.string.msg_printer_lake_paper));
+    		                    } else if (ret == Printer.STATUS_OK) {
+    		                    	//ok
+    		                        messageManager
+    		                        .AppendInfoMessage("\n"+shower.getString(R.string.msg_printer_has_paper));
+    		                    } else if (ret == Printer.STATUS_LOWVOL) {
+    		                    	//low vol
+    		                        messageManager
+    		                        .AppendInfoMessage("\n"+shower.getString(R.string.msg_printer_has_paper));
+    		                    } else if (ret == Printer.STATUS_OVERHEAT) {
+    		                    	//too heat
+    		                        messageManager
+    		                        .AppendInfoMessage("\n"+shower.getString(R.string.msg_printer_has_paper));
+    		                    } else {
+    		                        messageManager
+    		                        .AppendInfoMessage("\n"+shower.getString(R.string.msg_printer_unknow_status));
+    		                    }
+    				        }
+    					}
+    				});
+    			}
+    		});
+    	}
+    	else{
+    		messageManager.AppendInfoMessage(shower.getString(R.string.msg_printer_print_error),
+                    Color.RED);
+    	}
+    }
+    private final Handler mHandler=new Handler(Looper.getMainLooper());
+    @Override
+    protected void onDestroy() {
+        if (mPrint.getStatus() != Device.STATUS_CLOSED) {
+            mPrint.close();
+        }
+        super.onDestroy();
+    }
+
+}

+ 213 - 0
ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/test/PsamCardActivity.java

@@ -0,0 +1,213 @@
+package com.yijia.zthandpos.pos.test;
+
+import android.os.Bundle;
+import android.os.HandlerThread;
+import android.text.method.ScrollingMovementMethod;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.szzt.sdk.device.Device;
+import com.szzt.sdk.device.card.SmartCardReader;
+import com.yijia.zthandpos.pos.BaseActivity;
+import com.yijia.zthandpos.pos.utils.MessageManager;
+import com.yijia.zthandpos.pos.utils.Shower;
+
+import com.yijia.zthandpos.pos.R;
+
+public class PsamCardActivity extends BaseActivity {
+	private SmartCardReader mSmartCardReader;
+	private Button mOpenButton, mOpen2Button;
+	private Button mClearButton;
+	private Button mCloseButton;
+	private TextView mTextViewResult;
+	MessageManager messageManager;
+	HandlerThread mWaitForCardHandlerThread;
+	int mTestDeviceType = Device.TYPE_UNKNOWN;
+	private Shower shower;
+
+	private final int SlotIndex1 = 1;
+
+	private final int SlotIndex2 = 2;
+
+	private final int SUCCESS = 1;
+
+	private final int FAIL = -1;
+
+	byte[] apduSend = { 0x00, (byte) 0xA4, 0x00, 0x00, 0x02, (byte) 0xDF, 0x01 };
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState) {
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_psamcard);
+		shower = new Shower(this);
+		boolean isConnected = mainApplication.isDeviceManagerConnetcted();
+		init(isConnected);
+		if (messageManager != null) {
+			messageManager.AppendInfoMessage("test_psamcardreader");
+		}
+	}
+
+	@Override
+	protected void onStop() {
+		super.onStop();
+		if (mSmartCardReader != null) {
+			mSmartCardReader.close();
+		}
+	}
+
+	private void init(boolean isConnected) {
+		if (mCloseButton == null) {
+			mTextViewResult = (TextView) findViewById(R.id.mag_text);
+			mTextViewResult.setMovementMethod(ScrollingMovementMethod.getInstance());
+
+			messageManager = new MessageManager(this, mTextViewResult);
+
+			mOpenButton = (Button) findViewById(R.id.psam1_open);
+			mOpenButton.setOnClickListener(listener);
+
+			mOpen2Button = (Button) findViewById(R.id.psam2_open);
+			mOpen2Button.setOnClickListener(listener);
+
+			mClearButton = (Button) findViewById(R.id.psam_clear);
+			mClearButton.setOnClickListener(listener);
+
+		}
+		mTextViewResult.setEnabled(isConnected);
+		mOpenButton.setEnabled(isConnected);
+		mOpen2Button.setEnabled(isConnected);
+		mClearButton.setEnabled(isConnected);
+		if (isConnected) {
+			mSmartCardReader = mainApplication.getSmartCardReader();
+		} else {
+			mSmartCardReader = null;
+		}
+	}
+
+	public byte[] exchangeApdu(int mSlotIndex, byte[] apdu) {
+		// TODO Auto-generated method stub
+		byte[] apduResp = new byte[512];
+		int mRet = mSmartCardReader.transmit(mSlotIndex, apdu, apduResp);
+		if (mRet > 0) {
+			byte[] apduRespTemp = new byte[mRet];
+			System.arraycopy(apduResp, 0, apduRespTemp, 0, mRet);
+			return apduRespTemp;
+		}
+		return null;
+	}
+
+	/**
+	 * @param buffer
+	 * @return
+	 */
+	public String byte2hex(byte buffer) {
+		String h = "";
+
+		String temp = Integer.toHexString(buffer & 0xFF);
+		if (temp.length() == 1) {
+			temp = "0" + temp;
+		}
+		h = h + "" + temp;
+
+		return h;
+	}
+
+	/**
+	 * @param buffer
+	 * @return
+	 */
+	public String bytes2hex(byte[] buffer) {
+		String h = "";
+
+		for (int i = 0; i < buffer.length; i++) {
+			String temp = Integer.toHexString(buffer[i] & 0xFF);
+			if (temp.length() == 1) {
+				temp = "0" + temp;
+			}
+			h = h + "  " + temp;
+		}
+
+		return h;
+	}
+
+
+	public int open(int mSlotIndex) {
+		if (mSmartCardReader == null) {
+			mSmartCardReader = mainApplication.getSmartCardReader();
+			if (mSmartCardReader == null) {
+				mSmartCardReader = mainApplication.getSmartCardReader();
+				return FAIL;
+			}
+			return FAIL;
+		}
+
+		int mRet = mSmartCardReader.open(mSlotIndex, null);
+
+		if (mRet >= 0)
+			return SUCCESS;
+
+		return FAIL;
+	}
+
+	private void testPsamCardReader(int slotIndex) {
+		byte[] apdu = new byte[64];
+		int mRet = mSmartCardReader.powerOn(slotIndex, apdu);
+		messageManager.AppendInfoMessageInUiThread("POWER ON:"
+				+ (mRet > 0 ? SUCCESS : FAIL) + ",slotIndex=" + slotIndex);
+		if (mRet >= 0) {
+			byte[] response = exchangeApdu(slotIndex, apduSend);
+			if (response != null) {
+				messageManager.AppendInfoMessageInUiThread("PSAM" + slotIndex
+						+ ": apdu response  (len " + response.length + "):");
+				messageManager.AppendInfoMessageInUiThread(bytes2hex(response));
+			}
+			mSmartCardReader.powerOff(slotIndex);
+		}
+		mSmartCardReader.close(slotIndex);
+		messageManager.AppendInfoMessage(shower
+				.getString(R.string.btn_psamcard_close));
+
+	}
+
+	private final View.OnClickListener listener = new View.OnClickListener() {
+		@Override
+		public void onClick(View v) {
+			switch (v.getId()) {
+			case R.id.psam1_open: {
+				int nret = open(SlotIndex1);
+				if (nret >= 0) {
+					messageManager.AppendInfoMessage(shower
+							.getString(R.string.msg_card_open_success));
+
+					testPsamCardReader(SlotIndex1);
+
+				} else {
+					messageManager.AppendInfoMessage(shower
+							.getString(R.string.msg_card_open_error));
+				}
+			}
+				break;
+			case R.id.psam2_open: {
+				int nret = open(SlotIndex2);
+				if (nret >= 0) {
+					messageManager.AppendInfoMessage(shower
+							.getString(R.string.msg_card_open_success));
+
+					testPsamCardReader(SlotIndex2);
+
+				} else {
+					messageManager.AppendInfoMessage(shower
+							.getString(R.string.msg_card_open_error));
+				}
+			}
+				break;
+				
+			case R.id.psam_clear:
+				messageManager.clear();
+				break;
+			default:
+				break;
+			}
+		}
+	};
+}

+ 287 - 0
ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/test/RFCardActivity.java

@@ -0,0 +1,287 @@
+package com.yijia.zthandpos.pos.test;
+
+import android.graphics.Color;
+import android.os.Bundle;
+import android.text.method.ScrollingMovementMethod;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.szzt.sdk.device.Constants.Error;
+import com.szzt.sdk.device.card.ContactlessCardReader;
+import com.szzt.sdk.device.card.M1KeyType;
+import com.yijia.zthandpos.pos.BaseActivity;
+import com.yijia.zthandpos.pos.utils.MessageManager;
+import com.yijia.zthandpos.pos.utils.Shower;
+import com.yijia.zthandpos.pos.utils.StringUtility;
+
+import com.yijia.zthandpos.pos.R;
+
+public class RFCardActivity extends BaseActivity{
+    private ContactlessCardReader mContactlessCardReader;
+    private Button mOpenButton;
+    private Button mClearButton;
+    private Button mCloseButton;
+    private TextView mTextViewResult;
+    MessageManager messageManager;
+    private Shower shower ;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_card);
+        shower = new Shower(this) ;
+        boolean isConnected = mainApplication.isDeviceManagerConnetcted();
+        init(isConnected);
+    }
+    
+    @Override
+    protected void onStop() {
+    	super.onStop();
+    	if (mContactlessCardReader != null){
+    		mContactlessCardReader.close();
+    	}
+    }
+    
+    private void init(boolean isConnected) {
+        if (mCloseButton == null) {
+            mTextViewResult = (TextView) findViewById(R.id.mag_text);
+            mTextViewResult.setMovementMethod(ScrollingMovementMethod
+                    .getInstance());
+
+            messageManager = new MessageManager(this, mTextViewResult);
+
+            mOpenButton = (Button) findViewById(R.id.mag_open);
+            mOpenButton.setOnClickListener(listener);
+
+            mClearButton = (Button) findViewById(R.id.mag_clear);
+            mClearButton.setOnClickListener(listener);
+
+            mCloseButton = (Button) findViewById(R.id.mag_close);
+            mCloseButton.setOnClickListener(listener);
+        }
+        mTextViewResult.setEnabled(isConnected);
+        mOpenButton.setEnabled(isConnected);
+        mClearButton.setEnabled(isConnected);
+        mCloseButton.setEnabled(isConnected);
+        
+        if (isConnected) {
+        	mContactlessCardReader = mainApplication.getContactlessCardReader();
+        } else {
+            mContactlessCardReader = null;
+        }
+    }
+    
+    void testContactlessCardReader() {
+        int result = mContactlessCardReader.waitForCard(60000);
+        if (result == 0) {
+            byte[] data=new byte[256];
+            result=mContactlessCardReader.powerOn(data);            
+            messageManager.AppendInfoMessageInUiThread("Power On ATR:" +( result>0?StringUtility.ByteArrayToString(data, result):""));
+            int cardType = mContactlessCardReader.getCardType();
+
+            switch (cardType) {
+                case 0x0000:
+                    messageManager
+                            .AppendInfoMessageInUiThread("Get Card Type: A_CPU");
+                    break;
+                case 0x0100:
+                    messageManager
+                            .AppendInfoMessageInUiThread("Get Card Type: B_CPU");
+                    break;
+                case 0x0001:
+                    messageManager
+                            .AppendInfoMessageInUiThread("Get Card Type: CLASSIC_MINI");
+                    break;
+                case 0x0002:
+                    messageManager
+                            .AppendInfoMessageInUiThread("Get Card Type: CLASSIC_1K");
+                    break;
+                case 0x0003:
+                    messageManager
+                            .AppendInfoMessageInUiThread("Get Card Type: CLASSIC_4K");
+                    break;
+                case 0x0004:
+                    messageManager
+                            .AppendInfoMessageInUiThread("Get Card Type: UL_64");
+                    break;
+                case 0x0005:
+                    messageManager
+                            .AppendInfoMessageInUiThread("Get Card Type: UL_192");
+                    break;
+                case 0x0006:
+                    messageManager
+                            .AppendInfoMessageInUiThread("Get Card Type: MP_2K_SL1");
+                    break;
+                case 0x0007:
+                    messageManager
+                            .AppendInfoMessageInUiThread("Get Card Type: MP_4K_SL1");
+                    break;
+                case 0x0008:
+                    messageManager
+                            .AppendInfoMessageInUiThread("Get Card Type: MP_2K_SL2");
+                    break;
+                case 0x0009:
+                    messageManager
+                            .AppendInfoMessageInUiThread("Get Card Type: MP_4K_SL2");
+                    break;
+//                default:
+//                    messageManager.AppendInfoMessageInUiThread(
+//                            "Get Card Type: UNKNOW", Color.RED);
+                default:
+                    messageManager.AppendInfoMessageInUiThread(
+                            "Get Card Type: A_CPU", Color.BLACK);
+                    break;
+            }
+
+            ContactlessCardReader.CardInfo cardInfo = mContactlessCardReader.getCardInfo();
+            if (cardInfo != null) {
+                messageManager.AppendInfoMessageInUiThread("CardInfo of UID:"
+                        + StringUtility.getStringFormat(cardInfo.uid));
+            }
+
+            if (cardType == 0x0000 || cardType == 0x0100) {
+                testContactlessCardReaderIOApdu();
+            } else if (cardType == 0x0002 || cardType == 0x0003) {
+                testContactlessCardReaderIO_M1();
+            } else {
+                testContactlessCardReaderIOApdu();
+            }
+        } else if (result == Error.TIMEOUT) {
+            messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.msg_card_time_out),
+                    Color.RED);
+        } else if (result == Error.DEVICE_FORCE_CLOSED) {
+            messageManager.AppendInfoMessageInUiThread(
+                    shower.getString(R.string.msg_card_force_close), Color.RED);
+        } else {
+            messageManager.AppendInfoMessageInUiThread(
+                    shower.getString(R.string.msg_card_read_error), Color.RED);
+        }
+    }
+
+    void testContactlessCardReaderIO_M1() {
+        int iSecIdx = 0x02; //����02
+        int iBlkIdx = 0x02; //��02
+        byte[] pin = new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+                (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
+        int iRet = mContactlessCardReader.verifyPinMifare(iSecIdx, M1KeyType.KEYTYPE_A, pin);
+        if (iRet >= 0) {
+            messageManager.AppendInfoMessageInUiThread("Sector " + iSecIdx
+                    + shower.getString(R.string.msg_card_verify_pass_succ), Color.GREEN);
+
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+
+            byte[] inData = new byte[] { (byte) 0x01, (byte) 0x02, (byte) 0x03,
+                    (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
+                    (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x0B,
+                    (byte) 0x0C, (byte) 0xA1, (byte) 0xB2, (byte) 0xC3,
+                    (byte) 0xD4 };
+
+            iRet = mContactlessCardReader.writeMifare(iSecIdx, iBlkIdx, inData);
+            if (iRet >= 0) {
+                messageManager.AppendInfoMessageInUiThread("Write [" + iSecIdx
+                        + ", " + iBlkIdx + "]:"
+                        + StringUtility.ByteArrayToString(inData, 16));
+            } else {
+                messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.msg_card_write_op_error), Color.RED);
+            }
+
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+
+            byte[] outBuf = new byte[16];
+
+            iRet = mContactlessCardReader.readMifare(iSecIdx, iBlkIdx, outBuf);
+            if (iRet >= 0) {
+                messageManager.AppendInfoMessageInUiThread("Read [" + iSecIdx
+                        + ", " + iBlkIdx + "]:"
+                        + StringUtility.ByteArrayToString(outBuf, iRet));
+            } else {
+                messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.msg_card_read_op_error), Color.RED);
+            }
+        } else {
+            messageManager.AppendInfoMessageInUiThread(shower.getString(R.string.msg_card_verify_pass_error), Color.RED);
+        }
+    }
+
+    void testContactlessCardReaderIOApdu() {
+        // 00 A4 04 00 0E 2PAY.SYS.DDF01
+        byte[] apdu = new byte[] { (byte) 0x00, (byte) 0xA4, (byte) 0x04,
+                (byte) 0x00, (byte) 0x0E, 0x32, 0x50, 0x41, 0x59, 0x2E, 0x53,
+                0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31 };
+        byte[] ret = new byte[255];
+        int len = mContactlessCardReader.transmit(apdu, ret);
+        if (len >= 0) {
+            if (len >= 2 && ret[len - 2] == 97) {
+                apdu = new byte[] { 0x00, (byte) 0xC0, 0x00, 0x00,
+                        (byte) (ret[len - 1] & 0xFF) };
+                ret = new byte[255];
+                len = mContactlessCardReader.transmit(apdu, ret);
+            }
+        }
+        if (len >= 0) {
+            messageManager.AppendInfoMessageInUiThread("APDU:"
+                    + StringUtility.ByteArrayToString(ret, len));
+        } else {
+            messageManager.AppendInfoMessageInUiThread(
+                    shower.getString(R.string.msg_card_exe_apdu_error), Color.RED);
+        }
+    }
+    
+    private final View.OnClickListener listener = new View.OnClickListener() {
+        @Override
+        public void onClick(View v) {
+            switch (v.getId()) {
+                case R.id.mag_open: {
+                    int nret = mContactlessCardReader.open();
+                    if (nret >= 0) {
+                        messageManager
+                                .AppendInfoMessage(shower.getString(R.string.msg_card_open_success));
+                        messageManager
+                                .AppendInfoMessage(
+                                        shower.getString(R.string.msg_card_wait_for_card),
+                                        Color.GREEN);
+                        new Thread(){
+                        	@Override
+                        	public void run() {
+                        		testContactlessCardReader();
+                        	}
+                        }.start();
+                    } else {
+                        messageManager
+                                .AppendInfoMessage(shower.getString(R.string.msg_card_open_error));
+                    }
+                }
+                break;
+                case R.id.mag_clear:
+                    messageManager.clear();
+                    break;
+                case R.id.mag_close: {
+                    int ret = mContactlessCardReader.close();
+                    if (ret >= 0) {
+                        messageManager
+                                .AppendInfoMessage(shower.getString(R.string.msg_card_close_succ));
+                    } else {
+                        messageManager
+                                .AppendInfoMessage(
+                                        shower.getString(R.string.msg_card_close_succ),
+                                        Color.RED);
+                    }
+                }
+                break;
+                default:
+                    break;
+            }
+        }
+    };
+
+}

+ 454 - 0
ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/test/ReadCardActivity.java

@@ -0,0 +1,454 @@
+package com.yijia.zthandpos.pos.test;
+
+import android.graphics.Color;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.text.method.ScrollingMovementMethod;
+import android.view.View;
+import android.view.Window;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.szzt.sdk.device.Constants.Error;
+import com.szzt.sdk.device.card.ContactlessCardReader;
+import com.szzt.sdk.device.card.MagneticStripeCardReader;
+import com.szzt.sdk.device.card.SmartCardReader;
+import com.yijia.zthandpos.pos.BaseActivity;
+import com.yijia.zthandpos.pos.utils.MessageManager;
+import com.yijia.zthandpos.pos.utils.StringUtility;
+
+import com.yijia.zthandpos.pos.R;
+
+public class ReadCardActivity extends BaseActivity {
+	private MessageManager      mMessageManager;	
+    private Button              mReadButton;
+    private Button              mClearButton;
+    private Button 				mCloseButton;
+    private static final int    CARD_SHOW_MESSAGE=11;
+    private static final int    CARD_READ_FINISH=13;
+    private boolean             IsRead=false;
+    private SmartCardReader     mContactCard;
+    private ContactlessCardReader mContactlessCard;
+    private MagneticStripeCardReader mMagCard;
+    private final boolean[] mTypes=new boolean[]{true,false,false,false,false,false,true,true,false};
+	@Override
+	protected void onCreate(Bundle savedInstanceState) {
+		super.onCreate(savedInstanceState);
+		requestWindowFeature(Window.FEATURE_NO_TITLE); 
+		setContentView(R.layout.activity_card);
+		boolean isConnected = mainApplication.isDeviceManagerConnetcted();
+		init(isConnected);
+	}
+	@Override
+	protected void onDestroy() {
+		if(mMagCard!=null){
+			mMagCard.close();
+			mMagCard=null;
+		}
+		if(mContactlessCard!=null){
+			mContactlessCard.close();
+			mContactlessCard=null;
+		}
+		if(mContactCard!=null){
+			mContactCard.close(0);
+			mContactCard=null;
+		}
+		super.onDestroy();
+	}
+	private void init(boolean isConnected) {
+		TextView mTextView=(TextView) findViewById(R.id.mag_text);
+		mTextView.setMovementMethod(ScrollingMovementMethod.getInstance());
+		mMessageManager=new MessageManager(this, mTextView);
+		mMessageManager.InfoMessage(getString(R.string.info_card_test)+"\n");
+		mClearButton=(Button) findViewById(R.id.mag_clear);
+		mClearButton.setOnClickListener(mClick);
+		mReadButton=(Button) findViewById(R.id.mag_open);
+		mReadButton.setOnClickListener(mClick);
+		mReadButton.setEnabled(isConnected);
+		mCloseButton = (Button) findViewById(R.id.mag_close);
+		mCloseButton.setOnClickListener(mClick);
+		mMagCard=mainApplication.getMagneticStripeCardReader();
+		mContactCard=mainApplication.getSmartCardReader();
+		mContactlessCard=mainApplication.getContactlessCardReader();
+	}
+    private final View.OnClickListener mClick=new View.OnClickListener() {
+		@Override
+		public void onClick(View v) {
+			switch (v.getId()) {
+			case R.id.mag_clear:
+				mMessageManager.clear();
+				break;
+			case R.id.mag_open:
+				CardRead();
+				break;
+			case R.id.mag_close:
+				boolean ret = false;
+				ret = mMagCard.close() >=0;
+				ret = mContactlessCard.close()>=0;
+				ret = mContactCard.close()>=0;
+				IsRead = true;
+				if(ret)
+					mMessageManager.AppendInfoMessageInUiThread(getString(R.string.info_readcard_stop_test)+getString(R.string.info_success));
+				else
+					mMessageManager.AppendInfoMessageInUiThread(getString(R.string.info_readcard_stop_test)+getString(R.string.info_failed));
+				break;
+			default:
+				break;
+			}
+		}
+	};
+	
+	private final Handler mHandler=new Handler(){
+		public void handleMessage(android.os.Message msg) {
+			Bundle mBundle=(Bundle) msg.obj;  
+			switch (msg.what) {		
+			case CARD_SHOW_MESSAGE:
+				if(!mBundle.getBoolean("isSuccess")){
+					mMessageManager.AppendInfoMessageInUiThread(mBundle.getString("showMessage"),Color.RED);
+				}
+				else{
+					mMessageManager.AppendInfoMessageInUiThread(mBundle.getString("showMessage"));
+				}
+				break;
+			//��������
+			case CARD_READ_FINISH:
+				IsRead=false;
+				mMessageManager.AppendInfoMessageInUiThread("Card Read Finish",Color.RED);
+				mHandler.postDelayed(new Runnable() {
+					
+					@Override
+					public void run() {
+						CardRead();
+					}
+				}, 3000);				
+				break;
+			default:
+				break;
+			}
+		}
+	};
+ 
+	protected void CardRead() {
+		IsRead = false;
+		if(!IsRead){
+			IsRead=true;
+			if(mTypes[0])SmartOpen(0);
+			if(mTypes[1])SmartOpen(1);  
+			if(mTypes[2])SmartOpen(2);
+			if(mTypes[3])SmartOpen(3);
+			if(mTypes[4])SmartOpen(4);
+			if(mTypes[5])SmartOpen(5);
+			if(mTypes[6])ContactlessOpen(6);
+			if(mTypes[7])MagOpen(7);
+		}
+	}
+	/**
+	 * ������
+	 */
+	private void MagOpen(final int index) { 
+		if(mMagCard==null){
+			return;
+		}
+		new Thread(new Runnable() {
+			@Override
+			public void run() {				
+				int ret=mMagCard.open();
+				if(ret>=0){
+					sendMessage(CARD_SHOW_MESSAGE, getString(R.string.info_card_mag)+"-->"+getString(R.string.info_mag_waitforcard), true);
+					ret=mMagCard.waitForCard(100000);					
+					if(ret==0){
+						mainApplication.playWav(R.raw.success_tone,1);
+						sendMessage(CARD_SHOW_MESSAGE, getString(R.string.info_card_mag)+"-->"+getString(R.string.info_waitforcard_success), true);
+						CardCloseAll(index);
+						getTrackData(MagneticStripeCardReader.TRACK_INDEX_1);
+						getTrackData(MagneticStripeCardReader.TRACK_INDEX_2);
+						getTrackData(MagneticStripeCardReader.TRACK_INDEX_3);
+						MagClose();
+						sendMessage(CARD_READ_FINISH, null, false);
+					}
+					else if(ret==Error.TIMEOUT){
+						sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_card_mag)+"-->"+getString(R.string.info_waitforcard_timeout),false);
+						MagClose();
+						sendMessage(CARD_READ_FINISH, null, false);
+					}
+				}					
+				else
+					sendMessage(CARD_SHOW_MESSAGE, getString(R.string.info_card_mag)+"-->"+getString(R.string.info_open_device_failed), false);
+				
+				
+			}
+		}).start();
+	}
+	protected void MagClose() {
+		int ret=mMagCard.close();
+		if(ret>=0){
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_card_mag)+getString(R.string.info_close_device_success),true);
+		}
+		else
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_card_mag)+getString(R.string.info_close_device_failed),false);
+	}
+	//�ر����еĿ����豸
+	protected void CardCloseAll(int index) {
+		if(mTypes[0]&&index!=0)SmartClose(0);
+		if(mTypes[1]&&index!=1)SmartClose(1);
+		if(mTypes[2]&&index!=2)SmartClose(2);
+		if(mTypes[3]&&index!=3)SmartClose(3);
+		if(mTypes[4]&&index!=4)SmartClose(4);
+		if(mTypes[5]&&index!=5)SmartClose(5);
+		if(mTypes[6]&&index!=6)ContactlessClose();
+		if(mTypes[7]&&index!=7)MagClose();	
+	}
+	private void SmartClose(int nSlotIndex) {	
+		int ret=mContactCard.close(nSlotIndex);
+		if(ret>=0){
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_card_contact)+getString(R.string.info_close_device_success),true);
+		}
+		else
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_card_contact)+getString(R.string.info_close_device_failed),false);
+		
+	}
+	//��ôŵ�����
+	private String getTrackData(int nTrackIndex) {
+		sendMessage(CARD_SHOW_MESSAGE,"trackIndex-->"+nTrackIndex,false);
+		byte[] ret=mMagCard.getTrackData(nTrackIndex);
+		sendMessage(CARD_SHOW_MESSAGE, "trackData-->"+(ret==null?"":new String(ret)), true);
+		return ret==null?null:new String(ret).trim();
+	}
+	//�ǽӿ�
+	private void ContactlessOpen(final int index) {
+		if(mContactlessCard==null){
+			return;
+		}
+		new Thread(new Runnable() {			
+			@Override
+			public void run() {
+				
+				int ret=mContactlessCard.open();
+				if(ret>=0){
+					sendMessage(CARD_SHOW_MESSAGE, getString(R.string.info_card_contactless)+"-->"+getString(R.string.info_contactless_waitforcard), true);
+					ret=mContactlessCard.waitForCard(100000);
+					if(ret==0){
+						mainApplication.playWav(R.raw.success_tone,1);
+						CardCloseAll(index);
+						sendMessage(CARD_SHOW_MESSAGE, getString(R.string.info_card_contactless)+"-->"+getString(R.string.info_waitforcard_success), true);
+						int nCardType=mContactlessCard.getCardType();
+						if (nCardType == 0x0000 || nCardType == 0x0100) {
+							sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_card_cpu), true);
+							ContactlessPowerOn();
+		                } else if (nCardType == 0x0002 || nCardType == 0x0003) {
+		                	sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_card_mifare), true);
+		                	ContactlessVerifyPin("FFFFFFFFFFFF");
+		                } else {
+		                	ContactlessPowerOn();
+		                }
+					}
+					else if(ret==Error.TIMEOUT){
+						sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_card_contactless)+"-->"+getString(R.string.info_waitforcard_timeout),false);
+						ContactlessClose();
+						sendMessage(CARD_READ_FINISH, null, false);
+					}
+				}
+				else
+					sendMessage(CARD_SHOW_MESSAGE, getString(R.string.info_card_contactless)+"-->"+getString(R.string.info_open_device_failed), false);
+				
+			}
+		}).start();
+		
+	}
+	//M����
+	protected void ContactlessVerifyPin(String str) {
+		byte[] mPin=StringUtility.StringToByteArray(str);
+		int ret=mContactlessCard.verifyPinMifare(0x00, 0x0A, mPin);
+		if(ret>=0){
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_contactless_pin_check)+getString(R.string.info_success),true);
+			ContactlessWrite("0102030405060708090a0b0c0d0e0f");
+		}
+		else
+		{
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_contactless_pin_check)+getString(R.string.info_failed),false);
+			sendMessage(CARD_READ_FINISH, null, false);
+			ContactlessClose();
+		}
+	}
+	//M��д��ָ����������
+	private void ContactlessWrite(String str) {
+		byte[] data=StringUtility.StringToByteArray(str);
+		int ret=mContactlessCard.writeMifare(0x00, 0x01, data);
+		if(ret>=0){
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_contactless_write)+getString(R.string.info_success),true);
+			ContactlessRead();
+		}
+		else
+		{
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_contactless_write)+getString(R.string.info_failed),false);
+			sendMessage(CARD_READ_FINISH, null, false);
+			ContactlessClose();
+		}
+	}
+	//M����ȡָ����������
+	private void ContactlessRead() {
+		byte[] result=new byte[256];
+		int ret=mContactlessCard.readMifare(0x00, 0x01, result);
+		if(ret>=0){
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_contactless_read)+getString(R.string.info_success),true);
+			sendMessage(CARD_SHOW_MESSAGE,"return data-->"+StringUtility.ByteArrayToString(result, ret),true);
+			ContactlessClose();
+			sendMessage(CARD_READ_FINISH, null, false);
+		}
+		else
+		{
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_contactless_read)+getString(R.string.info_failed),false);
+			sendMessage(CARD_READ_FINISH, null, false);
+			ContactlessClose();
+		}
+	}
+	//�ǽӿ��ϵ�
+	protected void ContactlessPowerOn() {
+		byte[] atr=new byte[256];
+		int ret=mContactlessCard.powerOn(atr);
+		if(ret>=0){
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_card_poweron)+getString(R.string.info_success),true);
+			sendMessage(CARD_SHOW_MESSAGE,"PowerOn Atr-->"+StringUtility.ByteArrayToString(atr, ret),true);
+			ContactLessApdu("00A404000E315041592E5359532E4444463031");
+		}
+		else
+		{
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_card_poweron)+getString(R.string.info_failed),false);
+			sendMessage(CARD_READ_FINISH, null, false);
+			ContactlessClose();
+		}
+	}
+	//�ǽӿ�ִ��APDU
+	private void ContactLessApdu(String apdu) {
+		byte[] mApdu=StringUtility.StringToByteArray(apdu);
+		byte[] result=new byte[256];
+		int ret=mContactlessCard.transmit( mApdu, result);
+		if(ret>=0){
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_card_apdu)+getString(R.string.info_success),true);
+			sendMessage(CARD_SHOW_MESSAGE,"Apdu Return-->"+StringUtility.ByteArrayToString(result, ret),true);
+			ContactlessPowerOff();
+		}
+		else
+		{
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_card_apdu)+getString(R.string.info_failed),false);
+			sendMessage(CARD_READ_FINISH, null, false);
+			ContactlessClose();
+		}
+	}
+	//�ǽӿ��µ�
+	private void ContactlessPowerOff() {
+		int ret=mContactlessCard.powerOff();
+		if(ret>=0){
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_card_poweroff)+getString(R.string.info_success),true);
+		}
+		else
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_card_poweroff)+getString(R.string.info_failed),false);
+		ContactlessClose();
+		sendMessage(CARD_READ_FINISH, null, false);
+		
+	}
+	private void ContactlessClose() {
+		int ret=mContactlessCard.close();
+		if(ret>=0){
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_card_contactless)+getString(R.string.info_close_device_success),true);
+		}
+		else
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_card_contactless)+getString(R.string.info_close_device_failed),false);
+		
+	}
+	//�Ӵ���
+	private void SmartOpen(final int nSlotIndex) {
+		if(mContactCard==null){
+			return;
+		}
+		int ret=mContactCard.open(nSlotIndex, new SmartCardReader.SCReaderListener() {
+			@Override
+			public void notify(int nSlotIndex, int nEvent) {				 
+				if(nEvent==SmartCardReader.EVENT_SMARTCARD_NOT_READY){
+					sendMessage(CARD_SHOW_MESSAGE, getString(R.string.info_contact_card_remove), false);
+				}
+			}
+		});
+		if(ret>=0){
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_contact_waitforcard), true);
+			new Thread(new Runnable() {
+				@Override
+				public void run() {
+					int retCode=mContactCard.waitForCard(nSlotIndex, 100000);
+					if(retCode==0){
+						mainApplication.playWav(R.raw.success_tone,1);
+						CardCloseAll(nSlotIndex);
+						sendMessage(CARD_SHOW_MESSAGE, getString(R.string.info_card_contact)+"-->"+nSlotIndex,true);
+						sendMessage(CARD_SHOW_MESSAGE, getString(R.string.info_waitforcard_success),true);
+						ContactPowerOn(nSlotIndex);
+					}
+					else if(retCode==Error.TIMEOUT){
+						sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_waitforcard_timeout),false);
+						SmartClose(nSlotIndex);
+						sendMessage(CARD_READ_FINISH, null, false);
+					}
+				}
+			}).start();
+		}
+		else{			
+			mMessageManager.AppendInfoMessage(getString(R.string.info_open_device_failed),Color.RED);
+		}
+	}
+	
+	//�Ӵ����ϵ�
+	protected void ContactPowerOn(int nSlotIndex) {
+		byte[] atr=new byte[256];
+		int ret=mContactCard.powerOn(nSlotIndex, atr);
+		if(ret>=0){
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_card_poweron)+getString(R.string.info_success),true);
+			sendMessage(CARD_SHOW_MESSAGE,"PowerOn Atr-->"+StringUtility.ByteArrayToString(atr, ret),true);
+			ContactApdu(nSlotIndex,"00A404000E315041592E5359532E44444630310000");
+		}
+		else
+		{
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_card_poweron)+getString(R.string.info_failed),false);
+			sendMessage(CARD_READ_FINISH, null, false);
+			SmartClose(nSlotIndex);
+			
+		}
+	}
+	//�Ӵ���ִ��APDU
+	private void ContactApdu(int nSlotIndex,String apdu) {
+		byte[] mApdu=StringUtility.StringToByteArray(apdu);
+		byte[] result=new byte[256];
+		int ret=mContactCard.transmit(nSlotIndex, mApdu, result);
+		if(ret>=0){
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_card_apdu)+getString(R.string.info_success),true);
+			sendMessage(CARD_SHOW_MESSAGE,"Apdu Return-->"+StringUtility.ByteArrayToString(result, ret),true);
+			ContactPowerOff(nSlotIndex);
+		}
+		else
+		{
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_card_apdu)+getString(R.string.info_failed),false);
+			sendMessage(CARD_READ_FINISH, null, false);
+			SmartClose(nSlotIndex);
+		}
+	}
+	//�Ӵ����µ�
+	private void ContactPowerOff(int nSlotIndex) {
+		int ret=mContactCard.powerOff(nSlotIndex);
+		if(ret>=0){
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_card_poweroff)+getString(R.string.info_success),true);
+		}
+		else
+			sendMessage(CARD_SHOW_MESSAGE,getString(R.string.info_card_poweroff)+getString(R.string.info_failed),false);
+		SmartClose(nSlotIndex);
+		sendMessage(CARD_READ_FINISH, null, false);
+	}
+	private void sendMessage(int mWhat, String mStr,boolean isSuccess) {
+		Message msg= new Message();
+		msg.what=mWhat;
+		Bundle b=new Bundle();
+		b.putString("showMessage", mStr);
+		b.putBoolean("isSuccess", isSuccess);
+		msg.obj=b;
+		mHandler.sendMessage(msg);
+	}
+
+}

+ 123 - 0
ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/test/ScanActivity.java

@@ -0,0 +1,123 @@
+package com.yijia.zthandpos.pos.test;
+
+import android.graphics.Color;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.text.method.ScrollingMovementMethod;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.Window;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.szzt.sdk.device.Constants.Error;
+import com.szzt.sdk.device.barcode.CameraScan;
+import com.yijia.zthandpos.pos.BaseActivity;
+import com.yijia.zthandpos.pos.utils.MessageManager;
+
+import com.yijia.zthandpos.pos.R;
+/**
+ * 扫描界面
+ *
+ */
+public class ScanActivity extends BaseActivity {
+    private MessageManager messageManager;
+    private CameraScan mScan;
+    private Button  mClearButton;
+    private Button  mFrontButton;
+    private Button  mBackButton;
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        requestWindowFeature(Window.FEATURE_NO_TITLE); 
+        setContentView(R.layout.activity_scan);
+        boolean isConnected = mainApplication.isDeviceManagerConnetcted();
+        init(isConnected);
+    }
+
+    private void init(boolean isConnected) {
+        if (messageManager == null) {
+            TextView text = (TextView) findViewById(R.id.scan_text);
+            text.setMovementMethod(ScrollingMovementMethod.getInstance());
+            messageManager = new MessageManager(this, text);
+            mClearButton = (Button) findViewById(R.id.scan_clear);
+            mClearButton.setOnClickListener(listener);
+            mFrontButton = (Button) findViewById(R.id.scan_front);
+            mFrontButton.setOnClickListener(listener);
+            mBackButton = (Button) findViewById(R.id.scan_back);
+            mBackButton.setOnClickListener(listener);
+            mScan = mainApplication.getCameraScanImpl();
+        }
+        mClearButton.setEnabled(isConnected);
+        mFrontButton.setEnabled(isConnected);
+        mBackButton.setEnabled(isConnected);
+    }
+
+    private final OnClickListener listener = new OnClickListener() {
+
+        @Override
+        public void onClick(View v) {
+            switch (v.getId()) {
+            case R.id.scan_clear:
+                messageManager.clear();
+                break;
+            //前置摄像头
+            case R.id.scan_front: {
+            	Scan(CameraScan.CarmeraType.TYPE_FRONT_FACING,true);                
+            }
+            	break;
+            //后置摄像头
+            case R.id.scan_back: {
+            	Scan(CameraScan.CarmeraType.TYPE_BACK_FACING,true);             
+            }
+            break;
+            default:
+                break;
+            }
+        }
+    };
+    protected void Scan(int typeFrontFacing, boolean b) {
+    	Bundle bundle=new Bundle();
+    	bundle.putInt(CameraScan.BARCODE_CAMERA_TYPE,typeFrontFacing);
+    	bundle.putBoolean(CameraScan.BARCODE_BEEP, b);
+    	mScan.setConfig(bundle);
+    	mScan.scan(30000, new CameraScan.CameraListener() {
+			@Override
+			public void onNotify(final int ret, final byte[] data) {
+				mHandler.post(new Runnable() {
+					@Override
+					public void run() {
+						 if (ret >= 0) {
+							 messageManager
+				                .AppendInfoMessage(getString(R.string.info_scan_success)+"\n"+new String(data));
+				        }
+						 else if(ret==Error.TIMEOUT){
+							 messageManager
+					            .AppendInfoMessage(getString(R.string.info_scan_timeout),Color.RED);
+						 }
+						 else if(ret==Error.DEVICE_FORCE_CANCLE){
+							 messageManager
+					            .AppendInfoMessage(getString(R.string.info_scan_cancle),Color.RED);
+						 }
+						 else if(ret==Error.DEVICE_USED){
+							 messageManager
+					            .AppendInfoMessage(getString(R.string.info_scan_used),Color.RED);
+						 }
+						 else {
+				            messageManager
+				            .AppendInfoMessage(getString(R.string.info_scan_failed), Color.RED);
+				        }
+					}
+				});
+			}
+		});
+	}
+
+	private final Handler mHandler=new Handler(Looper.getMainLooper());
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+    }
+
+}

+ 157 - 0
ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/test/SystemManagerActivity.java

@@ -0,0 +1,157 @@
+package com.yijia.zthandpos.pos.test;
+
+import android.graphics.Color;
+import android.os.Bundle;
+import android.os.Environment;
+import android.text.method.ScrollingMovementMethod;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.szzt.sdk.system.SystemManager;
+import com.szzt.sdk.system.SystemManager.DeviceInfo;
+import com.yijia.zthandpos.pos.BaseActivity;
+import com.yijia.zthandpos.pos.utils.MessageManager;
+import com.yijia.zthandpos.pos.utils.Shower;
+
+import com.yijia.zthandpos.pos.R;
+
+public class SystemManagerActivity extends BaseActivity{
+    private SystemManager mSystemManager;
+    private Button sytem_reboot,system_shutdown,system_uninstall,system_install,
+    				system_setTime,system_getDeviceMsg,system_getUnionPayEncryptedSN;
+    private Button mClearButton;
+    private TextView mTextViewResult;
+    MessageManager messageManager;
+    private Shower shower;
+    
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_system);
+        shower = new Shower(this) ;
+        boolean isConnected = mainApplication.isDeviceManagerConnetcted();
+        init(isConnected);
+        if (messageManager != null) {
+            messageManager.AppendInfoMessage(R.string.button_system_test);
+        }
+    }
+    
+    private void init(boolean isConnected) {
+            mTextViewResult = (TextView) findViewById(R.id.mag_text);
+            mTextViewResult.setMovementMethod(ScrollingMovementMethod.getInstance());
+
+            messageManager = new MessageManager(this, mTextViewResult);
+
+            sytem_reboot = (Button) findViewById(R.id.sytem_reboot);
+            sytem_reboot.setOnClickListener(listener);
+
+            mClearButton = (Button) findViewById(R.id.mag_clear);
+            mClearButton.setOnClickListener(listener);
+
+            system_shutdown = (Button) findViewById(R.id.system_shutdown);
+            system_shutdown.setOnClickListener(listener);
+            
+            system_uninstall = (Button) findViewById(R.id.system_uninstall);
+            system_uninstall.setOnClickListener(listener);
+            
+            system_install = (Button) findViewById(R.id.system_install);
+            system_install.setOnClickListener(listener);
+            
+            system_setTime = (Button) findViewById(R.id.system_setTime);
+            system_setTime.setOnClickListener(listener);
+            
+            system_getDeviceMsg = (Button) findViewById(R.id.system_getDeviceMsg);
+            system_getDeviceMsg.setOnClickListener(listener);
+            
+            system_getUnionPayEncryptedSN = (Button) findViewById(R.id.system_getUnionPayEncryptedSN);
+            system_getUnionPayEncryptedSN.setOnClickListener(listener);
+            
+	        mTextViewResult.setEnabled(isConnected);
+	        sytem_reboot.setEnabled(isConnected);
+	        system_shutdown.setEnabled(isConnected);
+	        system_uninstall.setEnabled(isConnected);
+	        system_install.setEnabled(isConnected);
+	        system_setTime.setEnabled(isConnected);
+	        system_getDeviceMsg.setEnabled(isConnected);
+	        mClearButton.setEnabled(isConnected);
+	        system_getUnionPayEncryptedSN.setEnabled(isConnected);
+	        if (isConnected) {
+	        	mSystemManager = mainApplication.getSystemManager();
+	        } else {
+	        	mSystemManager = null;
+	        }
+    }
+    
+    private final View.OnClickListener listener = new View.OnClickListener() {
+        @Override
+        public void onClick(View v) {
+            switch (v.getId()) {
+                case R.id.sytem_reboot: {
+                    int nret = mSystemManager.reboot();
+                    if (nret < 0) {
+                    	messageManager.AppendInfoMessage(shower.getString(R.string.msg_sytem_reboot_fail), Color.RED);
+                    }
+                }
+                break;
+                case R.id.system_shutdown:
+                	messageManager.AppendInfoMessage(shower.getString(R.string.msg_sytem_sleep_start));
+                	int ret =mSystemManager.sleep(1000);//2s�����ٹػ�
+                	if (ret >= 0) {//���߳ɹ�
+                		messageManager.AppendInfoMessage(shower.getString(R.string.msg_sytem_sleep_end));
+                    }
+                	int nret =mSystemManager.shutdown();
+                	if (nret < 0) {
+                    	messageManager.AppendInfoMessage(shower.getString(R.string.msg_sytem_shutdown_fail), Color.RED);
+                    }
+                	break;
+                case R.id.system_uninstall:
+                	int ret2 =mSystemManager.uninstall("com.szzt.smartboxdemo");
+                	if(ret2>=0){//ж�سɹ�
+                		messageManager.AppendInfoMessage(shower.getString(R.string.msg_sytem_uninstall_suc));
+                	}else messageManager.AppendInfoMessage(shower.getString(R.string.msg_sytem_uninstall_fail), Color.RED);
+                	break;
+                case R.id.system_install:
+//                	int ret3 =mSystemManager.install(Environment.getExternalStorageDirectory().getAbsolutePath()+"/SmartBoxDemo.apk");
+                	int ret3 =mSystemManager.replace(Environment.getExternalStorageDirectory().getAbsolutePath()+"/SmartBoxDemo.apk");
+                	if(ret3>=0){//��װ�ɹ�
+                		messageManager.AppendInfoMessage(shower.getString(R.string.msg_sytem_install_suc));
+                	}else messageManager.AppendInfoMessage(shower.getString(R.string.msg_sytem_install_fail), Color.RED);
+                	break;
+                case R.id.system_setTime: 
+                	int ret4 =mSystemManager.setTime(System.currentTimeMillis()-1000*60);
+                	if(ret4>=0){//���óɹ�
+                		messageManager.AppendInfoMessage(shower.getString(R.string.msg_sytem_settime_suc));
+                	}else messageManager.AppendInfoMessage(shower.getString(R.string.msg_sytem_settime_fail), Color.RED);
+                	break;
+                case R.id.system_getDeviceMsg:
+                	getDeviceMsg();//��ȡ�豸��Ϣ
+                    break;
+                case R.id.system_getUnionPayEncryptedSN:
+                	if(mSystemManager.isSupportUinonPaySN()){
+                		byte[] sn=mSystemManager.getUnionPayEncryptedSN("123123");
+                		if(sn!=null){
+                			messageManager.AppendInfoMessage(shower.getString(R.string.msg_sytem_getuinonpaysn_suc)+"���к�Ϊ��"+sn);
+                		}else {
+                			messageManager.AppendInfoMessage(shower.getString(R.string.msg_sytem_getuinonpaysn_fail), Color.RED);
+						}
+                	}else messageManager.AppendInfoMessage(shower.getString(R.string.msg_sytem_getuinonpaysn_unsuport), Color.RED);
+                	break;
+                default:
+                    break;
+            }
+        }
+
+		private void getDeviceMsg() {
+			DeviceInfo mDeviceInfo=	mSystemManager.getDeviceInfo();
+			if(mDeviceInfo!=null){
+    			messageManager.AppendInfoMessage(shower.getString(R.string.msg_sytem_getdevice_msg_suc)+"\n �豸��Ϣ:"
+    					+"\n�豸���к�:"+mDeviceInfo.getSn()+"\n�豸����(0��������1������):"+mDeviceInfo.getType()
+    					+"\n�豸�ͺ�:"+mDeviceInfo.getModel()+"\n����Ӳ�����к�:"+mDeviceInfo.getHardwareSN());
+    		}else {
+    			messageManager.AppendInfoMessage(shower.getString(R.string.msg_sytem_getdevice_msg_fail), Color.RED);
+			}
+			
+		}
+    };
+}

+ 291 - 0
ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/test/WaveFileReader.java

@@ -0,0 +1,291 @@
+package com.yijia.zthandpos.pos.test;
+
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class WaveFileReader {  
+    private String filename = null;  
+    private int[][] data = null;  
+  
+    private int len = 0;  
+      
+    private String chunkdescriptor = null;  
+    static private final int lenchunkdescriptor = 4;
+  
+    private long chunksize = 0;  
+    static private final int lenchunksize = 4;
+  
+    private String waveflag = null;  
+    static private final int lenwaveflag = 4;
+  
+    private String fmtubchunk = null;  
+    static private final int lenfmtubchunk = 4;
+      
+    private long subchunk1size = 0;  
+    static private final int lensubchunk1size = 4;
+      
+    private int audioformat = 0;  
+    static private final int lenaudioformat = 2;
+      
+    private int numchannels = 0;  
+    static private final int lennumchannels = 2;
+      
+    private long samplerate = 0;  
+    static private final int lensamplerate = 2;
+      
+    private long byterate = 0;  
+    static private final int lenbyterate = 4;
+      
+    private int blockalign = 0;  
+    static private final int lenblockling = 2;
+      
+    private int bitspersample = 0;  
+    static private final int lenbitspersample = 2;
+      
+    private String datasubchunk = null;  
+    static private final int lendatasubchunk = 4;
+      
+    private long subchunk2size = 0;  
+    static private final int lensubchunk2size = 4;
+      
+      
+    private InputStream fis = null;  
+    private BufferedInputStream bis = null;  
+      
+    private boolean issuccess = false;  
+      
+    public WaveFileReader(String filename) {  
+          
+        this.initReader(filename);
+    }  
+    
+    public WaveFileReader(InputStream wavInStream) {  
+    	this.initReader(wavInStream);
+    }
+      
+    // �ж��Ƿ񴴽�wav��ȡ���ɹ�  
+    public boolean isSuccess() {  
+        return issuccess;  
+    }  
+      
+    // ��ȡÿ������ı��볤�ȣ�?8bit����16bit  
+    public int getBitPerSample(){  
+        return this.bitspersample;  
+    }  
+      
+    // ��ȡ������  
+    public long getSampleRate(){  
+        return this.samplerate;  
+    }  
+      
+    // ��ȡ�������?1��?���? 2���������?  
+    public int getNumChannels(){  
+        return this.numchannels;  
+    }  
+      
+    // ��ȡ��ݳ��ȣ�Ҳ����һ��������ٸ�  
+    public int getDataLen(){  
+        return this.len;  
+    }  
+      
+    // ��ȡ���?  
+    // �����һ����ά���飬[n][m]����n������ĵ�m������ֵ  
+    public int[][] getData(){  
+        return this.data;  
+    }  
+      
+    private void initReader(String filename){  
+        this.filename = filename;  
+  
+        try {  
+            fis = new FileInputStream(this.filename);  
+            bis = new BufferedInputStream(fis);  
+  
+            this.chunkdescriptor = readString(lenchunkdescriptor);  
+            if(!chunkdescriptor.endsWith("RIFF"))  
+                throw new IllegalArgumentException("RIFF miss, " + filename + " is not a wave file.");  
+              
+            this.chunksize = readLong();  
+            this.waveflag = readString(lenwaveflag);  
+            if(!waveflag.endsWith("WAVE"))  
+                throw new IllegalArgumentException("WAVE miss, " + filename + " is not a wave file.");  
+              
+            this.fmtubchunk = readString(lenfmtubchunk);  
+            if(!fmtubchunk.endsWith("fmt "))  
+                throw new IllegalArgumentException("fmt miss, " + filename + " is not a wave file.");  
+              
+            this.subchunk1size = readLong();  
+            this.audioformat = readInt();  
+            this.numchannels = readInt();  
+            this.samplerate = readLong();  
+            this.byterate = readLong();  
+            this.blockalign = readInt();  
+            this.bitspersample = readInt();  
+              
+            this.datasubchunk = readString(lendatasubchunk);  
+            if(!datasubchunk.endsWith("data"))  
+                throw new IllegalArgumentException("data miss, " + filename + " is not a wave file.");  
+            this.subchunk2size = readLong();  
+              
+            this.len = (int)(this.subchunk2size/(this.bitspersample/8)/this.numchannels);  
+              
+            this.data = new int[this.numchannels][this.len];  
+              
+            for(int i=0; i<this.len; ++i){  
+                for(int n=0; n<this.numchannels; ++n){  
+                    if(this.bitspersample == 8){  
+                        this.data[n][i] = bis.read();  
+                    }  
+                    else if(this.bitspersample == 16){  
+                        this.data[n][i] = this.readInt();  
+                    }  
+                }  
+            }  
+              
+            issuccess = true;  
+        } catch (Exception e) {  
+            e.printStackTrace();  
+        }  
+        finally{  
+            try{  
+            if(bis != null)  
+                bis.close();  
+            if(fis != null)  
+                fis.close();  
+            }  
+            catch(Exception e1){  
+                e1.printStackTrace();  
+            }  
+        }  
+    }  
+    
+    private void initReader(InputStream wavInStream){  
+        try {  
+        	fis = wavInStream;
+            bis = new BufferedInputStream(fis);  
+  
+            this.chunkdescriptor = readString(lenchunkdescriptor);  
+            if(!chunkdescriptor.endsWith("RIFF"))  
+                throw new IllegalArgumentException("RIFF miss, " + filename + " is not a wave file.");  
+              
+            this.chunksize = readLong();  
+            this.waveflag = readString(lenwaveflag);  
+            if(!waveflag.endsWith("WAVE"))  
+                throw new IllegalArgumentException("WAVE miss, " + filename + " is not a wave file.");  
+              
+            this.fmtubchunk = readString(lenfmtubchunk);  
+            if(!fmtubchunk.endsWith("fmt "))  
+                throw new IllegalArgumentException("fmt miss, " + filename + " is not a wave file.");  
+              
+            this.subchunk1size = readLong();  
+            this.audioformat = readInt();  
+            this.numchannels = readInt();  
+            this.samplerate = readLong();  
+            this.byterate = readLong();  
+            this.blockalign = readInt();  
+            this.bitspersample = readInt();  
+              
+            this.datasubchunk = readString(lendatasubchunk);  
+            if(!datasubchunk.endsWith("data"))  
+                throw new IllegalArgumentException("data miss, " + filename + " is not a wave file.");  
+            this.subchunk2size = readLong();  
+              
+            this.len = (int)(this.subchunk2size/(this.bitspersample/8)/this.numchannels);  
+              
+            this.data = new int[this.numchannels][this.len];  
+            
+            if (this.numchannels == 1 && this.bitspersample == 8) {
+            	pcm_8k_8b_data = new byte[this.len];
+            	bis.read(pcm_8k_8b_data);
+            }
+            else {
+	            for(int i=0; i<this.len; ++i){  
+	                for(int n=0; n<this.numchannels; ++n){  
+	                    if(this.bitspersample == 8){  
+	                        this.data[n][i] = bis.read();  
+	                    }  
+	                    else if(this.bitspersample == 16){  
+	                        this.data[n][i] = this.readInt();  
+	                    }  
+	                }  
+	            }  
+            }
+              
+            issuccess = true;  
+        } catch (Exception e) {  
+            e.printStackTrace();  
+        }  
+        finally{  
+            try{  
+            if(bis != null)  
+                bis.close();  
+            if(fis != null)  
+                fis.close();  
+            }  
+            catch(Exception e1){  
+                e1.printStackTrace();  
+            }  
+        }  
+    }  
+    
+    private byte [] pcm_8k_8b_data = null;
+    
+    public byte [] getPcmData() {
+    	return pcm_8k_8b_data;
+    }
+      
+    private String readString(int len){  
+        byte[] buf = new byte[len];  
+        try {  
+            if(bis.read(buf)!=len)  
+                throw new IOException("no more data!!!");  
+        } catch (IOException e) {  
+            e.printStackTrace();  
+        }  
+        return new String(buf);  
+    }  
+      
+    private int readInt(){  
+        byte[] buf = new byte[2];  
+        int res = 0;  
+        try {  
+            if(bis.read(buf)!=2)  
+                throw new IOException("no more data!!!");  
+            res = (buf[0]&0x000000FF) | (((int)buf[1])<<8);  
+        } catch (IOException e) {  
+            e.printStackTrace();  
+        }  
+        return res;  
+    }  
+      
+    private long readLong(){  
+        long res = 0;  
+        try {  
+            long[] l = new long[4];  
+            for(int i=0; i<4; ++i){  
+                l[i] = bis.read();  
+                if(l[i]==-1){  
+                    throw new IOException("no more data!!!");  
+                }  
+            }  
+            res = l[0] | (l[1]<<8) | (l[2]<<16) | (l[3]<<24);  
+        } catch (IOException e) {  
+            e.printStackTrace();  
+        }  
+        return res;  
+    }  
+      
+    private byte[] readBytes(int len){  
+        byte[] buf = new byte[len];  
+        try {  
+            if(bis.read(buf)!=len)  
+                throw new IOException("no more data!!!");  
+        } catch (IOException e) {  
+            e.printStackTrace();  
+        }  
+        return buf;  
+    }  
+}  
+

+ 30 - 0
ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/utils/FileUtils.java

@@ -0,0 +1,30 @@
+package com.yijia.zthandpos.pos.utils;
+import android.content.Context;
+import android.content.res.AssetManager;
+import android.util.Log;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public final class FileUtils {
+	public static boolean copyApkFromAssetsToData(Context context ,String fileName) {
+        try {
+            AssetManager as = context.getAssets();
+            InputStream ins = as.open(fileName);
+            String dstFilePath = context.getFilesDir().getAbsolutePath()
+                    + "/" + fileName;
+            OutputStream outs =context.openFileOutput(fileName,Context.MODE_WORLD_READABLE);
+            byte[] data = new byte[1 << 20];
+            int length = ins.read(data);
+            outs.write(data, 0, length);
+            ins.close();
+            outs.flush();
+            outs.close();
+            return true;
+        } catch (Exception e) {
+        	e.printStackTrace();
+        	Log.e("APP", "copy success");
+            return false;
+        }
+    }
+}

+ 346 - 0
ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/utils/HexDump.java

@@ -0,0 +1,346 @@
+package com.yijia.zthandpos.pos.utils;
+
+import android.annotation.SuppressLint;
+
+@SuppressLint("DefaultLocale")
+public class HexDump
+{
+    private final static char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+
+    public static String getHexString(byte[] bytes) {
+        String str = "";
+        for (byte b : bytes) {
+            str += String.format("%02X ", b);
+        }
+        return str;
+    }
+
+    public static String dumpHexString(byte[] array)
+    {
+        return dumpHexString(array, 0, array.length);
+    }
+    
+    public static String decBytesToHex(byte[] buffs) {
+		if (buffs == null || buffs.length == 0) {
+			return null;
+		}
+		StringBuffer buffer = new StringBuffer();
+		int len = buffs.length;
+		for (int i = 0; i < len; i++) {
+			buffer.append(String.format("%02X", buffs[i]));
+		}
+		return buffer.toString();
+	}
+
+    public static String dumpHexString(byte[] array, int offset, int length)
+    {
+        StringBuilder result = new StringBuilder();
+
+        byte[] line = new byte[16];
+        int lineIndex = 0;
+
+        result.append("\n0x");
+        result.append(toHexString(offset));
+
+        for (int i = offset ; i < offset + length ; i++)
+        {
+            if (lineIndex == 16)
+            {
+                result.append(" ");
+
+                for (int j = 0 ; j < 16 ; j++)
+                {
+                    if (line[j] > ' ' && line[j] < '~')
+                    {
+                        result.append(new String(line, j, 1));
+                    }
+                    else
+                    {
+                        result.append(".");
+                    }
+                }
+
+                result.append("\n0x");
+                result.append(toHexString(i));
+                lineIndex = 0;
+            }
+
+            byte b = array[i];
+            result.append(" ");
+            result.append(HEX_DIGITS[(b >>> 4) & 0x0F]);
+            result.append(HEX_DIGITS[b & 0x0F]);
+
+            line[lineIndex++] = b;
+        }
+
+        if (lineIndex != 16)
+        {
+            int count = (16 - lineIndex) * 3;
+            count++;
+            for (int i = 0 ; i < count ; i++)
+            {
+                result.append(" ");
+            }
+
+            for (int i = 0 ; i < lineIndex ; i++)
+            {
+                if (line[i] > ' ' && line[i] < '~')
+                {
+                    result.append(new String(line, i, 1));
+                }
+                else
+                {
+                    result.append(".");
+                }
+            }
+        }
+
+        return result.toString();
+    }
+
+    public static String dumpHex(byte[] array)
+    {
+        if(array==null)return "null";
+        return dumpHex(array, 0, array.length);
+    }
+    
+    public static String decBytesToHex(byte[] buffs, int length){
+		if (buffs == null || length == 0) {
+			return null;
+		}
+		StringBuffer buffer = new StringBuffer();
+		for (int i = 0; i < length; i++) {
+			buffer.append(String.format("%02X", buffs[i]));
+		}
+		return buffer.toString();
+	}
+
+    public static String dumpHex(byte[] array, int offset, int length)
+    {
+        StringBuilder result = new StringBuilder();
+
+        for (int i = offset ; i < offset + length ; i++)
+        {
+            byte b = array[i];
+            if(i!=offset){
+                result.append(" ");
+            }
+            result.append("0x");
+            result.append(HEX_DIGITS[(b >>> 4) & 0x0F]);
+            result.append(HEX_DIGITS[b & 0x0F]);
+
+        }
+        result.append(" ");
+        return result.toString();
+    }
+
+    public static String toHexString(byte b)
+    {
+        return toHexString(toByteArray(b));
+    }
+
+    public static String toHexStringX(byte b)
+    {
+        return "0x"+toHexString(toByteArray(b));
+    }
+
+    public static String toHexString(byte[] array)
+    {
+    	if (array == null){
+    		return "null";
+    	}
+        return toHexString(array, 0, array.length);
+    }
+
+    public static String toHexString(byte[] array, int offset, int length)
+    {
+        char[] buf = new char[length * 2];
+
+        int bufIndex = 0;
+        for (int i = offset ; i < offset + length; i++)
+        {
+            byte b = array[i];
+            buf[bufIndex++] = HEX_DIGITS[(b >>> 4) & 0x0F];
+            buf[bufIndex++] = HEX_DIGITS[b & 0x0F];
+        }
+
+        return new String(buf);
+    }
+
+    public static String toHexString(int i)
+    {
+        return toHexString(toByteArray(i));
+    }
+
+    public static String toHexStringX(int i)
+    {
+        return "0x"+toHexString(toByteArray(i));
+    }
+
+    public static byte[] toByteArray(byte b)
+    {
+        byte[] array = new byte[1];
+        array[0] = b;
+        return array;
+    }
+
+    public static byte[] toByteArray(int i)
+    {
+        byte[] array = new byte[4];
+
+        array[3] = (byte)(i & 0xFF);
+        array[2] = (byte)((i >> 8) & 0xFF);
+        array[1] = (byte)((i >> 16) & 0xFF);
+        array[0] = (byte)((i >> 24) & 0xFF);
+
+        return array;
+    }
+
+    private static int toByte(char c)
+    {
+        if (c >= '0' && c <= '9') return (c - '0');
+        if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
+        if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
+
+        throw new RuntimeException ("Invalid hex char '" + c + "'");
+    }
+
+    public static byte[] hexStringToByteArray(String hexString)
+    {
+        int length = hexString.length();
+        byte[] buffer = new byte[length / 2];
+
+        for (int i = 0 ; i < length ; i += 2)
+        {
+            buffer[i / 2] = (byte)((toByte(hexString.charAt(i)) << 4) | toByte(hexString.charAt(i+1)));
+        }
+
+        return buffer;
+    }
+
+    public static String bcd2Str(byte[] bytes) {
+        StringBuffer temp = new StringBuffer(bytes.length * 2);
+        for (int i = 0; i < bytes.length; i++) {
+            temp.append((byte) ((bytes[i] & 0xf0) >> 4));
+            temp.append((byte) (bytes[i] & 0x0f));
+        }
+        return temp.toString().substring(0, 1).equalsIgnoreCase("0") ? temp
+                .toString().substring(1) : temp.toString();
+    }
+
+    public static String byte2bcd(byte[] bcds)
+    {
+        char[] ascii = "0123456789abcdef".toCharArray();
+        byte[] temp = new byte[bcds.length * 2];
+        for (int i = 0; i < bcds.length; i++) {
+            temp[(i * 2)] = (byte)(bcds[i] >> 4 & 0xF);
+            temp[(i * 2 + 1)] = (byte)(bcds[i] & 0xF);
+        }
+        StringBuffer res = new StringBuffer();
+
+        for (int i = 0; i < temp.length; i++) {
+            res.append(ascii[temp[i]]);
+        }
+        return res.toString().toUpperCase();
+    }
+
+    public static byte[] str2Bcd(String asc) {
+
+        int len = asc.length();
+
+        int mod = len % 2;
+
+        if (mod != 0) {
+
+            asc = "0" + asc;
+
+            len = asc.length();
+
+        }
+
+        byte[] abt = new byte[len];
+
+        if (len >= 2) {
+
+            len = len / 2;
+
+        }
+
+        byte[] bbt = new byte[len];
+
+        abt = asc.getBytes();
+
+        int j, k;
+
+        for (int p = 0; p < asc.length() / 2; p++) {
+
+            if ((abt[2 * p] >= '0') && (abt[2 * p] <= '9')) {
+
+                j = abt[2 * p] - '0';
+
+            } else if ((abt[2 * p] >= 'a') && (abt[2 * p] <= 'z')) {
+
+                j = abt[2 * p] - 'a' + 0x0a;
+
+            } else {
+
+                j = abt[2 * p] - 'A' + 0x0a;
+
+            }
+
+            if ((abt[2 * p + 1] >= '0') && (abt[2 * p + 1] <= '9')) {
+
+                k = abt[2 * p + 1] - '0';
+
+            } else if ((abt[2 * p + 1] >= 'a') && (abt[2 * p + 1] <= 'z')) {
+
+                k = abt[2 * p + 1] - 'a' + 0x0a;
+
+            } else {
+
+                k = abt[2 * p + 1] - 'A' + 0x0a;
+
+            }
+
+            int a = (j << 4) + k;
+
+            byte b = (byte) a;
+
+            bbt[p] = b;
+
+        }
+
+        return bbt;
+
+    }
+    
+	public static int byteToInt(byte[] b) {
+		if (b == null || b.length > 4){
+			return 0;
+		}
+		int value = 0;
+		for (int i = 0; i < b.length; i++) {
+			int shift = (b.length - 1 - i) * 8;
+			value += (b[i + 0] & 0x000000FF) << shift;
+		}
+		return value;
+	}
+	
+
+//    public static byte[] hexStringToByte(String hex)
+//    {
+//        int len = hex.length() / 2;
+//        byte[] result = new byte[len];
+//        char[] achar = hex.toCharArray();
+//        for (int i = 0; i < len; i++) {
+//            int pos = i * 2;
+//            result[i] = (byte)(tobyte(achar[pos]) << 4 | tobyte(achar[(pos + 1)]));
+//        }
+//        return result;
+//    }
+//
+//    private static byte tobyte(char c) {
+//        byte b = (byte)"0123456789ABCDEF".indexOf(c);
+//        return b;
+//    }
+}

+ 106 - 0
ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/utils/MessageManager.java

@@ -0,0 +1,106 @@
+package com.yijia.zthandpos.pos.utils;
+
+import android.app.Activity;
+import android.content.Context;
+import android.graphics.Color;
+import android.text.Spannable;
+import android.text.style.ForegroundColorSpan;
+import android.widget.TextView;
+
+public class MessageManager {
+    private final TextView msgView;
+    private final Context  mContext;
+
+    public MessageManager(Context context, TextView textview) {
+        msgView = textview;
+        mContext = context;
+    }
+
+    public void InfoMessage(String msg) {
+        InfoMessage(msg, Color.BLACK);
+    }
+
+    public void InfoMessage(String msg, int color) {
+        msgView.setText(msg, TextView.BufferType.SPANNABLE);
+        Spannable style = (Spannable) msgView.getText();
+        int start = 0;
+        int end = start + msg.length();
+        ForegroundColorSpan colors = new ForegroundColorSpan(color);
+        style.setSpan(colors, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+    }
+
+    public void AppendInfoMessage(String msg, int color) {
+        int start = msgView.getText().length();
+        msgView.append(msg + "\n");
+        Spannable style = (Spannable) msgView.getText();
+        int end = start + msg.length();
+        ForegroundColorSpan colors = new ForegroundColorSpan(color);
+        style.setSpan(colors, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+    }
+
+    public void AppendInfoMessage(int id) {
+        AppendInfoMessage(mContext.getString(id));
+    }
+
+    public void AppendInfoMessage(int id, int color) {
+        AppendInfoMessage(mContext.getString(id), color);
+    }
+
+    public void AppendInfoMessageInUiThread(final String msg, final int color) {
+        final Activity activity = (Activity) mContext;
+        activity.runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                if (activity.isFinishing() == false)
+                    AppendInfoMessage(msg, color);
+
+            }
+        });
+    }
+
+    public void AppendInfoMessageInUiThread(final String msg) {
+        final Activity activity = (Activity) mContext;
+        activity.runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                if (activity.isFinishing() == false)
+                    AppendInfoMessage(msg);
+
+            }
+        });
+    }
+
+    public void AppendInfoMessageInUiThread(final int id, final int color) {
+        final Activity activity = (Activity) mContext;
+        activity.runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                if (activity.isFinishing() == false)
+                    AppendInfoMessage(mContext.getString(id), color);
+
+            }
+        });
+
+    }
+
+    public void AppendInfoMessageInUiThread(final int id) {
+        final Activity activity = (Activity) mContext;
+        activity.runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                if (activity.isFinishing() == false)
+                    AppendInfoMessage(mContext.getString(id));
+
+            }
+        });
+    }
+
+    public void AppendInfoMessage(String msg) {
+        AppendInfoMessage(msg, Color.BLACK);
+    }
+
+    public void clear() {
+        msgView.setText("");
+
+    }
+}

+ 17 - 0
ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/utils/Shower.java

@@ -0,0 +1,17 @@
+package com.yijia.zthandpos.pos.utils;
+
+import android.content.Context;
+
+/**
+ * Created by zq on 2016/6/7.
+ */
+public class Shower {
+    private static Context context ;
+    public Shower(Context c){
+        context = c ;
+    }
+
+    public String getString(int rid){
+        return  context.getResources().getString(rid);
+    }
+}

+ 563 - 0
ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/utils/StringUtil.java

@@ -0,0 +1,563 @@
+package com.yijia.zthandpos.pos.utils;
+
+public class StringUtil {
+    private static final String HexChars  = "1234567890abcdefABCDEF";
+    public static final int     LCD_WIDTH = 16;
+
+    /** A table of hex digits */
+    public static final char[]  hexDigit  = { '0', '1', '2', '3', '4', '5',
+            '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+
+    /**
+     * Convert a nibble to a hex character
+     * 
+     * @param nibble
+     *          the nibble to convert.
+     */
+    public static char toHexChar(int nibble) {
+        return hexDigit[(nibble & 0xF)];
+    }
+
+    public static int getSaveConvertLength(String theString) {
+        return saveConvert(theString, null, 0, true, true, true);
+    }
+
+    public static int saveConvert(String theString, byte[] dst, int offset) {
+        return saveConvert(theString, dst, offset, true, true, false);
+    }
+
+    /*
+     * Converts unicodes to encoded &#92;uxxxx and writes out any of the
+     * characters in specialSaveChars with a preceding slash
+     *
+     * @param theString
+     *            the String needing convert. 
+     * @param dst
+     *            Save of the result 
+     * @param offset
+     *            the offset of result 
+     * @param escapeSpace
+     *            if <code>true</code>, escape Space 
+     * @param lengthFlag
+     *            Whether add one byte of length in the result. 
+     *            <code>true</code> add one byte of length in the result
+     * @param getLengthFlag
+     *            Calculate the length of result, if <code>true</code>, theString length that return. 
+     * @return  if getLengthFlag = false, return offset of the result.
+     *          if getLengthFlag = true, the length of the sequence of characters represented by this
+     *          object.
+     */
+    public static int saveConvert(String theString, byte[] dst, int offset,
+            boolean escapeSpace, boolean lengthFlag, boolean getLengthFlag) {
+        if (false == getLengthFlag
+                && (null == dst || dst.length < (offset + (lengthFlag ? 1 : 0))
+                        || dst.length < 1 || offset < 0)) {
+            return -1;
+        }
+        if (null == theString) {
+            theString = "";
+        }
+        int length;
+        byte[] outBuffer = null;
+        if (getLengthFlag) {
+            length =
+                    UTF8Util.char2ByteUTF8(theString, 0, theString.length(),
+                            null, 0, 0, true);
+        } else {
+            outBuffer = UTF8Util.string2BytesUTF8(theString);
+            length = outBuffer.length;
+        }
+
+        if (length > 255) {
+            length = 255;
+        }
+        if (getLengthFlag) {
+            if (lengthFlag) {
+                length = length + 1;
+            }
+        } else {
+            if (dst.length >= offset + length + (lengthFlag ? 1 : 0)) {
+                if (lengthFlag) {
+                    dst[offset] = (byte) (length & 0xFF);
+                    offset++;
+                }
+                System.arraycopy(outBuffer, 0, dst, offset, length);
+                offset += length;
+
+                length = offset;
+            } else {
+                length = -1;
+            }
+        }
+
+        outBuffer = null;
+
+        return length;
+    }
+
+    /*
+     * Converts encoded &#92;uxxxx to unicode chars and changes special saved
+     * chars to their original forms
+     *
+     * @param s
+     *            the  byte arrary needing convert. 
+     * @param offset
+     *            the offset of byte arrary 
+     * @param lengthFlag
+     *            Whether add one byte of length in the result. 
+     *            <code>true</code> add one byte of length in the result
+     * @return  the convert result of the byte arrary. 
+     */
+    public static String loadConvert(byte[] s, int offset, boolean lengthFlag)
+            throws IllegalArgumentException {
+        if (null == s || (offset + (lengthFlag ? 1 : 0)) > s.length)
+            throw new IllegalArgumentException("invalid byte arrary");
+
+        int len = (s.length - offset);
+
+        if (lengthFlag) {
+            len = s[offset] & 0xFF;
+            offset++;
+        }
+
+        return UTF8Util.bytes2StringUTF8(s, offset, len, true);
+    }
+
+    public static String returnString(String str) {
+        if (null == str)
+            return "";
+        else
+            return str;
+    }
+
+    public static String returnString(int intValue) {
+        if (intValue < 0)
+            return "";
+        else
+            return "" + intValue;
+    }
+
+    public static String returnString(short shortValue) {
+        return returnString((int) shortValue);
+    }
+
+    public static String returnString(byte byteValue) {
+        return returnString((int) byteValue);
+    }
+
+    /**
+    * Method trim space
+    *
+    * @param The string to be format.
+    *
+    */
+    public static String trimSpace(String oldString) {
+        if (null == oldString)
+            return null;
+        if (0 == oldString.length())
+            return "";
+
+        StringBuffer sbuf = new StringBuffer();
+        int oldLen = oldString.length();
+        for (int i = 0; i < oldLen; i++) {
+            if (' ' != oldString.charAt(i))
+                sbuf.append(oldString.charAt(i));
+        }
+        String returnString = sbuf.toString();
+        sbuf = null;
+        return returnString;
+    }
+
+    /**
+     * Method trim space
+     *
+     * @param oldString The string to be format.
+     * @param trimFlag The trim flag, 
+     *         =0:trim both sides,
+     *         >0:trim right sides,
+     *         <0:trim left sides,
+     *
+     */
+    public static String trimSpace(String oldString, int trimFlag) {
+        if (null == oldString)
+            return null;
+        if (0 == oldString.length())
+            return "";
+
+        int length = oldString.length();
+        int j = 0;
+        for (j = 0; j < length
+                && (oldString.charAt(j) == ' ' || oldString.charAt(j) == '\0'); j++)
+            ;
+        if (trimFlag < 0) // trim left sides
+            return (j <= 0 ? oldString : oldString.substring(j));
+        for (; j < length
+                && (oldString.charAt(length - 1) == ' ' || oldString
+                        .charAt(length - 1) == '\0'); length--)
+            ;
+        if (trimFlag > 0) //trim right sides
+            return (length >= oldString.length() ? oldString : oldString
+                    .substring(0, length));
+
+        return (j <= 0 && length >= oldString.length() ? oldString : oldString
+                .substring(j, length));
+    }
+
+    /**
+    * Method convert byte[] to String
+    *
+    * @param The string to be format.
+    *
+    */
+    public static String toString(byte[] abyte0) {
+        if (null == abyte0)
+            return null;
+        else
+            return new String(abyte0);
+    }
+
+    public static String[] buffer2Message(String bufferString, int width,
+            int height) {
+        int buffLen;
+        int i = 0;
+        int h, w;
+        if (null == bufferString)
+            buffLen = 0;
+        else
+            buffLen = bufferString.length();
+
+        if (height < 1 && width > 0) {
+            if (0 == (buffLen % width))
+                h = buffLen / width;
+            else
+                h = (buffLen / width) + 1;
+            w = width;
+        } else {
+            if (height > 0 && width < 1) {
+                if (0 == (buffLen % height))
+                    w = buffLen / height;
+                else
+                    w = (buffLen / height) + 1;
+                h = height;
+            } else {
+                if (height > 0 && width > 0) {
+                    h = height;
+                    w = width;
+                } else {
+                    return null;
+                }
+            }
+        }
+
+        String[] buff = new String[h];
+
+        for (i = 0; i < h; i++) {
+            if ((w * (i + 1)) < buffLen)
+                buff[i] = bufferString.substring(w * i, w * (i + 1));
+            else if ((w * (i + 1)) >= buffLen && (w * i) < buffLen)
+                buff[i] = bufferString.substring(w * i, buffLen);
+            else
+                buff[i] = "";
+        }
+
+        return buff;
+    }
+
+    /**
+    * Method Format string
+    *
+    * @param The string to be format.
+    *
+    */
+    public static String[] buffer2Message(String bufferString) {
+        return buffer2Message(bufferString, LCD_WIDTH, 3);
+    }
+
+    /**
+    * Method fill string
+    *
+    * @param The string to be format.
+    *
+    */
+    public static String fillString(String formatString, int length,
+            char fillChar, boolean leftFillFlag) {
+        if (null == formatString) {
+            formatString = "";
+        }
+        int strLen = formatString.length();
+        if (strLen >= length) {
+            if (true == leftFillFlag) // left fill 
+                return formatString.substring(strLen - length, strLen);
+            else
+                return formatString.substring(0, length);
+        } else {
+            StringBuffer sbuf = new StringBuffer();
+            int fillLen = length - formatString.length();
+            for (int i = 0; i < fillLen; i++) {
+                sbuf.append(fillChar);
+            }
+
+            if (true == leftFillFlag) // left fill 
+            {
+                sbuf.append(formatString);
+            } else {
+                sbuf.insert(0, formatString);
+            }
+            String returnString = sbuf.toString();
+            sbuf = null;
+            return returnString;
+        }
+    }
+
+    /**
+    * Method fill string
+    *
+    * @param The string to be format.
+    *
+    */
+    public static String fillSpace(String formatString, int length) {
+        return fillString(formatString, length, ' ', false);
+    }
+
+    /**
+    * Method Format string
+    *
+    * @param The string to be format.
+    *
+    */
+    public static String formatLine(String formatString, boolean leftFillFlag) {
+        return fillString(formatString, LCD_WIDTH, ' ', leftFillFlag);
+    }
+
+    private static final char[] space8 = { ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+            ' '                       };
+
+    /**
+    * Method fill space , converted String lenth to LCD_WIDTH
+    *
+    * @param The string to be format.
+    *
+    */
+    public static String fillShowSpace(String formatString) {
+        if (null == formatString)
+            return "";
+
+        if (formatString.length() <= LCD_WIDTH) {
+            int len = 8 - (formatString.length() / 2);
+            StringBuffer sbuf = new StringBuffer();
+            sbuf.append(space8, 0, len);
+            sbuf.append(formatString);
+            sbuf.append(space8, 0, len);
+            sbuf.setLength(LCD_WIDTH);
+
+            String returnString = sbuf.toString();
+            sbuf = null;
+            return returnString;
+        } else {
+            return formatString.substring(0, LCD_WIDTH);
+        }
+    }
+
+    /**
+    * Method Format string
+    *
+    * @param The string to be format.
+    *
+    */
+    public static String fillZero(String formatString, int length) {
+        return fillString(formatString, length, '0', true);
+    }
+
+    /**
+         * @param s source string (with Hex representation)
+         * @return byte array
+         */
+    //StringUtil.hexString2bytes("11111111111111111111111111111111")结果是 16个0x11
+    //与其相反的是 StringUtil.toHexString(result, false) 类似于bcd转ascii但是转成的是utf格式, 0x12 转成“12”
+    public static byte[] hexString2bytes(String s) {
+        if (null == s)
+            return null;
+
+        s = trimSpace(s);
+
+        if (false == isHexChar(s, false))
+            return null;
+
+        return hex2byte(s, 0, s.length() >> 1);
+    }
+
+    /**
+     * @param   s       source string
+     * @param   offset  starting offset
+     * @param   len     number of bytes in destination (processes len*2)
+     * @return  byte[len]
+     */
+    public static byte[] hex2byte(String s, int offset, int len) {
+        byte[] d = new byte[len];
+        int byteLen = len * 2;
+        for (int i = 0; i < byteLen; i++) {
+            int shift = (i % 2 == 1) ? 0 : 4;
+            d[i >> 1] |= Character.digit(s.charAt(offset + i), 16) << shift;
+        }
+        return d;
+    }
+
+    private static void appendHex(StringBuffer stringbuffer, byte byte0) {
+        stringbuffer.append(toHexChar(byte0 >> 4));
+        stringbuffer.append(toHexChar(byte0));
+    }
+
+    public static String toHexString(byte[] abyte0, int beginIndex,
+                                     int endIndex, boolean spaceFlag) {
+        if (null == abyte0)
+            return null;
+        if (0 == abyte0.length)
+            return "";
+        StringBuffer sbuf = new StringBuffer();
+        appendHex(sbuf, abyte0[beginIndex]);
+        for (int i = (beginIndex + 1); i < endIndex; i++) {
+            if (spaceFlag)
+                sbuf.append(" ");
+            appendHex(sbuf, abyte0[i]);
+        }
+        String returnString = sbuf.toString();
+        sbuf = null;
+        return returnString;
+    }
+
+    public static String
+            toHexString(byte[] abyte0, int beginIndex, int endIndex) {
+        if (null == abyte0)
+            return null;
+        return toHexString(abyte0, beginIndex, endIndex, true);
+    }
+
+    public static String toHexString(byte[] abyte0, boolean spaceFlag) {
+        if (null == abyte0)
+            return null;
+        return toHexString(abyte0, 0, abyte0.length, spaceFlag);
+    }
+
+    /**
+    * Method convert byte[] to HexString
+    *
+    * @param The string to be format.
+    *
+    */
+
+    public static String toHexString(byte[] abyte0) {
+        if (null == abyte0)
+            return null;
+        return toHexString(abyte0, 0, abyte0.length, true);
+    }
+
+    public static String toHexString(byte abyte0) {
+        StringBuffer sbuf = new StringBuffer();
+        appendHex(sbuf, abyte0);
+
+        String returnString = sbuf.toString();
+        sbuf = null;
+        return returnString;
+    }
+
+    /**
+    * Method Method convert byte[] to HexString and String
+    *
+    * @param The string to be format.
+    *
+    */
+    public static String toFullString(byte[] abyte0) {
+        return "(" + toHexString(abyte0) + ") " + toString(abyte0);
+    }
+
+    /**
+    * Method Format string
+    *
+    * @param The string to be format.
+    *
+    */
+    public static String toBestString(byte[] abyte0) {
+        boolean flag = false;
+        if (abyte0 != null) {
+            int byteLen = abyte0.length;
+            for (int i = 0; !flag && i < byteLen; i++)
+                if (abyte0[i] != 32 && (abyte0[i] != 33) & (abyte0[i] != 63))
+                    flag = abyte0[i] < 48;
+
+        }
+        if (flag)
+            return toHexString(abyte0);
+        else
+            return toString(abyte0);
+    }
+
+    /**
+    * Method Check String 
+    *
+    * @param The string to be format.
+    *
+    */
+    public static boolean isHexChar(String hexString, boolean trimSpaceFlag) {
+        if (null == hexString || 0 == hexString.length())
+            return false;
+
+        if (trimSpaceFlag)
+            hexString = trimSpace(hexString);
+
+        if (hexString.length() % 2 != 0)
+            return false;
+        int hexLen = hexString.length();
+        for (int i = 0; i < hexLen; i++) {
+            if (HexChars.indexOf(hexString.charAt(i)) < 0)
+                return false;
+        }
+
+        return true;
+    }
+
+    public static boolean isHexChar(String hexString) {
+        return isHexChar(hexString, true);
+    }
+
+    /**
+     * Return true if the string is alphanum.
+     * <code>{letter digit }</code>
+     * 
+     **/
+    public static boolean isLetterNumeric(String s) {
+        int i = 0, len = s.length();
+        while (i < len
+                && (Character.isLowerCase(s.charAt(i))
+                        || Character.isUpperCase(s.charAt(i)) || Character
+                            .isDigit(s.charAt(i)))) {
+            i++;
+        }
+        return (i >= len);
+    }
+
+    /**
+     * 获取字符串的长度,如果有中文,则每个中文字符计为2位
+     * 
+     * @param value
+     *            指定的字符串
+     * @return 字符串的长度
+     */
+    public static int length(String value) {
+        int valueLength = 0;
+        String chinese = "[\u0391-\uFFE5]";
+        /* 获取字段值的长度,如果含中文字符,则每个中文字符长度为2,否则为1 */
+        for (int i = 0; i < value.length(); i++) {
+            /* 获取一个字符 */
+            String temp = value.substring(i, i + 1);
+            /* 判断是否为中文字符 */
+            if (temp.matches(chinese)) {
+                /* 中文字符长度为2 */
+                valueLength += 2;
+            } else {
+                /* 其他字符长度为1 */
+                valueLength += 1;
+            }
+        }
+        return valueLength;
+    }
+}

+ 140 - 0
ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/utils/StringUtility.java

@@ -0,0 +1,140 @@
+package com.yijia.zthandpos.pos.utils;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import android.text.TextUtils;
+import android.util.Log;
+
+public class StringUtility {
+    /**
+     * @param strInput
+     *            浼犲叆String
+     * @return boolean 浼犲叆鐨凷tring鏄惁涓虹┖
+     * */
+    static public boolean isEmpty(String strInput) {
+        /*
+         * if(strInput == null) return true; return strInput.length() == 0 ?
+         * true : false;
+         */
+        return TextUtils.isEmpty(strInput);
+
+    }
+
+    public static String getStringFormat(byte[] bytes) {
+        String str = "";
+        for (byte b : bytes) {
+            str += String.format("%02X ", b);
+        }
+        return str;
+    }
+    public static String getStringFormat(byte[] bytes, int length) {
+        String str = "";
+        for (int i = 0; i < length; i++) {
+            str += String.format("%02X ", bytes[i]);
+        }
+        return str;
+    }
+    static protected boolean CheckByte(byte byteIn) {
+        // '0' - '9'
+        if (byteIn <= 0x39 && byteIn >= 0x30)
+            return true;
+        // 'A' - 'F'
+        if (byteIn <= 0x46 && byteIn >= 0x41)
+            return true;
+        // 'a' - 'f'
+        return byteIn <= 0x66 && byteIn >= 0x61;
+    }
+
+    static protected boolean CheckString(String strInput) {
+        strInput = strInput.trim();
+        if (strInput.length() != 2)
+            return false;
+        byte[] byteArry = strInput.getBytes();
+        for (int i = 0; i < 2; i++) {
+            if (!CheckByte(byteArry[i]))
+                return false;
+        }
+        return true;
+    }
+
+    static protected byte StringToByte(String strInput) {
+        byte[] byteArry = strInput.getBytes();
+        for (int i = 0; i < 2; i++) {
+
+            if (byteArry[i] <= 0x39 && byteArry[i] >= 0x30) {
+                byteArry[i] -= 0x30;
+            } else if (byteArry[i] <= 0x46 && byteArry[i] >= 0x41) {
+                byteArry[i] -= 0x37;
+            } else if (byteArry[i] <= 0x66 && byteArry[i] >= 0x61) {
+                byteArry[i] -= 0x57;
+            }
+        }
+        // Log.i("APP", String.format("byteArry[0] = 0x%X\n", byteArry[0]));
+        // Log.i("APP", String.format("byteArry[1] = 0x%X\n", byteArry[1]));
+        return (byte) ((byteArry[0] << 4) | (byteArry[1] & 0x0F));
+    }
+
+    /**
+     * @param String
+     *            strInput
+     * @param byte[] arryByte
+     * @return int
+     * */
+    static public int StringToByteArray(String strInput, byte[] arryByte) {
+        strInput = strInput.trim();
+        String[] arryString = strInput.split(" ");
+        if (arryByte.length < arryString.length)
+            return -1;
+        for (int i = 0; i < arryString.length; i++) {
+            if (!CheckString(arryString[i]))
+                return -1;
+            arryByte[i] = StringToByte(arryString[i]);
+            Log.i("APP", String.format("%02X", arryByte[i]));
+        }
+
+        return arryString.length;
+    }
+    /**
+     * @param String
+     *            strInput
+     * @param byte[] arryByte
+     * @return int
+     * */
+    static public byte[] StringToByteArray(String strInput) {
+    	if(strInput==null)return null;
+        strInput = strInput.trim().replace(" ", "");
+        int len=strInput.length()/2; 
+        byte[] arryByte=new byte[len];
+        for(int i=0;i<len;i++){
+        	arryByte[i]=StringToByte(strInput.substring(2*i,2*(i+1)));
+        }
+        return arryByte;
+    }
+
+    static public String ByteArrayToString(byte[] arryByte, int nDataLength) {
+        String strOut = "";
+        for (int i = 0; i < nDataLength; i++)
+            strOut += String.format("%02X ", arryByte[i]);
+        return strOut;
+    }
+
+    /**
+     * @param String
+     *            str 浼犲叆瀛楃锟�
+     * @param String
+     *            reg 鎸夌収鍝鏂瑰紡鎴栧摢涓瓧娈垫媶锟�
+     * @return Stringp[] 杩斿洖鎷嗗垎鍚庣殑鏁扮粍锟�
+     * */
+    static public String[] spiltStrings(String str, String reg) {
+        String[] arrayStr = str.split(reg);
+        return arrayStr;
+    }
+    
+    /*获取系统时间 格式为:"yyyy-MM-dd HH:mm:ss"*/
+    public static String getCurrentDateF() {
+        Date d = new Date();
+        SimpleDateFormat sf  = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return sf.format(d);
+    }
+}

+ 216 - 0
ZTHandPOS/app/src/main/java/com/yijia/zthandpos/pos/utils/UTF8Util.java

@@ -0,0 +1,216 @@
+package com.yijia.zthandpos.pos.utils;
+
+public class UTF8Util {
+    /*
+        U-00000000 - U-0000007F:  0xxxxxxx  
+        U-00000080 - U-000007FF:  110xxxxx 10xxxxxx  
+        U-00000800 - U-0000FFFF:  1110xxxx 10xxxxxx 10xxxxxx  
+        U-00010000 - U-001FFFFF:  11110xxx 10xxxxxx 10xxxxxx 10xxxxxx  
+        U-00200000 - U-03FFFFFF:  111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx  
+        U-04000000 - U-7FFFFFFF:  1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
+     *  only consider first three line!!
+     *  if the format is illegal:
+     *  shorter then valid length, 0x3f instead
+     *  longer then valid length, discard
+     */
+
+    /**
+     * encode the byte[] to char[] in UTF-8
+     * @param buf
+     * @param cbuf
+     * @return      the cbuf valid length
+     */
+    private static int bytes2charsUTF8(byte[] buf, int bufOffset,
+            int bufLength, char[] cbuf, boolean bigEndian) {
+        int cpos = 0, pos = bufOffset;
+        byte b1, b2;
+        b1 = 0;
+        b2 = 0;
+        while (pos < (bufOffset + bufLength)) {
+            if ((buf[pos] & 0x80) == 0x00) {
+                //U-00000000 - U-0000007F:  0xxxxxxx
+                b1 = 0;
+                b2 = buf[pos];
+                pos++;
+            } else if ((buf[pos] & 0xe0) == 0xc0) {
+                //U-00000080 - U-000007FF:  110xxxxx 10xxxxxx
+                if ((buf[pos + 1] & 0x80) == 0x80) {
+                    b1 = (byte) (((buf[pos] & 0x1f) >> 2) & 0xff);
+                    b2 =
+                            (byte) (((buf[pos] & 0x03) << 6) | (buf[pos + 1] & 0x3f) & 0xff);
+                    pos += 2;
+                } else {
+                    /* invalid format, use ? instead 
+                     * -- 2006-3-29 13:55:32 */
+                    b1 = 0x00;
+                    b2 = 0x3f;
+                    pos += 1;
+                }
+            } else if ((buf[pos] & 0xf0) == 0xe0) { //U-00000800 - U-0000FFFF:  1110xxxx 10xxxxxx 10xxxxxx
+                if (((buf[pos + 1] & 0x80) == 0x80)
+                        && ((buf[pos + 2] & 0x80) == 0x80)) {
+                    b1 =
+                            (byte) ((((buf[pos] & 0x0f) << 4) | ((buf[pos + 1] & 0x3f) >> 2)) & 0xff);
+                    b2 =
+                            (byte) (((buf[pos + 1] & 0x03) << 6) | (buf[pos + 2] & 0x3f) & 0xff);
+                    pos += 3;
+                } else if ((buf[pos + 1] & 0x80) == 0x80) {
+                    /* invalid format, use ? instead 
+                     * -- 2006-3-29 13:55:32 */
+                    b1 = 0x00;
+                    b2 = 0x3f;
+                    pos += 2;
+                } else {
+                    /* invalid format, use ? instead 
+                     * -- 2006-3-29 13:55:32 */
+                    b1 = 0x00;
+                    b2 = 0x3f;
+                    pos += 1;
+                }
+            } else {
+                b1 = 0;
+                b2 = 0;
+                pos++;
+                continue;
+            }
+            if (bigEndian) {
+                cbuf[cpos] = (char) (((b1 & 0xff) << 8 | (b2 & 0xff)) & 0xffff);
+            } else {
+                cbuf[cpos] = (char) (((b2 & 0xff) << 8 | (b1 & 0xff)) & 0xffff);
+            }
+            cpos++;
+        }
+        return cpos;
+    }
+
+    /**
+     * get the length of the bytes in UTF-8
+     * rules: 0xxxxxxx or 11xxxxxx is the first the byte of the 
+     * @param buf
+     * @return
+     */
+    private static int bytesUTF8len(byte[] buf, int bufOffset, int bufLength) {
+        int len = 0;
+        for (int i = bufOffset; i < (bufOffset + bufLength); i++) {
+            if (((buf[i]) & 0x80) == 0x00 || ((buf[i]) & 0xc0) == 0xc0) {
+                len++;
+            }
+        }
+        return len;
+    }
+
+    /**
+     * format the byte[] to String in UTF-8 encode
+     * @param buf
+     * @param bigEndian
+     * @return
+     */
+    public static String bytes2StringUTF8(byte[] buf, int bufOffset,
+            int bufLength, boolean bigEndian) {
+        int len = bytesUTF8len(buf, bufOffset, bufLength);
+        char[] cbuf = new char[len];
+
+        len = bytes2charsUTF8(buf, bufOffset, bufLength, cbuf, bigEndian);
+        String str = new String(cbuf, 0, len);
+        cbuf = null;
+        return str;
+    }
+
+    public static String bytes2StringUTF8(byte[] buf) {
+        return bytes2StringUTF8(buf, 0, buf.length, true);
+    }
+
+    /*
+     *  U-00000000 - U-0000007F:  0xxxxxxx  
+     *  U-00000080 - U-000007FF:  110xxxxx 10xxxxxx  
+     *  U-00000800 - U-0000FFFF:  1110xxxx 10xxxxxx 10xxxxxx  
+     *  U-00010000 - U-001FFFFF:  11110xxx 10xxxxxx 10xxxxxx 10xxxxxx  
+     *  U-00200000 - U-03FFFFFF:  111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx  
+     *  U-04000000 - U-7FFFFFFF:  1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
+     *  only consider first three line!!
+     *  if the format is illegal:
+     *  shorter then valid length, 0x3f instead
+     *  longer then valid length, discard
+     */
+    private static final byte[] outputByte = new byte[3];
+
+    public static byte[] string2BytesUTF8(String str) {
+        byte[] bufByte = new byte[str.length() * 3];
+
+        int byteLen =
+                char2ByteUTF8(str, 0, str.length(), bufByte, 0, bufByte.length,
+                        false);
+        byte[] ret = new byte[byteLen];
+        System.arraycopy(bufByte, 0, ret, 0, byteLen);
+        return ret;
+    }
+
+    public static int char2ByteUTF8(String input, int inOff, int inEnd,
+            byte[] output, int outOff, int outEnd, boolean getLengthFlag) {
+        char inputChar;
+        int outputSize;
+
+        int charOff = inOff;
+        int byteOff = outOff;
+
+        while (charOff < inEnd) {
+            inputChar = input.charAt(charOff);
+            if (inputChar < 0x80) {
+                outputByte[0] = (byte) inputChar;
+                outputSize = 1;
+            } else if (inputChar < 0x800) {
+                outputByte[0] = (byte) (0xc0 | ((inputChar >> 6) & 0x1f));
+                outputByte[1] = (byte) (0x80 | (inputChar & 0x3f));
+                outputSize = 2;
+            } else {
+                outputByte[0] = (byte) (0xe0 | ((inputChar >> 12)) & 0x0f);
+                outputByte[1] = (byte) (0x80 | ((inputChar >> 6) & 0x3f));
+                outputByte[2] = (byte) (0x80 | (inputChar & 0x3f));
+                outputSize = 3;
+            }
+            if (getLengthFlag) {
+                byteOff += outputSize;
+            } else {
+                if ((byteOff + outputSize) > outEnd) {
+                    return -1;
+                }
+                for (int i = 0; i < outputSize; i++) {
+                    output[byteOff++] = outputByte[i];
+                }
+            }
+            charOff++;
+        }
+        return byteOff - outOff;
+    }
+
+    /**
+     * format the byte[] to String in UNICODE encode
+     * @param buf
+     * @param bigEndian
+     * @return
+     */
+    public static String bytes2StringUNICODE(byte[] buf, int offset,
+            int length, boolean bigEndian) {
+        if (buf != null && offset >= 0 && length >= 2
+                && buf.length >= (offset + length)) {
+            int charsLen = length / 2;
+            char[] cbuf = new char[charsLen];
+            for (int i = 0; i < charsLen; i++) {
+                if (bigEndian) {
+                    cbuf[i] =
+                            (char) (((buf[i * 2 + offset] & 0xff) << 8 | (buf[i
+                                    * 2 + 1 + offset] & 0xff)) & 0xffff);
+                } else {
+                    cbuf[i] =
+                            (char) (((buf[i * 2 + 1 + offset] & 0xff) << 8 | (buf[i
+                                    * 2 + offset] & 0xff)) & 0xffff);
+                }
+            }
+            String str = new String(cbuf, 0, charsLen);
+            cbuf = null;
+            return str;
+        }
+
+        return null;
+    }
+}

+ 10 - 0
ZTHandPOS/app/src/main/res/anim/anmitation.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+    android:interpolator="@android:anim/accelerate_interpolator">
+    <translate android:fromYDelta="-100%p"
+        android:toYDelta="0%p"
+        android:repeatMode="restart"
+        android:interpolator="@android:anim/linear_interpolator"
+        android:repeatCount="0"
+        android:duration="500" />
+</set>

+ 5 - 0
ZTHandPOS/app/src/main/res/anim/cycle_interpolator.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<cycleInterpolator 
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:cycles="2"/>

+ 30 - 0
ZTHandPOS/app/src/main/res/drawable-v24/ic_launcher_foreground.xml

@@ -0,0 +1,30 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:aapt="http://schemas.android.com/aapt"
+    android:width="108dp"
+    android:height="108dp"
+    android:viewportWidth="108"
+    android:viewportHeight="108">
+    <path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
+        <aapt:attr name="android:fillColor">
+            <gradient
+                android:endX="85.84757"
+                android:endY="92.4963"
+                android:startX="42.9492"
+                android:startY="49.59793"
+                android:type="linear">
+                <item
+                    android:color="#44000000"
+                    android:offset="0.0" />
+                <item
+                    android:color="#00000000"
+                    android:offset="1.0" />
+            </gradient>
+        </aapt:attr>
+    </path>
+    <path
+        android:fillColor="#FFFFFF"
+        android:fillType="nonZero"
+        android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
+        android:strokeWidth="1"
+        android:strokeColor="#00000000" />
+</vector>

BIN
ZTHandPOS/app/src/main/res/drawable-xxhdpi/cantact.png


BIN
ZTHandPOS/app/src/main/res/drawable-xxhdpi/cantactless.png


BIN
ZTHandPOS/app/src/main/res/drawable-xxhdpi/card.png


BIN
ZTHandPOS/app/src/main/res/drawable-xxhdpi/emv.png


BIN
ZTHandPOS/app/src/main/res/drawable-xxhdpi/exit.png


BIN
ZTHandPOS/app/src/main/res/drawable-xxhdpi/mag.png


BIN
ZTHandPOS/app/src/main/res/drawable-xxhdpi/pinpad.png


BIN
ZTHandPOS/app/src/main/res/drawable-xxhdpi/print.png


BIN
ZTHandPOS/app/src/main/res/drawable-xxhdpi/sx.png


BIN
ZTHandPOS/app/src/main/res/drawable/a_side.jpg


BIN
ZTHandPOS/app/src/main/res/drawable/app_launcher.png


+ 21 - 0
ZTHandPOS/app/src/main/res/drawable/btn_round_solid_blue.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android" >  
+    <item android:state_pressed="true">
+        <shape>
+            <gradient android:startColor="#A93013" android:endColor="#A93013" android:centerColor="#A93013" android:angle="270"/>
+            <corners android:radius="8sp" /> 
+            <padding android:left="30sp" android:top="15sp" 
+                android:right="30sp" android:bottom="13sp" /> 
+        </shape>
+    </item>
+
+     <item> 
+        <shape> 
+            <gradient android:startColor="#0E4F7B" android:endColor="#0E4F7B" android:centerColor="#0E4F7B"
+                android:angle="270" /> 
+            <corners android:radius="5sp" /> 
+            <padding android:left="30sp" android:top="15sp" 
+                android:right="30sp" android:bottom="13sp" /> 
+        </shape> 
+    </item> 
+</selector>

+ 21 - 0
ZTHandPOS/app/src/main/res/drawable/btn_round_solid_blue_2.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android" >  
+    <item android:state_pressed="true">
+        <shape>
+            <gradient android:startColor="#A93013" android:endColor="#A93013" android:centerColor="#A93013" android:angle="270"/>
+            <corners android:radius="8sp" /> 
+            <padding android:left="10sp" android:top="15sp" 
+                android:right="10sp" android:bottom="13sp" /> 
+        </shape>
+    </item>
+
+     <item> 
+        <shape> 
+            <gradient android:startColor="#3E8F8F" android:endColor="#3E8F8F" android:centerColor="#3E8F8F"
+                android:angle="270" /> 
+            <corners android:radius="10sp" /> 
+            <padding android:left="10sp" android:top="15sp" 
+                android:right="10sp" android:bottom="13sp" /> 
+        </shape> 
+    </item> 
+</selector>

+ 21 - 0
ZTHandPOS/app/src/main/res/drawable/btn_round_solid_green.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android" >  
+    <item android:state_pressed="true">
+        <shape>
+            <gradient android:startColor="#A93013" android:endColor="#A93013" android:centerColor="#A93013" android:angle="270"/>
+            <corners android:radius="8sp" /> 
+            <padding android:left="30sp" android:top="15sp" 
+                android:right="30sp" android:bottom="13sp" /> 
+        </shape>
+    </item>
+
+     <item> 
+        <shape> 
+            <gradient android:startColor="#457745" android:endColor="#457745" android:centerColor="#457745"
+                android:angle="270" /> 
+            <corners android:radius="10sp" /> 
+            <padding android:left="30sp" android:top="15sp" 
+                android:right="30sp" android:bottom="13sp" /> 
+        </shape> 
+    </item> 
+</selector>

+ 12 - 0
ZTHandPOS/app/src/main/res/drawable/btn_style.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android" >  
+    <item> 
+        <shape>
+            <gradient android:startColor="#fff" android:endColor="#fff" android:centerColor="#fff" android:angle="270"/>
+             <stroke android:width="0.1dip" android:color="#D54D2B" /> 
+            <corners android:radius="2dp" /> 
+            <padding android:left="5dp" android:top="3dp" 
+                android:right="5dp" android:bottom="3dp" /> 
+        </shape>
+    </item> 
+</selector>

+ 23 - 0
ZTHandPOS/app/src/main/res/drawable/btn_styleblue.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android" >
+    <item android:state_checked="true">
+        <shape>
+            <gradient android:startColor="#0fdedc" android:endColor="#0fdedc" android:centerColor="#9a0faa" android:angle="270"/>
+             <stroke android:width="0.5px" android:color="#9a0faa" /> 
+            <corners android:radius="2px" /> 
+            <padding android:left="10px" android:top="8px" 
+                android:right="10px" android:bottom="5px" /> 
+        </shape>
+    </item>
+  
+    <item android:state_checked="false"> 
+        <shape> 
+            <gradient android:startColor="#fff" android:endColor="#fff" android:centerColor="#fff"
+                android:angle="270" /> 
+            <stroke android:width="0.1px" android:color="#b2b4b4" /> 
+            <corners android:radius="2px" /> 
+            <padding android:left="10px" android:top="8px" 
+                android:right="10px" android:bottom="5px" /> 
+        </shape> 
+    </item> 
+</selector>

+ 18 - 0
ZTHandPOS/app/src/main/res/drawable/btnstyle.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android" >
+    <corners 
+        android:topLeftRadius="30px"
+        android:topRightRadius="30px"
+        android:bottomLeftRadius="30px"
+        android:bottomRightRadius="30px"/>
+
+    <stroke 
+        android:width="2px"
+        android:color="@color/ClassicalPurse"/>
+    
+    <gradient 
+        android:startColor="@color/ClassicalYellow"
+        android:centerColor="@color/ClassicalYellow"
+        android:endColor="@color/ClassicalYellow"
+        android:type="sweep"/>
+</shape>

BIN
ZTHandPOS/app/src/main/res/drawable/luncher.jpg


+ 18 - 0
ZTHandPOS/app/src/main/res/drawable/shape.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android" >
+    <corners 
+        android:topLeftRadius="30px"
+        android:topRightRadius="30px"
+        android:bottomLeftRadius="30px"
+        android:bottomRightRadius="30px"/>
+    
+    <stroke 
+        android:width="5px"
+        android:color="@color/ClassicalPurse"/>
+    
+    <gradient 
+        android:startColor="@color/ClassicalLightBlue"
+        android:centerColor="@color/ClassicalLightBlue"
+        android:endColor="@color/ClassicalLightBlue"
+        android:type="sweep"/>
+</shape>

BIN
ZTHandPOS/app/src/main/res/drawable/side.jpg


BIN
ZTHandPOS/app/src/main/res/drawable/szzt.bmp


+ 53 - 0
ZTHandPOS/app/src/main/res/layout/activity_card.xml

@@ -0,0 +1,53 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:orientation="vertical"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    android:padding="@dimen/device_padding" >
+        <TextView 
+            android:layout_height="0dp"
+            android:id="@+id/mag_text"
+            android:layout_weight="8"
+            android:layout_width="match_parent"
+            android:layout_marginBottom="@dimen/btn_padding"
+            style="@style/txtStyle"/>
+        <HorizontalScrollView
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="1.6" >
+        <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="fill_parent"
+                android:orientation="horizontal"
+                android:gravity="center_vertical"
+                android:scrollbars="horizontal" >
+            <Button 
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:id="@+id/mag_open"
+                style="@style/btn_list_style"
+                android:text="@string/btn_card_check"/>
+            <Button 
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                style="@style/btn_list_style"
+                android:id="@+id/mag_close"
+                android:text="@string/btn_card_close"/>
+            <TextView 
+                android:layout_width="1dp"
+                android:layout_height="match_parent"/>
+            <Button 
+               	android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                android:id="@+id/mag_clear"
+                style="@style/btn_list_style"
+                android:text="@string/btn_clear_content"/>
+        </LinearLayout>
+        </HorizontalScrollView>
+    </LinearLayout>

+ 79 - 0
ZTHandPOS/app/src/main/res/layout/activity_emv.xml

@@ -0,0 +1,79 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:padding="@dimen/device_padding"
+    android:orientation="vertical"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin" >
+        <TextView
+            android:id="@+id/emv_text"
+            style="@style/txtStyle"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_marginBottom="@dimen/btn_padding"
+            android:layout_weight="8" />
+
+        <HorizontalScrollView
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="1.6" >
+
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="fill_parent"
+                android:orientation="horizontal"
+                android:gravity="center_vertical"
+                android:scrollbars="horizontal" >
+
+                <Button
+                    android:id="@+id/emv_start"
+                    style="@style/btn_list_style"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/btn_emv_start" />
+
+                <Button
+                    android:id="@+id/emv_electronic_cash"
+                    style="@style/btn_list_style"
+                    android:layout_width="wrap_content"
+                    android:layout_marginLeft="@dimen/btn_padding"
+                    android:layout_height="wrap_content"
+                    android:text="@string/btn_electronic_cash" />
+
+                <Button
+                    android:id="@+id/emv_electronic_cash_inquiry"
+                    style="@style/btn_list_style"
+                    android:layout_width="wrap_content"
+                    android:layout_marginLeft="@dimen/btn_padding"
+                    android:layout_height="wrap_content"
+                    android:text="@string/btn_electronic_cash_inquiry" />
+
+                <Button
+                    android:id="@+id/emv_set_param"
+                    style="@style/btn_list_style"
+                    android:layout_width="wrap_content"
+                    android:layout_marginLeft="@dimen/btn_padding"
+                    android:layout_height="wrap_content"
+                    android:text="@string/btn_emv_setting_param" />
+
+                <Button
+                    android:id="@+id/emv_stop"
+                    style="@style/btn_list_style"
+                    android:layout_width="wrap_content"
+                    android:layout_marginLeft="@dimen/btn_padding"
+                    android:layout_height="wrap_content"
+                    android:text="@string/btn_emv_close" />
+
+                <Button
+                    android:id="@+id/emv_clear"
+                    style="@style/btn_list_style"
+                    android:layout_width="wrap_content"
+                    android:layout_marginLeft="@dimen/btn_padding"
+                    android:layout_height="wrap_content"
+                    android:text="@string/btn_clear_content" />
+            </LinearLayout>
+        </HorizontalScrollView>
+    </LinearLayout>

+ 95 - 0
ZTHandPOS/app/src/main/res/layout/activity_hw_security.xml

@@ -0,0 +1,95 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:orientation="vertical"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    android:padding="@dimen/device_padding" >
+        <TextView 
+            android:layout_height="0dp"
+            android:id="@+id/mag_text"
+            android:layout_weight="8"
+            android:layout_width="match_parent"
+            android:layout_marginBottom="@dimen/btn_padding"
+            style="@style/txtStyle"/>
+        <HorizontalScrollView
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="1.6" >
+        <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="fill_parent"
+                android:orientation="horizontal"
+                android:gravity="center_vertical"
+                android:scrollbars="horizontal" >
+            <Button 
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:id="@+id/security_open"
+                style="@style/btn_list_style"
+                android:text="@string/btn_security_open"/>
+           <!--  <Button 
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                style="@style/btn_list_style"
+                android:id="@+id/security_close"
+                android:text="@string/btn_security_close"/> -->
+            <Button 
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                style="@style/btn_list_style"
+                android:id="@+id/security_injectCert"
+                android:text="@string/btn_security_injectCert"/>
+            <Button 
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                style="@style/btn_list_style"
+                android:id="@+id/security_deleteCert"
+                android:text="@string/btn_security_deleteCert"/>
+             <Button 
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                style="@style/btn_list_style"
+                android:id="@+id/security_KeyPair"
+                android:text="@string/btn_security_KeyPair"/>
+              <Button 
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                style="@style/btn_list_style"
+                android:id="@+id/security_generateCSR"
+                android:text="@string/btn_security_csr"/>
+               <Button 
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                style="@style/btn_list_style"
+                android:id="@+id/security_RSA"
+                android:text="@string/btn_security_rsa"/>
+               <Button 
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                style="@style/btn_list_style"
+                android:id="@+id/security_query"
+                android:text="@string/btn_security_query"/>
+            <TextView 
+                android:layout_width="1dp"
+                android:layout_height="match_parent"/>
+            <Button 
+               	android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                android:id="@+id/mag_clear"
+                style="@style/btn_list_style"
+                android:text="@string/btn_clear_content"/>
+        </LinearLayout>
+        </HorizontalScrollView>
+    </LinearLayout>

+ 74 - 0
ZTHandPOS/app/src/main/res/layout/activity_id_card.xml

@@ -0,0 +1,74 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:orientation="vertical"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    android:padding="@dimen/device_padding" >
+        <TextView 
+            android:layout_height="0dp"
+            android:id="@+id/mag_text"
+            android:layout_weight="8"
+            android:layout_width="match_parent"
+            android:layout_marginBottom="@dimen/btn_padding"
+            style="@style/txtStyle"/>
+        <HorizontalScrollView
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="1.6" >
+        <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="fill_parent"
+                android:orientation="horizontal"
+                android:gravity="center_vertical"
+                android:scrollbars="horizontal" >
+            <Button 
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:id="@+id/idCard_open"
+                style="@style/btn_list_style"
+                android:text="@string/btn_id_card_open"/>
+            <Button 
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                style="@style/btn_list_style"
+                android:id="@+id/idCard_close"
+                android:text="@string/btn_id_card_close"/>
+            <Button 
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                style="@style/btn_list_style"
+                android:id="@+id/idCard_readcard"
+                android:text="@string/btn_id_card_readCard"/>
+            <Button 
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                style="@style/btn_list_style"
+                android:id="@+id/idCard_info"
+                android:text="@string/btn_id_card_info"/>
+            <Button 
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                style="@style/btn_list_style"
+                android:id="@+id/idCard_cancle"
+                android:text="@string/btn_id_card_cancle"/>
+            <TextView 
+                android:layout_width="1dp"
+                android:layout_height="match_parent"/>
+            <Button 
+               	android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                android:id="@+id/mag_clear"
+                style="@style/btn_list_style"
+                android:text="@string/btn_clear_content"/>
+        </LinearLayout>
+        </HorizontalScrollView>
+    </LinearLayout>

+ 134 - 0
ZTHandPOS/app/src/main/res/layout/activity_idc.xml

@@ -0,0 +1,134 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:background="@android:color/white"
+    android:orientation="horizontal" >
+    <RelativeLayout 
+        android:layout_width="0dp"
+        android:layout_height="match_parent"
+        android:layout_weight="7">
+        <LinearLayout 
+            android:layout_width="400dp"
+        	android:layout_height="500dp"
+        	android:layout_alignParentLeft="true"
+        	android:id="@+id/viewL"
+        	android:orientation="vertical"
+        	android:visibility="invisible">
+            <RelativeLayout 
+            	android:layout_width="fill_parent"
+            	android:background="@drawable/side"
+            	android:layout_height="0dp"
+            	android:layout_weight="1">
+            <TextView 
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textColor="#03AEDA"
+                    android:id="@+id/tv_nation"
+                    android:layout_marginLeft="170dp"
+                    android:layout_marginTop="78dp"/>
+                <TextView 
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textColor="#03AEDA"
+                    android:id="@+id/tv_sex"
+                    android:layout_marginLeft="95dp"
+                    android:layout_marginTop="78dp"/>
+                <TextView 
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textColor="#03AEDA"
+                    android:id="@+id/tv_name"
+                    android:layout_marginLeft="95dp"
+                    android:layout_marginTop="59dp"/>
+                <TextView 
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textColor="#03AEDA"
+                    android:id="@+id/tv_addr"
+                    android:layout_marginLeft="95dp"
+                    android:layout_marginTop="130dp"/>
+                <TextView 
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textColor="#03AEDA"
+                    android:id="@+id/tv_birth"
+                    android:layout_marginLeft="95dp"
+                    android:layout_marginTop="100dp"/>
+                <TextView 
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textColor="#03AEDA"
+                    android:id="@+id/tv_id"
+                    android:layout_marginLeft="137dp"
+                    android:layout_marginTop="185dp"/>
+            </RelativeLayout>
+            <RelativeLayout
+                android:visibility="invisible" 
+            	android:layout_width="fill_parent"
+            	android:background="@drawable/a_side"
+            	android:id="@+id/viewR"
+            	android:layout_height="0dp"
+            	android:layout_weight="1">
+             <TextView 
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textColor="#03AEDA"
+                    android:id="@+id/tv_sina"
+                    android:layout_marginLeft="155dp"
+                    android:layout_marginTop="155dp"/> 
+             <TextView 
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textColor="#03AEDA"
+                    android:id="@+id/tv_start"
+                    android:layout_marginLeft="155dp"
+                    android:layout_marginTop="180dp"/>
+             <TextView 
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textColor="#03AEDA"
+                    android:text="至"
+                    android:layout_marginLeft="222dp"
+                    android:layout_marginTop="180dp"/>
+              <TextView 
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textColor="#03AEDA"
+                    android:id="@+id/tv_over"
+                    android:layout_marginLeft="240dp"
+                    android:layout_marginTop="180dp"/>
+            </RelativeLayout>
+        </LinearLayout>
+    </RelativeLayout>
+    <LinearLayout 
+        android:layout_width="0dp"
+        android:layout_height="match_parent"
+        android:orientation="vertical"
+        android:layout_weight="3">
+        <ScrollView 
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="3"
+            android:background="#CAFF70"
+            android:id="@+id/sv">    
+            <TextView 
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:textSize="20sp"
+            android:id="@+id/tv"
+            android:textColor="@android:color/holo_blue_light"/>  
+        </ScrollView>
+        <Button android:layout_width="fill_parent"
+                android:id="@+id/idc_start"
+                android:layout_height="wrap_content"
+                style="@style/btn_list_style"
+                android:layout_marginTop="@dimen/btn_padding"
+                android:text="@string/btn_idc_start"/>
+         <Button android:layout_width="fill_parent"
+             android:id="@+id/idc_clear"
+             android:layout_height="wrap_content"
+             style="@style/btn_list_style"
+             android:layout_marginTop="@dimen/btn_padding"
+             android:text="@string/btn_clear_content"/>
+    </LinearLayout>
+</LinearLayout>

+ 18 - 0
ZTHandPOS/app/src/main/res/layout/activity_main.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:background="#FFFFFF"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical" >
+    <ImageView 
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@drawable/szzt"/>
+
+	<ListView
+	    android:id="@+id/listview"
+        android:layout_margin="30dp"
+	    android:layout_width="match_parent"
+	    android:layout_height="match_parent">
+	</ListView>
+</LinearLayout>

+ 319 - 0
ZTHandPOS/app/src/main/res/layout/activity_new_main.xml

@@ -0,0 +1,319 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="#FFFFFF"
+    android:orientation="vertical" >
+
+    <ImageView
+        android:id="@+id/img_touch"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="5dp"
+        android:layout_marginRight="5dp"
+        android:background="@drawable/szzt" />
+
+    <LinearLayout
+        android:id="@+id/lin_all"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_marginTop="10dp"
+        android:orientation="vertical" >
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_marginLeft="5dp"
+            android:layout_marginRight="5dp"
+            android:layout_marginTop="10dp"
+            android:layout_weight="1"
+            android:gravity="center"
+            android:orientation="horizontal" >
+
+            <LinearLayout
+                android:id="@+id/lin_citiao"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_weight="1"
+                android:orientation="horizontal"
+                android:background="#6495ED"
+                android:paddingLeft="@dimen/btn_text_padding" >
+
+                <ImageView
+                    android:layout_width="@dimen/img_size"
+                    android:layout_height="@dimen/img_size"
+                    android:layout_gravity="center_vertical"
+                    android:src="@drawable/card" />
+
+                <TextView
+                    android:id="@+id/tv_citiao_test"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center"
+                    android:layout_margin="5dp"
+                    android:text="@string/button_card_read_test"
+                    android:textColor="#fff" />
+            </LinearLayout>
+
+            <LinearLayout
+                 android:id="@+id/lin_psam"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_marginLeft="5dp"
+                android:layout_weight="1"
+                android:orientation="horizontal"
+                android:background="#6495ED"
+                android:paddingLeft="@dimen/btn_text_padding" >
+
+                <ImageView
+                    android:layout_width="@dimen/img_size"
+                    android:layout_height="@dimen/img_size"
+                    android:layout_gravity="center_vertical"
+                    android:src="@drawable/cantact" />
+
+                <TextView
+                    android:id="@+id/tv_psam_test"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center"
+                    android:layout_margin="5dp"
+                    android:text="test_psamcardreader"
+                    android:textColor="#fff" />
+            </LinearLayout>
+        </LinearLayout>
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_marginLeft="5dp"
+            android:layout_marginRight="5dp"
+            android:layout_marginTop="10dp"
+            android:layout_weight="1"
+            android:gravity="center"
+            android:orientation="horizontal" >
+
+            <LinearLayout
+                android:id="@+id/lin_cantact"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_weight="1"
+                android:paddingLeft="@dimen/btn_text_padding" >
+
+                <ImageView
+                    android:layout_width="@dimen/img_size"
+                    android:layout_height="@dimen/img_size"
+                    android:layout_gravity="center_vertical"
+                    android:src="@drawable/cantact" />
+
+                <TextView
+                    android:id="@+id/tv_cantact_test"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center"
+                    android:layout_margin="5dp"
+                    android:text="test_smartcardreader"
+                    android:textColor="#fff" />
+            </LinearLayout>
+
+            <LinearLayout
+                android:id="@+id/lin_cantactless"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_marginLeft="5dp"
+                android:layout_weight="1"
+                android:paddingLeft="@dimen/btn_text_padding" >
+
+                <ImageView
+                    android:layout_width="@dimen/img_size"
+                    android:layout_height="@dimen/img_size"
+                    android:layout_gravity="center_vertical"
+                    android:src="@drawable/cantactless" />
+
+                <TextView
+                    android:id="@+id/tv_cantactless_test"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center"
+                    android:layout_margin="5dp"
+                    android:text="test_contacltesscardreader"
+                    android:textColor="#fff" />
+            </LinearLayout>
+        </LinearLayout>
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_marginLeft="5dp"
+            android:layout_marginRight="5dp"
+            android:layout_marginTop="10dp"
+            android:layout_weight="1"
+            android:gravity="center"
+            android:orientation="horizontal" >
+
+            <LinearLayout
+                android:id="@+id/lin_pinpad"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_weight="1"
+                android:orientation="horizontal"
+                android:paddingLeft="@dimen/btn_text_padding" >
+
+                <ImageView
+                    android:layout_width="@dimen/img_size"
+                    android:layout_height="@dimen/img_size"
+                    android:layout_gravity="center_vertical"
+                    android:src="@drawable/pinpad" />
+
+                <TextView
+                    android:id="@+id/tv_pinpad_test"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center"
+                    android:layout_margin="5dp"
+                    android:text="@string/button_pinpad_test"
+                    android:textColor="#fff" />
+            </LinearLayout>
+
+            <LinearLayout
+                android:id="@+id/lin_printer"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_marginLeft="5dp"
+                android:layout_weight="1"
+                android:orientation="horizontal"
+                android:paddingLeft="@dimen/btn_text_padding" >
+
+                <ImageView
+                    android:layout_width="@dimen/img_size"
+                    android:layout_height="@dimen/img_size"
+                    android:layout_gravity="center_vertical"
+                    android:src="@drawable/print" />
+
+                <TextView
+                    android:id="@+id/tv_printer_test"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center"
+                    android:layout_margin="5dp"
+                    android:text="@string/button_printer_test"
+                    android:textColor="#fff" />
+            </LinearLayout>
+        </LinearLayout>
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_marginLeft="5dp"
+            android:layout_marginRight="5dp"
+            android:layout_marginTop="10dp"
+            android:layout_weight="1"
+            android:gravity="center"
+            android:orientation="horizontal" >
+
+            <LinearLayout
+                android:id="@+id/lin_emv"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_weight="1"
+                android:paddingLeft="@dimen/btn_text_padding" >
+
+                <ImageView
+                    android:layout_width="@dimen/img_size"
+                    android:layout_height="@dimen/img_size"
+                    android:layout_gravity="center_vertical"
+                    android:src="@drawable/emv" />
+
+                <TextView
+                    android:id="@+id/tv_emv_test"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center"
+                    android:layout_margin="5dp"
+                    android:text="@string/button_emv_test"
+                    android:textColor="#fff" />
+            </LinearLayout>
+
+            <LinearLayout
+                android:id="@+id/lin_camera"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_marginLeft="5dp"
+                android:layout_weight="1"
+                android:paddingLeft="@dimen/btn_text_padding" >
+
+                <ImageView
+                    android:layout_width="@dimen/img_size"
+                    android:layout_height="@dimen/img_size"
+                    android:layout_gravity="center_vertical"
+                    android:src="@drawable/sx" />
+
+                <TextView
+                    android:id="@+id/tv_camera_test"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center"
+                    android:layout_margin="5dp"
+                    android:text="@string/button_camera_scan_test"
+                    android:textColor="#fff" />
+            </LinearLayout>
+        </LinearLayout>
+
+
+            <LinearLayout
+                android:id="@+id/lin_SystemManager"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+            android:layout_marginBottom="5dp"
+            android:layout_marginLeft="5dp"
+            android:layout_marginRight="5dp"
+            android:layout_marginTop="10dp"
+            android:layout_weight="1"
+            android:gravity="center"
+            android:orientation="horizontal">
+
+                <ImageView
+                    android:layout_width="@dimen/img_size"
+                    android:layout_height="@dimen/img_size"
+                    android:layout_gravity="center_vertical"
+                    android:src="@drawable/emv" />
+
+                <TextView
+                    android:id="@+id/tv_SystemManager"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center"
+                    android:layout_margin="5dp"
+                    android:text="@string/button_system_test"
+                    android:textColor="#fff" />
+            </LinearLayout>
+
+        <LinearLayout
+            android:id="@+id/lin_exit"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_marginBottom="5dp"
+            android:layout_marginLeft="5dp"
+            android:layout_marginRight="5dp"
+            android:layout_marginTop="10dp"
+            android:layout_weight="1"
+            android:gravity="center"
+            android:orientation="horizontal" >
+
+            <ImageView
+                android:layout_width="@dimen/img_size"
+                android:layout_height="@dimen/img_size"
+                android:layout_gravity="center_vertical"
+                android:src="@drawable/exit" />
+
+            <TextView
+                android:id="@+id/tv_exit_test"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center"
+                android:layout_margin="5dp"
+                android:text="@string/button_exit_app"
+                android:textColor="#fff" />
+        </LinearLayout>
+    </LinearLayout>
+
+</LinearLayout>

+ 93 - 0
ZTHandPOS/app/src/main/res/layout/activity_pinpad.xml

@@ -0,0 +1,93 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:padding="@dimen/device_padding"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    android:orientation="vertical" 
+    tools:context=".PinPadActivity" >
+        <TextView
+            android:id="@+id/pinpad_text"
+            style="@style/txtStyle"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_marginBottom="@dimen/btn_padding"
+            android:layout_weight="8"
+            android:text="@string/test_pinpad" />
+
+        <HorizontalScrollView
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="1.6" >
+
+            <LinearLayout
+                android:id="@+id/pinpad_layer"
+                android:layout_width="wrap_content"
+                android:layout_height="fill_parent"
+                android:gravity="center_vertical"
+                android:orientation="horizontal"
+                android:scrollbars="horizontal" >
+
+                <Button
+                    android:id="@+id/pinpad_open" 
+                    style="@style/btn_list_style"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/btn_pinpad_open" />
+                <Button
+                    android:id="@+id/pinpad_close"
+                    style="@style/btn_list_style"
+                    android:layout_width="wrap_content"
+                    android:layout_marginLeft="@dimen/btn_padding"
+                    android:layout_height="wrap_content"
+                    android:text="@string/btn_pinpad_close" />
+                <Button
+                    android:id="@+id/pinpad_loadMasterKey"
+                    style="@style/btn_list_style"
+                    android:layout_width="wrap_content"
+                    android:layout_marginLeft="@dimen/btn_padding"
+                    android:layout_height="wrap_content"
+                    android:text="@string/btn_pinpad_main_key" />
+                <Button
+                    android:id="@+id/pinpad_updateWorkKey"
+                    style="@style/btn_list_style"
+                    android:layout_width="wrap_content"
+                    android:layout_marginLeft="@dimen/btn_padding"
+                    android:layout_height="wrap_content"
+                    android:text="@string/btn_pinpad_work_keu" />
+                <Button
+                    android:id="@+id/pinpad_encryptData"
+                    style="@style/btn_list_style"
+                    android:layout_width="wrap_content"
+                    android:layout_marginLeft="@dimen/btn_padding"
+                    android:layout_height="wrap_content"
+                    android:text="@string/btn_pinpad_encrypt" />
+                <Button
+                    android:id="@+id/pinpad_showText"
+                    style="@style/btn_list_style"
+                    android:layout_width="wrap_content"
+                    android:layout_marginLeft="@dimen/btn_padding"
+                    android:layout_height="wrap_content"
+                    android:text="@string/btn_pinpad_show_test" />
+                <Button
+                    android:id="@+id/pinpad_clear"
+                    style="@style/btn_list_style"
+                    android:layout_width="wrap_content"
+                    android:layout_marginLeft="@dimen/btn_padding"
+                    android:layout_height="wrap_content"
+                    android:text="@string/btn_pinpad_cal_mac" />
+
+                <Button
+                    android:id="@+id/pinpad_pin"
+                    style="@style/btn_list_style"
+                    android:layout_width="wrap_content"
+                    android:layout_marginLeft="@dimen/btn_padding"
+                    android:layout_height="wrap_content"
+                    android:onClick="cal_pin"
+                    android:text="@string/btn_pinpad_cal_pin" />
+            </LinearLayout>
+        </HorizontalScrollView>
+    </LinearLayout>

+ 73 - 0
ZTHandPOS/app/src/main/res/layout/activity_printer.xml

@@ -0,0 +1,73 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:padding="@dimen/device_padding"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:orientation="vertical"
+    android:paddingTop="@dimen/activity_vertical_margin" >
+        <TextView
+            android:id="@+id/print_text"
+            style="@style/txtStyle"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_marginBottom="@dimen/btn_padding"
+            android:layout_weight="8"
+            android:text="@string/test_printer" />
+
+        <HorizontalScrollView
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="1.6" >
+
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="fill_parent"
+                android:orientation="horizontal"
+                android:gravity="center_vertical"
+                android:scrollbars="horizontal" >
+
+                <Button
+                    android:id="@+id/print_open"
+                    style="@style/btn_list_style"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/btn_printer_open" />
+
+                <Button
+                    android:id="@+id/print_print"
+                    style="@style/btn_list_style"
+                    android:layout_width="wrap_content"
+                    android:layout_marginLeft="@dimen/btn_padding"
+                    android:layout_height="wrap_content"
+                    android:text="@string/btn_printer_print" />
+
+                <Button
+                    android:id="@+id/print_loop"
+                    style="@style/btn_list_style"
+                    android:layout_width="wrap_content"
+                    android:layout_marginLeft="@dimen/btn_padding"
+                    android:layout_height="wrap_content"
+                    android:text="@string/info_print_times" />
+
+                <Button
+                    android:id="@+id/print_close"
+                    style="@style/btn_list_style"
+                    android:layout_width="wrap_content"
+                    android:layout_marginLeft="@dimen/btn_padding"
+                    android:layout_height="wrap_content"
+                    android:text="@string/btn_printer_clsoe" />
+
+                <Button
+                    android:id="@+id/print_clear"
+                    style="@style/btn_list_style"
+                    android:layout_width="wrap_content"
+                    android:layout_marginLeft="@dimen/btn_padding"
+                    android:layout_height="wrap_content"
+                    android:text="@string/btn_clear_content" />
+            </LinearLayout>
+        </HorizontalScrollView>
+
+</LinearLayout>

+ 55 - 0
ZTHandPOS/app/src/main/res/layout/activity_psamcard.xml

@@ -0,0 +1,55 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:orientation="vertical"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    android:padding="@dimen/device_padding" >
+        <TextView 
+            android:layout_height="0dp"
+            android:id="@+id/mag_text"
+            android:layout_weight="8"
+            android:layout_width="match_parent"
+            android:layout_marginBottom="@dimen/btn_padding"
+            style="@style/txtStyle"/>
+        <HorizontalScrollView
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="1.6" >
+        <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="fill_parent"
+                android:orientation="horizontal"
+                android:gravity="center_vertical"
+                android:scrollbars="horizontal" >
+            <Button 
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:id="@+id/psam1_open"
+                style="@style/btn_list_style"
+                android:text="@string/btn_psamcard1_check"/>
+            
+            <Button 
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:id="@+id/psam2_open"
+                style="@style/btn_list_style"
+                android:text="@string/btn_psamcard2_check"/>
+            
+            <TextView 
+                android:layout_width="1dp"
+                android:layout_height="match_parent"/>
+            <Button 
+               	android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                android:id="@+id/psam_clear"
+                style="@style/btn_list_style"
+                android:text="@string/btn_clear_content"/>
+        </LinearLayout>
+        </HorizontalScrollView>
+    </LinearLayout>

+ 55 - 0
ZTHandPOS/app/src/main/res/layout/activity_scan.xml

@@ -0,0 +1,55 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:orientation="vertical"     
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    android:padding="@dimen/device_padding" >
+        <TextView 
+            android:layout_height="0dp"
+            android:layout_weight="8"
+            android:id="@+id/scan_text"
+            android:layout_marginBottom="3dp"
+            android:text="@string/test_scan"
+            android:layout_width="match_parent"
+            style="@style/txtStyle"/>
+       <HorizontalScrollView
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="1.5" >
+
+           <LinearLayout
+               android:layout_width="wrap_content"
+               android:layout_height="fill_parent"
+               android:gravity="center_vertical"
+               android:orientation="horizontal"
+               android:scrollbars="horizontal">
+
+               <Button
+                   android:id="@+id/scan_front"
+                   style="@style/btn_list_style"
+                   android:layout_width="wrap_content"
+                   android:layout_height="wrap_content"
+                   android:text="@string/test_scan_front" />
+
+               <Button
+                   android:id="@+id/scan_back"
+                   style="@style/btn_list_style"
+                   android:layout_width="wrap_content"
+                   android:layout_height="wrap_content"
+                   android:layout_marginLeft="@dimen/btn_padding"
+                   android:text="@string/test_scan_back" />
+
+               <Button
+                   android:id="@+id/scan_clear"
+                   style="@style/btn_list_style"
+                   android:layout_width="wrap_content"
+                   android:layout_height="wrap_content"
+                   android:layout_marginLeft="@dimen/btn_padding"
+                   android:text="@string/btn_clear_content" />
+           </LinearLayout>
+        </HorizontalScrollView>
+     </LinearLayout>

+ 65 - 0
ZTHandPOS/app/src/main/res/layout/activity_serial.xml

@@ -0,0 +1,65 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:orientation="vertical"     
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    android:padding="@dimen/device_padding" >
+        <TextView 
+            android:layout_height="0dp"
+            android:layout_weight="8"
+            android:id="@+id/scan_text"
+            android:layout_marginBottom="3dp"
+            android:text="@string/button_serial_port_test"
+            android:layout_width="match_parent"
+            style="@style/txtStyle"/>
+       <HorizontalScrollView
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="1.5" >
+       <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="fill_parent"
+                android:orientation="horizontal"
+                android:gravity="center_vertical"
+                android:scrollbars="horizontal" >
+            <Button 
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:id="@+id/serial_open"
+                style="@style/btn_list_style"
+                android:text="@string/btn_serial_open"/>
+            <Button 
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                android:id="@+id/serial_receive"
+                style="@style/btn_list_style"
+                android:text="@string/btn_serial_receive"/>
+            <Button 
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                android:id="@+id/serial_send"
+                style="@style/btn_list_style"
+                android:text="@string/btn_serial_send"/>
+            <Button 
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                android:id="@+id/serial_close"
+                style="@style/btn_list_style"
+                android:text="@string/btn_serial_close"/>
+            <Button 
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                android:id="@+id/scan_clear"
+                style="@style/btn_list_style"
+                android:text="@string/btn_clear_content"/>
+        </LinearLayout>
+        </HorizontalScrollView>
+     </LinearLayout>

+ 88 - 0
ZTHandPOS/app/src/main/res/layout/activity_system.xml

@@ -0,0 +1,88 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:orientation="vertical"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    android:padding="@dimen/device_padding" >
+        <TextView 
+            android:layout_height="0dp"
+            android:id="@+id/mag_text"
+            android:layout_weight="8"
+            android:layout_width="match_parent"
+            android:layout_marginBottom="@dimen/btn_padding"
+            style="@style/txtStyle"/>
+        <HorizontalScrollView
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="1.6" >
+        <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="fill_parent"
+                android:orientation="horizontal"
+                android:gravity="center_vertical"
+                android:scrollbars="horizontal" >
+            <Button 
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:id="@+id/sytem_reboot"
+                style="@style/btn_list_style"
+                android:text="@string/btn_sytem_reboot"/>
+            <Button 
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                style="@style/btn_list_style"
+                android:id="@+id/system_shutdown"
+                android:text="@string/btn_sytem_shutdown"/>
+            <Button 
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                style="@style/btn_list_style"
+                android:id="@+id/system_uninstall"
+                android:text="@string/btn_sytem_uninstall"/>
+            <Button 
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                style="@style/btn_list_style"
+                android:id="@+id/system_install"
+                android:text="@string/btn_sytem_install"/>
+            <Button 
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                style="@style/btn_list_style"
+                android:id="@+id/system_setTime"
+                android:text="@string/btn_sytem_settime"/>
+             <Button 
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                style="@style/btn_list_style"
+                android:id="@+id/system_getDeviceMsg"
+                android:text="@string/btn_sytem_getdevice_msg"/>
+             <Button 
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                style="@style/btn_list_style"
+                android:id="@+id/system_getUnionPayEncryptedSN"
+                android:text="@string/btn_sytem_getuinonpaysn"/>
+            <TextView 
+                android:layout_width="1dp"
+                android:layout_height="match_parent"/>
+            <Button 
+               	android:layout_width="wrap_content"
+                android:layout_marginLeft="@dimen/btn_padding"
+                android:layout_height="wrap_content"
+                android:id="@+id/mag_clear"
+                style="@style/btn_list_style"
+                android:text="@string/btn_clear_content"/>
+        </LinearLayout>
+        </HorizontalScrollView>
+    </LinearLayout>

+ 21 - 0
ZTHandPOS/app/src/main/res/layout/list_item.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout 
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="50dp"
+    android:orientation="horizontal">
+	<ImageView 
+	    android:src="@android:drawable/ic_menu_manage"
+	    android:layout_gravity="center"
+	    android:layout_width="0dp"
+	    android:layout_weight="1"
+	    android:layout_height="50dp"/>
+	<TextView
+	    android:id="@+id/listview_text"
+	    android:text="测试选项"
+	    android:layout_width="0dp"
+	    android:layout_weight="4"
+	    android:textStyle="bold"
+	    android:layout_height="wrap_content"
+	    android:textSize="18sp" />
+</LinearLayout>

+ 44 - 0
ZTHandPOS/app/src/main/res/layout/progress.xml

@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>  
+<RelativeLayout
+    android:layout_width="fill_parent" 
+    android:layout_height="fill_parent"
+   	xmlns:android="http://schemas.android.com/apk/res/android">
+     <LinearLayout 
+	    android:layout_width="300dp"
+	    android:layout_height="200dp"
+	    android:layout_centerHorizontal="true"
+	    android:layout_centerInParent="true"
+	    android:background="@drawable/shape"
+	    android:id="@+id/p_dialog"
+	    android:orientation="vertical">
+	       <TextView
+		    android:layout_width="match_parent"
+			android:text="请输入密码"
+	        android:layout_height="0dp"
+	        android:layout_weight="1"
+	        android:textSize="30dp"
+	        android:textColor="@color/ClassicalPurse"
+	        android:textStyle="bold"
+	        android:gravity="center"/>
+			<LinearLayout 
+		    android:layout_width="match_parent"
+		    android:orientation="horizontal"
+	        android:layout_height="0dp"
+	        android:layout_weight="2">
+		   	<EditText
+		   	    android:id="@+id/p_edit"
+		   	    android:layout_width="match_parent"
+				android:layout_marginRight="10dp"
+				android:layout_marginLeft="10dp"
+				android:focusable="false"
+				android:inputType="numberPassword"
+				android:hint="请输入密码"
+		   	    android:layout_weight="1"
+		   	    android:layout_gravity="center_vertical"
+		   	    android:textStyle="bold"
+	        	android:layout_height="50dp"
+	        	android:background="@drawable/btnstyle"/>
+		</LinearLayout>  
+	</LinearLayout>
+</RelativeLayout>
+

+ 9 - 0
ZTHandPOS/app/src/main/res/menu/all_card.xml

@@ -0,0 +1,9 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item
+        android:id="@+id/action_settings"
+        android:orderInCategory="100"
+        android:showAsAction="never"
+        android:title="action_settings"/>
+
+</menu>

+ 9 - 0
ZTHandPOS/app/src/main/res/menu/main.xml

@@ -0,0 +1,9 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item
+        android:id="@+id/action_settings"
+        android:orderInCategory="100"
+        android:showAsAction="never"
+        android:title="action_settings"/>
+
+</menu>

+ 5 - 0
ZTHandPOS/app/src/main/res/menu/menu_main.xml

@@ -0,0 +1,5 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
+    <item android:id="@+id/action_settings" android:title="action_settings"
+        android:orderInCategory="100" android:showAsAction="never" />
+</menu>

+ 9 - 0
ZTHandPOS/app/src/main/res/menu/new_main.xml

@@ -0,0 +1,9 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item
+        android:id="@+id/action_settings"
+        android:orderInCategory="100"
+        android:showAsAction="never"
+        android:title="action_settings"/>
+
+</menu>

+ 9 - 0
ZTHandPOS/app/src/main/res/menu/read_card.xml

@@ -0,0 +1,9 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item
+        android:id="@+id/action_settings"
+        android:orderInCategory="100"
+        android:showAsAction="never"
+        android:title="action_settings"/>
+
+</menu>

+ 5 - 0
ZTHandPOS/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+    <background android:drawable="@drawable/ic_launcher_foreground" />
+    <foreground android:drawable="@drawable/ic_launcher_foreground" />
+</adaptive-icon>

+ 5 - 0
ZTHandPOS/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+    <background android:drawable="@drawable/ic_launcher_foreground" />
+    <foreground android:drawable="@drawable/ic_launcher_foreground" />
+</adaptive-icon>

BIN
ZTHandPOS/app/src/main/res/mipmap-hdpi/ic_launcher.png


BIN
ZTHandPOS/app/src/main/res/mipmap-mdpi/ic_launcher.png


BIN
ZTHandPOS/app/src/main/res/mipmap-xhdpi/ic_launcher.png


BIN
ZTHandPOS/app/src/main/res/mipmap-xxhdpi/ic_launcher.png


BIN
ZTHandPOS/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png


BIN
ZTHandPOS/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png


BIN
ZTHandPOS/app/src/main/res/raw/alert_tone.wav


BIN
ZTHandPOS/app/src/main/res/raw/app_test


BIN
ZTHandPOS/app/src/main/res/raw/err.wav


+ 21 - 0
ZTHandPOS/app/src/main/res/raw/params

@@ -0,0 +1,21 @@
+AID=
+08A0000003330101020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FC70F488F00010000000FC70F4F8F00100000000010000000000000000000000000000000000000000000000008C8001560004039F370400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100F9F02065F2A029A039C0195059F3704000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101000000050000017600800001000005000001000005000001000005000001
+08A0000003330101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FC70F488F00010000000FC70F4F8F00100000000010000000000000000000000000000000000000000000000008C8001560004039F370400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100F9F02065F2A029A039C0195059F3704000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101000000050000017600800001000005000001000005000001000005000001
+08A0000003330101030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FC70F488F00010000000FC70F4F8F00100000000010000000000000000000000000000000000000000000000008C8001560004039F370400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100F9F02065F2A029A039C0195059F3704000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101000000050000017600800001000005000001000005000001000005000001
+08A0000003330101060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FC70F488F00010000000FC70F4F8F00100000000010000000000000000000000000000000000000000000000008C8001560004039F370400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100F9F02065F2A029A039C0195059F3704000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101000000050000017600800001000005000001000005000001000005000001
+07A0000000031010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D84000A8000810000000D84004F8000100000000010000000000000000000000000000000000000000000000008C8001560004039F370400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100F9F02065F2A029A039C0195059F3704000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101000000050000017600800001000005000001000005000001000005000001
+07A0000000999090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D84000A8000010000000D84004F8000100000000010000000000000000000000000000000000000000000000008C8001560004039F370400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100F9F02065F2A029A039C0195059F3704000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101000000050000017600800001000005000001000005000001000005000001
+07A0000000032010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D84000A8000010000000D84004F8000100000000010000000000000000000000000000000000000000000000008C8001560004039F370400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100F9F02065F2A029A039C0195059F3704000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101000000050000017600800001000005000001000005000001000005000001
+05A0000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FC50ACA0000400000000F850ACF800010000000001000000000000000000000000000000000000000000000000028001560004039F370400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100F9F02065F2A029A039C0195059F3704000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101000000050000017600800001000005000001000005000001000005000001
+07A0000000043060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FC50ACA0000400000000F850ACF800010000000001000000000000000000000000000000000000000000000000028001560004039F370400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100F9F02065F2A029A039C0195059F3704000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101000000050000017600800001000005000001000005000001000005000001
+07A0000000046000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FC50ACA0000400000000F850ACF800010000000001000000000000000000000000000000000000000000000000028001560004039F370400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100F9F02065F2A029A039C0195059F3704000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101000000050000017600800001000005000001000005000001000005000001
+07A0000000101030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FC50ACA0000400000000F850ACF800010000000001000000000000000000000000000000000000000000000000028001560004039F370400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100F9F02065F2A029A039C0195059F3704000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101000000050000017600800001000005000001000005000001000005000001
+07A0000000651010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FC6024A8000010000000FC60ACF800010000000001000000000000000000000000000000000000000000000002008001560004039F370400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100F9F02065F2A029A039C0195059F3704000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101000000050000017600800001000005000001000005000001000005000001
+CAPK=
+A00000033308010090000000B61645EDFD5498FB246444037A0FA18C0F101EBD8EFA54573CE6E6A7FBF63ED21D66340852B0211CF5EEF6A1CD989F66AF21A8EB19DBD8DBC3706D135363A0D683D046304F5A836BC1BC632821AFE7A2F75DA3C50AC74C545A754562204137169663CFCC0B06E67E2109EBA41BC67FF20CC8AC80D7B6EE1A95465B3B2657533EA56D92D539E5064360EA4850FED2D1BF000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001030000EE23B616C95C02652AD18860E48787C079E8E85A32303330313233300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+A000000333090100B0000000EB374DFC5A96B71D2863875EDA2EAFB96B1B439D3ECE0B1826A2672EEEFA7990286776F8BD989A15141A75C384DFC14FEF9243AAB32707659BE9E4797A247C2F0B6D99372F384AF62FE23BC54BCDC57A9ACD1D5585C303F201EF4E8B806AFB809DB1A3DB1CD112AC884F164A67B99C7D6E5A8A6DF1D3CAE6D7ED3D5BE725B2DE4ADE23FA679BF4EB15A93D8A6E29C7FFA1A70DE2E54F593D908A3BF9EBBD760BBFDC8DB8B54497E6C5BE0E4A4DAC29E500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001030000A075306EAB0045BAF72CDD33B3B678779DE1F52732303330313233300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+A0000003330A010080000000B2AB1B6E9AC55A75ADFD5BBC34490E53C4C3381F34E60E7FAC21CC2B26DD34462B64A6FAE2495ED1DD383B8138BEA100FF9B7A111817E7B9869A9742B19E5C9DAC56F8B8827F11B05A08ECCF9E8D5E85B0F7CFA644EFF3E9B796688F38E006DEB21E101C01028903A06023AC5AAB8635F8E307A53AC742BDCE6A283F585F48EF4ADE23FA679BF4EB15A93D8A6E29C7FFA1A70DE2E54F593D908A3BF9EBBD760BBFDC8DB8B54497E6C5BE0E4A4DAC29E500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001030000C88BE6B2417C4F941C9371EA35A377158767E4E332303330313233300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+A0000003330B0100F8000000CF9FDF46B356378E9AF311B0F981B21A1F22F250FB11F55C958709E3C7241918293483289EAE688A094C02C344E2999F315A72841F489E24B1BA0056CFAB3B479D0E826452375DCDBB67E97EC2AA66F4601D774FEAEF775ACCC621BFEB65FB0053FC5F392AA5E1D4C41A4DE9FFDFDF1327C4BB874F1F63A599EE3902FE95E729FD78D4234DC7E6CF1ABABAA3F6DB29B7F05D1D901D2E76A606A8CBFFFFECBD918FA2D278BDB43B0434F5D45134BE1C2781D157D501FF43E5F1C470967CD57CE53B64D82974C8275937C5D8502A1252A8A5D6088A259B694F98648D9AF2CB0EFD9D943C69F896D49FA39702162ACB5AF29B90BADE005BC15701030000BD331F9996A490B33C13441066A09AD3FEB5F66C32303330313233300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+A00000033308010190000000B61645EDFD5498FB246444037A0FA18C0F101EBD8EFA54573CE6E6A7FBF63ED21D66340852B0211CF5EEF6A1CD989F66AF21A8EB19DBD8DBC3706D135363A0D683D046304F5A836BC1BC632821AFE7A2F75DA3C50AC74C545A754562204137169663CFCC0B06E67E2109EBA41BC67FF20CC8AC80D7B6EE1A95465B3B2657533EA56D92D539E5064360EA4850FED2D1BFF05D1D901D2E76A606A8CBFFFFECBD918FA2D278BDB43B0434F5D45134BE1C2781D157D501FF43E5F1C470967CD57CE53B64D82974C8275937C5D8502A1252A8A5D6088A259B694F98648D9AF2CB0EFD9D943C69F896D49FA39702162ACB5AF29B90BADE005BC15701030000EE23B616C95C02652AD18860E48787C079E8E85A33323330333233300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+TERM=
+0156000000000000000031323334353637380156E0F0C81400E000F0A00100000000000000000000000000000000000000000000000000000001

+ 8 - 0
ZTHandPOS/app/src/main/res/raw/params_ms

@@ -0,0 +1,8 @@
+AID=
+9F0608A000000333010101DF0101009F08020020DF1105D84000A800DF1205D84004F800DF130500100000009F1B0431303030DF150435303030DF160100DF170100DF14039F3704DF1801019F7B06000000100000DF1906000000020000DF2006000000020000DF2106000000020000
+CAPK=
+9F0605A0000003339F22010BDF05083230333031323330DF060101DF070101DF0281F8CF9FDF46B356378E9AF311B0F981B21A1F22F250FB11F55C958709E3C7241918293483289EAE688A094C02C344E2999F315A72841F489E24B1BA0056CFAB3B479D0E826452375DCDBB67E97EC2AA66F4601D774FEAEF775ACCC621BFEB65FB0053FC5F392AA5E1D4C41A4DE9FFDFDF1327C4BB874F1F63A599EE3902FE95E729FD78D4234DC7E6CF1ABABAA3F6DB29B7F05D1D901D2E76A606A8CBFFFFECBD918FA2D278BDB43B0434F5D45134BE1C2781D157D501FF43E5F1C470967CD57CE53B64D82974C8275937C5D8502A1252A8A5D6088A259B694F98648D9AF2CB0EFD9D943C69F896D49FA39702162ACB5AF29B90BADE005BC157DF040103DF0314BD331F9996A490B33C13441066A09AD3FEB5F66C
+9F0605A0000003339F220108DF05083230333031323330DF060101DF070101DF028190B61645EDFD5498FB246444037A0FA18C0F101EBD8EFA54573CE6E6A7FBF63ED21D66340852B0211CF5EEF6A1CD989F66AF21A8EB19DBD8DBC3706D135363A0D683D046304F5A836BC1BC632821AFE7A2F75DA3C50AC74C545A754562204137169663CFCC0B06E67E2109EBA41BC67FF20CC8AC80D7B6EE1A95465B3B2657533EA56D92D539E5064360EA4850FED2D1BFDF040103DF0314EE23B616C95C02652AD18860E48787C079E8E85A
+9F0605A0000003339F220109DF05083230333031323330DF060101DF070101DF0281B0EB374DFC5A96B71D2863875EDA2EAFB96B1B439D3ECE0B1826A2672EEEFA7990286776F8BD989A15141A75C384DFC14FEF9243AAB32707659BE9E4797A247C2F0B6D99372F384AF62FE23BC54BCDC57A9ACD1D5585C303F201EF4E8B806AFB809DB1A3DB1CD112AC884F164A67B99C7D6E5A8A6DF1D3CAE6D7ED3D5BE725B2DE4ADE23FA679BF4EB15A93D8A6E29C7FFA1A70DE2E54F593D908A3BF9EBBD760BBFDC8DB8B54497E6C5BE0E4A4DAC29E5DF040103DF0314A075306EAB0045BAF72CDD33B3B678779DE1F527
+TERM=
+0156000000000000000031323300000000000156E0E9C822026000D0100100000000000000000000000000000000000000000036

BIN
ZTHandPOS/app/src/main/res/raw/plsswca.wav


BIN
ZTHandPOS/app/src/main/res/raw/selftest_affirm.wav


Some files were not shown because too many files changed in this diff