541 changed files with 38894 additions and 33 deletions
-
5.idea/compiler.xml
-
4.idea/gradle.xml
-
19app/build.gradle
-
4app/src/main/assets/apps/__UNI__2B9497D/www/app-config-service.js
-
2app/src/main/assets/apps/__UNI__2B9497D/www/app-service.js
-
2app/src/main/assets/apps/__UNI__2B9497D/www/app-view.js
-
2app/src/main/assets/apps/__UNI__2B9497D/www/manifest.json
-
1app/src/main/assets/apps/__UNI__2B9497D/www/pages/index/scan.js
-
2app/src/main/assets/apps/__UNI__2B9497D/www/pages/sample/ext-component.js
-
2app/src/main/assets/apps/__UNI__2B9497D/www/pages/sample/ext-module.js
-
2app/src/main/assets/apps/__UNI__2B9497D/www/view.css
-
4app/src/main/assets/apps/__UNI__2B9497D/www/view.umd.min.js
-
1app/src/main/assets/apps/__UNI__2B9497D/www0/__uniappchooselocation.js
-
BINapp/src/main/assets/apps/__UNI__2B9497D/www0/__uniapperror.png
-
1app/src/main/assets/apps/__UNI__2B9497D/www0/__uniappes6.js
-
1app/src/main/assets/apps/__UNI__2B9497D/www0/__uniappopenlocation.js
-
1app/src/main/assets/apps/__UNI__2B9497D/www0/__uniapppicker.js
-
8app/src/main/assets/apps/__UNI__2B9497D/www0/__uniappquill.js
-
1app/src/main/assets/apps/__UNI__2B9497D/www0/__uniappquillimageresize.js
-
1app/src/main/assets/apps/__UNI__2B9497D/www0/__uniappscan.js
-
BINapp/src/main/assets/apps/__UNI__2B9497D/www0/__uniappsuccess.png
-
25app/src/main/assets/apps/__UNI__2B9497D/www0/__uniappview.html
-
8app/src/main/assets/apps/__UNI__2B9497D/www0/app-config-service.js
-
1app/src/main/assets/apps/__UNI__2B9497D/www0/app-config.js
-
1app/src/main/assets/apps/__UNI__2B9497D/www0/app-service.js
-
1app/src/main/assets/apps/__UNI__2B9497D/www0/app-view.js
-
1app/src/main/assets/apps/__UNI__2B9497D/www0/manifest.json
-
1app/src/main/assets/apps/__UNI__2B9497D/www0/pages/sample/ext-component.js
-
1app/src/main/assets/apps/__UNI__2B9497D/www0/pages/sample/ext-module.js
-
BINapp/src/main/assets/apps/__UNI__2B9497D/www0/static/logo.png
-
169app/src/main/assets/apps/__UNI__2B9497D/www0/static/new_file.json
-
1app/src/main/assets/apps/__UNI__2B9497D/www0/view.css
-
6app/src/main/assets/apps/__UNI__2B9497D/www0/view.umd.min.js
-
10app/src/main/assets/dcloud_uniplugins.json
-
1face_module/.gitignore
-
71face_module/build.gradle
-
0face_module/consumer-rules.pro
-
BINface_module/libs/FaceSDK-6.0.jar
-
BINface_module/libs/arm64-v8a/libaikl_calc_arm.so
-
BINface_module/libs/arm64-v8a/libaikl_cluster_arm.so
-
BINface_module/libs/arm64-v8a/libbd_unifylicense.so
-
BINface_module/libs/arm64-v8a/libbdface_sdk.so
-
BINface_module/libs/arm64-v8a/libc++_shared.so
-
BINface_module/libs/arm64-v8a/libliantian.so
-
BINface_module/libs/arm64-v8a/libpaddle_light_api_shared.so
-
BINface_module/libs/armeabi-v7a/libaikl_calc_arm.so
-
BINface_module/libs/armeabi-v7a/libaikl_cluster_arm.so
-
BINface_module/libs/armeabi-v7a/libbd_unifylicense.so
-
BINface_module/libs/armeabi-v7a/libbdface_sdk.so
-
BINface_module/libs/armeabi-v7a/libc++_shared.so
-
BINface_module/libs/armeabi-v7a/libliantian.so
-
BINface_module/libs/armeabi-v7a/libpaddle_light_api_shared.so
-
BINface_module/libs/bd_unifylicense.jar
-
BINface_module/libs/liantian.jar
-
BINface_module/libs/orbbec_module-debug.aar
-
21face_module/proguard-rules.pro
-
26face_module/src/androidTest/java/com/appdev/face_module/ExampleInstrumentedTest.java
-
7face_module/src/main/AndroidManifest.xml
-
29face_module/src/main/java/com/appdev/face_module/FaceAppProxy.java
-
352face_module/src/main/java/com/appdev/face_module/MyManager.java
-
65face_module/src/main/java/com/appdev/face_module/faceClass.java
-
17face_module/src/test/java/com/appdev/face_module/ExampleUnitTest.java
-
1face_module_2/.gitignore
-
62face_module_2/build.gradle
-
0face_module_2/consumer-rules.pro
-
23face_module_2/proguard-rules.pro
-
26face_module_2/src/androidTest/java/io/dcloud/zmt_module/ExampleInstrumentedTest.java
-
5face_module_2/src/main/AndroidManifest.xml
-
43face_module_2/src/main/java/io/dcloud/zmt_module/MyThread.java
-
8face_module_2/src/main/java/io/dcloud/zmt_module/SocketConfig.java
-
53face_module_2/src/main/java/io/dcloud/zmt_module/SocketHelper.java
-
193face_module_2/src/main/java/io/dcloud/zmt_module/TcpServer.java
-
189face_module_2/src/main/java/io/dcloud/zmt_module/Zmt_AppProxy.java
-
49face_module_2/src/main/java/io/dcloud/zmt_module/mqtt/MQTTRequest.java
-
402face_module_2/src/main/java/io/dcloud/zmt_module/mqtt/MQTTSample.java
-
92face_module_2/src/main/java/io/dcloud/zmt_module/zmtClass.java
-
17face_module_2/src/test/java/io/dcloud/zmt_module/ExampleUnitTest.java
-
3facelibrary/.gitignore
-
52facelibrary/build.gradle
-
1facelibrary/gradle.properties
-
BINfacelibrary/libs/FaceSDK-6.0.jar
-
BINfacelibrary/libs/arm64-v8a/libaikl_calc_arm.so
-
BINfacelibrary/libs/arm64-v8a/libaikl_cluster_arm.so
-
BINfacelibrary/libs/arm64-v8a/libbd_unifylicense.so
-
BINfacelibrary/libs/arm64-v8a/libbdface_sdk.so
-
BINfacelibrary/libs/arm64-v8a/libc++_shared.so
-
BINfacelibrary/libs/arm64-v8a/libliantian.so
-
BINfacelibrary/libs/arm64-v8a/libpaddle_light_api_shared.so
-
BINfacelibrary/libs/armeabi-v7a/libaikl_calc_arm.so
-
BINfacelibrary/libs/armeabi-v7a/libaikl_cluster_arm.so
-
BINfacelibrary/libs/armeabi-v7a/libbd_unifylicense.so
-
BINfacelibrary/libs/armeabi-v7a/libbdface_sdk.so
-
BINfacelibrary/libs/armeabi-v7a/libc++_shared.so
-
BINfacelibrary/libs/armeabi-v7a/libliantian.so
-
BINfacelibrary/libs/armeabi-v7a/libpaddle_light_api_shared.so
-
BINfacelibrary/libs/bd_unifylicense.jar
-
BINfacelibrary/libs/liantian.jar
-
BINfacelibrary/libs/orbbec_module-debug.aar
-
17facelibrary/proguard-rules.pro
-
12facelibrary/src/main/AndroidManifest.xml
@ -1,8 +1,8 @@ |
|||||
|
|
||||
var isReady=false;var onReadyCallbacks=[]; |
var isReady=false;var onReadyCallbacks=[]; |
||||
var isServiceReady=false;var onServiceReadyCallbacks=[]; |
var isServiceReady=false;var onServiceReadyCallbacks=[]; |
||||
var __uniConfig = {"pages":["pages/index/index","pages/sample/ext-module","pages/sample/ext-component","pages/sample/richAlert"],"window":{"navigationBarTextStyle":"black","navigationBarTitleText":"uni-app","navigationBarBackgroundColor":"#F8F8F8","backgroundColor":"#F8F8F8"},"nvueCompiler":"uni-app","nvueStyleCompiler":"weex","renderer":"auto","splashscreen":{"alwaysShowBeforeRender":true,"autoclose":false},"appname":"unipluginDemo","compilerVersion":"3.2.9","entryPagePath":"pages/index/index","networkTimeout":{"request":60000,"connectSocket":60000,"uploadFile":60000,"downloadFile":60000}}; |
|
||||
var __uniRoutes = [{"path":"/pages/index/index","meta":{"isQuit":true},"window":{"navigationBarTitleText":"uni-app"}},{"path":"/pages/sample/ext-module","meta":{"isNVue":true},"window":{"navigationBarTitleText":"扩展 module"}},{"path":"/pages/sample/ext-component","meta":{"isNVue":true},"window":{"navigationBarTitleText":"扩展 component"}},{"path":"/pages/sample/richAlert","meta":{},"window":{"navigationBarTitleText":"RichAlert"}}]; |
|
||||
|
var __uniConfig = {"pages":["pages/index/index","pages/index/ball_list","pages/index/scan","pages/sample/ext-module","pages/sample/ext-component","pages/sample/richAlert"],"window":{"navigationBarTextStyle":"black","navigationBarTitleText":"uni-app","navigationBarBackgroundColor":"#F8F8F8","backgroundColor":"#F8F8F8"},"nvueCompiler":"uni-app","nvueStyleCompiler":"weex","renderer":"auto","splashscreen":{"alwaysShowBeforeRender":true,"autoclose":false},"appname":"unipluginDemo","compilerVersion":"3.3.11","entryPagePath":"pages/index/index","networkTimeout":{"request":60000,"connectSocket":60000,"uploadFile":60000,"downloadFile":60000}}; |
||||
|
var __uniRoutes = [{"path":"/pages/index/index","meta":{"isQuit":true},"window":{"navigationBarTitleText":"uni-app"}},{"path":"/pages/index/ball_list","meta":{},"window":{"navigationBarTitleText":"uni-app"}},{"path":"/pages/index/scan","meta":{"isNVue":true},"window":{"navigationBarTitleText":"22222"}},{"path":"/pages/sample/ext-module","meta":{"isNVue":true},"window":{"navigationBarTitleText":"扩展 module"}},{"path":"/pages/sample/ext-component","meta":{"isNVue":true},"window":{"navigationBarTitleText":"扩展 component"}},{"path":"/pages/sample/richAlert","meta":{},"window":{"navigationBarTitleText":"RichAlert"}}]; |
||||
__uniConfig.onReady=function(callback){if(__uniConfig.ready){callback()}else{onReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"ready",{get:function(){return isReady},set:function(val){isReady=val;if(!isReady){return}const callbacks=onReadyCallbacks.slice(0);onReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}}); |
__uniConfig.onReady=function(callback){if(__uniConfig.ready){callback()}else{onReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"ready",{get:function(){return isReady},set:function(val){isReady=val;if(!isReady){return}const callbacks=onReadyCallbacks.slice(0);onReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}}); |
||||
__uniConfig.onServiceReady=function(callback){if(__uniConfig.serviceReady){callback()}else{onServiceReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"serviceReady",{get:function(){return isServiceReady},set:function(val){isServiceReady=val;if(!isServiceReady){return}const callbacks=onServiceReadyCallbacks.slice(0);onServiceReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}}); |
__uniConfig.onServiceReady=function(callback){if(__uniConfig.serviceReady){callback()}else{onServiceReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"serviceReady",{get:function(){return isServiceReady},set:function(val){isServiceReady=val;if(!isServiceReady){return}const callbacks=onServiceReadyCallbacks.slice(0);onServiceReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}}); |
||||
service.register("uni-app-config",{create(a,b,c){if(!__uniConfig.viewport){var d=b.weex.config.env.scale,e=b.weex.config.env.deviceWidth,f=Math.ceil(e/d);Object.assign(__uniConfig,{viewport:f,defaultFontSize:Math.round(f/20)})}return{instance:{__uniConfig:__uniConfig,__uniRoutes:__uniRoutes,global:void 0,window:void 0,document:void 0,frames:void 0,self:void 0,location:void 0,navigator:void 0,localStorage:void 0,history:void 0,Caches:void 0,screen:void 0,alert:void 0,confirm:void 0,prompt:void 0,fetch:void 0,XMLHttpRequest:void 0,WebSocket:void 0,webkit:void 0,print:void 0}}}}); |
service.register("uni-app-config",{create(a,b,c){if(!__uniConfig.viewport){var d=b.weex.config.env.scale,e=b.weex.config.env.deviceWidth,f=Math.ceil(e/d);Object.assign(__uniConfig,{viewport:f,defaultFontSize:Math.round(f/20)})}return{instance:{__uniConfig:__uniConfig,__uniRoutes:__uniRoutes,global:void 0,window:void 0,document:void 0,frames:void 0,self:void 0,location:void 0,navigator:void 0,localStorage:void 0,history:void 0,Caches:void 0,screen:void 0,alert:void 0,confirm:void 0,prompt:void 0,fetch:void 0,XMLHttpRequest:void 0,WebSocket:void 0,webkit:void 0,print:void 0}}}}); |
2
app/src/main/assets/apps/__UNI__2B9497D/www/app-service.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
2
app/src/main/assets/apps/__UNI__2B9497D/www/app-view.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1 +1 @@ |
|||||
{"@platforms":["android","iPhone","iPad"],"id":"__UNI__2B9497D","name":"unipluginDemo","version":{"name":"1.0.0","code":"100"},"description":"","launch_path":"__uniappview.html","developer":{"name":"","email":"","url":""},"permissions":{"UniNView":{"description":"UniNView原生渲染"}},"plus":{"useragent":{"value":"uni-app","concatenate":true},"splashscreen":{"target":"id:1","autoclose":true,"waiting":true,"delay":0},"popGesture":"close","launchwebview":{"render":"always","id":"1","kernel":"WKWebview"},"statusbar":{"immersed":"supportedDevice","style":"dark","background":"#F8F8F8"},"usingComponents":true,"nvueCompiler":"uni-app","compilerVersion":3,"allowsInlineMediaPlayback":true,"uni-app":{"compilerVersion":"3.2.9","control":"uni-v3","nvueCompiler":"uni-app","renderer":"auto","nvue":{"flex-direction":"column"},"nvueLaunchMode":"normal"},"launch_path":"__uniappview.html"}} |
|
||||
|
{"@platforms":["android","iPhone","iPad"],"id":"__UNI__2B9497D","name":"unipluginDemo","version":{"name":"1.0.0","code":"100"},"description":"","launch_path":"__uniappview.html","developer":{"name":"","email":"","url":""},"permissions":{"UniNView":{"description":"UniNView原生渲染"}},"plus":{"useragent":{"value":"uni-app","concatenate":true},"splashscreen":{"target":"id:1","autoclose":true,"waiting":true,"delay":0},"popGesture":"close","launchwebview":{"render":"always","id":"1","kernel":"WKWebview"},"statusbar":{"immersed":"supportedDevice","style":"dark","background":"#F8F8F8"},"usingComponents":true,"nvueCompiler":"uni-app","compilerVersion":3,"allowsInlineMediaPlayback":true,"uni-app":{"compilerVersion":"3.3.11","control":"uni-v3","nvueCompiler":"uni-app","renderer":"auto","nvue":{"flex-direction":"column"},"nvueLaunchMode":"normal"},"launch_path":"__uniappview.html"}} |
1
app/src/main/assets/apps/__UNI__2B9497D/www/pages/index/scan.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
2
app/src/main/assets/apps/__UNI__2B9497D/www/pages/sample/ext-component.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
2
app/src/main/assets/apps/__UNI__2B9497D/www/pages/sample/ext-module.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
2
app/src/main/assets/apps/__UNI__2B9497D/www/view.css
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
4
app/src/main/assets/apps/__UNI__2B9497D/www/view.umd.min.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1
app/src/main/assets/apps/__UNI__2B9497D/www0/__uniappchooselocation.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
After Width: 200 | Height: 200 | Size: 5.7 KiB |
1
app/src/main/assets/apps/__UNI__2B9497D/www0/__uniappes6.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1
app/src/main/assets/apps/__UNI__2B9497D/www0/__uniappopenlocation.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1
app/src/main/assets/apps/__UNI__2B9497D/www0/__uniapppicker.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
8
app/src/main/assets/apps/__UNI__2B9497D/www0/__uniappquill.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1
app/src/main/assets/apps/__UNI__2B9497D/www0/__uniappquillimageresize.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1
app/src/main/assets/apps/__UNI__2B9497D/www0/__uniappscan.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
After Width: 165 | Height: 165 | Size: 2.0 KiB |
@ -0,0 +1,25 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="zh-CN"> |
||||
|
|
||||
|
<head> |
||||
|
<meta charset="UTF-8" /> |
||||
|
<script> |
||||
|
var __UniViewStartTime__ = Date.now(); |
||||
|
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || |
||||
|
CSS.supports('top: constant(a)')) |
||||
|
document.write( |
||||
|
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + |
||||
|
(coverSupport ? ', viewport-fit=cover' : '') + '" />') |
||||
|
</script> |
||||
|
<title>View</title> |
||||
|
<link rel="stylesheet" href="view.css" /> |
||||
|
</head> |
||||
|
|
||||
|
<body> |
||||
|
<div id="app"></div> |
||||
|
<script src="__uniappes6.js"></script> |
||||
|
<script src="view.umd.min.js"></script> |
||||
|
<script src="app-view.js"></script> |
||||
|
</body> |
||||
|
|
||||
|
</html> |
@ -0,0 +1,8 @@ |
|||||
|
|
||||
|
var isReady=false;var onReadyCallbacks=[]; |
||||
|
var isServiceReady=false;var onServiceReadyCallbacks=[]; |
||||
|
var __uniConfig = {"pages":["pages/index/index","pages/sample/ext-module","pages/sample/ext-component","pages/sample/richAlert"],"window":{"navigationBarTextStyle":"black","navigationBarTitleText":"uni-app","navigationBarBackgroundColor":"#F8F8F8","backgroundColor":"#F8F8F8"},"nvueCompiler":"uni-app","nvueStyleCompiler":"weex","renderer":"auto","splashscreen":{"alwaysShowBeforeRender":true,"autoclose":false},"appname":"unipluginDemo","compilerVersion":"3.2.9","entryPagePath":"pages/index/index","networkTimeout":{"request":60000,"connectSocket":60000,"uploadFile":60000,"downloadFile":60000}}; |
||||
|
var __uniRoutes = [{"path":"/pages/index/index","meta":{"isQuit":true},"window":{"navigationBarTitleText":"uni-app"}},{"path":"/pages/sample/ext-module","meta":{"isNVue":true},"window":{"navigationBarTitleText":"扩展 module"}},{"path":"/pages/sample/ext-component","meta":{"isNVue":true},"window":{"navigationBarTitleText":"扩展 component"}},{"path":"/pages/sample/richAlert","meta":{},"window":{"navigationBarTitleText":"RichAlert"}}]; |
||||
|
__uniConfig.onReady=function(callback){if(__uniConfig.ready){callback()}else{onReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"ready",{get:function(){return isReady},set:function(val){isReady=val;if(!isReady){return}const callbacks=onReadyCallbacks.slice(0);onReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}}); |
||||
|
__uniConfig.onServiceReady=function(callback){if(__uniConfig.serviceReady){callback()}else{onServiceReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"serviceReady",{get:function(){return isServiceReady},set:function(val){isServiceReady=val;if(!isServiceReady){return}const callbacks=onServiceReadyCallbacks.slice(0);onServiceReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}}); |
||||
|
service.register("uni-app-config",{create(a,b,c){if(!__uniConfig.viewport){var d=b.weex.config.env.scale,e=b.weex.config.env.deviceWidth,f=Math.ceil(e/d);Object.assign(__uniConfig,{viewport:f,defaultFontSize:Math.round(f/20)})}return{instance:{__uniConfig:__uniConfig,__uniRoutes:__uniRoutes,global:void 0,window:void 0,document:void 0,frames:void 0,self:void 0,location:void 0,navigator:void 0,localStorage:void 0,history:void 0,Caches:void 0,screen:void 0,alert:void 0,confirm:void 0,prompt:void 0,fetch:void 0,XMLHttpRequest:void 0,WebSocket:void 0,webkit:void 0,print:void 0}}}}); |
@ -0,0 +1 @@ |
|||||
|
(function(e){function r(r){for(var n,l,i=r[0],p=r[1],a=r[2],c=0,s=[];c<i.length;c++)l=i[c],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&s.push(o[l][0]),o[l]=0;for(n in p)Object.prototype.hasOwnProperty.call(p,n)&&(e[n]=p[n]);f&&f(r);while(s.length)s.shift()();return u.push.apply(u,a||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++){var p=t[i];0!==o[p]&&(n=!1)}n&&(u.splice(r--,1),e=l(l.s=t[0]))}return e}var n={},o={"app-config":0},u=[];function l(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,l),t.l=!0,t.exports}l.m=e,l.c=n,l.d=function(e,r,t){l.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},l.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,r){if(1&r&&(e=l(e)),8&r)return e;if(4&r&&"object"===typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(l.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)l.d(t,n,function(r){return e[r]}.bind(null,n));return t},l.n=function(e){var r=e&&e.__esModule?function(){return e["default"]}:function(){return e};return l.d(r,"a",r),r},l.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},l.p="/";var i=this["webpackJsonp"]=this["webpackJsonp"]||[],p=i.push.bind(i);i.push=r,i=i.slice();for(var a=0;a<i.length;a++)r(i[a]);var f=p;t()})([]); |
1
app/src/main/assets/apps/__UNI__2B9497D/www0/app-service.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1
app/src/main/assets/apps/__UNI__2B9497D/www0/app-view.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1 @@ |
|||||
|
{"@platforms":["android","iPhone","iPad"],"id":"__UNI__2B9497D","name":"unipluginDemo","version":{"name":"1.0.0","code":"100"},"description":"","launch_path":"__uniappview.html","developer":{"name":"","email":"","url":""},"permissions":{"UniNView":{"description":"UniNView原生渲染"}},"plus":{"useragent":{"value":"uni-app","concatenate":true},"splashscreen":{"target":"id:1","autoclose":true,"waiting":true,"delay":0},"popGesture":"close","launchwebview":{"render":"always","id":"1","kernel":"WKWebview"},"statusbar":{"immersed":"supportedDevice","style":"dark","background":"#F8F8F8"},"usingComponents":true,"nvueCompiler":"uni-app","compilerVersion":3,"allowsInlineMediaPlayback":true,"uni-app":{"compilerVersion":"3.2.9","control":"uni-v3","nvueCompiler":"uni-app","renderer":"auto","nvue":{"flex-direction":"column"},"nvueLaunchMode":"normal"},"launch_path":"__uniappview.html"}} |
1
app/src/main/assets/apps/__UNI__2B9497D/www0/pages/sample/ext-component.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1
app/src/main/assets/apps/__UNI__2B9497D/www0/pages/sample/ext-module.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
After Width: 72 | Height: 72 | Size: 3.9 KiB |
@ -0,0 +1,169 @@ |
|||||
|
{ |
||||
|
"id": "__UNI__09EF501", |
||||
|
"name": "掌上喵", |
||||
|
"version": { |
||||
|
"name": "1.4.40", |
||||
|
"code": 1440 |
||||
|
}, |
||||
|
"description": "", |
||||
|
"launch_path": "__uniappview.html", |
||||
|
"developer": { |
||||
|
"name": "", |
||||
|
"email": "", |
||||
|
"url": "" |
||||
|
}, |
||||
|
"permissions": { |
||||
|
"OAuth": { |
||||
|
"description": "OAuth" |
||||
|
}, |
||||
|
"Share": { |
||||
|
"description": "plus.share.*" |
||||
|
}, |
||||
|
"VideoPlayer": { |
||||
|
"description": "VideoPlayer" |
||||
|
}, |
||||
|
"Push": { |
||||
|
"description": "Push" |
||||
|
}, |
||||
|
"UniNView": { |
||||
|
"description": "UniNView" |
||||
|
}, |
||||
|
"Stream": { |
||||
|
"description": "plus.stream.*" |
||||
|
}, |
||||
|
"Confusion": { |
||||
|
"description": "Resource confusion" |
||||
|
}, |
||||
|
"Audio": { |
||||
|
"description": "plus.audio.*" |
||||
|
}, |
||||
|
"Accelerometer": { |
||||
|
"description": "plus.accelerometer.*" |
||||
|
}, |
||||
|
"Barcode": { |
||||
|
"description": "plus.barcode.*" |
||||
|
}, |
||||
|
"Cache": { |
||||
|
"description": "plus.cache.*" |
||||
|
}, |
||||
|
"Camera": { |
||||
|
"description": "plus.camera.*" |
||||
|
}, |
||||
|
"Console": { |
||||
|
"description": "plus.console.*" |
||||
|
}, |
||||
|
"Device": { |
||||
|
"description": "plus.device.*" |
||||
|
}, |
||||
|
"Downloader": { |
||||
|
"description": "plus.downloader.*" |
||||
|
}, |
||||
|
"File": { |
||||
|
"description": "plus.io.*" |
||||
|
}, |
||||
|
"Gallery": { |
||||
|
"description": "plus.gallery.*" |
||||
|
}, |
||||
|
"Geolocation": { |
||||
|
"description": "plus.geolocation.*" |
||||
|
}, |
||||
|
"Invocation": { |
||||
|
"description": "plus.android.*" |
||||
|
}, |
||||
|
"NativeObj": { |
||||
|
"description": "plus.nativeObj.*" |
||||
|
}, |
||||
|
"NativeUI": { |
||||
|
"description": "plus.nativeUI.*" |
||||
|
}, |
||||
|
"Navigator": { |
||||
|
"description": "plus.navigator.*" |
||||
|
}, |
||||
|
"Orientation": { |
||||
|
"description": "plus.orientation.*" |
||||
|
}, |
||||
|
"Proximity": { |
||||
|
"description": "plus.proximity.*" |
||||
|
}, |
||||
|
"Runtime": { |
||||
|
"description": "plus.runtime.*" |
||||
|
}, |
||||
|
"Storage": { |
||||
|
"description": "plus.storage.*" |
||||
|
}, |
||||
|
"Uploader": { |
||||
|
"description": "plus.uploader.*" |
||||
|
}, |
||||
|
"Webview": { |
||||
|
"description": "plus.webview.*" |
||||
|
}, |
||||
|
"XMLHttpRequest": { |
||||
|
"description": "plus.net.*" |
||||
|
}, |
||||
|
"Zip": { |
||||
|
"description": "plus.zip.*" |
||||
|
} |
||||
|
}, |
||||
|
"plus": { |
||||
|
"useragent": { |
||||
|
"value": "uni-app", |
||||
|
"concatenate": true |
||||
|
}, |
||||
|
"splashscreen": { |
||||
|
"target": "id:1", |
||||
|
"autoclose": true, |
||||
|
"waiting": false, |
||||
|
"delay": 0 |
||||
|
}, |
||||
|
"popGesture": "close", |
||||
|
"launchwebview": { |
||||
|
"id": "1", |
||||
|
"kernel": "WKWebview", |
||||
|
"uni-app": "auto" |
||||
|
}, |
||||
|
"statusbar": { |
||||
|
"immersed": "supportedDevice", |
||||
|
"style": "dark", |
||||
|
"background": "#F7F7F7" |
||||
|
}, |
||||
|
"compatible": { |
||||
|
"ignoreVersion": true |
||||
|
}, |
||||
|
"usingComponents": true, |
||||
|
"allowsInlineMediaPlayback": true, |
||||
|
"safearea": { |
||||
|
"background": "#ffffff", |
||||
|
"bottom": { |
||||
|
"offset": "auto" |
||||
|
} |
||||
|
}, |
||||
|
"uni-app": { |
||||
|
"compilerVersion": "2.4.6", |
||||
|
"control": "v8", |
||||
|
"nvueCompiler": "uni-app", |
||||
|
"renderer": "auto", |
||||
|
"nvue": { |
||||
|
"flex-direction": "column" |
||||
|
} |
||||
|
}, |
||||
|
"tabBar": { |
||||
|
"borderStyle": "rgba(0,0,0,0.4)", |
||||
|
"backgroundColor": "#ffffff", |
||||
|
"list": [{ |
||||
|
"pagePath": "pages\/mall\/mall" |
||||
|
}, { |
||||
|
"pagePath": "pages\/navbar\/navbar" |
||||
|
}, { |
||||
|
"pagePath": "pages\/material\/material" |
||||
|
}, { |
||||
|
"pagePath": "pages\/my\/my" |
||||
|
}, { |
||||
|
"pagePath": "pages\/product\/rank" |
||||
|
}], |
||||
|
"selectedColor": "#0062cc", |
||||
|
"height": "50px" |
||||
|
}, |
||||
|
"adid": "129854030308", |
||||
|
"channel": "" |
||||
|
} |
||||
|
} |
1
app/src/main/assets/apps/__UNI__2B9497D/www0/view.css
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
6
app/src/main/assets/apps/__UNI__2B9497D/www0/view.umd.min.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1 @@ |
|||||
|
/build |
@ -0,0 +1,71 @@ |
|||||
|
plugins { |
||||
|
id 'com.android.library' |
||||
|
} |
||||
|
|
||||
|
android { |
||||
|
compileSdkVersion 30 |
||||
|
buildToolsVersion "30.0.2" |
||||
|
|
||||
|
defaultConfig { |
||||
|
minSdkVersion 23 |
||||
|
targetSdkVersion 30 |
||||
|
versionCode 1 |
||||
|
versionName "1.0" |
||||
|
|
||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
||||
|
consumerProguardFiles "consumer-rules.pro" |
||||
|
} |
||||
|
|
||||
|
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' |
||||
|
// testImplementation 'junit:junit:4.+' |
||||
|
// androidTestImplementation 'androidx.test.ext:junit:1.1.1' |
||||
|
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' |
||||
|
|
||||
|
//必须添加的依赖 |
||||
|
// compileOnly 'com.android.support:recyclerview-v7:28.0.0' |
||||
|
// compileOnly 'com.android.support:support-v4:28.0.0' |
||||
|
// compileOnly 'com.android.support:appcompat-v7:28.0.0' |
||||
|
// compileOnly 'com.alibaba:fastjson:1.1.46.android' |
||||
|
// |
||||
|
// compileOnly fileTree(include: ['uniapp-v8-release.aar'], dir: '../app/libs') |
||||
|
|
||||
|
|
||||
|
// compileOnly fileTree(dir: 'libs', include: ['*.jar']) |
||||
|
//noinspection GradleCompatible |
||||
|
compileOnly 'com.android.support:recyclerview-v7:28.0.0' |
||||
|
//noinspection GradleCompatible |
||||
|
compileOnly 'com.android.support:support-v4:28.0.0' |
||||
|
//noinspection GradleCompatible |
||||
|
compileOnly 'com.android.support:appcompat-v7:28.0.0' |
||||
|
compileOnly 'com.alibaba:fastjson:1.1.46.android' |
||||
|
|
||||
|
// compileOnly 'androidx.recyclerview:recyclerview:1.0.0' |
||||
|
// compileOnly 'androidx.legacy:legacy-support-v4:1.0.0' |
||||
|
// compileOnly 'androidx.appcompat:appcompat:1.0.0' |
||||
|
// compileOnly 'com.alibaba:fastjson:1.1.46.android' |
||||
|
|
||||
|
compileOnly fileTree(dir: '../app/libs', include: ['uniapp-v8-release.aar']) |
||||
|
|
||||
|
compileOnly 'com.alibaba:fastjson:1.1.46.android' |
||||
|
|
||||
|
implementation project(path: ':registerlibrary') |
||||
|
implementation project(path: ':facelibrary') |
||||
|
|
||||
|
implementation project(path: ':gatelibrary') |
||||
|
|
||||
|
} |
@ -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 |
@ -0,0 +1,26 @@ |
|||||
|
package com.appdev.face_module; |
||||
|
|
||||
|
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.appdev.face_module.test", appContext.getPackageName()); |
||||
|
} |
||||
|
} |
@ -0,0 +1,7 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||
|
xmlns:tools="http://schemas.android.com/tools" |
||||
|
package="com.appdev.face_module" |
||||
|
tools:overrideLibrary="com.appdev.face_module"> |
||||
|
|
||||
|
</manifest> |
@ -0,0 +1,29 @@ |
|||||
|
package com.appdev.face_module; |
||||
|
|
||||
|
import android.app.Application; |
||||
|
|
||||
|
import com.taobao.weex.common.WXException; |
||||
|
|
||||
|
import io.dcloud.feature.uniapp.UniAppHookProxy; |
||||
|
|
||||
|
public class FaceAppProxy implements UniAppHookProxy { |
||||
|
private MyManager myManager; |
||||
|
private faceClass mfaceClass; |
||||
|
@Override |
||||
|
public void onSubProcessCreate(Application application) { |
||||
|
// myManager.initSDK(application.getApplicationContext(),"S4E6-8LLD-JRAQ-XES41"); |
||||
|
mfaceClass.setContext(application.getApplicationContext()); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onCreate(Application application) { |
||||
|
System.out.println("zmt-face: app onCreate!"+application.getBaseContext() +"--"+application.getApplicationContext()); |
||||
|
try { |
||||
|
mfaceClass.setContext(application.getBaseContext()); |
||||
|
|
||||
|
}catch (Exception e){ |
||||
|
System.out.println("zmt-face: error: "+e); |
||||
|
} |
||||
|
// myManager.initSDK(application.getApplicationContext(),"S4E6-8LLD-JRAQ-XES41"); |
||||
|
} |
||||
|
} |
@ -0,0 +1,352 @@ |
|||||
|
package com.appdev.face_module; |
||||
|
|
||||
|
import android.app.Activity; |
||||
|
import android.content.Context; |
||||
|
import android.os.Looper; |
||||
|
import android.widget.Toast; |
||||
|
|
||||
|
import com.baidu.idl.main.facesdk.FaceAuth; |
||||
|
import com.baidu.idl.main.facesdk.callback.Callback; |
||||
|
import com.baidu.idl.main.facesdk.registerlibrary.user.listener.SdkInitListener; |
||||
|
import com.baidu.idl.main.facesdk.registerlibrary.user.manager.FaceSDKManager; |
||||
|
import com.baidu.idl.main.facesdk.registerlibrary.user.manager.ImportFileManager; |
||||
|
import com.baidu.idl.main.facesdk.registerlibrary.user.manager.UserInfoManager; |
||||
|
import com.baidu.idl.main.facesdk.registerlibrary.user.model.User; |
||||
|
import com.baidu.idl.main.facesdk.utils.FileUtils; |
||||
|
import com.baidu.idl.main.facesdk.utils.GateConfigUtils; |
||||
|
import com.baidu.idl.main.facesdk.utils.NetUtil; |
||||
|
import com.baidu.idl.main.facesdk.utils.ToastUtils; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Timer; |
||||
|
import java.util.TimerTask; |
||||
|
|
||||
|
//import com.baidu.idl.main.facesdk.listener.SdkInitListener; |
||||
|
|
||||
|
public class MyManager { |
||||
|
private FaceAuth faceAuth; |
||||
|
|
||||
|
private List<User> mUserInfoList; |
||||
|
private UserListListener mUserListListener; |
||||
|
|
||||
|
private Context mContext; |
||||
|
|
||||
|
private String TAG = "zmt-face:"; |
||||
|
/** |
||||
|
* 初始化SDK |
||||
|
*/ |
||||
|
public void initSDK(final Context context, final String number){ |
||||
|
mContext = context; |
||||
|
System.out.println(TAG+"initSDK"); |
||||
|
faceAuth = new FaceAuth(); |
||||
|
|
||||
|
System.out.println(TAG+"FaceAuth"); |
||||
|
|
||||
|
// boolean isConfigExit = GateConfigUtils.isConfigExit(); |
||||
|
// boolean isInitConfig = GateConfigUtils.initConfig(); |
||||
|
|
||||
|
// System.out.println(TAG+"是否成功初始化:"+isConfigExit+" "+isInitConfig); |
||||
|
|
||||
|
// if (isInitConfig && isConfigExit) { |
||||
|
// Toast.makeText(context, "初始配置加载成功999999", Toast.LENGTH_SHORT).show(); |
||||
|
// } else { |
||||
|
// Toast.makeText(context, "初始配置失败,将重置文件内容为默认配置", Toast.LENGTH_SHORT).show(); |
||||
|
// GateConfigUtils.modityJson(); |
||||
|
// } |
||||
|
|
||||
|
|
||||
|
initLicense(context,number); |
||||
|
} |
||||
|
public String testFun(){ |
||||
|
return "zmt-testFun"; |
||||
|
} |
||||
|
|
||||
|
public void initLicense(final Context context,final String number) { |
||||
|
|
||||
|
System.out.println(TAG+"初始化成功进行授权"); |
||||
|
FaceSDKManager.getInstance().init(context, new SdkInitListener() { |
||||
|
@Override |
||||
|
public void initStart() { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public void initLicenseSuccess() { |
||||
|
|
||||
|
System.out.println(TAG+"授权成功"); |
||||
|
|
||||
|
TimerTask task = new TimerTask() { |
||||
|
@Override |
||||
|
public void run() { |
||||
|
/** |
||||
|
*要执行的操作 (设备已经激活) |
||||
|
*/ |
||||
|
// startActivity(new Intent(mContext, HomeActivity.class)); |
||||
|
// finish(); |
||||
|
Looper.prepare(); |
||||
|
Toast.makeText(context,"该设备已授权激活。。。"+ "有效期至" + FaceSDKManager.getInstance().getLicenseData(context),Toast.LENGTH_LONG).show(); |
||||
|
initListener(context); |
||||
|
Looper.loop(); |
||||
|
} |
||||
|
}; |
||||
|
Timer timer = new Timer(); |
||||
|
timer.schedule(task, 2000); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void initLicenseFail(int errorCode, String msg) { |
||||
|
System.out.println(TAG+"授权失败:"+errorCode); |
||||
|
TimerTask task = new TimerTask() { |
||||
|
@Override |
||||
|
public void run() { |
||||
|
/** |
||||
|
*要执行的操作 (设备还未激活) |
||||
|
*/ |
||||
|
// startActivity(new Intent(mContext, ActivitionActivity.class)); |
||||
|
// finish(); |
||||
|
|
||||
|
Looper.prepare(); |
||||
|
Toast.makeText(context,"正在授权激活中...",Toast.LENGTH_LONG).show(); |
||||
|
accredit_onTv(number,context); |
||||
|
Looper.loop(); |
||||
|
|
||||
|
} |
||||
|
}; |
||||
|
Timer timer = new Timer(); |
||||
|
timer.schedule(task, 2000); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void initModelSuccess() { |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void initModelFail(int errorCode, String msg) { |
||||
|
|
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 监听SDK模型是否加载成功 |
||||
|
*/ |
||||
|
|
||||
|
public void initListener(final Context context) { |
||||
|
if (com.baidu.idl.main.facesdk.manager.FaceSDKManager.initStatus != com.baidu.idl.main.facesdk.manager.FaceSDKManager.SDK_MODEL_LOAD_SUCCESS) { |
||||
|
com.baidu.idl.main.facesdk.manager.FaceSDKManager.getInstance().initModel(context, new com.baidu.idl.main.facesdk.listener.SdkInitListener() { |
||||
|
@Override |
||||
|
public void initStart() { |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void initLicenseSuccess() { |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void initLicenseFail(int errorCode, String msg) { |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void initModelSuccess() { |
||||
|
com.baidu.idl.main.facesdk.manager.FaceSDKManager.initModelSuccess = true; |
||||
|
ToastUtils.toast(context, "模型加载成功,欢迎使用"); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void initModelFail(int errorCode, String msg) { |
||||
|
com.baidu.idl.main.facesdk.manager.FaceSDKManager.initModelSuccess = false; |
||||
|
if (errorCode != -12) { |
||||
|
ToastUtils.toast(context, "模型加载失败,请尝试重启应用"); |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 在线激活 |
||||
|
*/ |
||||
|
public void accredit_onTv(String number, final Context context){ |
||||
|
faceAuth = new FaceAuth(); |
||||
|
boolean onNetworkConnected = NetUtil.isNetworkConnected(context); |
||||
|
if (onNetworkConnected) { |
||||
|
faceAuth.initLicenseOnLine(context, number, new Callback() { |
||||
|
@Override |
||||
|
public void onResponse(final int code, final String response) { |
||||
|
if (code == 0) { |
||||
|
Activity activity = (Activity )context; |
||||
|
try { |
||||
|
if (activity instanceof Activity){ |
||||
|
activity.runOnUiThread(new Runnable() { |
||||
|
@Override |
||||
|
public void run() { |
||||
|
Toast.makeText(context,"授权激活成功。。。 "+ "有效期至" + FaceSDKManager.getInstance().getLicenseData(context),Toast.LENGTH_LONG).show(); |
||||
|
initListener(context); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
}catch (Exception e){ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} else { |
||||
|
Activity activity = (Activity )context; |
||||
|
try { |
||||
|
if (activity instanceof Activity){ |
||||
|
activity.runOnUiThread(new Runnable() { |
||||
|
@Override |
||||
|
public void run() { |
||||
|
|
||||
|
if (response.equals("key invalid")) { |
||||
|
Toast.makeText(context,"序列号有误,请重新输入",Toast.LENGTH_LONG).show(); |
||||
|
} else if (response.equals("license has actived on other device")) { |
||||
|
Toast.makeText(context,"激活失败,该序列号已在其它设备激活,请使用其它有效序列号",Toast.LENGTH_LONG).show(); |
||||
|
|
||||
|
} else if (code == 14) { |
||||
|
Toast.makeText(context,"激活失败,该序列号不在有效期范围内",Toast.LENGTH_LONG).show(); |
||||
|
} else if (response.equals("在线激活失败")) { |
||||
|
Toast.makeText(context,"激活失败,该序列号不在有效期范围内",Toast.LENGTH_LONG).show(); |
||||
|
} else if (response.equals("auth expired time")) { |
||||
|
Toast.makeText(context,"激活失败,该序列号不在有效期范围内",Toast.LENGTH_LONG).show(); |
||||
|
} else { |
||||
|
Toast.makeText(context,response,Toast.LENGTH_LONG).show(); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
}catch (Exception e){ |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
}else { |
||||
|
Toast.makeText(context,"激活失败,请保证设备网络通畅",Toast.LENGTH_LONG).show(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
public void importFace(){ |
||||
|
if (!FileUtils.isSdCardAvailable()) { |
||||
|
ToastUtils.toast(mContext, "请插入SD卡"); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
// 开始导入 |
||||
|
// ImportFileManager.getInstance().setIsNeedImport(true);//是否需要导入 |
||||
|
ImportFileManager.getInstance().batchImport(); |
||||
|
} |
||||
|
|
||||
|
public void delFace(final Context context){ |
||||
|
mContext = context; |
||||
|
|
||||
|
FaceSDKManager.getInstance().initDataBases(context); |
||||
|
mUserListListener = new UserListListener(); |
||||
|
// 读取数据库,获取用户信息 |
||||
|
UserInfoManager.getInstance().getUserListInfo(null, mUserListListener); |
||||
|
} |
||||
|
|
||||
|
// 用于返回读取用户的结果 |
||||
|
private class UserListListener extends UserInfoManager.UserInfoListener { |
||||
|
Activity activity = (Activity )mContext; |
||||
|
|
||||
|
// 读取用户列表成功 |
||||
|
@Override |
||||
|
public void userListQuerySuccess(final String userName, final List<User> listUserInfo) { |
||||
|
try { |
||||
|
if (activity instanceof Activity){ |
||||
|
activity.runOnUiThread(new Runnable() { |
||||
|
@Override |
||||
|
public void run() { |
||||
|
|
||||
|
mUserInfoList = listUserInfo; |
||||
|
if (listUserInfo == null || listUserInfo.size() == 0) { |
||||
|
|
||||
|
// 显示无内容判断 |
||||
|
if (userName == null) { |
||||
|
System.out.println( "读取用户列表成功 暂无内容: "+ mUserInfoList.size()); |
||||
|
} else { |
||||
|
System.out.println( "读取用户列表成功 暂无搜索结果: "+ mUserInfoList.size()); |
||||
|
} |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
if (userName == null || userName.length() == 0) { |
||||
|
|
||||
|
} else { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
if (mUserInfoList != null && mUserInfoList.size() != 0) { |
||||
|
System.out.println( "读取用户列表成功 删除: "+ mUserInfoList.size()); |
||||
|
|
||||
|
// 删除数据库全部人脸信息 |
||||
|
for (int i = 0; i < mUserInfoList.size(); i++){ |
||||
|
|
||||
|
if( mUserInfoList.get(i).getUserName().equals("10") ){ |
||||
|
System.out.println( "读取用户列表成功 用户10: "+ mUserInfoList.size()); |
||||
|
|
||||
|
mUserInfoList.get(i).setChecked(true); |
||||
|
UserInfoManager.getInstance().deleteUserListInfo(mUserInfoList, mUserListListener, |
||||
|
mUserInfoList.size()); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
}catch (Exception e){ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
// 读取用户列表失败 |
||||
|
@Override |
||||
|
public void userListQueryFailure(final String message) { |
||||
|
activity.runOnUiThread(new Runnable() { |
||||
|
@Override |
||||
|
public void run() { |
||||
|
System.out.println( "9999读取用户列表失败: "+ mUserInfoList); |
||||
|
if (mContext == null) { |
||||
|
return; |
||||
|
} |
||||
|
ToastUtils.toast(mContext, message); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
// 删除用户列表成功 |
||||
|
@Override |
||||
|
public void userListDeleteSuccess() { |
||||
|
UserInfoManager.getInstance().getUserListInfo(null, mUserListListener); |
||||
|
} |
||||
|
|
||||
|
// 删除用户列表失败 |
||||
|
@Override |
||||
|
public void userListDeleteFailure(final String message) { |
||||
|
activity.runOnUiThread(new Runnable() { |
||||
|
@Override |
||||
|
public void run() { |
||||
|
System.out.println( "9999删除用户列表失败: "+ mUserInfoList); |
||||
|
if (mContext == null) { |
||||
|
return; |
||||
|
} |
||||
|
ToastUtils.toast(mContext, message); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,65 @@ |
|||||
|
package com.appdev.face_module; |
||||
|
|
||||
|
import android.app.Activity; |
||||
|
import android.content.Context; |
||||
|
import android.util.Log; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
|
||||
|
import io.dcloud.feature.uniapp.annotation.UniJSMethod; |
||||
|
import io.dcloud.feature.uniapp.bridge.UniJSCallback; |
||||
|
import io.dcloud.feature.uniapp.common.UniModule; |
||||
|
|
||||
|
public class faceClass extends UniModule { |
||||
|
|
||||
|
String TAG = "zmt-face-"; |
||||
|
private MyManager myManager; |
||||
|
// public static Context mContext; |
||||
|
public Context mContext; |
||||
|
//run ui thread |
||||
|
|
||||
|
|
||||
|
public void setContext(Context context) { |
||||
|
mContext = context; |
||||
|
} |
||||
|
|
||||
|
@UniJSMethod(uiThread = true) |
||||
|
public void faceAsyncFunc(JSONObject options, final UniJSCallback callback) { |
||||
|
Log.e(TAG, "faceAsyncFunc--zmt:"+options+mContext ); |
||||
|
|
||||
|
myManager = new MyManager(); |
||||
|
// myManager.initSDK(mContext,"S4E6-8LLD-JRAQ-XES4"); |
||||
|
// myManager.initSDK(mUniSDKInstance.getContext(),"S4E6-8LLD-JRAQ-XES4"); |
||||
|
try{ |
||||
|
|
||||
|
Log.e(TAG,"test2222:"+mUniSDKInstance.getContext() +" "+this.mContext+" "+ myManager.testFun()); |
||||
|
// if(mUniSDKInstance != null && mUniSDKInstance.getContext() instanceof Activity) { |
||||
|
// mContext = mUniSDKInstance.getContext(); |
||||
|
// } |
||||
|
myManager.initSDK(mUniSDKInstance.getContext(),"S4E6-8LLD-JRAQ-XES4"); |
||||
|
}catch (Exception e){ |
||||
|
System.out.println("666666"+e); |
||||
|
System.out.println("-----666666-----"); |
||||
|
} |
||||
|
|
||||
|
if(callback != null) { |
||||
|
JSONObject data = new JSONObject(); |
||||
|
data.put("code", "faceAsyncFunc- get it"+myManager.testFun()); |
||||
|
callback.invoke(data); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//run JS thread |
||||
|
@UniJSMethod(uiThread = false) |
||||
|
public JSONObject faceSyncFunc(){ |
||||
|
Log.e(TAG, "faceSyncFunc"); |
||||
|
|
||||
|
JSONObject data = new JSONObject(); |
||||
|
data.put("code", "success-faceSyncFunc sync"); |
||||
|
return data; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
package com.appdev.face_module; |
||||
|
|
||||
|
import org.junit.Test; |
||||
|
|
||||
|
import static org.junit.Assert.*; |
||||
|
|
||||
|
/** |
||||
|
* Example local unit test, which will execute on the development machine (host). |
||||
|
* |
||||
|
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> |
||||
|
*/ |
||||
|
public class ExampleUnitTest { |
||||
|
@Test |
||||
|
public void addition_isCorrect() { |
||||
|
assertEquals(4, 2 + 2); |
||||
|
} |
||||
|
} |
@ -0,0 +1 @@ |
|||||
|
/build |
@ -0,0 +1,62 @@ |
|||||
|
plugins { |
||||
|
id 'com.android.library' |
||||
|
} |
||||
|
|
||||
|
android { |
||||
|
compileSdkVersion 29 |
||||
|
|
||||
|
defaultConfig { |
||||
|
minSdkVersion 16 |
||||
|
targetSdkVersion 28 |
||||
|
versionCode 1 |
||||
|
versionName "1.0" |
||||
|
|
||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
||||
|
consumerProguardFiles "consumer-rules.pro" |
||||
|
} |
||||
|
|
||||
|
buildTypes { |
||||
|
release { |
||||
|
minifyEnabled false |
||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//导入aar需要的配置 |
||||
|
repositories { |
||||
|
flatDir { |
||||
|
dirs 'libs' |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
dependencies { |
||||
|
|
||||
|
// implementation 'androidx.appcompat:appcompat:1.1.0' |
||||
|
// implementation 'com.google.android.material:material:1.1.0' |
||||
|
// testImplementation 'junit:junit:4.+' |
||||
|
// androidTestImplementation 'androidx.test.ext:junit:1.1.1' |
||||
|
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' |
||||
|
// |
||||
|
// //必须添加的依赖 |
||||
|
//// compileOnly 'com.android.support:recyclerview-v7:28.0.0' |
||||
|
//// compileOnly 'com.android.support:support-v4:28.0.0' |
||||
|
//// compileOnly 'com.android.support:appcompat-v7:28.0.0' |
||||
|
// compileOnly 'com.alibaba:fastjson:1.1.46.android' |
||||
|
// |
||||
|
// compileOnly fileTree(include: ['uniapp-v8-release.aar'], dir: '../app/libs') |
||||
|
|
||||
|
compileOnly fileTree(dir: 'libs', include: ['*.jar']) |
||||
|
|
||||
|
compileOnly 'androidx.recyclerview:recyclerview:1.0.0' |
||||
|
compileOnly 'androidx.legacy:legacy-support-v4:1.0.0' |
||||
|
compileOnly 'androidx.appcompat:appcompat:1.0.0' |
||||
|
compileOnly 'com.alibaba:fastjson:1.1.46.android' |
||||
|
|
||||
|
compileOnly fileTree(dir: '../app/libs', include: ['uniapp-v8-release.aar']) |
||||
|
|
||||
|
compileOnly 'com.alibaba:fastjson:1.1.46.android' |
||||
|
|
||||
|
implementation 'com.tencent.iot.hub:hub-device-android:3.3.5' |
||||
|
|
||||
|
} |
@ -0,0 +1,23 @@ |
|||||
|
# 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 |
||||
|
|
||||
|
-keep public class * extends io.dcloud.feature.uniapp.common.UniModule{*;} |
@ -0,0 +1,26 @@ |
|||||
|
package io.dcloud.zmt_module; |
||||
|
|
||||
|
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("io.dcloud.zmt_module.test", appContext.getPackageName()); |
||||
|
} |
||||
|
} |
@ -0,0 +1,5 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||
|
package="io.dcloud.zmt_module"> |
||||
|
|
||||
|
</manifest> |
@ -0,0 +1,43 @@ |
|||||
|
package io.dcloud.zmt_module; |
||||
|
|
||||
|
public class MyThread extends Thread { |
||||
|
String TAG = "zmt---"; |
||||
|
public void run(){ |
||||
|
System.out.println("MyThread thread running..."); |
||||
|
|
||||
|
TcpServer server = new TcpServer(); |
||||
|
server.initSocket((Integer.parseInt("16666"))); |
||||
|
|
||||
|
while (true){ |
||||
|
String message = server.receiveMessage(SocketConfig.UTF_8); |
||||
|
System.out.println(TAG+"接收消息:"+message); |
||||
|
|
||||
|
String send_msg = "收到消息了,你说的对!"; |
||||
|
|
||||
|
send_msg = SocketHelper.getMessageByReadLine(send_msg); |
||||
|
server.sendMessage(send_msg,SocketConfig.UTF_8); |
||||
|
try { |
||||
|
Thread.sleep(1000); |
||||
|
} catch (InterruptedException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
// while (true){ |
||||
|
// String message = server.receiveMessage(SocketConfig.UTF_8); |
||||
|
// System.out.println(TAG+"接收消息:"+message); |
||||
|
// |
||||
|
// String send_msg = "101010"; |
||||
|
// |
||||
|
// send_msg = SocketHelper.getMessageByReadLine(send_msg); |
||||
|
// server.sendMessage(send_msg,SocketConfig.UTF_8); |
||||
|
// try { |
||||
|
// Thread.sleep(1000); |
||||
|
// } catch (InterruptedException e) { |
||||
|
// e.printStackTrace(); |
||||
|
// } |
||||
|
// |
||||
|
// } |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
package io.dcloud.zmt_module; |
||||
|
|
||||
|
public class SocketConfig { |
||||
|
|
||||
|
// 设置编码 |
||||
|
public static final String UTF_8 = "UTF-8"; |
||||
|
public static final String GBK = "GBK"; |
||||
|
} |
@ -0,0 +1,53 @@ |
|||||
|
package io.dcloud.zmt_module; |
||||
|
|
||||
|
import java.io.ByteArrayOutputStream; |
||||
|
import java.io.IOException; |
||||
|
import java.io.InputStream; |
||||
|
import java.util.Arrays; |
||||
|
|
||||
|
public class SocketHelper { |
||||
|
public static String getMessageByReadLine(String message) { |
||||
|
message = message + "\n"; |
||||
|
return message; |
||||
|
} |
||||
|
|
||||
|
public static byte[] toByteArray(InputStream in) throws IOException { |
||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream(); |
||||
|
byte[] buffer = new byte[1024 * 4]; |
||||
|
int n = 0; |
||||
|
while ((n = in.read(buffer)) != -1) { |
||||
|
out.write(buffer, 0, n); |
||||
|
} |
||||
|
return out.toByteArray(); |
||||
|
} |
||||
|
|
||||
|
public static byte[] toIntByteArray(InputStream in) throws IOException { |
||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream(); |
||||
|
byte[] buffer = new byte[100]; |
||||
|
|
||||
|
System.out.println("zmt-toIntByteArray--" + buffer[0] + buffer[1] + buffer[2] + buffer[3] + buffer[4] + buffer[5] + " " + Arrays.toString(buffer)); |
||||
|
int n = 0; |
||||
|
while ((n = in.read(buffer)) != -1) { |
||||
|
out.write(buffer, 0, n); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
return out.toByteArray(); |
||||
|
} |
||||
|
|
||||
|
public static String byte2hex(byte[] bytes) { |
||||
|
StringBuilder sb = new StringBuilder(); |
||||
|
String tmp = null; |
||||
|
for (byte b : bytes) { |
||||
|
//将每个字节与0xFF进行与运算,然后转化为10进制,然后借助于Integer再转化为16进制 |
||||
|
tmp = Integer.toHexString(0xFF & b); |
||||
|
if (tmp.length() == 1) { |
||||
|
tmp = "0" + tmp; |
||||
|
} |
||||
|
sb.append(tmp); |
||||
|
|
||||
|
} |
||||
|
return sb.toString(); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,193 @@ |
|||||
|
package io.dcloud.zmt_module; |
||||
|
|
||||
|
import android.content.Context; |
||||
|
import android.net.ConnectivityManager; |
||||
|
import android.net.NetworkInfo; |
||||
|
|
||||
|
import java.io.BufferedInputStream; |
||||
|
import java.io.BufferedReader; |
||||
|
import java.io.IOException; |
||||
|
import java.io.InputStream; |
||||
|
import java.io.InputStreamReader; |
||||
|
import java.io.OutputStream; |
||||
|
import java.io.OutputStreamWriter; |
||||
|
import java.io.PrintStream; |
||||
|
import java.io.PrintWriter; |
||||
|
import java.net.Inet4Address; |
||||
|
import java.net.InetAddress; |
||||
|
import java.net.NetworkInterface; |
||||
|
import java.net.ServerSocket; |
||||
|
import java.net.Socket; |
||||
|
import java.net.SocketException; |
||||
|
import java.nio.charset.Charset; |
||||
|
import java.util.Arrays; |
||||
|
import java.util.Enumeration; |
||||
|
|
||||
|
public class TcpServer { |
||||
|
// 私有变量 |
||||
|
private String TAG = "zmt---"; |
||||
|
private ServerSocket mServerSocket; |
||||
|
// private DatagramSocket mServerSocket; |
||||
|
private Socket mServer; |
||||
|
|
||||
|
private OutputStream mOutStream; |
||||
|
private PrintWriter mPrinter; |
||||
|
|
||||
|
private InputStream mInputStream; |
||||
|
private BufferedInputStream mBufferedInputStream; |
||||
|
private InputStreamReader mInputStreamReader; |
||||
|
private BufferedReader mBufferedReader; |
||||
|
|
||||
|
/** |
||||
|
*使用本机ip 建立socket server |
||||
|
* @param port 端口号:0-65535 |
||||
|
* |
||||
|
*/ |
||||
|
public void initSocket(int port){ |
||||
|
System.out.println(TAG+"initSocket"); |
||||
|
try{ |
||||
|
if (mServerSocket != null) { mServerSocket.close(); mServerSocket = null; } |
||||
|
|
||||
|
if (mServerSocket==null){ |
||||
|
mServerSocket = new ServerSocket(port); |
||||
|
mServerSocket.setReuseAddress(true); |
||||
|
|
||||
|
// mServerSocket.bind(new InetSocketAddress(port)); |
||||
|
InetAddress inetAddress = InetAddress.getLocalHost(); //本机地址 |
||||
|
System.out.println(TAG+"tcp server 建立完成:host name"+inetAddress.getHostName()+"\n ---host address:" + |
||||
|
inetAddress.getHostAddress()+" , address:"+inetAddress.getAddress().toString()+" 端口:"+port+ "----"+getIPAddressForNetwork()); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
// if(mServerSocket==null){ |
||||
|
// //自己IP收信 |
||||
|
//// IPAddress ip = IPAddress.Parse("192.168.1.96"); |
||||
|
// |
||||
|
//// String ip = "192.168.1.96"; |
||||
|
// InetAddress ip = InetAddress.getByName("192.168.1.96"); |
||||
|
// |
||||
|
// mServerSocket = new ServerSocket(port); |
||||
|
// mServerSocket.bind(new IPEndPoint(ip,port)); |
||||
|
// |
||||
|
// Socket mServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); |
||||
|
// m_serverListenSocket.Bind(new IPEndPoint(ip, 10035)); |
||||
|
// m_serverListenSocket.Listen(100); |
||||
|
// } |
||||
|
}catch (IOException e){ |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
private String getIPAddressForNetwork() throws SocketException { |
||||
|
String address = null; |
||||
|
for(Enumeration<NetworkInterface> enum1 = NetworkInterface.getNetworkInterfaces(); enum1.hasMoreElements();){ |
||||
|
NetworkInterface networkInterface = enum1.nextElement(); |
||||
|
for(Enumeration<InetAddress> enum2=networkInterface.getInetAddresses(); enum2.hasMoreElements();){ |
||||
|
InetAddress inetAddress = enum2.nextElement(); |
||||
|
if(!inetAddress.isLoopbackAddress() && inetAddress instanceof Inet4Address){ |
||||
|
address = "type: 手机网络\n本机IP: " + inetAddress.getHostAddress().toString(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return address; |
||||
|
} |
||||
|
|
||||
|
// 接收消息 |
||||
|
public String receiveMessage(String charsetName){ |
||||
|
String receiveData=null; |
||||
|
String readLine=null; |
||||
|
|
||||
|
// if(mServerSocket==null){ |
||||
|
// System.out.println(TAG+"Socket 未启动"); |
||||
|
// return null; |
||||
|
// } |
||||
|
System.out.println(TAG+"tcp server receiveMessage ing..."); |
||||
|
try{ |
||||
|
System.out.println("mServerSocket:"+mServerSocket.toString()); |
||||
|
// 获取输入信息 |
||||
|
// if(mServerSocket==null){ |
||||
|
// System.out.println("mServerSocket 未初始化,无法receiveMessage"); |
||||
|
// return null; |
||||
|
// } |
||||
|
mServer = mServerSocket.accept(); |
||||
|
mInputStream = mServer.getInputStream(); |
||||
|
|
||||
|
byte[] data = SocketHelper.toByteArray(mInputStream); |
||||
|
|
||||
|
// String _rs = new String(data, "gbk"); |
||||
|
|
||||
|
// System.out.println(TAG+"二进制读取结果:"+data+" - "+_rs +" - "+SocketHelper.toIntByteArray(mInputStream) + Arrays.toString(data)) ; |
||||
|
|
||||
|
System.out.println(TAG+SocketHelper.byte2hex(data)); |
||||
|
receiveData = SocketHelper.byte2hex(data); |
||||
|
// 读取输入流 |
||||
|
// charsetName = null; |
||||
|
// if(charsetName!=null&&charsetName!=""){ |
||||
|
// mInputStreamReader = new InputStreamReader(mInputStream, Charset.forName(charsetName)); |
||||
|
// }else{ |
||||
|
// mInputStreamReader = new InputStreamReader(mInputStream); |
||||
|
// } |
||||
|
|
||||
|
// mBufferedReader = new BufferedReader(mInputStreamReader); |
||||
|
// readLine = mBufferedReader.readLine(); |
||||
|
// while (readLine!=null&&readLine!=""){ |
||||
|
// System.out.println(TAG+"读取结果:"+readLine); |
||||
|
// break; |
||||
|
// } |
||||
|
System.out.println(TAG+"接收结束,数据:"+receiveData); |
||||
|
|
||||
|
} catch (IOException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
return receiveData; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
// 发送消息 |
||||
|
public void sendMessage(String message,String charsetName){ |
||||
|
if(mServer != null){ |
||||
|
System.out.println(TAG+"sendMessage ing..."); |
||||
|
|
||||
|
try { |
||||
|
mOutStream = mServer.getOutputStream(); |
||||
|
mPrinter = new PrintWriter(new OutputStreamWriter(mOutStream,Charset.forName(charsetName))); |
||||
|
mPrinter.println(message); |
||||
|
mPrinter.flush(); |
||||
|
|
||||
|
System.out.println(TAG+"发送成功 :"+message); |
||||
|
} catch (IOException e) { |
||||
|
System.out.println(TAG+"tcp server sendMessage err :"+message); |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 关闭连接 |
||||
|
public void close(){ |
||||
|
try { |
||||
|
if (mPrinter!=null){ |
||||
|
mPrinter.close(); |
||||
|
} |
||||
|
if (mOutStream!=null){ |
||||
|
mOutStream.close(); |
||||
|
} |
||||
|
if (mInputStream!=null){ |
||||
|
mInputStream.close(); |
||||
|
} |
||||
|
if (mInputStreamReader!=null){ |
||||
|
mInputStreamReader.close(); |
||||
|
} |
||||
|
if (mBufferedReader!=null){ |
||||
|
mBufferedReader.close(); |
||||
|
} |
||||
|
if (mServer!=null){ |
||||
|
mServer.close(); |
||||
|
} |
||||
|
System.out.println(TAG+"关闭tcp server <------"); |
||||
|
} catch (IOException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,189 @@ |
|||||
|
package io.dcloud.zmt_module; |
||||
|
|
||||
|
import android.app.Application; |
||||
|
import android.content.Context; |
||||
|
import android.content.SharedPreferences; |
||||
|
import android.util.Log; |
||||
|
|
||||
|
import com.tencent.iot.hub.device.android.core.gateway.TXGatewayConnection; |
||||
|
import com.tencent.iot.hub.device.android.core.util.TXLog; |
||||
|
import com.tencent.iot.hub.device.java.core.common.Status; |
||||
|
import com.tencent.iot.hub.device.java.core.mqtt.TXMqttActionCallBack; |
||||
|
|
||||
|
import org.eclipse.paho.client.mqttv3.IMqttToken; |
||||
|
import org.eclipse.paho.client.mqttv3.MqttMessage; |
||||
|
|
||||
|
import java.util.Arrays; |
||||
|
|
||||
|
import io.dcloud.feature.uniapp.UniAppHookProxy; |
||||
|
import io.dcloud.zmt_module.mqtt.MQTTRequest; |
||||
|
import io.dcloud.zmt_module.mqtt.MQTTSample; |
||||
|
|
||||
|
public class Zmt_AppProxy implements UniAppHookProxy { |
||||
|
|
||||
|
String TAG = "zmt proxy"; |
||||
|
|
||||
|
private MQTTSample mMQTTSample; |
||||
|
|
||||
|
|
||||
|
|
||||
|
// Default testing parameters |
||||
|
private String mBrokerURL = null; //传入null,即使用腾讯云物联网通信默认地址 "${ProductId}.iotcloud.tencentdevices.com:8883" https://cloud.tencent.com/document/product/634/32546 |
||||
|
private String mProductID = ""; |
||||
|
private String mDevName = ""; |
||||
|
private String mDevPSK = ""; |
||||
|
private String mSubProductID = ""; // If you wont test gateway, let this to be null |
||||
|
private String mSubDevName = ""; |
||||
|
private String mSubDevPsk = ""; |
||||
|
private String mTestTopic = ""; // productID/DeviceName/TopicName |
||||
|
// private String mDevCertName = "YOUR_DEVICE_NAME_cert.crt"; |
||||
|
// private String mDevKeyName = "YOUR_DEVICE_NAME_private.key"; |
||||
|
// private String mProductKey = BuildConfig.PRODUCT_KEY; // Used for dynamic register |
||||
|
private String mDevCert = ""; // Cert String |
||||
|
private String mDevPriv = ""; // Priv String |
||||
|
|
||||
|
private final static String BROKER_URL = "broker_url"; |
||||
|
private final static String PRODUCT_ID = "product_id"; |
||||
|
private final static String DEVICE_NAME = "dev_name"; |
||||
|
private final static String DEVICE_PSK = "dev_psk"; |
||||
|
private final static String SUB_PRODUCID = "sub_prodid"; |
||||
|
private final static String SUB_DEVNAME = "sub_devname"; |
||||
|
private final static String TEST_TOPIC = "test_topic"; |
||||
|
|
||||
|
private final static String DEVICE_CERT = "dev_cert"; |
||||
|
private final static String DEVICE_PRIV = "dev_priv"; |
||||
|
private final static String PRODUCT_KEY = "product_key"; |
||||
|
private final static String SUB_DEVICE_PSK = "sub_dev_psk"; |
||||
|
|
||||
|
private volatile boolean mIsConnected; |
||||
|
|
||||
|
@Override |
||||
|
public void onCreate(Application application) { |
||||
|
|
||||
|
|
||||
|
Log.e(TAG, "testAsyncFunc--zmt:onCreate"); |
||||
|
//当前uni应用进程回调 仅触发一次 多进程不会触发 |
||||
|
//可通过UniSDKEngine注册UniModule或者UniComponent |
||||
|
|
||||
|
Context mContext = application.getBaseContext(); |
||||
|
|
||||
|
Object mBrokerURL; |
||||
|
// mMqttConnection = new TXGatewayConnection(mContext, mBrokerURL, mProductID, mDevName, mDevPSK,null,null ,mMqttLogFlag, mMqttLogCallBack, mMqttActionCallBack); |
||||
|
// mMqttConnection.connect(options, mqttRequest); |
||||
|
|
||||
|
// SharedPreferences settings = mParent.getSharedPreferences("config", Context.MODE_PRIVATE); |
||||
|
mBrokerURL =null; |
||||
|
mProductID = "BE8N7UZ7OF"; |
||||
|
mDevName = "pad20220105"; |
||||
|
mDevPSK = "7udrYcfTVThbzdMlLT9fHQ=="; |
||||
|
|
||||
|
mSubProductID = ""; |
||||
|
mSubDevName = ""; |
||||
|
mSubDevPsk =""; |
||||
|
mTestTopic = "BE8N7UZ7OF/pad20220105/data"; |
||||
|
mDevCert = ""; |
||||
|
mDevPriv = ""; |
||||
|
|
||||
|
// mMQTTSample = new MQTTSample(mContext, new SelfMqttActionCallBack(), null, mProductID, mDevName, mDevPSK, |
||||
|
// mDevCert, mDevPriv, mSubProductID, mSubDevName, mTestTopic, null, null, true, null); |
||||
|
// mMQTTSample.setSubDevPsk(mSubDevPsk); |
||||
|
// mMQTTSample.connect(); |
||||
|
|
||||
|
|
||||
|
// MyThread mt = new MyThread(); |
||||
|
// mt.run(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onSubProcessCreate(Application application) { |
||||
|
Log.e(TAG, "testAsyncFunc--zmt:onSubProcessCreate"); |
||||
|
//其他子进程初始化回调 可用于初始化需要子进程初始化需要的逻辑 |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 实现TXMqttActionCallBack回调接口 |
||||
|
*/ |
||||
|
private class SelfMqttActionCallBack extends TXMqttActionCallBack { |
||||
|
|
||||
|
@Override |
||||
|
public void onConnectCompleted(Status status, boolean reconnect, Object userContext, String msg, Throwable cause) { |
||||
|
String userContextInfo = ""; |
||||
|
if (userContext instanceof MQTTRequest) { |
||||
|
userContextInfo = userContext.toString(); |
||||
|
} |
||||
|
String logInfo = String.format("我在uni里链接成功了!onConnectCompleted, status[%s], reconnect[%b], userContext[%s], msg[%s]", |
||||
|
status.name(), reconnect, userContextInfo, msg); |
||||
|
// mParent.printLogInfo(TAG, logInfo, mLogInfoText, TXLog.LEVEL_INFO); |
||||
|
|
||||
|
System.out.println(TAG+logInfo); |
||||
|
mIsConnected = true; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onConnectionLost(Throwable cause) { |
||||
|
String logInfo = String.format("onConnectionLost, cause[%s]", cause.toString()); |
||||
|
// mParent.printLogInfo(TAG, logInfo, mLogInfoText, TXLog.LEVEL_INFO); |
||||
|
System.out.println(TAG+logInfo); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onDisconnectCompleted(Status status, Object userContext, String msg, Throwable cause) { |
||||
|
String userContextInfo = ""; |
||||
|
if (userContext instanceof MQTTRequest) { |
||||
|
userContextInfo = userContext.toString(); |
||||
|
} |
||||
|
String logInfo = String.format("onDisconnectCompleted, status[%s], userContext[%s], msg[%s]", status.name(), userContextInfo, msg); |
||||
|
// mParent.printLogInfo(TAG, logInfo, mLogInfoText, TXLog.LEVEL_INFO); |
||||
|
System.out.println(TAG+logInfo); |
||||
|
mIsConnected = false; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onPublishCompleted(Status status, IMqttToken token, Object userContext, String errMsg, Throwable cause) { |
||||
|
String userContextInfo = ""; |
||||
|
if (userContext instanceof MQTTRequest) { |
||||
|
userContextInfo = userContext.toString(); |
||||
|
} |
||||
|
String logInfo = String.format("onPublishCompleted, status[%s], topics[%s], userContext[%s], errMsg[%s]", |
||||
|
status.name(), Arrays.toString(token.getTopics()), userContextInfo, errMsg); |
||||
|
// mParent.printLogInfo(TAG, logInfo, mLogInfoText); |
||||
|
System.out.println(TAG+logInfo); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onSubscribeCompleted(Status status, IMqttToken asyncActionToken, Object userContext, String errMsg, Throwable cause) { |
||||
|
String userContextInfo = ""; |
||||
|
if (userContext instanceof MQTTRequest) { |
||||
|
userContextInfo = userContext.toString(); |
||||
|
} |
||||
|
String logInfo = String.format("onSubscribeCompleted, status[%s], topics[%s], userContext[%s], errMsg[%s]", |
||||
|
status.name(), Arrays.toString(asyncActionToken.getTopics()), userContextInfo, errMsg); |
||||
|
if (Status.ERROR == status) { |
||||
|
// mParent.printLogInfo(TAG, logInfo, mLogInfoText, TXLog.LEVEL_ERROR); |
||||
|
System.out.println(TAG+logInfo); |
||||
|
} else { |
||||
|
// mParent.printLogInfo(TAG, logInfo, mLogInfoText); |
||||
|
System.out.println(TAG+logInfo); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onUnSubscribeCompleted(Status status, IMqttToken asyncActionToken, Object userContext, String errMsg, Throwable cause) { |
||||
|
String userContextInfo = ""; |
||||
|
if (userContext instanceof MQTTRequest) { |
||||
|
userContextInfo = userContext.toString(); |
||||
|
} |
||||
|
String logInfo = String.format("onUnSubscribeCompleted, status[%s], topics[%s], userContext[%s], errMsg[%s]", |
||||
|
status.name(), Arrays.toString(asyncActionToken.getTopics()), userContextInfo, errMsg); |
||||
|
// mParent.printLogInfo(TAG, logInfo, mLogInfoText); |
||||
|
System.out.println(TAG+logInfo); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onMessageReceived(final String topic, final MqttMessage message) { |
||||
|
String logInfo = String.format("receive command, topic[%s], message[%s]", topic, message.toString()); |
||||
|
// mParent.printLogInfo(TAG, logInfo, mLogInfoText); |
||||
|
System.out.println(TAG+logInfo); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,49 @@ |
|||||
|
package io.dcloud.zmt_module.mqtt; |
||||
|
|
||||
|
|
||||
|
public class MQTTRequest { |
||||
|
|
||||
|
private static final String TAG = MQTTRequest.class.getSimpleName(); |
||||
|
|
||||
|
/** |
||||
|
* 请求类型 |
||||
|
*/ |
||||
|
private String requestType = ""; |
||||
|
|
||||
|
/** |
||||
|
* 请求ID |
||||
|
*/ |
||||
|
private int requestId = 0; |
||||
|
|
||||
|
public MQTTRequest() { |
||||
|
} |
||||
|
|
||||
|
public MQTTRequest(String requestType, int requestId) { |
||||
|
this.requestType = requestType; |
||||
|
this.requestId = requestId; |
||||
|
} |
||||
|
|
||||
|
public String getRequestType() { |
||||
|
return requestType; |
||||
|
} |
||||
|
|
||||
|
public void setRequestType(String requestType) { |
||||
|
this.requestType = requestType; |
||||
|
} |
||||
|
|
||||
|
public int getRequestId() { |
||||
|
return requestId; |
||||
|
} |
||||
|
|
||||
|
public void setRequestId(int requestId) { |
||||
|
this.requestId = requestId; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public String toString() { |
||||
|
return "MQTTRequest{" + |
||||
|
"requestType='" + requestType + '\'' + |
||||
|
", requestId=" + requestId + |
||||
|
'}'; |
||||
|
} |
||||
|
} |
@ -0,0 +1,402 @@ |
|||||
|
package io.dcloud.zmt_module.mqtt; |
||||
|
|
||||
|
import android.content.Context; |
||||
|
import android.os.Environment; |
||||
|
import android.util.Log; |
||||
|
|
||||
|
import com.tencent.iot.hub.device.android.core.gateway.TXGatewayConnection; |
||||
|
import com.tencent.iot.hub.device.android.core.util.AsymcSslUtils; |
||||
|
import com.tencent.iot.hub.device.android.core.util.TXLog; |
||||
|
import com.tencent.iot.hub.device.java.core.log.TXMqttLogCallBack; |
||||
|
import com.tencent.iot.hub.device.java.core.mqtt.TXMqttActionCallBack; |
||||
|
import com.tencent.iot.hub.device.java.core.mqtt.TXMqttConstants; |
||||
|
import com.tencent.iot.hub.device.java.core.mqtt.TXOTACallBack; |
||||
|
import com.tencent.iot.hub.device.java.core.mqtt.TXOTAConstansts; |
||||
|
|
||||
|
import org.eclipse.paho.client.mqttv3.DisconnectedBufferOptions; |
||||
|
import org.eclipse.paho.client.mqttv3.MqttConnectOptions; |
||||
|
import org.eclipse.paho.client.mqttv3.MqttMessage; |
||||
|
import org.json.JSONException; |
||||
|
import org.json.JSONObject; |
||||
|
|
||||
|
import java.io.ByteArrayInputStream; |
||||
|
import java.util.Map; |
||||
|
import java.util.concurrent.atomic.AtomicInteger; |
||||
|
|
||||
|
public class MQTTSample { |
||||
|
|
||||
|
private static final String TAG = "TXMQTT"; |
||||
|
// Default Value, should be changed in testing |
||||
|
private String mBrokerURL = null; //传入null,即使用腾讯云物联网通信默认地址 "${ProductId}.iotcloud.tencentdevices.com:8883" https://cloud.tencent.com/document/product/634/32546 |
||||
|
private String mProductID = "PRODUCT-ID"; |
||||
|
private String mDevName = "DEVICE-NAME"; |
||||
|
private String mDevPSK = "DEVICE-SECRET"; |
||||
|
|
||||
|
private String mDevCertName = "DEVICE_CERT-NAME "; |
||||
|
private String mDevKeyName = "DEVICE_KEY-NAME "; |
||||
|
|
||||
|
private String mSubProductID = "SUBDEV_PRODUCT-ID"; |
||||
|
private String mSubDevName = "SUBDEV_DEV-NAME"; |
||||
|
private String mSubDevPsk = "SUBDEV_DEVICE-SECRET"; |
||||
|
private String mTestTopic = "TEST_TOPIC_WITH_SUB_PUB"; |
||||
|
private String mDevCert; |
||||
|
private String mDevPriv; |
||||
|
|
||||
|
private boolean mMqttLogFlag; |
||||
|
private TXMqttLogCallBack mMqttLogCallBack; |
||||
|
|
||||
|
private Context mContext; |
||||
|
private String path2Store = ""; |
||||
|
|
||||
|
private TXMqttActionCallBack mMqttActionCallBack; |
||||
|
|
||||
|
/** |
||||
|
* MQTT连接实例 |
||||
|
*/ |
||||
|
private TXGatewayConnection mMqttConnection; |
||||
|
|
||||
|
/** |
||||
|
* 请求ID |
||||
|
*/ |
||||
|
private static AtomicInteger requestID = new AtomicInteger(0); |
||||
|
|
||||
|
public MQTTSample(Context context, TXMqttLogCallBack logCallBack, TXMqttActionCallBack callBack) { |
||||
|
mContext = context; |
||||
|
mMqttActionCallBack = callBack; |
||||
|
} |
||||
|
|
||||
|
public MQTTSample(Context context, TXMqttActionCallBack callBack, String brokerURL, String productId, |
||||
|
String devName, String devPSK, String subProductID, String subDevName, String testTopic, String devCertName, String devKeyName, |
||||
|
Boolean mqttLogFlag, TXMqttLogCallBack logCallBack) { |
||||
|
mBrokerURL = brokerURL; |
||||
|
mProductID = productId; |
||||
|
mDevName = devName; |
||||
|
mDevPSK = devPSK; |
||||
|
mSubProductID = subProductID; |
||||
|
mSubDevName = subDevName; |
||||
|
mTestTopic = testTopic; |
||||
|
mDevCertName = devCertName; |
||||
|
mDevKeyName = devKeyName; |
||||
|
|
||||
|
mMqttLogFlag = mqttLogFlag; |
||||
|
mMqttLogCallBack = logCallBack; |
||||
|
|
||||
|
mContext = context; |
||||
|
mMqttActionCallBack = callBack; |
||||
|
} |
||||
|
|
||||
|
public MQTTSample(Context context, TXMqttActionCallBack callBack, String brokerURL, String productId, |
||||
|
String devName, String devPsk, String devCert, String devPriv, String subProductID, String subDevName, String testTopic, String devCertName, String devKeyName, |
||||
|
Boolean mqttLogFlag, TXMqttLogCallBack logCallBack) { |
||||
|
mBrokerURL = brokerURL; |
||||
|
mProductID = productId; |
||||
|
mDevName = devName; |
||||
|
mDevPSK = devPsk; |
||||
|
mDevCert = devCert; |
||||
|
mDevPriv = devPriv; |
||||
|
mSubProductID = subProductID; |
||||
|
mSubDevName = subDevName; |
||||
|
mTestTopic = testTopic; |
||||
|
mDevCertName = devCertName; |
||||
|
mDevKeyName = devKeyName; |
||||
|
|
||||
|
mMqttLogFlag = mqttLogFlag; |
||||
|
mMqttLogCallBack = logCallBack; |
||||
|
|
||||
|
mContext = context; |
||||
|
mMqttActionCallBack = callBack; |
||||
|
path2Store = mContext.getCacheDir().getAbsolutePath(); |
||||
|
} |
||||
|
|
||||
|
public MQTTSample(Context context, TXMqttActionCallBack callBack, String brokerURL, String productId, |
||||
|
String devName, String devPsk, String devCert, String devPriv, String subProductID, String subDevName, String subDevPsk, String testTopic, String devCertName, String devKeyName, |
||||
|
Boolean mqttLogFlag, TXMqttLogCallBack logCallBack) { |
||||
|
this(context, callBack, brokerURL, productId, devName, devPsk, devCert, devPriv, subProductID, subDevName, testTopic, devCertName, devKeyName, mqttLogFlag, logCallBack); |
||||
|
mSubDevPsk = subDevPsk; |
||||
|
} |
||||
|
|
||||
|
public void setSubDevPsk(String val) { |
||||
|
mSubDevPsk = val; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public MQTTSample(Context context, TXMqttActionCallBack callBack, String brokerURL, String productId, |
||||
|
String devName, String devPSK, String subProductID, String subDevName, String testTopic) { |
||||
|
mBrokerURL = brokerURL; |
||||
|
mProductID = productId; |
||||
|
mDevName = devName; |
||||
|
mDevPSK = devPSK; |
||||
|
mSubProductID = subProductID; |
||||
|
mSubDevName = subDevName; |
||||
|
mTestTopic = testTopic; |
||||
|
|
||||
|
mContext = context; |
||||
|
mMqttActionCallBack = callBack; |
||||
|
} |
||||
|
|
||||
|
private TXOTACallBack oTACallBack = new TXOTACallBack() { |
||||
|
|
||||
|
@Override |
||||
|
public void onReportFirmwareVersion(int resultCode, String version, String resultMsg) { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public boolean onLastestFirmwareReady(String url, String md5, String version) { |
||||
|
System.out.println("onLastestFirmwareReady url=" + url + " version " + version); |
||||
|
mMqttConnection.gatewayDownSubdevApp(url, path2Store + "/" + md5, md5, version); |
||||
|
return true; // false 自动触发下载升级文件 true 需要手动触发下载升级文件 |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onDownloadProgress(int percent, String version) { |
||||
|
mMqttConnection.gatewaySubdevReportProgress(percent, version); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onDownloadCompleted(String outputFile, String version) { |
||||
|
mMqttConnection.gatewaySubdevReportStart(version); |
||||
|
mMqttConnection.gatewaySubdevReportSuccess(version); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onDownloadFailure(int errCode, String version) { |
||||
|
mMqttConnection.gatewaySubdevReportFail(errCode, "", version); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
/** |
||||
|
* 建立MQTT连接 |
||||
|
*/ |
||||
|
public void connect() { |
||||
|
mMqttConnection = new TXGatewayConnection(mContext, mBrokerURL, mProductID, mDevName, mDevPSK,null,null ,mMqttLogFlag, mMqttLogCallBack, mMqttActionCallBack); |
||||
|
mMqttConnection.setSubDevName(mSubDevName); |
||||
|
mMqttConnection.setSubDevProductKey(mSubDevPsk); |
||||
|
mMqttConnection.setSubProductID(mSubProductID); |
||||
|
MqttConnectOptions options = new MqttConnectOptions(); |
||||
|
options.setConnectionTimeout(8); |
||||
|
options.setKeepAliveInterval(240); |
||||
|
options.setAutomaticReconnect(true); |
||||
|
|
||||
|
if (mDevPriv != null && mDevCert != null && mDevPriv.length() != 0 && mDevCert.length() != 0) { |
||||
|
TXLog.i(TAG, "Using cert stream " + mDevPriv + " " + mDevCert); |
||||
|
options.setSocketFactory(AsymcSslUtils.getSocketFactoryByStream(new ByteArrayInputStream(mDevCert.getBytes()), new ByteArrayInputStream(mDevPriv.getBytes()))); |
||||
|
} else if (mDevPSK != null && mDevPSK.length() != 0){ |
||||
|
TXLog.i(TAG, "Using PSK"); |
||||
|
// options.setSocketFactory(AsymcSslUtils.getSocketFactory()); 如果您使用的是3.3.0及以下版本的 hub-device-android sdk,由于密钥认证默认配置的ssl://的url,请添加此句setSocketFactory配置。 |
||||
|
} else { |
||||
|
TXLog.i(TAG, "Using cert assets file"); |
||||
|
options.setSocketFactory(AsymcSslUtils.getSocketFactoryByAssetsFile(mContext, mDevCertName, mDevKeyName)); |
||||
|
} |
||||
|
|
||||
|
MQTTRequest mqttRequest = new MQTTRequest("connect", requestID.getAndIncrement()); |
||||
|
mMqttConnection.connect(options, mqttRequest); |
||||
|
|
||||
|
DisconnectedBufferOptions bufferOptions = new DisconnectedBufferOptions(); |
||||
|
bufferOptions.setBufferEnabled(true); |
||||
|
bufferOptions.setBufferSize(1024); |
||||
|
bufferOptions.setDeleteOldestMessages(true); |
||||
|
mMqttConnection.setBufferOpts(bufferOptions); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 断开MQTT连接 |
||||
|
*/ |
||||
|
public void disconnect() { |
||||
|
MQTTRequest mqttRequest = new MQTTRequest("disconnect", requestID.getAndIncrement()); |
||||
|
mMqttConnection.disConnect(mqttRequest); |
||||
|
} |
||||
|
|
||||
|
public void setSubdevOnline() { |
||||
|
// set subdev online |
||||
|
mMqttConnection.gatewaySubdevOnline(mSubProductID, mSubDevName); |
||||
|
} |
||||
|
|
||||
|
public void setSubDevOffline() { |
||||
|
mMqttConnection.gatewaySubdevOffline(mSubProductID, mSubDevName); |
||||
|
} |
||||
|
|
||||
|
public void setSubDevBinded() { |
||||
|
mMqttConnection.gatewayBindSubdev(mSubProductID, mSubDevName, mSubDevPsk); |
||||
|
} |
||||
|
|
||||
|
public void setSubDevUnbinded() { |
||||
|
mMqttConnection.gatewayUnbindSubdev(mSubProductID, mSubDevName); |
||||
|
} |
||||
|
|
||||
|
public void checkSubdevRelation() { |
||||
|
mMqttConnection.getGatewaySubdevRealtion(); |
||||
|
} |
||||
|
|
||||
|
public void getRemoteConfig() { |
||||
|
mMqttConnection.getRemoteConfig(); |
||||
|
} |
||||
|
|
||||
|
public void concernRemoteConfig() { |
||||
|
mMqttConnection.concernConfig(); |
||||
|
} |
||||
|
|
||||
|
public void reportSubDevVersion(String version) { |
||||
|
mMqttConnection.gatewaySubdevReportVer(version); |
||||
|
} |
||||
|
|
||||
|
public void subscribeNTPTopic() { |
||||
|
// QOS等级 |
||||
|
int qos = TXMqttConstants.QOS1; |
||||
|
// 用户上下文(请求实例) |
||||
|
MQTTRequest mqttRequest = new MQTTRequest("subscribeNTPTopic", requestID.getAndIncrement()); |
||||
|
mMqttConnection.subscribeNTPTopic(qos, mqttRequest); |
||||
|
} |
||||
|
|
||||
|
public void getNTPService() { |
||||
|
mMqttConnection.getNTPService(); |
||||
|
} |
||||
|
|
||||
|
public void initOTA() { |
||||
|
TXLog.e(TAG, "path2Store " + path2Store); |
||||
|
mMqttConnection.initOTA(path2Store, oTACallBack); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 订阅广播主题 |
||||
|
*/ |
||||
|
public void subscribeBroadCastTopic() { |
||||
|
// 用户上下文(请求实例) |
||||
|
MQTTRequest mqttRequest = new MQTTRequest("subscribeTopic", requestID.getAndIncrement()); |
||||
|
// 订阅广播主题 |
||||
|
mMqttConnection.subscribeBroadcastTopic(TXMqttConstants.QOS1, mqttRequest); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 订阅主题 |
||||
|
* |
||||
|
*/ |
||||
|
public void subscribeTopic() { |
||||
|
// 主题 |
||||
|
String topic = mTestTopic; |
||||
|
// QOS等级 |
||||
|
int qos = TXMqttConstants.QOS1; |
||||
|
// 用户上下文(请求实例) |
||||
|
MQTTRequest mqttRequest = new MQTTRequest("subscribeTopic", requestID.getAndIncrement()); |
||||
|
|
||||
|
Log.d(TAG, "sub topic is " + topic); |
||||
|
|
||||
|
// 订阅主题 |
||||
|
mMqttConnection.subscribe(topic, qos, mqttRequest); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取消订阅主题 |
||||
|
* |
||||
|
*/ |
||||
|
public void unSubscribeTopic() { |
||||
|
// 主题 |
||||
|
String topic = mTestTopic; |
||||
|
// 用户上下文(请求实例) |
||||
|
MQTTRequest mqttRequest = new MQTTRequest("unSubscribeTopic", requestID.getAndIncrement()); |
||||
|
Log.d(TAG, "Start to unSubscribe" + topic); |
||||
|
// 取消订阅主题 |
||||
|
mMqttConnection.unSubscribe(topic, mqttRequest); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 发布主题 |
||||
|
*/ |
||||
|
public void publishTopic(String topicName, Map<String, String> data) { |
||||
|
// 主题 |
||||
|
String topic = mTestTopic; |
||||
|
// MQTT消息 |
||||
|
MqttMessage message = new MqttMessage(); |
||||
|
|
||||
|
JSONObject jsonObject = new JSONObject(); |
||||
|
try { |
||||
|
for (Map.Entry<String, String> entrys : data.entrySet()) { |
||||
|
jsonObject.put(entrys.getKey(), entrys.getValue()); |
||||
|
} |
||||
|
} catch (JSONException e) { |
||||
|
TXLog.e(TAG, e, "pack json data failed!"); |
||||
|
} |
||||
|
message.setQos(TXMqttConstants.QOS1); |
||||
|
message.setPayload(jsonObject.toString().getBytes()); |
||||
|
|
||||
|
// 用户上下文(请求实例) |
||||
|
MQTTRequest mqttRequest = new MQTTRequest("publishTopic", requestID.getAndIncrement()); |
||||
|
|
||||
|
Log.d(TAG, "pub topic " + topic + message); |
||||
|
// 发布主题 |
||||
|
mMqttConnection.publish(topic, message, mqttRequest); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 订阅RRPC主题 |
||||
|
* |
||||
|
*/ |
||||
|
public void subscribeRRPCTopic() { |
||||
|
// 用户上下文(请求实例) |
||||
|
MQTTRequest mqttRequest = new MQTTRequest("subscribeTopic", requestID.getAndIncrement()); |
||||
|
// 订阅主题 |
||||
|
mMqttConnection.subscribeRRPCTopic(TXMqttConstants.QOS0, mqttRequest); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 生成一条日志 |
||||
|
* @param logLevel 日志级别: |
||||
|
* 错误:TXMqttLogConstants.LEVEL_ERROR |
||||
|
* 警告:TXMqttLogConstants.LEVEL_WARN |
||||
|
* 通知:TXMqttLogConstants.LEVEL_INFO |
||||
|
* 调试:TXMqttLogConstants.LEVEL_DEBUG |
||||
|
* @param tag |
||||
|
* @param format |
||||
|
* @param obj |
||||
|
*/ |
||||
|
public void mLog(int logLevel, final String tag,final String format, final Object... obj) { |
||||
|
if (mMqttLogFlag) |
||||
|
mMqttConnection.mLog(logLevel, tag, format, obj); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 发起一次日志上传 |
||||
|
*/ |
||||
|
public void uploadLog() { |
||||
|
mMqttConnection.uploadLog(); |
||||
|
} |
||||
|
|
||||
|
public void checkFirmware() { |
||||
|
|
||||
|
mMqttConnection.initOTA(Environment.getExternalStorageDirectory().getAbsolutePath(), new TXOTACallBack() { |
||||
|
@Override |
||||
|
public void onReportFirmwareVersion(int resultCode, String version, String resultMsg) { |
||||
|
TXLog.e(TAG, "onReportFirmwareVersion:" + resultCode + ", version:" + version + ", resultMsg:" + resultMsg); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public boolean onLastestFirmwareReady(String url, String md5, String version) { |
||||
|
TXLog.e(TAG, "MQTTSample onLastestFirmwareReady"); |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onDownloadProgress(int percent, String version) { |
||||
|
TXLog.e(TAG, "onDownloadProgress:" + percent); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onDownloadCompleted(String outputFile, String version) { |
||||
|
TXLog.e(TAG, "onDownloadCompleted:" + outputFile + ", version:" + version); |
||||
|
|
||||
|
mMqttConnection.reportOTAState(TXOTAConstansts.ReportState.DONE, 0, "OK", version); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onDownloadFailure(int errCode, String version) { |
||||
|
TXLog.e(TAG, "onDownloadFailure:" + errCode); |
||||
|
|
||||
|
mMqttConnection.reportOTAState(TXOTAConstansts.ReportState.FAIL, errCode, "FAIL", version); |
||||
|
} |
||||
|
}); |
||||
|
mMqttConnection.reportCurrentFirmwareVersion("0.0.1"); |
||||
|
} |
||||
|
} |
@ -0,0 +1,92 @@ |
|||||
|
package io.dcloud.zmt_module; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.tencent.iot.hub.device.android.core.gateway.TXGatewayConnection; |
||||
|
|
||||
|
import io.dcloud.feature.uniapp.annotation.UniJSMethod; |
||||
|
import io.dcloud.feature.uniapp.bridge.UniJSCallback; |
||||
|
import io.dcloud.feature.uniapp.common.UniModule; |
||||
|
|
||||
|
import android.util.Log; |
||||
|
|
||||
|
public class zmtClass extends UniModule { |
||||
|
|
||||
|
String TAG = "zmt--22222-"; |
||||
|
|
||||
|
//run ui thread |
||||
|
@UniJSMethod(uiThread = true) |
||||
|
public void testAsyncFunc(JSONObject options, final UniJSCallback callback) { |
||||
|
Log.e(TAG, "testAsync22222Func--zmt:"+options); |
||||
|
|
||||
|
//启动线程 |
||||
|
// MyThread mt = new MyThread(); |
||||
|
// mt.run(); |
||||
|
|
||||
|
if(callback != null) { |
||||
|
JSONObject data = new JSONObject(); |
||||
|
data.put("code", "2222已开启服务,等待接收数据"); |
||||
|
// callback.invoke(data); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
// Android 4.0 之后不能在主线程中请求HTTP请求 |
||||
|
new Thread(new Runnable(){ |
||||
|
@Override |
||||
|
public void run() { |
||||
|
System.out.println("MyThread thread running..."); |
||||
|
|
||||
|
TcpServer server = new TcpServer(); |
||||
|
server.initSocket((Integer.parseInt("16666"))); |
||||
|
|
||||
|
while (true){ |
||||
|
String message = server.receiveMessage(SocketConfig.UTF_8); |
||||
|
System.out.println(TAG+"接收消息:"+message); |
||||
|
|
||||
|
JSONObject data = new JSONObject(); |
||||
|
data.put("code", message); |
||||
|
// callback.invoke(data); |
||||
|
callback.invokeAndKeepAlive(data); |
||||
|
|
||||
|
String send_msg = "1111111111111"; |
||||
|
|
||||
|
send_msg = SocketHelper.getMessageByReadLine(send_msg); |
||||
|
server.sendMessage(send_msg,SocketConfig.UTF_8); |
||||
|
try { |
||||
|
Thread.sleep(1000); |
||||
|
} catch (InterruptedException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
||||
|
}).start(); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
// @UniJSMethod(uiThread = true) |
||||
|
// public void testAsyncFunc(JSONObject options, UniJSCallback callback) { |
||||
|
// Log.e(TAG, "testAsyncFunc--zmt:"+options); |
||||
|
// |
||||
|
// if(callback != null) { |
||||
|
// JSONObject data = new JSONObject(); |
||||
|
// data.put("code", "success-zmt async"); |
||||
|
// callback.invoke(data); |
||||
|
// } |
||||
|
// } |
||||
|
|
||||
|
//run JS thread |
||||
|
@UniJSMethod(uiThread = false) |
||||
|
public JSONObject testSyncFunc(){ |
||||
|
Log.e(TAG, "testSyncFunc--zmt2"); |
||||
|
|
||||
|
|
||||
|
JSONObject data = new JSONObject(); |
||||
|
data.put("code", "success-zmt sync"); |
||||
|
return data; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
package io.dcloud.zmt_module; |
||||
|
|
||||
|
import org.junit.Test; |
||||
|
|
||||
|
import static org.junit.Assert.*; |
||||
|
|
||||
|
/** |
||||
|
* Example local unit test, which will execute on the development machine (host). |
||||
|
* |
||||
|
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> |
||||
|
*/ |
||||
|
public class ExampleUnitTest { |
||||
|
@Test |
||||
|
public void addition_isCorrect() { |
||||
|
assertEquals(4, 2 + 2); |
||||
|
} |
||||
|
} |
@ -0,0 +1,3 @@ |
|||||
|
/build |
||||
|
/src/main/libs/ |
||||
|
/src/main/obj/ |
@ -0,0 +1,52 @@ |
|||||
|
apply plugin: 'com.android.library' |
||||
|
|
||||
|
android { |
||||
|
compileSdkVersion 29 |
||||
|
// buildToolsVersion '26.0.2' |
||||
|
publishNonDefault true |
||||
|
defaultConfig { |
||||
|
minSdkVersion 16 |
||||
|
targetSdkVersion 29 |
||||
|
versionCode 5 |
||||
|
versionName "5.0" |
||||
|
|
||||
|
ndk { |
||||
|
moduleName "facesdk" |
||||
|
ldLibs "log" |
||||
|
abiFilters "armeabi-v7a" |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
sourceSets.main { |
||||
|
jni.srcDirs "src/main/jni" |
||||
|
jniLibs.srcDir "libs" |
||||
|
} |
||||
|
*/ |
||||
|
|
||||
|
sourceSets.main { |
||||
|
jni.srcDirs = [] |
||||
|
jniLibs.srcDir "libs" |
||||
|
} |
||||
|
|
||||
|
buildTypes { |
||||
|
release { |
||||
|
minifyEnabled false |
||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
||||
|
buildConfigField 'boolean', 'USE_AIKL', 'true' |
||||
|
} |
||||
|
debug { |
||||
|
debuggable true |
||||
|
jniDebuggable true |
||||
|
buildConfigField 'boolean', 'USE_AIKL', 'true' |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
dependencies { |
||||
|
compile fileTree(include: ['*.jar'], dir: 'libs') |
||||
|
implementation 'org.jetbrains:annotations-java5:15.0' |
||||
|
compile files('libs/orbbec_module-debug.aar') |
||||
|
implementation files('libs/FaceSDK-6.0.jar') |
||||
|
implementation files('libs/bd_unifylicense.jar') |
||||
|
} |
@ -0,0 +1 @@ |
|||||
|
android.useDeprecatedNdk=true |
@ -0,0 +1,17 @@ |
|||||
|
# Add project specific ProGuard rules here. |
||||
|
# By default, the flags in this file are appended to flags specified |
||||
|
# in /Users/baidu/Documents/android/android_sdk_mac/tools/proguard/proguard-android.txt |
||||
|
# You can edit the include path and order by changing the proguardFiles |
||||
|
# directive in build.gradle. |
||||
|
# |
||||
|
# For more details, see |
||||
|
# http://developer.android.com/guide/developing/tools/proguard.html |
||||
|
|
||||
|
# Add any project specific keep options here: |
||||
|
|
||||
|
# 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 *; |
||||
|
#} |
@ -0,0 +1,12 @@ |
|||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||
|
package="com.baidu.idl.main.facesdk2"> |
||||
|
|
||||
|
<application > |
||||
|
|
||||
|
</application> |
||||
|
|
||||
|
<!-- android:allowBackup="false" |
||||
|
android:label="@string/app_name" |
||||
|
android:supportsRtl="true"--> |
||||
|
|
||||
|
</manifest> |
Some files were not shown because too many files changed in this diff
Write
Preview
Loading…
Cancel
Save
Reference in new issue