@@ -67,4 +67,7 @@ dependencies { |
||
67 | 67 |
compile 'com.google.code.gson:gson:2.7' |
68 | 68 |
compile files('libs/universal-image-loader-1.9.4.jar') |
69 | 69 |
compile files('libs/libammsdk.jar') |
70 |
+ compile files('libs/commons-lang-2.6.jar') |
|
71 |
+ compile files('libs/gprintersdkv2.1.4.jar') |
|
72 |
+ compile files('libs/jcc-bate-0.7.3.jar') |
|
70 | 73 |
} |
@@ -11,7 +11,9 @@ |
||
11 | 11 |
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" /> |
12 | 12 |
<uses-permission android:name="android.permission.CAMERA" /> |
13 | 13 |
<uses-permission android:name="android.permission.FLASHLIGHT" /> |
14 |
- |
|
14 |
+ <uses-permission android:name="android.permission.WAKE_LOCK"/> |
|
15 |
+ <uses-feature android:name="android.hardware.usb.host" /> |
|
16 |
+ <uses-permission android:name="android.hardware.usb.accessory" /> |
|
15 | 17 |
<uses-feature android:name="android.hardware.camera" /> |
16 | 18 |
<uses-feature android:name="android.hardware.camera.autofocus" /> |
17 | 19 |
|
@@ -90,6 +92,18 @@ |
||
90 | 92 |
|
91 | 93 |
<service android:name=".service.OrderDealService"/> |
92 | 94 |
|
95 |
+ <service |
|
96 |
+ android:name="com.gprinter.service.GpPrintService" |
|
97 |
+ android:label="GpPrintService" |
|
98 |
+ android:process=":remote" |
|
99 |
+ android:enabled="true" |
|
100 |
+ android:exported="true" |
|
101 |
+ > |
|
102 |
+ <intent-filter> |
|
103 |
+ <action android:name="com.gprinter.aidl.GpPrintService" /> |
|
104 |
+ </intent-filter> |
|
105 |
+ </service> |
|
106 |
+ |
|
93 | 107 |
</application> |
94 | 108 |
|
95 | 109 |
</manifest> |
@@ -1,6 +1,10 @@ |
||
1 | 1 |
package ai.pai.lensman.session; |
2 | 2 |
|
3 |
+import android.content.ComponentName; |
|
4 |
+import android.content.Context; |
|
3 | 5 |
import android.content.Intent; |
6 |
+import android.os.IBinder; |
|
7 |
+import android.util.Log; |
|
4 | 8 |
|
5 | 9 |
import java.util.ArrayList; |
6 | 10 |
|
@@ -9,6 +13,10 @@ import ai.pai.lensman.bean.PhotoBean; |
||
9 | 13 |
import ai.pai.lensman.bean.SessionBean; |
10 | 14 |
import ai.pai.lensman.db.DBService; |
11 | 15 |
import ai.pai.lensman.service.UploadService; |
16 |
+import android.content.ServiceConnection; |
|
17 |
+import com.gprinter.aidl.GpService; |
|
18 |
+ |
|
19 |
+ |
|
12 | 20 |
|
13 | 21 |
public class SessionPresenter implements SessionContract.Presenter, SessionInteractor.SessionListener { |
14 | 22 |
|
@@ -18,6 +26,11 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
18 | 26 |
private SessionBean sessionBean; |
19 | 27 |
private boolean isWorking; |
20 | 28 |
|
29 |
+ private GpService mGpService = null; |
|
30 |
+ private PrinterServiceConnection conn = null; |
|
31 |
+ |
|
32 |
+ |
|
33 |
+ |
|
21 | 34 |
public SessionPresenter(SessionBean sessionBean, SessionContract.View view) { |
22 | 35 |
this.sessionView = view; |
23 | 36 |
this.sessionBean = sessionBean; |
@@ -36,12 +49,16 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
36 | 49 |
} |
37 | 50 |
} |
38 | 51 |
interactor.startSession(); |
52 |
+ connection(); |
|
39 | 53 |
} |
40 | 54 |
|
41 | 55 |
@Override |
42 | 56 |
public void stop() { |
43 | 57 |
interactor.endSession(); |
44 | 58 |
isWorking = false; |
59 |
+ if (conn != null) { |
|
60 |
+ App.getAppContext().unbindService(conn); |
|
61 |
+ } |
|
45 | 62 |
} |
46 | 63 |
|
47 | 64 |
@Override |
@@ -79,4 +96,23 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
79 | 96 |
DBService.getInstance().deletePhotoBean(photoBean); |
80 | 97 |
interactor.deletePhoto(photoBean); |
81 | 98 |
} |
99 |
+ |
|
100 |
+ private void connection() { |
|
101 |
+ conn = new PrinterServiceConnection(); |
|
102 |
+ Intent intent = new Intent("com.gprinter.aidl.GpPrintService"); |
|
103 |
+ App.getAppContext().bindService(intent, conn, Context.BIND_AUTO_CREATE); |
|
104 |
+ } |
|
105 |
+ |
|
106 |
+ class PrinterServiceConnection implements ServiceConnection { |
|
107 |
+ @Override |
|
108 |
+ public void onServiceDisconnected(ComponentName name) { |
|
109 |
+ Log.i("ServiceConnection", "onServiceDisconnected() called"); |
|
110 |
+ mGpService = null; |
|
111 |
+ } |
|
112 |
+ |
|
113 |
+ @Override |
|
114 |
+ public void onServiceConnected(ComponentName name, IBinder service) { |
|
115 |
+ mGpService = GpService.Stub.asInterface(service); |
|
116 |
+ } |
|
117 |
+ } |
|
82 | 118 |
} |
@@ -0,0 +1,11 @@ |
||
1 |
+package com.gprinter.aidl; |
|
2 |
+interface GpService{ |
|
3 |
+ int openPort(int PrinterId,int PortType,String DeviceName,int PortNumber); |
|
4 |
+ void closePort(int PrinterId); |
|
5 |
+ int getPrinterConnectStatus(int PrinterId); |
|
6 |
+ int printeTestPage(int PrinterId); |
|
7 |
+ int queryPrinterStatus(int PrinterId,int Timesout); |
|
8 |
+ int getPrinterCommandType(int PrinterId); |
|
9 |
+ int sendEscCommand(int PrinterId, String b64); |
|
10 |
+ int sendTscCommand(int PrinterId, String b64); |
|
11 |
+} |