.gitignore
@@ -53,6 +53,7 @@ # Android Studio 3 in .gitignore file. .idea/caches .idea/modules.xml .idea/ # Comment next line if keeping position of elements in Navigation Editor is relevant for you .idea/navEditor.xml @@ -100,4 +101,9 @@ # Replacement of .externalNativeBuild directories introduced # with Android Studio 3.5. # End of https://www.toptal.com/developers/gitignore/api/android # End of https://www.toptal.com/developers/gitignore/api/android .idea/ HDLSDK/.idea/jarRepositories.xml HDLSDK/.idea/misc.xml HDLSDK/.idea/jarRepositories.xml HDLSDK/.idea/misc.xml HDLSDK.zipBinary files differ
HDLSDK/.DS_StoreBinary files differ
HDLSDK/.gitignore
File was deleted HDLSDK/.idea/.gitignore
File was deleted HDLSDK/.idea/gradle.xml
@@ -11,6 +11,7 @@ <set> <option value="$PROJECT_DIR$" /> <option value="$PROJECT_DIR$/app" /> <option value="$PROJECT_DIR$/com.hdl.sdk" /> <option value="$PROJECT_DIR$/hdl-common" /> <option value="$PROJECT_DIR$/hdl-connect" /> <option value="$PROJECT_DIR$/hdl-socket" /> HDLSDK/.idea/jarRepositories.xml
File was deleted HDLSDK/.idea/misc.xml
File was deleted HDLSDK/app/build.gradle
@@ -3,12 +3,12 @@ } android { compileSdk 31 compileSdk 28 defaultConfig { applicationId "com.hdl.hdlsdk1" applicationId "com.hdl.hdlsdk" minSdk 21 targetSdk 31 targetSdk 28 versionCode 1 versionName "1.0" HDLSDK/app/src/androidTest/java/com/hdl/hdlsdk/ExampleInstrumentedTest.java
File was deleted HDLSDK/app/src/main/java/com/hdl/.DS_StoreBinary files differ
HDLSDK/app/src/main/java/com/hdl/hdlsdk/MainActivity.java
@@ -35,6 +35,7 @@ import com.hdl.sdk.connect.bean.LinkRequest; import com.hdl.sdk.connect.bean.LinkResponse; import com.hdl.sdk.connect.bean.request.AuthenticateRequest; import com.hdl.sdk.connect.bean.request.BroadcastRequest; import com.hdl.sdk.connect.bean.request.PropertyReadRequest; import com.hdl.sdk.connect.bean.response.BaseLocalResponse; import com.hdl.sdk.connect.bean.response.GatewaySearchBean; @@ -86,6 +87,7 @@ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); responseTv = findViewById(R.id.response_tv); tv = findViewById(R.id.state_tv); HDLSDK/app/src/test/java/com/hdl/hdlsdk/ExampleUnitTest.java
File was deleted HDLSDK/com.hdl.sdk/.gitignore
New file @@ -0,0 +1 @@ /build HDLSDK/com.hdl.sdk/build.gradle
New file @@ -0,0 +1,154 @@ //打包的 apply plugin: 'com.android.library' apply plugin:'com.kezong.fat-aar' android { compileSdkVersion rootProject.compileSdkVersion defaultConfig { minSdkVersion rootProject.minSdkVersion targetSdkVersion rootProject.targetSdkVersion versionCode 2 versionName "1.0.13" } buildTypes { debug { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility 1.8 targetCompatibility 1.8 } } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') // embed 'com.ezviz.sdk:ezviz-sdk:4.16.1' // embed(name: 'hdl-common-release',ext: 'aar') // embed(name: 'hdl-connect-release',ext: 'aar') // embed(name: 'hdl-socket-release',ext: 'aar') embed project(path: ':hdl-common', configuration:'default') embed project(path: ':hdl-connect', configuration:'default') embed project(path: ':hdl-socket', configuration:'default') } //打包的 buildscript { repositories { google() jcenter() maven {url "https://plugins.gradle.org/m2/"} } dependencies { classpath 'com.android.tools.build:gradle:3.6.3' classpath 'com.kezong:fat-aar:1.2.16' } } //allprojects { // repositories { // flatDir{ // dirs 'libs' // } // google() // jcenter() // } //} ////运行的 // //apply plugin: 'com.android.application' //apply from: "../app-common/build_common.gradle" //apply plugin: 'kotlin-android' //apply plugin: 'kotlin-android-extensions' // ////如果有用到kapt添加如下配置 //kapt { // useBuildCache = true // javacOptions { // option("-Xmaxerrs", 500) // } //} // //android { // // compileSdkVersion 29 // buildToolsVersion "29.0.3" // // sourceSets { // main { // jniLibs.srcDirs = ['libs'] // } // } // lintOptions { // abortOnError false // } // defaultConfig { // applicationId "com.evoyo.home1111112" // minSdkVersion 21 // //noinspection ExpiredTargetSdkVersion // targetSdkVersion 28 // versionCode 4160 // versionName "v4.16.0.20201230" // ndk { // abiFilters "armeabi-v7a", "arm64-v8a" // } // /*禁止使用java8,如果sdk使用了java8编译,但是应用层使用了java7编译,会导致应用层打包无法通过*/ // compileOptions { // sourceCompatibility JavaVersion.VERSION_1_7 // targetCompatibility JavaVersion.VERSION_1_7 // } // } // //在Android代码块中添加如下配置:(可优化最上图中transformClassDexBuilderForDebug的时间) // dexOptions { // preDexLibraries true // maxProcessCount 8 // } // buildTypes { // debug { // minifyEnabled false // proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' // } // } // productFlavors { // } //} // // //dependencies { // /*萤石SDK核心模块,必须*/ //// api project(path: ':ezviz-sdk') // api 'com.ezviz.sdk:ezviz-sdk:4.16.1' // // /*视频通话模块,按需使用*/ //// api project(path: ':videotalk') // api 'com.ezviz.sdk:videotalk:1.2.0' // // /*视频通话模块,按需使用*/ //// api project(path: ':streamctrl') // api 'com.ezviz.sdk:streamctrl:1.2.0' // // /*萤石核心模块的三方依赖*/ //// implementation 'javax.jmdns:jmdns:3.4.1' // implementation 'com.google.code.gson:gson:2.8.0' // api 'com.squareup.okhttp3:okhttp:3.12.1' // // /*demo的依赖项*/ // api project(path: ':app-common') // implementation fileTree(include: ['*.jar'], dir: 'libs') // implementation 'com.android.support.constraint:constraint-layout:1.1.3' //} // ////repositories { //// maven { url 'https://dl.bintray.com/open-ezviz/mobile-sdk'} ////} HDLSDK/com.hdl.sdk/gradlew
New file @@ -0,0 +1,172 @@ #!/usr/bin/env sh ############################################################################## ## ## Gradle start up script for UN*X ## ############################################################################## # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" # Need this for relative symlinks. while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`"/$link" fi done SAVED="`pwd`" cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME="`pwd -P`" cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS="" # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" warn () { echo "$*" } die () { echo echo "$*" echo exit 1 } # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false case "`uname`" in CYGWIN* ) cygwin=true ;; Darwin* ) darwin=true ;; MINGW* ) msys=true ;; NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD="$JAVA_HOME/jre/sh/java" else JAVACMD="$JAVA_HOME/bin/java" fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else JAVACMD="java" which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi # Increase the maximum file descriptors if we can. if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then MAX_FD="$MAX_FD_LIMIT" fi ulimit -n $MAX_FD if [ $? -ne 0 ] ; then warn "Could not set maximum file descriptor limit: $MAX_FD" fi else warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" fi fi # For Darwin, add options to specify how the application appears in the dock if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi # For Cygwin, switch paths to Windows format before running java if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` SEP="" for dir in $ROOTDIRSRAW ; do ROOTDIRS="$ROOTDIRS$SEP$dir" SEP="|" done OURCYGPATTERN="(^($ROOTDIRS))" # Add a user-defined pattern to the cygpath arguments if [ "$GRADLE_CYGPATTERN" != "" ] ; then OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" fi # Now convert the arguments - kludge to limit ourselves to /bin/sh i=0 for arg in "$@" ; do CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` else eval `echo args$i`="\"$arg\"" fi i=$((i+1)) done case $i in (0) set -- ;; (1) set -- "$args0" ;; (2) set -- "$args0" "$args1" ;; (3) set -- "$args0" "$args1" "$args2" ;; (4) set -- "$args0" "$args1" "$args2" "$args3" ;; (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi # Escape application args save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } APP_ARGS=$(save "$@") # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then cd "$(dirname "$0")" fi exec "$JAVACMD" "$@" HDLSDK/com.hdl.sdk/gradlew.bat
New file @@ -0,0 +1,84 @@ @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @rem @rem ########################################################################## @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS= @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if "%ERRORLEVEL%" == "0" goto init echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto init echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :init @rem Get command-line arguments, handling Windows variants if not "%OS%" == "Windows_NT" goto win9xME_args :win9xME_args @rem Slurp the command line arguments. set CMD_LINE_ARGS= set _SKIP=2 :win9xME_args_slurp if "x%~1" == "x" goto execute set CMD_LINE_ARGS=%* :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% :end @rem End local scope for the variables with windows NT shell if "%ERRORLEVEL%"=="0" goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 exit /b 1 :mainEnd if "%OS%"=="Windows_NT" endlocal :omega HDLSDK/com.hdl.sdk/proguard-rules.pro
New file @@ -0,0 +1,107 @@ #*******************************************************************# #********** 以下是demo不能混淆的内容 *********# #*******************************************************************# -keep public class * extends android.app.Activity -keep public class * extends android.app.Application -keep public class * extends android.app.Service -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.content.ContentProvider -keep class * implements android.os.Parcelable -dontwarn com.google.zxing.** -keep class com.google.zxing.** { *;} -keep public class com.alibaba.android.arouter.routes.**{*;} -keep public class com.alibaba.android.arouter.facade.**{*;} -keep class * implements com.alibaba.android.arouter.facade.template.ISyringe{*;} # If you use the byType method to obtain Service, add the following rules to protect the interface: -keep interface * implements com.alibaba.android.arouter.facade.template.IProvider # If single-type injection is used, that is, no interface is defined to implement IProvider, the following rules need to be added to protect the implementation # -keep class * implements com.alibaba.android.arouter.facade.template.IProvider #*******************************************************************# #********** 以上是demo不能混淆的内容 *********# #*******************************************************************# #*******************************************************************# #********** 以下是SDK不能混淆的内容 *********# #*******************************************************************# #========SDK对外接口=======# -keep class com.ezviz.opensdk.** { *;} #========以下是hik二方库=======# -dontwarn com.ezviz.** -keep class com.ezviz.** { *;} -dontwarn com.ez.** -keep class com.ez.** { *;} -dontwarn com.hc.CASClient.** -keep class com.hc.CASClient.** { *;} -dontwarn com.videogo.** -keep class com.videogo.** { *;} -dontwarn com.hik.TTSClient.** -keep class com.hik.TTSClient.** { *;} -dontwarn com.hik.stunclient.** -keep class com.hik.stunclient.** { *;} -dontwarn com.hik.streamclient.** -keep class com.hik.streamclient.** { *;} -dontwarn com.hikvision.sadp.** -keep class com.hikvision.sadp.** { *;} -dontwarn com.hikvision.netsdk.** -keep class com.hikvision.netsdk.** { *;} -dontwarn com.neutral.netsdk.** -keep class com.neutral.netsdk.** { *;} -dontwarn com.hikvision.audio.** -keep class com.hikvision.audio.** { *;} -dontwarn com.mediaplayer.audio.** -keep class com.mediaplayer.audio.** { *;} -dontwarn com.hikvision.wifi.** -keep class com.hikvision.wifi.** { *;} -dontwarn com.hikvision.keyprotect.** -keep class com.hikvision.keyprotect.** { *;} -dontwarn com.hikvision.audio.** -keep class com.hikvision.audio.** { *;} -dontwarn org.MediaPlayer.PlayM4.** -keep class org.MediaPlayer.PlayM4.** { *;} #========以上是hik二方库=======# #========以下是第三方开源库=======# # JNA -dontwarn com.sun.jna.** -keep class com.sun.jna.** { *;} # Gson -keepattributes *Annotation* -keep class sun.misc.Unsafe { *; } -keep class com.idea.fifaalarmclock.entity.*** -keep class com.google.gson.stream.** { *; } # OkHttp # JSR 305 annotations are for embedding nullability information. -dontwarn javax.annotation.** # A resource is loaded with a relative path so the package of this class must be preserved. -keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase # Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java. -dontwarn org.codehaus.mojo.animal_sniffer.* # OkHttp platform used only on JVM and when Conscrypt dependency is available. -dontwarn okhttp3.internal.platform.ConscryptPlatform # 必须额外加的,否则编译无法通过 -dontwarn okio.** #========以上是第三方开源库=======# HDLSDK/com.hdl.sdk/src/main/AndroidManifest.xml
New file @@ -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.hdl.sdk"> <application/> </manifest> HDLSDK/config.gradle
@@ -2,6 +2,4 @@ minSdkVersion = 16 targetSdkVersion = 31 compileSdkVersion = 31 versionName = "1.0.0" } HDLSDK/hdl-common/build.gradle
@@ -10,7 +10,7 @@ targetSdkVersion rootProject.targetSdkVersion versionCode 2 versionName "1.0.10" versionName "1.0.13" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" } @@ -25,20 +25,10 @@ sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } /** * 打包自动命名 */ android.libraryVariants.all { variant -> variant.outputs.all { outputFileName = "hdl-common-V" + defaultConfig.versionName + ".aar" } } } dependencies { api 'com.google.code.gson:gson:2.8.8' api 'androidx.annotation:annotation:1.2.0' api 'androidx.collection:collection:1.1.0' // api project(path: ':hdl-connect') } HDLSDK/hdl-common/src/.DS_StoreBinary files differ
HDLSDK/hdl-common/src/androidTest/java/com/hdl/sdk/common/ExampleInstrumentedTest.java
File was deleted HDLSDK/hdl-common/src/main/java/com/hdl/sdk/.DS_StoreBinary files differ
HDLSDK/hdl-common/src/main/java/com/hdl/sdk/common/.DS_StoreBinary files differ
HDLSDK/hdl-common/src/main/java/com/hdl/sdk/common/HDLSdk.java
@@ -19,7 +19,7 @@ return version; } private String version="1.0.8"; private String version="1.0.13"; private HDLSdk() { } HDLSDK/hdl-common/src/main/java/com/hdl/sdk/common/event/EventDispatcher.java
@@ -4,6 +4,7 @@ import androidx.collection.ArrayMap; import com.hdl.sdk.common.utils.LogUtils; import com.hdl.sdk.common.utils.ThreadToolUtils; import java.util.ArrayList; @@ -32,12 +33,12 @@ private EventDispatcher() { } private static class SingletonInstance { private static final EventDispatcher INSTANCE = new EventDispatcher(); } // private static class SingletonInstance { private static final EventDispatcher instance = new EventDispatcher(); // } public static EventDispatcher getInstance() { return SingletonInstance.INSTANCE; return instance; } public synchronized void register(Object tag, EventListener listener) { @@ -77,12 +78,13 @@ EVENT.remove(tag); } } catch (Exception ignored) { LogUtils.e("移除event异常1:"+ignored.getMessage()); } } }); }catch (Exception e){} }catch (Exception e){ LogUtils.e("移除event异常2:"+e.getMessage()); } } public synchronized void remove(Object tag, EventListener listener) { @@ -99,12 +101,14 @@ } } } catch (Exception ignored) { LogUtils.e("移除event异常1:"+ignored.getMessage()); } } }); }catch (Exception e){} }catch (Exception e){ LogUtils.e("移除event异常2:"+e.getMessage()); } } @@ -165,12 +169,14 @@ ALL_TOPICS_EVENT.remove(listener); } } catch (Exception ignored) { LogUtils.e("移除event异常1:" + ignored.getMessage()); } } }); }catch (Exception e){} } catch (Exception e) { LogUtils.e("移除event异常2:" + e.getMessage()); } } public synchronized void clear() { HDLSDK/hdl-common/src/main/java/com/hdl/sdk/common/utils/ThreadToolUtils.java
@@ -20,12 +20,13 @@ private ThreadToolUtils() { } private static class SingletonInstance { private static final ThreadToolUtils INSTANCE = new ThreadToolUtils(); } // private static class SingletonInstance { // } private static final ThreadToolUtils instance = new ThreadToolUtils(); public static ThreadToolUtils getInstance() { return SingletonInstance.INSTANCE; return instance; } HDLSDK/hdl-common/src/test/java/com/hdl/sdk/common/ExampleUnitTest.java
File was deleted HDLSDK/hdl-connect/build.gradle
@@ -9,7 +9,7 @@ minSdkVersion rootProject.minSdkVersion targetSdkVersion rootProject.targetSdkVersion versionCode 2 versionName "1.0.10" versionName "1.0.13" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" @@ -25,23 +25,10 @@ sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } /** * 打包自动命名 */ android.libraryVariants.all { variant -> variant.outputs.all { outputFileName = "hdl-connect-V" + defaultConfig.versionName + ".aar" } } } dependencies { api project(path: ':hdl-socket') implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'com.google.android.material:material:1.3.0' // //加密 // implementation 'cn.hutool:hutool-all:5.6.5' // implementation 'org.bouncycastle:bcprov-jdk15on:1.60' } HDLSDK/hdl-connect/src/androidTest/java/com/hdl/sdk/connect/ExampleInstrumentedTest.java
File was deleted HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/.DS_StoreBinary files differ
HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/.DS_StoreBinary files differ
HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/HDLLink.java
@@ -23,26 +23,20 @@ /** * instance */ private volatile static HDLLink instance; private static final HDLLink instance=new HDLLink(); /** * getInstance * * @return HDLLink */ public static synchronized HDLLink getInstance() { if (instance == null) { synchronized (HDLLink.class) { if (instance == null) { instance = new HDLLink(); // ThreadToolUtils.getInstance().newScheduledThreadPool(1).scheduleWithFixedDelay(new Runnable() { // @Override // public void run() { ////定期搜索网关,后面看有必要再做 // } // },0,10, TimeUnit.SECONDS); } } } public static HDLLink getInstance() { // if (instance == null) { // synchronized (HDLLink.class) { // if (instance == null) { // instance = new HDLLink(); // } // } // } return instance; } @@ -215,6 +209,7 @@ * @param callBack 回调 */ public void tcpSendMsg(String topic, String bodyStr, HDLLinkCallBack callBack) { HDLAuthSocket.getInstance();//通过这个可以先初始化UDP监听事件 HDLSocket.getInstance().tcpSendMsg(topic, bodyStr, callBack); } @@ -245,6 +240,7 @@ * @param bodyStr 回复的主题 */ public void tcpSendMsg(String topic, String bodyStr) { HDLAuthSocket.getInstance();//通过这个可以先初始化UDP监听事件 HDLSocket.getInstance().tcpSendMsg(topic, bodyStr); } } HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/config/HDLLinkConfig.java
@@ -30,22 +30,26 @@ /** * instance */ private volatile static HDLLinkConfig instance; private static final HDLLinkConfig instance=new HDLLinkConfig(); private HDLLinkConfig() { loadConfig(); } /** * getInstance * * @return AuthenticateConfig */ public static synchronized HDLLinkConfig getInstance() { if (instance == null) { synchronized (HDLLinkConfig.class) { if (instance == null) { instance = new HDLLinkConfig(); instance.loadConfig(); } } } public static HDLLinkConfig getInstance() { // if (instance == null) { // synchronized (HDLLinkConfig.class) { // if (instance == null) { // instance = new HDLLinkConfig(); // instance.loadConfig(); // } // } // } return instance; } HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HDLAuthSocket.java
@@ -68,7 +68,7 @@ /** * instance */ private volatile static HDLAuthSocket instance; private static final HDLAuthSocket instance=new HDLAuthSocket(); private HDLAuthSocket() { initListenerGatewayEvent(); @@ -84,14 +84,14 @@ * * @return HDLAuthSocket */ public static synchronized HDLAuthSocket getInstance() { if (instance == null) { synchronized (HDLLinkConfig.class) { if (instance == null) { instance = new HDLAuthSocket(); } } } public static HDLAuthSocket getInstance() { // if (instance == null) { // synchronized (HDLAuthSocket.class) { // if (instance == null) { // instance = new HDLAuthSocket(); // } // } // } return instance; } @@ -110,7 +110,7 @@ * * @return 返回当前对象 */ private UdpSocketBoot getUdpBoot() { private synchronized UdpSocketBoot getUdpBoot() { try { if (udpSocketBoot == null) { udpSocketBoot = UdpClient.init(UDP_PORT, getUdpOptions()); HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HDLSocket.java
@@ -78,33 +78,44 @@ * 广播自身信息给主网关 */ private void broadcastRequest() { String time = String.valueOf(System.currentTimeMillis()); if (null == HDLLinkConfig.getInstance().getDeviceInfoBean()) { LogUtils.i("DeviceInfoBean为空,请设置当前对象"); return; } BroadcastRequest request = new BroadcastRequest(IdUtils.getUUId(), time, HDLLinkConfig.getInstance().getDeviceInfoBean(), "200"); HDLAuthSocket.getInstance().udpSendMsg(TopicConstant.BROADCAST, GsonConvert.getGson().toJson(request),true); HDLAuthSocket.getInstance().udpSendMsg(TopicConstant.BROADCAST, GsonConvert.getGson().toJson(request), true, new HDLLinkResponseCallBack() { new Thread(new Runnable() { @Override public void onSuccess(LinkResponse msg) { LogUtils.i("广播信息给主网关成功!"); } public void run() { try { LogUtils.i("广播设备本身信息"); @Override public void onError(HDLLinkException e) { String time = String.valueOf(System.currentTimeMillis()); if (null == HDLLinkConfig.getInstance().getDeviceInfoBean()) { LogUtils.i("DeviceInfoBean为空,请设置当前对象"); return; } BroadcastRequest request = new BroadcastRequest(IdUtils.getUUId(), time, HDLLinkConfig.getInstance().getDeviceInfoBean(), "200"); HDLAuthSocket.getInstance().udpSendMsg(TopicConstant.BROADCAST, GsonConvert.getGson().toJson(request), true, new HDLLinkResponseCallBack() { @Override public void onSuccess(LinkResponse msg) { LogUtils.i("广播信息给主网关成功!"); } @Override public void onError(HDLLinkException e) { LogUtils.i("广播信息给主网关失败!"); } }); HDLAuthSocket.getInstance().udpSendMsg(TopicConstant.BROADCAST, GsonConvert.getGson().toJson(request), true); HDLAuthSocket.getInstance().udpSendMsg(TopicConstant.BROADCAST, GsonConvert.getGson().toJson(request), true); } catch (Exception e) { LogUtils.e("广播设备本身信息失败,失败信息:" + e.getMessage()); } } }); HDLAuthSocket.getInstance().udpSendMsg(TopicConstant.BROADCAST, GsonConvert.getGson().toJson(request),true); }).start(); } private static class SingletonInstance { private static final HDLSocket INSTANCE = new HDLSocket(); } // private static class SingletonInstance { // } private static final HDLSocket instance = new HDLSocket(); public static HDLSocket getInstance() { return SingletonInstance.INSTANCE; return instance; } SocketOptions options; HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HdlSocketHelper.java
@@ -173,7 +173,7 @@ } } } catch (Exception e) { e.printStackTrace(); LogUtils.e("发送数据失败:" + e.getMessage()); } } else { //超出重发次数并没有收到回复 @@ -206,13 +206,17 @@ private void notifyFailure() { //移除监听 removeListener(); if (sendThread != null) { sendThread.shutdownNow(); sendThread = null; } if (listener != null) { listener.onFailure(); listener = null; try { if (sendThread != null) { sendThread.shutdownNow(); sendThread = null; } if (listener != null) { listener.onFailure(); listener = null; } } catch (Exception e) { } } } HDLSDK/hdl-connect/src/test/java/com/hdl/sdk/connect/ExampleUnitTest.java
File was deleted HDLSDK/hdl-socket/build.gradle
@@ -9,7 +9,7 @@ minSdkVersion rootProject.minSdkVersion targetSdkVersion rootProject.targetSdkVersion versionCode 2 versionName "1.0.10" versionName "1.0.13" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" @@ -25,17 +25,9 @@ sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } /** * 打包自动命名 */ android.libraryVariants.all { variant -> variant.outputs.all { outputFileName = "hdl-socket-V" + defaultConfig.versionName + ".aar" } } } dependencies { api project(path: ':hdl-common') } HDLSDK/hdl-socket/src/.DS_StoreBinary files differ
HDLSDK/hdl-socket/src/androidTest/java/com/hdl/sdk/socket/ExampleInstrumentedTest.java
File was deleted HDLSDK/hdl-socket/src/main/java/com/hdl/sdk/socket/.DS_StoreBinary files differ
HDLSDK/hdl-socket/src/main/java/com/hdl/sdk/socket/SocketBoot.java
@@ -74,9 +74,10 @@ try { LogUtils.i("TCP连接"); client.onConnectStatus(ConnectStatus.CONNECTING); Thread.sleep(700); Thread.sleep(1000); client.connect(); connected=true; LogUtils.i("TCP连接成功"); client.onConnectStatus(ConnectStatus.CONNECTED); }catch(Exception e) { LogUtils.e("连接异常"+e.getMessage()); @@ -175,7 +176,7 @@ } Thread.sleep(3*1000); } catch (Exception e) { LogUtils.e("定时连接失败:" + e.getMessage()); } } } @@ -198,15 +199,12 @@ if (connected && 10 * 1000 < (System.currentTimeMillis() - time)) { time = System.currentTimeMillis(); //心跳检测 try { if (iHeartbeat != null) iHeartbeat.heartbeat(); } catch (Exception e) { } if (iHeartbeat != null) iHeartbeat.heartbeat(); } Thread.sleep(1000); } catch (Exception e) { LogUtils.e("定时心跳检测网关异常:" + e.getMessage()); } } } @@ -243,7 +241,7 @@ } mMessageQueue.put(request); } catch (Exception e) { LogUtils.e("发送数据失败:" + e.getMessage()); } } HDLSDK/hdl-socket/src/main/java/com/hdl/sdk/socket/SocketPool.java
@@ -21,13 +21,10 @@ mUdpClientPool = new ConcurrentHashMap<>(); } private static class SingletonInstance { private static final SocketPool INSTANCE = new SocketPool(); } private static final SocketPool instance = new SocketPool(); public static SocketPool getInstance() { return SingletonInstance.INSTANCE; return instance; } public void clear() { HDLSDK/hdl-socket/src/main/java/com/hdl/sdk/socket/udp/UdpSocketBoot.java
@@ -114,7 +114,8 @@ if (listener != null && !TextUtils.isEmpty(request.getAction())) { sendMap.put(request.getAction(), listener); } client.sendMsg(ipAddress,port, msg); LogUtils.i("发送目标IP和端口", ipAddress + ":" + port); client.sendMsg(ipAddress, port, msg); } catch (Exception e) { LogUtils.i("发送失败:" + e.getMessage()); } HDLSDK/hdl-socket/src/test/java/com/hdl/sdk/socket/ExampleUnitTest.java
File was deleted HDLSDK/settings.gradle
@@ -3,4 +3,4 @@ include ':hdl-socket' include ':hdl-connect' include ':hdl-common' include ':com.hdl.sdk' HDLSDK_DEMO.zipBinary files differ
HDLSDK_DEMO/.DS_StoreBinary files differ
HDLSDK_DEMO/.gitignore
File was deleted HDLSDK_DEMO/app/.DS_StoreBinary files differ
HDLSDK_DEMO/app/libs/.DS_StoreBinary files differ
HDLSDK_DEMO/app/libs/com.hdl.sdk-v1.0.11.aarBinary files differ
HDLSDK_DEMO/app/libs/hdl-common-V1.0.8.aarBinary files differ
HDLSDK_DEMO/app/libs/hdl-connect-V1.0.8.aarBinary files differ
HDLSDK_DEMO/app/libs/hdl-socket-V1.0.8.aarBinary files differ
HDLSDK_DEMO/app/src/main/java/com/hdl/hdlsdk/MainActivity.java
@@ -80,8 +80,8 @@ infoBean.setDeviceName("音乐播放器");//设备名字 infoBean.setDeviceModel("MCLog.431");//设备型号 infoBean.setAccessMode("WIFI"); infoBean.setIPGateway("192.168.1.1"); infoBean.setIPAddress("192.168.1.102"); infoBean.setIPGateway("192.168.88.1"); infoBean.setIPAddress("192.168.88.153"); infoBean.setGateway_type("music.standard"); infoBean.setHw_version("HW2.0"); infoBean.setFw_version("Fw1.0");