Skip to content

Commit 6e8a596

Browse files
committed
修复静态代码扫描问题
1 parent e49b03f commit 6e8a596

File tree

9 files changed

+27
-18
lines changed

9 files changed

+27
-18
lines changed

explorer/device-android-demo/src/main/cpp/native-lib.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ char sg_cse_test_pic_path[256];
1818

1919
static void *thd_fn(void *arg) {
2020
pthread_detach(pthread_self());
21-
char *args[8] = {NULL, sg_dev_path, sg_flv_path, sg_cs_recv_talk_path, sg_cs_aac_path, sg_cs_video_path,sg_cse_srcipt_path,sg_cse_test_pic_path};
21+
char *args[8] = {NULL, sg_dev_path, sg_flv_path, sg_cs_recv_talk_path, sg_cs_aac_path,
22+
sg_cs_video_path, sg_cse_srcipt_path, sg_cse_test_pic_path};
2223
iot_video_main(8, args);
2324
}
2425

2526
extern "C" JNIEXPORT jstring JNICALL
2627
Java_com_tencent_iot_explorer_device_video_push_1stream_PushStreamActivity_nativeDemo(
27-
JNIEnv* env,
28+
JNIEnv *env,
2829
jobject /* this */,
2930
jstring dir) {
3031
const char *dir_path = env->GetStringUTFChars(dir, 0);

explorer/explorer-device-android/src/main/java/com/tencent/iot/explorer/device/android/http/retrofit/StringRequest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ class StringRequest private constructor() {
299299
isSuccess = (process.waitFor() == 0)
300300
} catch (e: Exception) {
301301
isSuccess = false
302-
e.printStackTrace()
302+
TXLog.d(TAG, e.message)
303303
process?.destroy()
304304
} finally {
305305
process?.destroy()

explorer/explorer-device-android/src/main/java/com/tencent/iot/explorer/device/android/http/retrofit/adapter/StringCallAdapterFactory.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
package com.tencent.iot.explorer.device.android.http.retrofit.adapter
22

3+
import org.slf4j.Logger
4+
import org.slf4j.LoggerFactory
5+
import retrofit2.Call
36
import retrofit2.CallAdapter
47
import retrofit2.Retrofit
58
import java.lang.reflect.Type
6-
import retrofit2.Call
7-
import java.lang.Exception
89

910

1011
class StringCallAdapterFactory private constructor() : CallAdapter.Factory() {
12+
13+
private val LOG: Logger = LoggerFactory.getLogger(StringCallAdapterFactory::class.java)
14+
1115
override fun get(
1216
type: Type?,
1317
array: Array<out Annotation>?,
@@ -23,7 +27,7 @@ class StringCallAdapterFactory private constructor() : CallAdapter.Factory() {
2327
try {
2428
return call.execute().body().toString()
2529
} catch (e: Exception) {
26-
e.printStackTrace()
30+
LOG.error(e.message)
2731
}
2832
return ""
2933
}

explorer/explorer-device-central/src/main/java/com/tencent/iot/explorer/device/central/message/payload/Payload.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
package com.tencent.iot.explorer.device.central.message.payload
22

33
import com.alibaba.fastjson.JSON
4+
import org.slf4j.Logger
5+
import org.slf4j.LoggerFactory
46

57
class Payload {
68

9+
private val LOG: Logger = LoggerFactory.getLogger(Payload::class.java)
10+
711
//设备监听到下发的数据字符串
812
var json = ""
913

@@ -26,7 +30,7 @@ class Payload {
2630
try {
2731
return JSON.parseObject(data)?.keys
2832
} catch (e: Exception) {
29-
e.printStackTrace()
33+
LOG.error(e.message)
3034
}
3135
return null
3236
}
@@ -42,7 +46,7 @@ class Payload {
4246
}
4347
}
4448
} catch (e: Exception) {
45-
e.printStackTrace()
49+
LOG.error(e.message)
4650
}
4751
return "0"
4852
}

hub/hub-device-android/src/main/java/com/tencent/iot/hub/device/android/core/shadow/TXShadowConnection.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
import org.eclipse.paho.client.mqttv3.MqttClientPersistence;
1313
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
1414
import org.eclipse.paho.client.mqttv3.MqttMessage;
15+
16+
import java.security.SecureRandom;
1517
import java.util.HashMap;
1618
import java.util.List;
17-
import java.util.Random;
1819

1920
/**
2021
* 影子连接类
@@ -139,7 +140,7 @@ public TXShadowConnection(Context context, String serverURI, String productID, S
139140
OPERATION_TOPIC = "$shadow/operation/" + productID + "/" + mMqttConnection.mDeviceName;
140141
OPERATION_RESULT_TOPIC = "$shadow/operation/result/" + productID + "/" + mMqttConnection.mDeviceName;
141142

142-
mPublishMessageId = new Random().nextInt(MAX_MESSAGE_ID);
143+
mPublishMessageId = new SecureRandom().nextInt(MAX_MESSAGE_ID);
143144

144145
mTXShadowConn.setMqttConnection(mMqttConnection);
145146
}

hub/hub-device-android/src/main/java/com/tencent/iot/hub/device/android/core/util/AsymcSslUtils.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.security.spec.KeySpec;
2323
import java.security.spec.PKCS8EncodedKeySpec;
2424
import java.security.spec.RSAPrivateCrtKeySpec;
25-
import java.util.Random;
2625

2726
import javax.net.ssl.SSLContext;
2827
import javax.net.ssl.SSLSocketFactory;
@@ -39,7 +38,7 @@ public class AsymcSslUtils {
3938
*/
4039
public static final String TAG = "iot.AsymcSslUtils";
4140

42-
private static String PASSWORD = String.valueOf(new Random(System.currentTimeMillis()).nextInt());
41+
private static String PASSWORD = String.valueOf(new SecureRandom().nextInt());
4342

4443
/**
4544
* 证书文件及 Key文件存放在 Android asset 目录下,通过 AssetManager 读取文件内容获取输入流,

hub/hub-device-java/src/main/java/com/tencent/iot/hub/device/java/core/shadow/TXShadowConnection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
import org.slf4j.Logger;
1717
import org.slf4j.LoggerFactory;
1818

19+
import java.security.SecureRandom;
1920
import java.util.ArrayList;
2021
import java.util.Arrays;
2122
import java.util.HashMap;
2223
import java.util.Iterator;
2324
import java.util.List;
24-
import java.util.Random;
2525
import java.util.concurrent.atomic.AtomicInteger;
2626

2727
/**
@@ -148,7 +148,7 @@ public TXShadowConnection(String serverURI, String productID, String deviceName,
148148
OPERATION_TOPIC = "$shadow/operation/" + productID + "/" + mMqttConnection.mDeviceName;
149149
OPERATION_RESULT_TOPIC = "$shadow/operation/result/" + productID + "/" + mMqttConnection.mDeviceName;
150150

151-
mPublishMessageId = new Random().nextInt(MAX_MESSAGE_ID);
151+
mPublishMessageId = new SecureRandom().nextInt(MAX_MESSAGE_ID);
152152
}
153153

154154
/**

hub/hub-device-java/src/main/java/com/tencent/iot/hub/device/java/core/util/AsymcSslUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import java.security.KeyStore;
1818
import java.security.NoSuchAlgorithmException;
1919
import java.security.PrivateKey;
20+
import java.security.SecureRandom;
2021
import java.security.Security;
2122
import java.security.cert.CertificateException;
2223
import java.security.cert.CertificateFactory;
@@ -27,7 +28,6 @@
2728
import java.security.spec.PKCS8EncodedKeySpec;
2829
import java.security.spec.RSAPrivateCrtKeySpec;
2930
import java.security.spec.X509EncodedKeySpec;
30-
import java.util.Random;
3131

3232
import javax.net.ssl.KeyManagerFactory;
3333
import javax.net.ssl.SSLContext;
@@ -56,7 +56,7 @@ public class AsymcSslUtils {
5656
private static final String TAG = AsymcSslUtils.class.getName();
5757
private static final Logger logger = LoggerFactory.getLogger(AsymcSslUtils.class);
5858
static { Loggor.setLogger(logger); }
59-
private static String PASSWORD = String.valueOf(new Random(System.currentTimeMillis()).nextInt());
59+
private static String PASSWORD = String.valueOf(new SecureRandom().nextInt());
6060

6161
/**
6262
* 读取 resouce 文件证书文件及 Key 文件存放在 Android asset 目录

hub/hub-device-java/src/main/java/com/tencent/iot/hub/device/java/core/util/SymcSslUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
import java.io.InputStream;
1515
import java.io.InputStreamReader;
1616
import java.security.KeyStore;
17+
import java.security.SecureRandom;
1718
import java.security.Security;
1819
import java.security.cert.CertificateException;
1920
import java.security.cert.CertificateFactory;
2021
import java.security.cert.X509Certificate;
21-
import java.util.Random;
2222

2323
import javax.net.ssl.KeyManagerFactory;
2424
import javax.net.ssl.SSLContext;
@@ -34,7 +34,7 @@ public class SymcSslUtils {
3434
private static final Logger logger = LoggerFactory.getLogger(SymcSslUtils.class);
3535
static { Loggor.setLogger(logger); }
3636

37-
private static String PASSWORD = String.valueOf(new Random(System.currentTimeMillis()).nextInt());
37+
private static String PASSWORD = String.valueOf(new SecureRandom().nextInt());
3838

3939
/**
4040
* 获取 socket SSL

0 commit comments

Comments
 (0)