Commit 72876d869c7d43c7b6fe8469e6c9798d23a9e982
1 parent
c05c7a9b
畅游通核销app: 1.增加5501H读身份证功能 2.增加本地写入日志功能
Showing
22 changed files
with
195 additions
and
131 deletions
AndroidManifest.xml
| ... | ... | @@ -356,6 +356,11 @@ |
| 356 | 356 | android:launchMode="singleTask" |
| 357 | 357 | android:theme="@android:style/Theme.Black.NoTitleBar" /> |
| 358 | 358 | |
| 359 | + <activity | |
| 360 | + android:name="com.ectrip.cyt.ui.BlackIdCardActivity" | |
| 361 | + android:keepScreenOn="true" | |
| 362 | + android:launchMode="singleTask" | |
| 363 | + android:theme="@android:style/Theme.Black.NoTitleBar" /> | |
| 359 | 364 | |
| 360 | 365 | <service android:name="com.ectrip.cyt.service.OrderRegularDelecteService"></service> |
| 361 | 366 | <service android:name="com.IDCard.ScanService"> | ... | ... |
build.gradle
| ... | ... | @@ -35,6 +35,9 @@ dependencies { |
| 35 | 35 | implementation files('libs\\zkandroididcardreader.jar') |
| 36 | 36 | implementation files('libs\\iodev2.jar') |
| 37 | 37 | implementation files('libs\\decoderapijni.jar') |
| 38 | + implementation files('libs\\android-logging-log4j-1.0.3.jar') | |
| 39 | + implementation files('libs\\log4j-1.2.17.jar') | |
| 40 | + implementation files('libs\\zypos1.8.jar') | |
| 38 | 41 | compileOnly files('external_libs/classes_2.1.11_20160907.jar') |
| 39 | 42 | compileOnly files('external_libs/bw_odm_20160526.jar') |
| 40 | 43 | implementation files('libs/bw_pos_sdk2.0.18.jar') | ... | ... |
libs/armeabi-v7a/libwltdecode.so
No preview for this file type
src/android_serialport_api/print_tool/MobilePrintTool.java
| ... | ... | @@ -216,7 +216,7 @@ public class MobilePrintTool extends Activity { |
| 216 | 216 | if (address == null) { |
| 217 | 217 | break; |
| 218 | 218 | } |
| 219 | - LogUtil.i("address" + address); | |
| 219 | + LogUtil.i(TAG,"address" + address); | |
| 220 | 220 | // 获取设备进行连接 |
| 221 | 221 | BluetoothDevice device = mBluetoothAdapter |
| 222 | 222 | .getRemoteDevice(address); |
| ... | ... | @@ -274,7 +274,7 @@ public class MobilePrintTool extends Activity { |
| 274 | 274 | printer = new PrinterEscCmd(); |
| 275 | 275 | } |
| 276 | 276 | final int printNum = MyApp.getInstance().getPrintNum(); |
| 277 | - LogUtil.d(printNum + getString(R.string.times)); | |
| 277 | + LogUtil.d(TAG,printNum + getString(R.string.times)); | |
| 278 | 278 | new Thread(new Runnable() { |
| 279 | 279 | @Override |
| 280 | 280 | public void run() { | ... | ... |
src/com/ectrip/cyt/config/DevicTool.java
| ... | ... | @@ -29,6 +29,7 @@ import android.os.Message; |
| 29 | 29 | import android.telephony.TelephonyManager; |
| 30 | 30 | import android.text.TextUtils; |
| 31 | 31 | import android.util.DisplayMetrics; |
| 32 | +import android.util.Log; | |
| 32 | 33 | import android.view.Display; |
| 33 | 34 | import android.view.WindowManager; |
| 34 | 35 | |
| ... | ... | @@ -480,5 +481,18 @@ public class DevicTool { |
| 480 | 481 | return false; |
| 481 | 482 | } |
| 482 | 483 | } |
| 483 | - | |
| 484 | + public static boolean isHiboryPos() { | |
| 485 | + try { | |
| 486 | + String sn = android.os.Build.MODEL; | |
| 487 | + LogUtil.d("SN", sn); | |
| 488 | + if (TextUtils.equals(sn, "5501H")) { | |
| 489 | + return true; | |
| 490 | + } else { | |
| 491 | + return false; | |
| 492 | + } | |
| 493 | + } catch (Exception e) { | |
| 494 | + e.printStackTrace(); | |
| 495 | + return false; | |
| 496 | + } | |
| 497 | + } | |
| 484 | 498 | } | ... | ... |
src/com/ectrip/cyt/config/MyApp.java
| ... | ... | @@ -529,7 +529,7 @@ public class MyApp extends BaseApplication { |
| 529 | 529 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 530 | 530 | startActivity(intent); |
| 531 | 531 | } catch (Exception e) { |
| 532 | - LogUtil.v(TAG, | |
| 532 | + LogUtil.i(TAG, | |
| 533 | 533 | "open network settings failed, please check..."); |
| 534 | 534 | e.printStackTrace(); |
| 535 | 535 | } |
| ... | ... | @@ -631,6 +631,32 @@ public class MyApp extends BaseApplication { |
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | |
| 634 | + private SerialPort mSerialPort = null; | |
| 634 | 635 | |
| 636 | + public SerialPort getSerialPort() throws SecurityException, IOException, InvalidParameterException { | |
| 637 | + if (mSerialPort == null) { | |
| 638 | + /* Read serial port parameters */ | |
| 639 | + SharedPreferences sp = getSharedPreferences("android_serialport_api.sample_preferences", MODE_PRIVATE); | |
| 640 | + String path = sp.getString("DEVICE", "/dev/ttyMT2"); | |
| 641 | + int baudrate = Integer.decode(sp.getString("BAUDRATE", "115200")); | |
| 642 | + | |
| 643 | + /* Check parameters */ | |
| 644 | + if ( (path.length() == 0) || (baudrate == -1)) { | |
| 645 | + throw new InvalidParameterException(); | |
| 646 | + } | |
| 647 | + | |
| 648 | + /* Open the serial port */ | |
| 649 | + // mSerialPort = new SerialPort(new File("/dev/ttySAC1"), 9600, 0); | |
| 650 | + mSerialPort = new SerialPort(new File("/dev/ttyMT3"), 115200, 0); | |
| 651 | +// mSerialPort = new SerialPort(new File("/dev/ttyS1"), baudrate, 0); | |
| 652 | + } | |
| 653 | + return mSerialPort; | |
| 654 | + } | |
| 655 | + public void closeSerialPort() { | |
| 656 | + if (mSerialPort != null) { | |
| 657 | + mSerialPort.close(); | |
| 658 | + mSerialPort = null; | |
| 659 | + } | |
| 660 | + } | |
| 635 | 661 | |
| 636 | 662 | } | ... | ... |
src/com/ectrip/cyt/constant/DeviceType.java
| ... | ... | @@ -14,8 +14,9 @@ public enum DeviceType { |
| 14 | 14 | //New_IDPOS:新的身份证pos机 |
| 15 | 15 | //New_HANDSET_POS:新版小的pos(手持pos)机 |
| 16 | 16 | //BASEWIN_REB_POS:盛本的红色pos机 |
| 17 | + //BLACK_ID_POS:5501H手持机 | |
| 17 | 18 | ID_POS(5),GENERAL_POS(6),SMALL_POS(7),HANDSET(8),MOBILE(9),New_POS(10), |
| 18 | - New_IDPOS(11),New_HANDSET_POS(12),BASEWIN_REB_POS(13); | |
| 19 | + New_IDPOS(11),New_HANDSET_POS(12),BASEWIN_REB_POS(13),BLACK_ID_POS(14); | |
| 19 | 20 | private int value; |
| 20 | 21 | |
| 21 | 22 | private DeviceType(int value) { | ... | ... |
src/com/ectrip/cyt/exceptionsave/debug/LocalLogRunnable.java
| ... | ... | @@ -8,6 +8,7 @@ import java.util.Calendar; |
| 8 | 8 | import java.util.Date; |
| 9 | 9 | |
| 10 | 10 | import com.ectrip.cyt.exceptionsave.init.InitAppValue; |
| 11 | +import com.ectrip.cyt.utils.LogUtil; | |
| 11 | 12 | |
| 12 | 13 | import android.content.Context; |
| 13 | 14 | import android.content.Intent; |
| ... | ... | @@ -19,7 +20,7 @@ import android.util.Log; |
| 19 | 20 | |
| 20 | 21 | public class LocalLogRunnable implements Runnable{ |
| 21 | 22 | |
| 22 | - private String TAG="LocalLogRunnable"; | |
| 23 | + public static final String TAG="LocalLogRunnable"; | |
| 23 | 24 | |
| 24 | 25 | private Context mContext; |
| 25 | 26 | private Throwable ex; |
| ... | ... | @@ -174,6 +175,7 @@ public class LocalLogRunnable implements Runnable{ |
| 174 | 175 | randomFile.close(); |
| 175 | 176 | } catch (IOException e) { |
| 176 | 177 | e.printStackTrace(); |
| 178 | + LogUtil.d(TAG, LogUtil.getExMsg(e)); | |
| 177 | 179 | } |
| 178 | 180 | } |
| 179 | 181 | } | ... | ... |
src/com/ectrip/cyt/ui/BaseActivity.java
| ... | ... | @@ -231,7 +231,7 @@ public abstract class BaseActivity extends FragmentActivity { |
| 231 | 231 | } |
| 232 | 232 | isPause.set(true); |
| 233 | 233 | super.onBackPressed(); |
| 234 | - LogUtil.i(getString(R.string.back_pressed)); | |
| 234 | + LogUtil.i(TAG,getString(R.string.back_pressed)); | |
| 235 | 235 | if (netDialog != null && netDialog.isShowing()) { |
| 236 | 236 | try { |
| 237 | 237 | netDialog.dismiss(); | ... | ... |
src/com/ectrip/cyt/ui/MainActivity.java
| ... | ... | @@ -150,7 +150,7 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V |
| 150 | 150 | && getSerialNumber().contains("CTY") && getSerialNumber() |
| 151 | 151 | .substring(0, 3).equals("CTY"))) { |
| 152 | 152 | // 新的pos机 |
| 153 | - LogUtil.i(getString(R.string.new_pos)); | |
| 153 | + LogUtil.i(TAG,getString(R.string.new_pos)); | |
| 154 | 154 | SharedPreferences2Obj.getInstance(MainActivity.this) |
| 155 | 155 | .setName("MachineType") |
| 156 | 156 | .setObject("type", DeviceType.New_POS.getValue()); |
| ... | ... | @@ -159,7 +159,7 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V |
| 159 | 159 | .substring(0, 2).equals("LY"))) { |
| 160 | 160 | release(); |
| 161 | 161 | // 新的手持pos机 |
| 162 | - LogUtil.i(getString(R.string.new_handset_pos)); | |
| 162 | + LogUtil.i(TAG,getString(R.string.new_handset_pos)); | |
| 163 | 163 | SharedPreferences2Obj |
| 164 | 164 | .getInstance(MainActivity.this) |
| 165 | 165 | .setName("MachineType") |
| ... | ... | @@ -169,13 +169,18 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V |
| 169 | 169 | && getSerialNumber().contains("DY") && getSerialNumber() |
| 170 | 170 | .substring(0, 2).equals("DY"))) { |
| 171 | 171 | // 新的身份证pos机 |
| 172 | - LogUtil.i(getString(R.string.new_id_pos)); | |
| 172 | + LogUtil.i(TAG,getString(R.string.new_id_pos)); | |
| 173 | 173 | SharedPreferences2Obj.getInstance(MainActivity.this) |
| 174 | 174 | .setName("MachineType") |
| 175 | 175 | .setObject("type", DeviceType.New_IDPOS.getValue()); |
| 176 | + } else if(DevicTool.isHiboryPos()){ | |
| 177 | + LogUtil.i(TAG,"5501H手持机"); | |
| 178 | + SharedPreferences2Obj.getInstance(MainActivity.this) | |
| 179 | + .setName("MachineType") | |
| 180 | + .setObject("type", DeviceType.BLACK_ID_POS.getValue()); | |
| 176 | 181 | } else if (HdxUtil.SetIDCARDPower(1) != -1) { |
| 177 | 182 | // 身份证pos机 |
| 178 | - LogUtil.i(getString(R.string.id_pos)); | |
| 183 | + LogUtil.i(TAG,getString(R.string.id_pos)); | |
| 179 | 184 | SharedPreferences2Obj.getInstance(MainActivity.this) |
| 180 | 185 | .setName("MachineType") |
| 181 | 186 | .setObject("type", DeviceType.ID_POS.getValue()); |
| ... | ... | @@ -183,7 +188,7 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V |
| 183 | 188 | || DevicTool.getInstance().isSerialPortHandset()) { |
| 184 | 189 | release(); |
| 185 | 190 | // 黄色手持机 |
| 186 | - LogUtil.i(getString(R.string.handset)); | |
| 191 | + LogUtil.i(TAG,getString(R.string.handset)); | |
| 187 | 192 | SharedPreferences2Obj.getInstance(MainActivity.this) |
| 188 | 193 | .setName("MachineType") |
| 189 | 194 | .setObject("type", DeviceType.HANDSET.getValue()); |
| ... | ... | @@ -193,14 +198,14 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V |
| 193 | 198 | && height <= 500) { |
| 194 | 199 | release(); |
| 195 | 200 | // 小pos机 |
| 196 | - LogUtil.i(getString(R.string.small_pos)); | |
| 201 | + LogUtil.i(TAG,getString(R.string.small_pos)); | |
| 197 | 202 | SharedPreferences2Obj.getInstance(MainActivity.this) |
| 198 | 203 | .setName("MachineType") |
| 199 | 204 | .setObject("type", DeviceType.SMALL_POS.getValue()); |
| 200 | 205 | } else if (DevicTool.getInstance().isSerialPort() |
| 201 | 206 | || DevicTool.getInstance().isIdPosPrint()) { |
| 202 | 207 | // 一般pos机 |
| 203 | - LogUtil.i(getString(R.string.general_pos)); | |
| 208 | + LogUtil.i(TAG,getString(R.string.general_pos)); | |
| 204 | 209 | SharedPreferences2Obj.getInstance(MainActivity.this) |
| 205 | 210 | .setName("MachineType") |
| 206 | 211 | .setObject("type", DeviceType.GENERAL_POS.getValue()); |
| ... | ... | @@ -208,7 +213,7 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V |
| 208 | 213 | //盛本pos机测试******************************* |
| 209 | 214 | else if (BindService.getInstance().isBasewin()) { |
| 210 | 215 | // 盛本pos机 |
| 211 | - LogUtil.i("盛本POS机"); | |
| 216 | + LogUtil.i(TAG,"盛本POS机"); | |
| 212 | 217 | SharedPreferences2Obj.getInstance(MainActivity.this) |
| 213 | 218 | .setName("MachineType") |
| 214 | 219 | .setObject("type", DeviceType.BASEWIN_REB_POS.getValue()); |
| ... | ... | @@ -217,7 +222,7 @@ public class MainActivity extends BaseActivity implements OnItemClickListener, V |
| 217 | 222 | else { |
| 218 | 223 | release(); |
| 219 | 224 | // 手机 |
| 220 | - LogUtil.i(getString(R.string.mobile)); | |
| 225 | + LogUtil.i(TAG,getString(R.string.mobile)); | |
| 221 | 226 | SharedPreferences2Obj.getInstance(MainActivity.this) |
| 222 | 227 | .setName("MachineType") |
| 223 | 228 | .setObject("type", DeviceType.MOBILE.getValue()); | ... | ... |
src/com/ectrip/cyt/ui/NewHandleScanerActivity.java
| ... | ... | @@ -159,7 +159,7 @@ public class NewHandleScanerActivity extends BaseActivity { |
| 159 | 159 | } else { |
| 160 | 160 | try { |
| 161 | 161 | if (result.startsWith("CYT_")) { |
| 162 | - LogUtil.i("result = " + result); | |
| 162 | + LogUtil.i(TAG,"result = " + result); | |
| 163 | 163 | typeScan = 0; |
| 164 | 164 | if (result.contains(",")) { |
| 165 | 165 | result = result.substring(result.indexOf("_") + 1, result.indexOf(",")); | ... | ... |
src/com/ectrip/cyt/ui/PhomeScanerOrderActivity.java
| ... | ... | @@ -177,7 +177,7 @@ public class PhomeScanerOrderActivity extends BaseActivity implements Callback { |
| 177 | 177 | QRCodeOrderListActivity.class); |
| 178 | 178 | intent.putExtra("mode", 1); |
| 179 | 179 | intent.putExtra("input_orid", resultString); |
| 180 | - LogUtil.i(getString(R.string.scan_result) + resultString); | |
| 180 | + LogUtil.i(TAG,getString(R.string.scan_result) + resultString); | |
| 181 | 181 | intent.putExtra("titleName", getString(R.string.show_result)); |
| 182 | 182 | intent.putExtra("typeScan", typeScan); |
| 183 | 183 | startActivity(intent); | ... | ... |
src/com/ectrip/cyt/ui/ScanerHandsetActivity.java
| ... | ... | @@ -189,7 +189,7 @@ public class ScanerHandsetActivity extends SerialPortHandsetActivity { |
| 189 | 189 | QRCodeOrderListActivity.class); |
| 190 | 190 | intent.putExtra("mode", 1); |
| 191 | 191 | intent.putExtra("input_orid", resultString); |
| 192 | - LogUtil.i("scan_result:" + resultString); | |
| 192 | + LogUtil.i(TAG,"scan_result:" + resultString); | |
| 193 | 193 | intent.putExtra("titleName", |
| 194 | 194 | getString(R.string.show_result)); |
| 195 | 195 | startActivity(intent); | ... | ... |
src/com/ectrip/cyt/ui/ScanerIdCardActivity.java
| ... | ... | @@ -142,10 +142,10 @@ public class ScanerIdCardActivity extends BaseActivity { |
| 142 | 142 | public void readIdCard(int num) throws Throwable { |
| 143 | 143 | if (idcread.Authenticate() == 1 && !isStop.get())/* 身份证认证 */ |
| 144 | 144 | { |
| 145 | - LogUtil.d(getString(R.string.id_auth_success)); | |
| 145 | + LogUtil.d(TAG,getString(R.string.id_auth_success)); | |
| 146 | 146 | if (idcread.ReadContent("/mnt/sdcard/") == 1)/* 读取身份证数据 */// |
| 147 | 147 | { |
| 148 | - LogUtil.d(getString(R.string.read_id_info_success)); | |
| 148 | + LogUtil.d(TAG,getString(R.string.read_id_info_success)); | |
| 149 | 149 | try { |
| 150 | 150 | testRead(); |
| 151 | 151 | } catch (Exception e) { |
| ... | ... | @@ -170,7 +170,7 @@ public class ScanerIdCardActivity extends BaseActivity { |
| 170 | 170 | e.printStackTrace(); |
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | - LogUtil.d(getString(R.string.read_id_info_fail)); | |
| 173 | + LogUtil.d(TAG,getString(R.string.read_id_info_fail)); | |
| 174 | 174 | MToast(ScanerIdCardActivity.this, |
| 175 | 175 | getString(R.string.read_id_info_fail), |
| 176 | 176 | MToast.LENGTH_SHORT); |
| ... | ... | @@ -191,7 +191,7 @@ public class ScanerIdCardActivity extends BaseActivity { |
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | num = 0; |
| 194 | - LogUtil.d(getString(R.string.id_auth_fail)); | |
| 194 | + LogUtil.d(TAG,getString(R.string.id_auth_fail)); | |
| 195 | 195 | MToast(ScanerIdCardActivity.this, |
| 196 | 196 | getString(R.string.id_stick_to_the_back), |
| 197 | 197 | MToast.LENGTH_SHORT); | ... | ... |
src/com/ectrip/cyt/ui/SelectActionActivity.java
| ... | ... | @@ -252,6 +252,24 @@ public class SelectActionActivity extends BaseActivity implements |
| 252 | 252 | intent.putExtra("titleName", getString(R.string.idcard)); |
| 253 | 253 | } |
| 254 | 254 | startActivity(intent); |
| 255 | + } else if (type == DeviceType.BLACK_ID_POS.getValue()) { | |
| 256 | + intent = new Intent(SelectActionActivity.this, | |
| 257 | + BlackIdCardActivity.class); | |
| 258 | + if (Select != null) { | |
| 259 | + if (Select == SelectAction.Check.getValue()) { | |
| 260 | + intent.putExtra("titleName", | |
| 261 | + getString(R.string.check_idcard)); | |
| 262 | + } else if (Select == SelectAction.Reprint.getValue()) { | |
| 263 | + intent.putExtra("titleName", | |
| 264 | + getString(R.string.reprint_idcard)); | |
| 265 | + } else if (Select == SelectAction.Query.getValue()) { | |
| 266 | + intent.putExtra("titleName", | |
| 267 | + getString(R.string.query_idcard)); | |
| 268 | + } | |
| 269 | + } else { | |
| 270 | + intent.putExtra("titleName", getString(R.string.idcard)); | |
| 271 | + } | |
| 272 | + startActivity(intent); | |
| 255 | 273 | } else if (type == DeviceType.New_POS.getValue()) {//10号手持机 |
| 256 | 274 | intent = new Intent(SelectActionActivity.this,IDHandleRSKActivity.class); |
| 257 | 275 | if (Select != null) { | ... | ... |
src/com/ectrip/cyt/ui/SettingsActivity.java
| ... | ... | @@ -675,14 +675,14 @@ public class SettingsActivity extends BaseActivity implements OnClickListener, |
| 675 | 675 | if (!ec_name.equals("")) { |
| 676 | 676 | try { |
| 677 | 677 | ec_name = AESEncryptor.decrypt(constant.decrypt, ec_name); |
| 678 | - LogUtil.d(getString(R.string.enterprise_communication_identifier) | |
| 678 | + LogUtil.d(TAG,getString(R.string.enterprise_communication_identifier) | |
| 679 | 679 | + ec_name); |
| 680 | 680 | ec_name = AESEncryptor.encrypt(constant.decrypt, ec_name); |
| 681 | 681 | } catch (Exception ex) { |
| 682 | 682 | try { |
| 683 | 683 | ec_name = AESEncryptor.encrypt(constant.decrypt, |
| 684 | 684 | ec_name); |
| 685 | - LogUtil.d(getString(R.string.not_successfully_decrypt) | |
| 685 | + LogUtil.d(TAG,getString(R.string.not_successfully_decrypt) | |
| 686 | 686 | + ec_name); |
| 687 | 687 | } catch (Exception e) { |
| 688 | 688 | e.printStackTrace(); | ... | ... |
src/com/ectrip/cyt/utils/LogUtil.java
| 1 | 1 | package com.ectrip.cyt.utils; |
| 2 | 2 | |
| 3 | +import android.text.TextUtils; | |
| 3 | 4 | import android.util.Log; |
| 4 | 5 | |
| 6 | +import com.ectrip.cyt.exceptionsave.debug.ConfigureLog4J; | |
| 7 | + | |
| 8 | +import org.apache.log4j.Logger; | |
| 9 | + | |
| 10 | +import java.io.ByteArrayOutputStream; | |
| 11 | +import java.io.PrintStream; | |
| 12 | + | |
| 5 | 13 | /** |
| 6 | 14 | * Log统一管理类 |
| 7 | 15 | */ |
| ... | ... | @@ -9,106 +17,87 @@ public class LogUtil |
| 9 | 17 | { |
| 10 | 18 | public static boolean isDebug = true;// 是否需要打印bug,可以在application的onCreate函数里面初始化 |
| 11 | 19 | private static final String TAG = "MyAndroid"; |
| 20 | + private static boolean isConfigured = false; | |
| 12 | 21 | |
| 13 | 22 | // 下面四个是默认tag的函数 |
| 14 | - public static void i(String msg) | |
| 15 | - { | |
| 16 | - if (isDebug) | |
| 17 | - try { | |
| 18 | - Log.i(TAG, msg); | |
| 19 | - } catch (Exception e) { | |
| 20 | - e.printStackTrace(); | |
| 21 | - } | |
| 23 | + public static void d(String tag, String message) { | |
| 24 | + if (isDebug) { | |
| 25 | + Logger LOGGER = getLogger(tag); | |
| 26 | + LOGGER.debug(message); | |
| 27 | + } | |
| 22 | 28 | } |
| 23 | 29 | |
| 24 | - public static void d(String msg) | |
| 25 | - { | |
| 26 | - if (isDebug) | |
| 27 | - try { | |
| 28 | - Log.d(TAG, msg); | |
| 29 | - } catch (Exception e) { | |
| 30 | - e.printStackTrace(); | |
| 31 | - } | |
| 30 | + public static void d(String tag, String message, Throwable exception) { | |
| 31 | + if (isDebug) { | |
| 32 | + Logger LOGGER = getLogger(tag); | |
| 33 | + LOGGER.debug(message, exception); | |
| 34 | + } | |
| 32 | 35 | } |
| 33 | 36 | |
| 34 | - public static void w(String msg) | |
| 35 | - { | |
| 36 | - if (isDebug) | |
| 37 | - try { | |
| 38 | - Log.w(TAG, msg); | |
| 39 | - } catch (Exception e) { | |
| 40 | - e.printStackTrace(); | |
| 41 | - } | |
| 37 | + public static void i(String tag, String message) { | |
| 38 | + if (isDebug) { | |
| 39 | + Logger LOGGER = getLogger(tag); | |
| 40 | + LOGGER.info(message); | |
| 41 | + } | |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public static void e(String msg) | |
| 45 | - { | |
| 46 | - if (isDebug) | |
| 47 | - try { | |
| 48 | - Log.e(TAG, msg); | |
| 49 | - } catch (Exception e1) { | |
| 50 | - e1.printStackTrace(); | |
| 51 | - } | |
| 44 | + public static void i(String tag, String message, Throwable exception) { | |
| 45 | + if (isDebug) { | |
| 46 | + Logger LOGGER = getLogger(tag); | |
| 47 | + LOGGER.info(message, exception); | |
| 48 | + } | |
| 52 | 49 | } |
| 53 | 50 | |
| 54 | - public static void v(String msg) | |
| 55 | - { | |
| 56 | - if (isDebug) | |
| 57 | - try { | |
| 58 | - Log.v(TAG, msg); | |
| 59 | - } catch (Exception e) { | |
| 60 | - e.printStackTrace(); | |
| 61 | - } | |
| 51 | + public static void w(String tag, String message) { | |
| 52 | + if (isDebug) { | |
| 53 | + Logger LOGGER = getLogger(tag); | |
| 54 | + LOGGER.warn(message); | |
| 55 | + } | |
| 62 | 56 | } |
| 63 | 57 | |
| 64 | - // 下面是传入自定义tag的函数 | |
| 65 | - public static void i(String tag, String msg) | |
| 66 | - { | |
| 67 | - if (isDebug) | |
| 68 | - try { | |
| 69 | - Log.i(tag, msg); | |
| 70 | - } catch (Exception e) { | |
| 71 | - e.printStackTrace(); | |
| 72 | - } | |
| 58 | + public static void w(String tag, String message, Throwable exception) { | |
| 59 | + if (isDebug) { | |
| 60 | + Logger LOGGER = getLogger(tag); | |
| 61 | + LOGGER.warn(message, exception); | |
| 62 | + } | |
| 73 | 63 | } |
| 74 | 64 | |
| 75 | - public static void d(String tag, String msg) | |
| 76 | - { | |
| 77 | - if (isDebug) | |
| 78 | - try { | |
| 79 | - Log.d(tag, msg); | |
| 80 | - } catch (Exception e) { | |
| 81 | - e.printStackTrace(); | |
| 82 | - } | |
| 65 | + public static void e(String tag, String message) { | |
| 66 | + if (isDebug) { | |
| 67 | + Logger LOGGER = getLogger(tag); | |
| 68 | + LOGGER.error(message); | |
| 69 | + } | |
| 83 | 70 | } |
| 84 | 71 | |
| 85 | - public static void w(String tag,String msg) | |
| 86 | - { | |
| 87 | - if (isDebug) | |
| 88 | - try { | |
| 89 | - Log.w(tag, msg); | |
| 90 | - } catch (Exception e) { | |
| 91 | - e.printStackTrace(); | |
| 92 | - } | |
| 72 | + public static void e(String tag, String message, Throwable exception) { | |
| 73 | + if (isDebug) { | |
| 74 | + Logger LOGGER = getLogger(tag); | |
| 75 | + LOGGER.error(message, exception); | |
| 76 | + } | |
| 93 | 77 | } |
| 94 | 78 | |
| 95 | - public static void e(String tag, String msg) | |
| 96 | - { | |
| 97 | - if (isDebug) | |
| 98 | - try { | |
| 99 | - Log.e(tag, msg); | |
| 100 | - } catch (Exception e1) { | |
| 101 | - e1.printStackTrace(); | |
| 102 | - } | |
| 79 | + private static Logger getLogger(String tag) { | |
| 80 | + if (!isConfigured) { | |
| 81 | + ConfigureLog4J configureLog4J = new ConfigureLog4J(); | |
| 82 | + configureLog4J.configure(); | |
| 83 | + isConfigured = true; | |
| 84 | + } | |
| 85 | + Logger logger; | |
| 86 | + if (TextUtils.isEmpty(tag)) { | |
| 87 | + logger = Logger.getRootLogger(); | |
| 88 | + } else { | |
| 89 | + logger = Logger.getLogger(tag); | |
| 90 | + } | |
| 91 | + return logger; | |
| 103 | 92 | } |
| 104 | 93 | |
| 105 | - public static void v(String tag, String msg) | |
| 106 | - { | |
| 107 | - if (isDebug) | |
| 108 | - try { | |
| 109 | - Log.v(tag, msg); | |
| 110 | - } catch (Exception e) { | |
| 111 | - e.printStackTrace(); | |
| 112 | - } | |
| 94 | + public static String getExMsg(Exception e) { | |
| 95 | + e.printStackTrace(); | |
| 96 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |
| 97 | + e.printStackTrace(new PrintStream(baos)); | |
| 98 | + String exception = baos.toString(); | |
| 99 | + return exception; | |
| 100 | + | |
| 113 | 101 | } |
| 102 | + | |
| 114 | 103 | } |
| 115 | 104 | \ No newline at end of file | ... | ... |
src/com/ectrip/cyt/version/DownApkRunnable.java
| ... | ... | @@ -23,7 +23,7 @@ import com.ectrip.cyt.utils.LogUtil; |
| 23 | 23 | * @author jigo app下载类 |
| 24 | 24 | */ |
| 25 | 25 | public class DownApkRunnable implements Runnable { |
| 26 | - | |
| 26 | + public static final String TAG = "DownApkRunnable"; | |
| 27 | 27 | private final int DOWN_NOSDCARD = 0; // 没有内存卡 |
| 28 | 28 | private final int DOWN_UPDATE = 1; // 更新中 |
| 29 | 29 | private final int DOWN_OVER = 2; // 下载完毕 |
| ... | ... | @@ -190,7 +190,7 @@ public class DownApkRunnable implements Runnable { |
| 190 | 190 | int count = 0; |
| 191 | 191 | byte buf[] = new byte[1024]; |
| 192 | 192 | // 总大小 |
| 193 | - LogUtil.d(df.format((float) length / 1024 / 1024) + "MB"); | |
| 193 | + LogUtil.d(TAG,df.format((float) length / 1024 / 1024) + "MB"); | |
| 194 | 194 | do { |
| 195 | 195 | int numread = is.read(buf); |
| 196 | 196 | count += numread; |
| ... | ... | @@ -198,7 +198,7 @@ public class DownApkRunnable implements Runnable { |
| 198 | 198 | String tmpFileSize = df.format((float) count / 1024 / 1024) + "MB"; |
| 199 | 199 | // 当前进度值 |
| 200 | 200 | progress = (int) (((float) count / length) * 100); |
| 201 | - LogUtil.d(numread + "apkFileSize" | |
| 201 | + LogUtil.d(TAG,numread + "apkFileSize" | |
| 202 | 202 | + conn.getContentLength()); |
| 203 | 203 | // 更新进度 |
| 204 | 204 | progressBean.setProgress(progress); | ... | ... |
src/com/ectrip/cyt/zxing/camera/FlashlightManager.java
| ... | ... | @@ -17,9 +17,9 @@ final class FlashlightManager { |
| 17 | 17 | iHardwareService = getHardwareService(); |
| 18 | 18 | setFlashEnabledMethod = getSetFlashEnabledMethod(iHardwareService); |
| 19 | 19 | if (iHardwareService == null) { |
| 20 | - LogUtil.v(TAG, "This device does supports control of a flashlight"); | |
| 20 | + LogUtil.i(TAG, "This device does supports control of a flashlight"); | |
| 21 | 21 | } else { |
| 22 | - LogUtil.v(TAG, "This device does not support control of a flashlight"); | |
| 22 | + LogUtil.i(TAG, "This device does not support control of a flashlight"); | |
| 23 | 23 | } |
| 24 | 24 | } |
| 25 | 25 | ... | ... |
src/com/ectrip/trips/net/DataTool.java
| ... | ... | @@ -12,6 +12,7 @@ import com.ectrip.cyt.utils.LogUtil; |
| 12 | 12 | import com.fourmob.datetimepicker.Utils; |
| 13 | 13 | |
| 14 | 14 | public class DataTool { |
| 15 | + public static final String TAG="DataTool"; | |
| 15 | 16 | /** |
| 16 | 17 | * 通过signkey和data验证数据,验证通过会返回true,未通过返回false |
| 17 | 18 | * 不建议外部调用此方法 |
| ... | ... | @@ -79,13 +80,13 @@ public class DataTool { |
| 79 | 80 | try { |
| 80 | 81 | String signData = signkey + data; |
| 81 | 82 | String base64 = Base64.encode(signData.getBytes("UTF-8")); |
| 82 | - LogUtil.i("responseData:" + base64); | |
| 83 | + LogUtil.i(TAG,"responseData:" + base64); | |
| 83 | 84 | String responseSign = MD5Util.signMD5(base64,"UTF-8"); |
| 84 | - LogUtil.i("responseSign:" + responseSign); | |
| 85 | + LogUtil.i(TAG,"responseSign:" + responseSign); | |
| 85 | 86 | return responseSign; |
| 86 | 87 | } catch (UnsupportedEncodingException e) { |
| 87 | 88 | e.printStackTrace(); |
| 88 | - LogUtil.i("OTA Service : getErrorResponseJson : String to xml UTF-8 Error !"); | |
| 89 | + LogUtil.i(TAG,"OTA Service : getErrorResponseJson : String to xml UTF-8 Error !"); | |
| 89 | 90 | }catch (Exception e){ |
| 90 | 91 | e.printStackTrace(); |
| 91 | 92 | } |
| ... | ... | @@ -103,7 +104,7 @@ public class DataTool { |
| 103 | 104 | } |
| 104 | 105 | /** |
| 105 | 106 | * 给对象 赋 签名, 返回带有签名的完整字符串, 在把对象封装成json字符串时使用此方法 |
| 106 | - * @param datain | |
| 107 | + * @param | |
| 107 | 108 | * @param signkey 标识 |
| 108 | 109 | * @param identity 编码 |
| 109 | 110 | * @return | ... | ... |
src/com/ectrip/trips/net/HttpHelper.java
| ... | ... | @@ -29,7 +29,7 @@ import com.ectrip.cyt.utils.SharedPreferences2Obj; |
| 29 | 29 | * @author jigo 网络访问工具类 |
| 30 | 30 | */ |
| 31 | 31 | public class HttpHelper extends HttpHelperCore { |
| 32 | - | |
| 32 | + public static final String TAG="HttpHelper"; | |
| 33 | 33 | private Context mContext; |
| 34 | 34 | public static HttpHelper helper = null; |
| 35 | 35 | |
| ... | ... | @@ -85,11 +85,11 @@ public class HttpHelper extends HttpHelperCore { |
| 85 | 85 | String requestParam = DataTool.envelopeData(orderRequest, MyApp |
| 86 | 86 | .getInstance().getSignkey(), MyApp.getInstance().getIdentity()); |
| 87 | 87 | map.put("requestParam", requestParam); |
| 88 | - LogUtil.i(requestParam + "requestParam"); | |
| 88 | + LogUtil.i(TAG,requestParam + "requestParam"); | |
| 89 | 89 | executeHttpPost( |
| 90 | 90 | "http://" + MyApp.getInstance().getServiceIp() + action, "", |
| 91 | 91 | map, httpCallback, "data", DataTrans.class); |
| 92 | - LogUtil.i("url = " + "http://" + MyApp.getInstance().getServiceIp() + action); | |
| 92 | + LogUtil.i(TAG,"url = " + "http://" + MyApp.getInstance().getServiceIp() + action); | |
| 93 | 93 | if (testMOdel != null && testMOdel) { // 这个是调试弹框 |
| 94 | 94 | if (type == null) { |
| 95 | 95 | return; |
| ... | ... | @@ -127,7 +127,7 @@ public class HttpHelper extends HttpHelperCore { |
| 127 | 127 | String requestParam = DataTool.envelopeData(consumeCount, MyApp |
| 128 | 128 | .getInstance().getSignkey(), MyApp.getInstance().getIdentity()); |
| 129 | 129 | map.put("requestParam", requestParam); |
| 130 | - LogUtil.i("requestParam" + requestParam); | |
| 130 | + LogUtil.i(TAG,"requestParam" + requestParam); | |
| 131 | 131 | executeHttpPost( |
| 132 | 132 | "http://" + MyApp.getInstance().getServiceIp() + action, "", |
| 133 | 133 | map, httpCallback, "data", DataTrans.class); |
| ... | ... | @@ -167,7 +167,7 @@ public class HttpHelper extends HttpHelperCore { |
| 167 | 167 | String requestParam = DataTool.envelopeData(consumeCount, MyApp |
| 168 | 168 | .getInstance().getSignkey(), MyApp.getInstance().getIdentity()); |
| 169 | 169 | map.put("requestParam", requestParam); |
| 170 | - LogUtil.i("requestParam" + requestParam); | |
| 170 | + LogUtil.i(TAG,"requestParam" + requestParam); | |
| 171 | 171 | executeHttpPost( |
| 172 | 172 | "http://" + MyApp.getInstance().getServiceIp() + action, "", |
| 173 | 173 | map, httpCallback, "data", DataTrans.class); |
| ... | ... | @@ -206,7 +206,7 @@ public class HttpHelper extends HttpHelperCore { |
| 206 | 206 | String requestParam = DataTool.envelopeData(consumeCount, MyApp |
| 207 | 207 | .getInstance().getSignkey(), MyApp.getInstance().getIdentity()); |
| 208 | 208 | map.put("requestParam", requestParam); |
| 209 | - LogUtil.i("requestParam" + requestParam); | |
| 209 | + LogUtil.i(TAG,"requestParam" + requestParam); | |
| 210 | 210 | executeHttpPost( |
| 211 | 211 | "http://" + MyApp.getInstance().getServiceIp() + action, "", |
| 212 | 212 | map, httpCallback, "data", DataTrans.class); |
| ... | ... | @@ -243,7 +243,7 @@ public class HttpHelper extends HttpHelperCore { |
| 243 | 243 | MyApp.getInstance().getSignkey(), MyApp.getInstance() |
| 244 | 244 | .getIdentity()); |
| 245 | 245 | map.put("requestParam", requestParam); |
| 246 | - LogUtil.i("requestParam" + requestParam); | |
| 246 | + LogUtil.i(TAG,"requestParam" + requestParam); | |
| 247 | 247 | executeHttpPost( |
| 248 | 248 | "http://" + MyApp.getInstance().getServiceIp() + action, "", |
| 249 | 249 | map, httpCallback, "data", DataTrans.class); |
| ... | ... | @@ -288,7 +288,7 @@ public class HttpHelper extends HttpHelperCore { |
| 288 | 288 | MyApp.getInstance().getSignkey(), MyApp.getInstance() |
| 289 | 289 | .getIdentity()); |
| 290 | 290 | map.put("requestParam", requestParam); |
| 291 | - LogUtil.i("requestParam" + requestParam); | |
| 291 | + LogUtil.i(TAG,"requestParam" + requestParam); | |
| 292 | 292 | executeHttpPost( |
| 293 | 293 | "http://" + MyApp.getInstance().getServiceIp() + action, "", |
| 294 | 294 | map, httpCallback, "data", DataTrans.class); |
| ... | ... | @@ -330,7 +330,7 @@ public class HttpHelper extends HttpHelperCore { |
| 330 | 330 | String requestParam = DataTool.envelopeData(detectVersionRequest, |
| 331 | 331 | signkey, identity); |
| 332 | 332 | map.put("requestParam", requestParam); |
| 333 | - LogUtil.i("requestParam" + requestParam); | |
| 333 | + LogUtil.i(TAG,"requestParam" + requestParam); | |
| 334 | 334 | executeHttpPost("http://" + url + action, "", map, httpCallback, |
| 335 | 335 | "data", DataTrans.class); |
| 336 | 336 | } |
| ... | ... | @@ -358,7 +358,7 @@ public class HttpHelper extends HttpHelperCore { |
| 358 | 358 | MyApp.getInstance().getSignkey(), MyApp.getInstance() |
| 359 | 359 | .getIdentity()); |
| 360 | 360 | map.put("requestParam", requestParam); |
| 361 | - LogUtil.i("requestParam" + requestParam); | |
| 361 | + LogUtil.i(TAG,"requestParam" + requestParam); | |
| 362 | 362 | executeHttpPost( |
| 363 | 363 | "http://" + MyApp.getInstance().getServiceIp() + action, "", |
| 364 | 364 | map, httpCallback, "data", DataTrans.class); | ... | ... |
src/com/ectrip/trips/net/HttpPostRunnable.java
| ... | ... | @@ -233,24 +233,24 @@ public class HttpPostRunnable<T> implements Runnable { |
| 233 | 233 | try { |
| 234 | 234 | // 获取服务器返回码 |
| 235 | 235 | if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) { |
| 236 | - LogUtil.v(TAG, "服务器成功返回网页"); | |
| 236 | + LogUtil.i(TAG, "服务器成功返回网页"); | |
| 237 | 237 | bufReader = new BufferedReader(new InputStreamReader( |
| 238 | 238 | connection.getInputStream(), "UTF-8")); |
| 239 | 239 | while ((line = bufReader.readLine()) != null) { |
| 240 | 240 | result.append(line); |
| 241 | 241 | } |
| 242 | - LogUtil.v(TAG, "返回数据:" + result.toString()); | |
| 242 | + LogUtil.i(TAG, "返回数据:" + result.toString()); | |
| 243 | 243 | } else if (connection.getResponseCode() == 400) { |
| 244 | - LogUtil.v(TAG, "服务器不理解请求的语法"); | |
| 244 | + LogUtil.i(TAG, "服务器不理解请求的语法"); | |
| 245 | 245 | return "CODE-"+"400错误!"; |
| 246 | 246 | } else if (connection.getResponseCode() == 404) { |
| 247 | - LogUtil.v(TAG, "服务器找不到请求的网页"); | |
| 247 | + LogUtil.i(TAG, "服务器找不到请求的网页"); | |
| 248 | 248 | return "CODE-"+"404错误!"; |
| 249 | 249 | } else if (connection.getResponseCode() == 500) { |
| 250 | - LogUtil.v(TAG, "服务端升级或者服务端程序有问题:500"); | |
| 250 | + LogUtil.i(TAG, "服务端升级或者服务端程序有问题:500"); | |
| 251 | 251 | return "CODE-"+"500错误!"; |
| 252 | 252 | } else { |
| 253 | - LogUtil.v(TAG, "响应失败" + connection.getResponseCode()); | |
| 253 | + LogUtil.i(TAG, "响应失败" + connection.getResponseCode()); | |
| 254 | 254 | return "CODE-"+"响应失败" + connection.getResponseCode(); |
| 255 | 255 | } |
| 256 | 256 | } catch (IOException e) { | ... | ... |