Skip to content

Commit 2b871f8

Browse files
committed
增加tpns默认不自启动的配置,去掉firebase Performance,因该sdk会在程序启动时获取个人信息字段,修改FirebaseApp初始化时机在用户同意之后,升级firebase crashlytics版本,优化获取手机品牌和型号。
Change-Id: Ic2e30ec97dbdd20f968fbfb446cd17bcd1b8f449
1 parent 265a609 commit 2b871f8

File tree

6 files changed

+43
-4
lines changed

6 files changed

+43
-4
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ dependencies {
177177
implementation 'com.google.firebase:firebase-analytics-ktx:20.0.2'
178178

179179
// Add the Firebase Crashlytics SDK.
180-
implementation 'com.google.firebase:firebase-crashlytics:18.2.6'
180+
implementation 'com.google.firebase:firebase-crashlytics:18.2.7'
181181

182-
implementation 'com.google.firebase:firebase-perf:20.0.4'
182+
// implementation 'com.google.firebase:firebase-perf:20.0.4'
183183

184184
implementation 'com.squareup.picasso:picasso:2.71828'
185185

app/src/main/AndroidManifest.xml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@
3535
<uses-permission android:name="android.permission.RECORD_AUDIO" />
3636
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
3737

38+
<!-- 移动推送TPNS自定义权限,用于发送接收广播权限校验(必选)-->
39+
<permission
40+
android:name="${applicationId}.permission.XGPUSH_RECEIVE"
41+
android:protectionLevel="signature" />
42+
<uses-permission android:name="${applicationId}.permission.XGPUSH_RECEIVE" />
43+
44+
<!-- 移动推送TPNS 网络权限 (必选)-->
45+
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
46+
3847
<application
3948
android:name=".App"
4049
android:allowBackup="false"
@@ -48,6 +57,11 @@
4857
tools:replace="android:allowBackup">
4958
<!-- 如果您出于某些原因(例如为了在收集数据前征得最终用户的同意)希望暂时停用 Analytics 数据收集功能 -->
5059
<meta-data android:name="firebase_analytics_collection_enabled" android:value="false" />
60+
<provider
61+
android:name="com.google.firebase.provider.FirebaseInitProvider"
62+
android:authorities="${applicationId}.firebaseinitprovider"
63+
tools:node="remove"
64+
/>
5165
<!-- 请您务必确保终端用户首次安装启动应用时,配置不自动启动推送服务,以确保应用首次安装启动时不会自启推送服务,直到调用了推送服务注册接口 XGPushManager.registerPush() 才会开启 -->
5266
<meta-data
5367
android:name="XG_SERVICE_PULL_UP_OFF"
@@ -64,6 +78,23 @@
6478
<action android:name="com.tencent.android.xg.vip.action.ACTION_SDK_KEEPALIVE" />
6579
</intent-filter>
6680
</receiver>
81+
82+
<!-- 在自身应用的AndroidManifest.xml文件中添加如下结点 -->
83+
<!-- 关闭与 移动推送TPNS 应用的联合保活功能,请配置 -->
84+
<provider
85+
android:name="com.tencent.android.tpush.XGPushProvider"
86+
tools:replace="android:authorities"
87+
android:authorities="${applicationId}.link.XGVIP_PUSH_AUTH"
88+
android:enabled="false"
89+
android:exported="false" />
90+
<!-- 关闭与 移动推送TPNS 应用的联合保活功能,请配置 -->
91+
<provider
92+
android:name="com.tencent.android.tpush.XGVipPushKAProvider"
93+
tools:replace="android:authorities"
94+
android:authorities="${applicationId}.AUTH_XGPUSH_KEEPALIVE"
95+
android:enabled="false"
96+
android:exported="false" />
97+
6798
<activity
6899
android:name=".kitlink.activity.BleOTADownloadActivity"
69100
android:exported="false" />

app/src/main/java/com/tencent/iot/explorer/link/App.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.tencent.iot.explorer.link
33
import android.app.Activity
44
import android.app.Application
55
import android.content.Intent
6+
import android.os.Build
67
import android.os.Bundle
78
import android.text.TextUtils
89
import android.widget.Toast
@@ -51,6 +52,8 @@ class App : Application(), Application.ActivityLifecycleCallbacks, PayloadMessag
5152
const val MUST_UPGRADE_TAG = "master"
5253
var language: String? = ""
5354
var uuid: String = ""
55+
var mobileBrand: String = ""
56+
var mobileModel: String = ""
5457

5558
// 根据编译使用的 buildType 类型确定是否是 debug 版本
5659
// 编译依赖的 buildType 包含 debug 字串即认为是 debug 版本
@@ -134,6 +137,8 @@ class App : Application(), Application.ActivityLifecycleCallbacks, PayloadMessag
134137
SharePreferenceUtil.saveString(this, CONFIG, CommonField.UUID, UUID.randomUUID().toString())
135138
uuid = SharePreferenceUtil.getString(this, CONFIG, CommonField.UUID)
136139
}
140+
mobileBrand = Build.BRAND
141+
mobileModel = Build.MODEL
137142
IoTAuth.setWebSocketTag(uuid) // 设置wss的uin
138143
IoTAuth.setWebSocketCallback(this) // 设置WebSocket连接状态回调
139144
IoTAuth.init(BuildConfig.TencentIotLinkAppkey, BuildConfig.TencentIotLinkAppSecret)

app/src/main/java/com/tencent/iot/explorer/link/kitlink/activity/PrivicyDialogActivity.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.tencent.iot.explorer.link.kitlink.activity
22

33
import android.content.Intent
44
import android.text.TextUtils
5+
import com.google.firebase.FirebaseApp
56
import com.google.firebase.analytics.FirebaseAnalytics
67
import com.tencent.iot.explorer.link.App
78
import com.tencent.iot.explorer.link.R
@@ -21,6 +22,7 @@ class PrivicyDialogActivity : BaseActivity() {
2122

2223
override fun initView() {
2324
if (!TextUtils.isEmpty(App.data.getToken())) {
25+
FirebaseApp.initializeApp(applicationContext)
2426
FirebaseAnalytics.getInstance(this).setAnalyticsCollectionEnabled(true)
2527
startActivity(Intent(this, MainActivity::class.java))
2628
return
@@ -34,6 +36,7 @@ class PrivicyDialogActivity : BaseActivity() {
3436
}
3537
override fun onOkClicked() {
3638
Utils.setXmlStringValue(this@PrivicyDialogActivity, CommonField.AGREED_RULE_FLAG, CommonField.AGREED_RULE_FLAG, "1")
39+
FirebaseApp.initializeApp(applicationContext)
3740
FirebaseAnalytics.getInstance(this@PrivicyDialogActivity).setAnalyticsCollectionEnabled(true)
3841
finish()
3942
App.toLogin()

app/src/main/java/com/tencent/iot/explorer/link/mvp/model/ControlPanelModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class ControlPanelModel(view: ControlPanelView) : ParentModel<ControlPanelView>(
177177
if (value == "1") { //并且状态值为1,代表应用正在call设备
178178
TRTCUIManager.getInstance().callingDeviceId = "$productId/$deviceName" //保存下设备id(productId/deviceName)
179179
val userId = SharePreferenceUtil.getString(App.activity, App.CONFIG, CommonField.USER_ID)
180-
val agent = "android/1.4.0 (Android" + Build.VERSION.SDK_INT + ";" + Build.BRAND + " " + Build.MODEL + ";" + Locale.getDefault().language + "-" + Locale.getDefault().country + ")"
180+
val agent = "android/1.4.0 (Android" + Build.VERSION.SDK_INT + ";" + App.mobileBrand + " " + App.mobileModel + ";" + Locale.getDefault().language + "-" + Locale.getDefault().country + ")"
181181
data = "{\"$id\":$value, \"$USERID\":\"$userId\", \"${MessageConst.AGENT}\":\"$agent\", \"${MessageConst.TRTC_CALLEDID}\":\"$deviceId\", \"${MessageConst.TRTC_CALLERID}\":\"$userId\"}"
182182

183183
}

sdkdemo/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ dependencies {
121121
implementation 'com.google.firebase:firebase-analytics-ktx:20.0.2'
122122

123123
// Add the Firebase Crashlytics SDK.
124-
implementation 'com.google.firebase:firebase-crashlytics:18.2.6'
124+
implementation 'com.google.firebase:firebase-crashlytics:18.2.7'
125125

126126
// implementation 'com.google.firebase:firebase-perf:19.0.7'
127127
implementation 'com.alibaba:fastjson:1.2.73'

0 commit comments

Comments
 (0)