MaintainPrinter2.java 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. package com.epson.mobilephone.common.maintain2;
  2. import android.content.Context;
  3. import com.epson.mobilephone.common.EpLog;
  4. import com.epson.mobilephone.common.escpr.EscprLib;
  5. import java.util.EnumMap;
  6. public class MaintainPrinter2 {
  7. public static final int STATUS_BUSY = 2;
  8. public static final int STATUS_CANCELLING = 3;
  9. public static final int STATUS_ERROR = 4;
  10. public static final int STATUS_IDEL = 0;
  11. public static final int STATUS_PRINTING = 1;
  12. private static Object lockObj = new Object();
  13. private static final MaintainPrinter2 maintainPrinter_INSTANCE = new MaintainPrinter2();
  14. protected EscprLib mEscpLib = EscprLib.getInstance();
  15. protected MaintainPrinterInfo2 mPrinterInfor = new MaintainPrinterInfo2();
  16. protected int mSearchPos = 0;
  17. private MaintainPrinter2() {
  18. }
  19. public static MaintainPrinter2 getInstance() {
  20. return maintainPrinter_INSTANCE;
  21. }
  22. public void setMSearchPos(int i) {
  23. mSearchPos = i;
  24. }
  25. public EscprLib getMEscpLib() {
  26. return mEscpLib;
  27. }
  28. public MaintainPrinterInfo2 getMPrinterInfor() {
  29. return mPrinterInfor;
  30. }
  31. public int getMSearchPos() {
  32. return mSearchPos;
  33. }
  34. public int doInitDriver(Context context, int i) {
  35. EpLog.m78i("MaintainPrinter2", " @@@@@@@ doInitDriver @");
  36. EpLog.m77i(mEscpLib.is64bit() ? "Native is operating at ☆ 64 bit !!" : "Native is operating at 32 bit");
  37. return mEscpLib.epsWrapperInitDriver(context, i);
  38. }
  39. public int doReleaseDriver() {
  40. EpLog.m78i("MaintainPrinter2", " xxxxxxx doReleaseDriver x");
  41. return mEscpLib.release_driver();
  42. }
  43. public int doFindPrinter(int i, int i2) {
  44. int doFindPrinter;
  45. synchronized (lockObj) {
  46. EpLog.m78i("MaintainPrinter2", "**********Call do find printer************");
  47. mEscpLib.setSearchStt(true);
  48. mEscpLib.resetIPAdressCheck();
  49. EpLog.m78i("MaintainPrinter2", "findType = " + i);
  50. doFindPrinter = mEscpLib.doFindPrinter(i, i2);
  51. EpLog.m78i("MaintainPrinter2", "**********Finish do find printer************");
  52. }
  53. return doFindPrinter;
  54. }
  55. public int doGetLang() {
  56. return mEscpLib.get_lang();
  57. }
  58. public String doGetIp() {
  59. return mEscpLib.epsWrapperGetIp();
  60. }
  61. public String doGetId() {
  62. return mEscpLib.epsWrapperGetId();
  63. }
  64. public int doCancelFindPrinter() {
  65. mEscpLib.setSearchStt(false);
  66. return mEscpLib.epsWrapperCancelFindPrinter();
  67. }
  68. public int doSetPrinter() {
  69. return mEscpLib.set_printer(mSearchPos);
  70. }
  71. public int doGetStatus() {
  72. int epsWrapperGetStatus;
  73. synchronized (lockObj) {
  74. epsWrapperGetStatus = mEscpLib.epsWrapperGetStatus(mPrinterInfor.getMStatus());
  75. }
  76. return epsWrapperGetStatus;
  77. }
  78. public int doDoMainteCmd(int i) {
  79. int epsWrapperDoMainteCmd;
  80. synchronized (lockObj) {
  81. EpLog.m78i("MaintainPrinter2", "**********doDoMainteCmd************");
  82. epsWrapperDoMainteCmd = mEscpLib.epsWrapperDoMainteCmd(i);
  83. }
  84. return epsWrapperDoMainteCmd;
  85. }
  86. public int doGetInkInfo() {
  87. int epsWrapperGetInkInfo2;
  88. synchronized (lockObj) {
  89. epsWrapperGetInkInfo2 = mEscpLib.epsWrapperGetInkInfo2(mPrinterInfor);
  90. }
  91. return epsWrapperGetInkInfo2;
  92. }
  93. public int doProbePrinter(int i, String str, String str2, int i2) {
  94. int epsWrapperProbePrinter2;
  95. synchronized (lockObj) {
  96. EpLog.m78i("MaintainPrinter2", "**********Call doProbePrinter************");
  97. mEscpLib.resetIPAdressCheck();
  98. epsWrapperProbePrinter2 = mEscpLib.epsWrapperProbePrinter2(i, str, str2, i2);
  99. if (epsWrapperProbePrinter2 < 0) {
  100. EpLog.m72e("MaintainPrinter2", "ret=" + epsWrapperProbePrinter2);
  101. }
  102. EpLog.m78i("MaintainPrinter2", "**********Finish doProbePrinter************");
  103. }
  104. return epsWrapperProbePrinter2;
  105. }
  106. private int[] getStatus() {
  107. return getMPrinterInfor().getMStatus();
  108. }
  109. public int[] getMediaInfo(int i, int i2) {
  110. return mEscpLib.epsWrapperGetMediaInfo(i, i2);
  111. }
  112. public int[] getPaperInfo() {
  113. int[] epsWrapperGetPaperInfo;
  114. synchronized (lockObj) {
  115. epsWrapperGetPaperInfo = mEscpLib.epsWrapperGetPaperInfo();
  116. }
  117. return epsWrapperGetPaperInfo;
  118. }
  119. public int getFirmwareInfo(EnumMap<EscprLib.PrinterFirmInfo, String> enumMap) {
  120. int firmwareInfo;
  121. synchronized (lockObj) {
  122. firmwareInfo = mEscpLib.getFirmwareInfo(enumMap);
  123. }
  124. return firmwareInfo;
  125. }
  126. public int getBatteryInfo(BatteryInfo batteryInfo) {
  127. int batteryInfo2;
  128. synchronized (lockObj) {
  129. batteryInfo2 = mEscpLib.getBatteryInfo(batteryInfo);
  130. }
  131. return batteryInfo2;
  132. }
  133. public int getBatteryInfo(BatteryInfoEx batteryInfoEx) {
  134. int batteryInfoEx2;
  135. synchronized (lockObj) {
  136. batteryInfoEx2 = mEscpLib.getBatteryInfoEx(batteryInfoEx);
  137. }
  138. return batteryInfoEx2;
  139. }
  140. public int[] getMaintenanceBoxInformation() {
  141. int[] epsWrapperGetMaintenanceBoxInformation;
  142. synchronized (lockObj) {
  143. epsWrapperGetMaintenanceBoxInformation = mEscpLib.epsWrapperGetMaintenanceBoxInformation();
  144. }
  145. return epsWrapperGetMaintenanceBoxInformation;
  146. }
  147. public int getEmaStatus(int[] iArr) {
  148. int epsWrapperGetEmaStatus;
  149. synchronized (lockObj) {
  150. epsWrapperGetEmaStatus = mEscpLib.epsWrapperGetEmaStatus(iArr);
  151. }
  152. return epsWrapperGetEmaStatus;
  153. }
  154. public int setEmaStatus(int i) {
  155. int epsWrapperSetEmaStatus;
  156. synchronized (lockObj) {
  157. epsWrapperSetEmaStatus = mEscpLib.epsWrapperSetEmaStatus(i);
  158. }
  159. return epsWrapperSetEmaStatus;
  160. }
  161. }