Skip to content

Commit 515460a

Browse files
committed
保存appkey、appsecrty
1 parent d5e649a commit 515460a

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/VideoTestInputActivity.kt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ class VideoTestInputActivity : VideoBaseActivity<ActivityVideoTestInputBinding>(
4242
VideoConst.VIDEO_CONFIG,
4343
VideoConst.MULTI_VIDEO_P2P_INFO
4444
)
45+
val isStartCross = SharePreferenceUtil.getInt(
46+
this@VideoTestInputActivity,
47+
VideoConst.VIDEO_CONFIG,
48+
"isStartCross"
49+
) == 1
4550
val appKey = SharePreferenceUtil.getString(
4651
this@VideoTestInputActivity,
4752
VideoConst.VIDEO_CONFIG,
@@ -76,6 +81,7 @@ class VideoTestInputActivity : VideoBaseActivity<ActivityVideoTestInputBinding>(
7681
if (appKey.isNotEmpty()) {
7782
appKeyLayout.evContent.setText(appKey)
7883
}
84+
swtCross.isChecked = isStartCross
7985
appKeyLayout.evContent.setHint(R.string.hint_app_key)
8086
appKeyLayout.evContent.inputType = InputType.TYPE_CLASS_TEXT
8187
if (appSecret.isNotEmpty()) {
@@ -162,6 +168,12 @@ class VideoTestInputActivity : VideoBaseActivity<ActivityVideoTestInputBinding>(
162168
show(getString(R.string.hint_p2p_info))
163169
return
164170
}
171+
SharePreferenceUtil.saveInt(
172+
this@VideoTestInputActivity,
173+
VideoConst.VIDEO_CONFIG,
174+
"isStartCross",
175+
if (isStartCross) 1 else 0
176+
)
165177
if (isStartCross) {
166178
if (appKeyLayout.evContent.text.isNullOrEmpty()) {
167179
show(getString(R.string.hint_app_key))
@@ -186,12 +198,6 @@ class VideoTestInputActivity : VideoBaseActivity<ActivityVideoTestInputBinding>(
186198
)
187199
}
188200
}
189-
SharePreferenceUtil.saveString(
190-
this@VideoTestInputActivity,
191-
VideoConst.VIDEO_CONFIG,
192-
VideoConst.MULTI_VIDEO_P2P_INFO,
193-
p2pInfoLayout.evContent.text.toString()
194-
)
195201
val intent = Intent(this@VideoTestInputActivity, VideoTestActivity::class.java)
196202
intent.putExtra("productId", productIdLayout.evContent.text.toString())
197203
intent.putExtra("deviceName", deviceNameLayout.evContent.text.toString())

sdkdemo/src/main/java/com/tencent/iot/explorer/link/demo/video/preview/VideoTestActivity.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ class VideoTestActivity : VideoBaseActivity<ActivityVideoTestBinding>(), XP2PCal
9797
ActivityVideoTestBinding.inflate(layoutInflater)
9898

9999
override fun initView() {
100-
productId = intent.getStringExtra("productId")?.toString() ?: ""
101-
deviceName = intent.getStringExtra("deviceName")?.toString() ?: ""
102-
xp2pInfo = intent.getStringExtra("p2pInfo")?.toString() ?: ""
103-
val appKey = intent.getStringExtra("appKey")?.toString() ?: ""
104-
val appSecret = intent.getStringExtra("appSecret")?.toString() ?: ""
105-
xP2PAppConfig.appKey = appKey
106-
xP2PAppConfig.appSecret = appSecret
100+
productId = (intent.getStringExtra("productId") ?: "").trim()
101+
deviceName = (intent.getStringExtra("deviceName") ?: "").trim()
102+
xp2pInfo = (intent.getStringExtra("p2pInfo") ?: "").trim()
103+
val appKey = intent.getStringExtra("appKey") ?: ""
104+
val appSecret = intent.getStringExtra("appSecret") ?: ""
105+
xP2PAppConfig.appKey = appKey.trim()
106+
xP2PAppConfig.appSecret = appSecret.trim()
107107
xP2PAppConfig.autoConfigFromDevice = intent.getBooleanExtra("isStartCross", false)
108-
val protocol = intent.getStringExtra("protocol")?.toString() ?: "auto"
108+
val protocol = intent.getStringExtra("protocol") ?: "auto"
109109
if (protocol == "udp") {
110110
xP2PAppConfig.type = XP2PProtocolType.XP2P_PROTOCOL_UDP
111111
} else if (protocol == "tcp") {
@@ -511,7 +511,7 @@ class VideoTestActivity : VideoBaseActivity<ActivityVideoTestBinding>(), XP2PCal
511511
if (event == 1004) {
512512
Log.e(tag, "====event === 1004")
513513
checkDeviceState()
514-
// delegateHttpFlv()
514+
delegateHttpFlv()
515515
}
516516
} else if (event == 1010) {
517517
Log.e(tag, "====event === 1010, 校验失败,info撞库防止串流: $msg")

0 commit comments

Comments
 (0)