diff --git a/app/src/main/java/com/tencent/iot/explorer/link/App.kt b/app/src/main/java/com/tencent/iot/explorer/link/App.kt index 81d37c8c6..0ddfd0920 100644 --- a/app/src/main/java/com/tencent/iot/explorer/link/App.kt +++ b/app/src/main/java/com/tencent/iot/explorer/link/App.kt @@ -50,6 +50,7 @@ class App : Application(), Application.ActivityLifecycleCallbacks, PayloadMessag const val CONFIG = "config" const val MUST_UPGRADE_TAG = "master" var language: String? = "" + var uuid: String = "" // 根据编译使用的 buildType 类型确定是否是 debug 版本 // 编译依赖的 buildType 包含 debug 字串即认为是 debug 版本 @@ -128,7 +129,12 @@ class App : Application(), Application.ActivityLifecycleCallbacks, PayloadMessag override fun onCreate() { super.onCreate() MultiDex.install(this) - IoTAuth.setWebSocketTag(Utils.getAndroidID(this)) // 设置wss的uin + uuid = SharePreferenceUtil.getString(this, CONFIG, CommonField.UUID) + if (TextUtils.isEmpty(uuid)) { + SharePreferenceUtil.saveString(this, CONFIG, CommonField.UUID, UUID.randomUUID().toString()) + uuid = SharePreferenceUtil.getString(this, CONFIG, CommonField.UUID) + } + IoTAuth.setWebSocketTag(uuid) // 设置wss的uin IoTAuth.setWebSocketCallback(this) // 设置WebSocket连接状态回调 IoTAuth.init(BuildConfig.TencentIotLinkAppkey, BuildConfig.TencentIotLinkAppSecret) //初始化弹框 diff --git a/app/src/main/java/com/tencent/iot/explorer/link/customview/dialog/TipShareDevDialog.java b/app/src/main/java/com/tencent/iot/explorer/link/customview/dialog/TipShareDevDialog.java index 3d5d5d9d5..775bd87a4 100644 --- a/app/src/main/java/com/tencent/iot/explorer/link/customview/dialog/TipShareDevDialog.java +++ b/app/src/main/java/com/tencent/iot/explorer/link/customview/dialog/TipShareDevDialog.java @@ -12,6 +12,7 @@ import androidx.constraintlayout.widget.ConstraintLayout; +import com.tencent.iot.explorer.link.App; import com.tencent.iot.explorer.link.R; import com.tencent.iot.explorer.link.T; import com.tencent.iot.explorer.link.core.utils.Utils; @@ -24,7 +25,7 @@ public class TipShareDevDialog extends IosCenterStyleDialog implements View.OnCl private ConstraintLayout outsideLayout; private ConstraintLayout dialogLayout; private TextView moreInfo; - private String ANDROID_ID = Utils.INSTANCE.getAndroidID(T.getContext()); + private String ANDROID_ID = App.Companion.getUuid(); public TipShareDevDialog(Context context) { super(context, R.layout.popup_tip_share_dev_layout); diff --git a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/AboutUsActivity.kt b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/AboutUsActivity.kt index c7f7c8666..3aa2758fe 100644 --- a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/AboutUsActivity.kt +++ b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/AboutUsActivity.kt @@ -27,7 +27,7 @@ import kotlinx.android.synthetic.main.menu_back_layout.* */ class AboutUsActivity : BaseActivity() { - private val ANDROID_ID = Utils.getAndroidID(T.getContext()) + private val ANDROID_ID = App.uuid override fun getContentView(): Int { return R.layout.activity_about_us diff --git a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/BuleToothActivity.kt b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/BuleToothActivity.kt index 6a3b02d9c..79f8854fb 100644 --- a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/BuleToothActivity.kt +++ b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/BuleToothActivity.kt @@ -65,9 +65,9 @@ class BuleToothActivity: BaseActivity(), View.OnClickListener, MyCallback { val ticketResponse = JSON.parse(response.data.toString()) as JSONObject var url = H5_PANEL_BASE_URL + "?productId=${productId}" + - "&uin=${Utils.getAndroidID(this)}" + + "&uin=${App.uuid}" + "&lid=${App.data.appLifeCircleId}" + - "&quid=${Utils.getAndroidID(this)}" + + "&quid=${App.uuid}" + "&ticket=${ticketResponse[CommonField.TOKEN_TICKET]}" + "&appID=${T.getContext().applicationInfo.packageName}" + "&platform=${HttpRequest.PLATFORM_TAG}" + diff --git a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/CommentDetailsActivity.kt b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/CommentDetailsActivity.kt index 0cfc7a2bc..6e1436c60 100644 --- a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/CommentDetailsActivity.kt +++ b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/CommentDetailsActivity.kt @@ -11,6 +11,7 @@ import android.widget.LinearLayout import android.widget.ProgressBar import com.alibaba.fastjson.JSON import com.alibaba.fastjson.JSONObject +import com.tencent.iot.explorer.link.App import com.tencent.iot.explorer.link.R import com.tencent.iot.explorer.link.T import com.tencent.iot.explorer.link.core.auth.callback.MyCallback @@ -113,7 +114,7 @@ class CommentDetailsActivity: BaseActivity(), View.OnClickListener, MyCallback { return } var js = JSON.parse(response.data.toString()) as JSONObject - var weburl = CommonField.H5_BASE_URL + "?uin=${Utils.getAndroidID(this)}#" + + var weburl = CommonField.H5_BASE_URL + "?uin=${App.uuid}#" + pathUrl + "&ticket=${js[CommonField.TOKEN_TICKET]}" + "&lang=${Utils.getLang()}" comment_detail_web.loadUrl(weburl) } diff --git a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/DevicePanelActivity.kt b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/DevicePanelActivity.kt index 05851234f..d888e5e63 100644 --- a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/DevicePanelActivity.kt +++ b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/DevicePanelActivity.kt @@ -72,11 +72,11 @@ class DevicePanelActivity: BaseActivity(), View.OnClickListener, MyCallback, App var url = H5_PANEL_BASE_URL + "?deviceId=${deviceEntity?.DeviceId}" + "&familyId=${deviceEntity?.FamilyId}" + - "&uin=${Utils.getAndroidID(this)}" + + "&uin=${App.uuid}" + "&roomId=${deviceEntity?.RoomId}" + "&familyType=${App.data.getCurrentFamily().FamilyType}" + "&lid=${App.data.appLifeCircleId}" + - "&quid=${Utils.getAndroidID(this)}" + + "&quid=${App.uuid}" + "&ticket=${ticketResponse[CommonField.TOKEN_TICKET]}" + "&appID=${T.getContext().applicationInfo.packageName}" + "&platform=android" + diff --git a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/ForgotPasswordActivity.kt b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/ForgotPasswordActivity.kt index 9429e37db..911e612f6 100644 --- a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/ForgotPasswordActivity.kt +++ b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/ForgotPasswordActivity.kt @@ -8,6 +8,7 @@ import android.text.method.LinkMovementMethod import android.text.style.ClickableSpan import android.view.LayoutInflater import android.view.View +import com.tencent.iot.explorer.link.App import com.tencent.iot.explorer.link.R import com.tencent.iot.explorer.link.core.log.L import com.tencent.iot.explorer.link.kitlink.consts.SocketConstants @@ -31,7 +32,7 @@ import kotlinx.android.synthetic.main.menu_back_layout.* */ class ForgotPasswordActivity : PActivity(), ForgotPasswordView, View.OnClickListener { - private val ANDROID_ID = Utils.getAndroidID(T.getContext()) + private val ANDROID_ID = App.uuid private lateinit var presenter: ForgotPasswordPresenter private var forgotType = true diff --git a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/GuideActivity.kt b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/GuideActivity.kt index 8376cc80d..b799ea76b 100644 --- a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/GuideActivity.kt +++ b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/GuideActivity.kt @@ -78,7 +78,7 @@ class GuideActivity : PActivity(), View.OnClickListener{ if (hits[0] >= SystemClock.uptimeMillis() - duration) { if (hits.size == 5) { // 获取AndroidID,并保存至剪切板 - Utils.copy(this, Utils.getAndroidID(T.getContext())) + Utils.copy(this, App.uuid) } } } diff --git a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/HelpWebViewActivity.kt b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/HelpWebViewActivity.kt index 338ca756e..ab3ed1fd0 100644 --- a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/HelpWebViewActivity.kt +++ b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/HelpWebViewActivity.kt @@ -141,7 +141,7 @@ class HelpWebViewActivity: BaseActivity(), MyCallback, View.OnClickListener { var js = JSON.parse(response.data.toString()) as JSONObject var url ="https://iot.cloud.tencent.com/explorer-h5/help-center/?" + "&ticket=" + js[CommonField.TOKEN_TICKET] - url += "&uin=${Utils.getAndroidID(this)}" + url += "&uin=${App.uuid}" if (!App.isOEMApp()) { url += "&appID=" + T.getContext().applicationInfo.packageName } diff --git a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/LogoutActivity.kt b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/LogoutActivity.kt index 451da56cd..ce47b0dec 100644 --- a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/LogoutActivity.kt +++ b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/LogoutActivity.kt @@ -26,7 +26,7 @@ class LogoutActivity : PActivity(), LogoutView, View.OnClickListener{ private lateinit var presenter: LogoutPresenter - private val ANDROID_ID = Utils.getAndroidID(T.getContext()) + private val ANDROID_ID = App.uuid override fun getPresenter(): IPresenter? { return presenter diff --git a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/RegisterActivity.kt b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/RegisterActivity.kt index 79074b182..4acf7b617 100644 --- a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/RegisterActivity.kt +++ b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/RegisterActivity.kt @@ -52,7 +52,7 @@ class RegisterActivity : PActivity(), RegisterView, View.OnClickListener { private lateinit var phoneView: View private lateinit var emailView: View - private val ANDROID_ID = Utils.getAndroidID(T.getContext()) + private val ANDROID_ID = App.uuid override fun getPresenter(): IPresenter? { return presenter diff --git a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/UserInfoActivity.kt b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/UserInfoActivity.kt index 499064589..ea14a6204 100644 --- a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/UserInfoActivity.kt +++ b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/UserInfoActivity.kt @@ -141,7 +141,7 @@ class UserInfoActivity : PActivity(), UserInfoView, View.OnClickListener, View.O if (hits[0] >= SystemClock.uptimeMillis() - duration) { if (hits.size == 5) { // 获取AndroidID,并保存至剪切板 - Utils.copy(this, Utils.getAndroidID(T.getContext())) + Utils.copy(this, App.uuid) } } } diff --git a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/fragment/CommentFragment.kt b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/fragment/CommentFragment.kt index 45816bcd8..9467a74c3 100644 --- a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/fragment/CommentFragment.kt +++ b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/fragment/CommentFragment.kt @@ -129,7 +129,7 @@ class CommentFragment : BaseFragment(), View.OnClickListener, MyCallback { if (response.code == 0) { var js = JSON.parse(response.data.toString()) as JSONObject var url = CommonField.H5_BASE_URL + "?ticket=" + js[CommonField.TOKEN_TICKET] - url += "&uin=${Utils.getAndroidID(context!!)}" + url += "&uin=${App.uuid}" url += "&lang=${Utils.getLang()}" if (!App.isOEMApp()) { url += "&appID=" + T.getContext().applicationInfo.packageName diff --git a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/util/HttpRequest.kt b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/util/HttpRequest.kt index 44f5e536b..accf34b70 100644 --- a/app/src/main/java/com/tencent/iot/explorer/link/kitlink/util/HttpRequest.kt +++ b/app/src/main/java/com/tencent/iot/explorer/link/kitlink/util/HttpRequest.kt @@ -54,7 +54,7 @@ class HttpRequest private constructor() { const val BUSI_APP = "studioapp" const val BUSI_OPENSOURCE = "studioappOpensource" - val ANDROID_ID = Utils.getAndroidID(T.getContext()) + val ANDROID_ID = App.uuid val PLATFORM_TAG = "android" } diff --git a/sdk/explorer-link-android/src/main/java/com/tencent/iot/explorer/link/core/utils/Utils.kt b/sdk/explorer-link-android/src/main/java/com/tencent/iot/explorer/link/core/utils/Utils.kt index b5362a735..0e40ef800 100644 --- a/sdk/explorer-link-android/src/main/java/com/tencent/iot/explorer/link/core/utils/Utils.kt +++ b/sdk/explorer-link-android/src/main/java/com/tencent/iot/explorer/link/core/utils/Utils.kt @@ -156,12 +156,6 @@ object Utils { return context.resources.configuration.locale.language == "zh" } - fun getAndroidID(context: Context): String { - val id = Settings.System.getString(context.contentResolver, Settings.System.ANDROID_ID) - return if (TextUtils.isEmpty(id)) "" - else id - } - fun bmpToByteArray(bitmap: Bitmap?): ByteArray? { // 要返回的字符串