Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_vedio
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
android
android_vedio
Commits
472989d0
Commit
472989d0
authored
Nov 13, 2024
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加引力sdk
parent
d63ef004
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
278 additions
and
193 deletions
+278
-193
build.gradle
video/app/build.gradle
+10
-8
MintsApplication.java
...c/main/java/com/duben/happyplayletu/MintsApplication.java
+3
-1
CsjAppLogManager.kt
.../java/com/duben/happyplayletu/manager/CsjAppLogManager.kt
+184
-184
GravityEngineManager.kt
...a/com/duben/happyplayletu/manager/GravityEngineManager.kt
+65
-0
build.gradle
video/build.gradle
+16
-0
No files found.
video/app/build.gradle
View file @
472989d0
...
...
@@ -10,8 +10,8 @@ android {
applicationId
"com.duben.happyplayletu"
minSdkVersion
rootProject
.
ext
.
androidMinSdkVersion
targetSdkVersion
rootProject
.
ext
.
androidTargetSdkVersion
versionCode
72
1
versionName
"7.2.
1
"
versionCode
72
2
versionName
"7.2.
2
"
flavorDimensions
"default"
// dex突破65535的限制
...
...
@@ -223,16 +223,18 @@ dependencies {
// 穿山甲聚合 接入【穿山甲、快手】
implementation
"com.pangle.cn:mediation-sdk:6.4.1.5"
// 穿山甲Applog 上报组件(必须)
implementation
'com.bytedance.applog:RangersAppLog-Lite-cn:6.16.3'
// 穿山甲商业化转化组件(必须)
implementation
'com.bytedance.ads:AppConvert:1.3.0.5'
//埋点开发工具,DevTools是 Debug 环境下辅助开发者或测试人员进行应用内埋点验证和 SDK 接入问题排查的组件。请使用 debug 依赖,建议仅在 debug 下做调试
// debugImplementation 'com.bytedance.applog:RangersAppLog-DevTools:3.3.4'
// // 穿山甲Applog 上报组件(必须)
// implementation 'com.bytedance.applog:RangersAppLog-Lite-cn:6.16.3'
// // 穿山甲商业化转化组件(必须)
// implementation 'com.bytedance.ads:AppConvert:1.3.0.5'
// 腾讯播放器
implementation
"com.tencent.liteav:LiteAVSDK_Player:11.3.0.13176"
// 引力引擎 SDK
implementation
"cn.gravity.android:GravityEngineSDK:4.8.11"
testImplementation
'junit:junit:4.13.2'
androidTestImplementation
'androidx.test.ext:junit:1.1.3'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.4.0'
...
...
video/app/src/main/java/com/duben/happyplayletu/MintsApplication.java
View file @
472989d0
...
...
@@ -12,6 +12,7 @@ import com.downloader.PRDownloaderConfig;
import
com.duben.happyplayletu.ad.TTAdManagerHolder
;
import
com.duben.happyplayletu.common.Constant
;
import
com.duben.happyplayletu.manager.CsjAppLogManager
;
import
com.duben.happyplayletu.manager.GravityEngineManager
;
import
com.duben.happyplayletu.manager.TXCSDKService
;
import
com.duben.happyplayletu.manager.TalkingDataManager
;
import
com.duben.happyplayletu.net.LoanService
;
...
...
@@ -82,7 +83,8 @@ public class MintsApplication extends MultiDexApplication {
TXCSDKService
.
init
(
this
);
CsjAppLogManager
.
INSTANCE
.
init
(
this
);
// CsjAppLogManager.INSTANCE.init(this);
GravityEngineManager
.
INSTANCE
.
initGravityEngine
(
this
);
TalkingDataManager
.
INSTANCE
.
init
(
this
);
...
...
video/app/src/main/java/com/duben/happyplayletu/manager/CsjAppLogManager.kt
View file @
472989d0
package
com.duben.happyplayletu.manager
import
android.app.Application
import
android.text.TextUtils
import
com.bytedance.ads.convert.BDConvert
import
com.bytedance.applog.AppLog
import
com.bytedance.applog.IDataObserver
import
com.bytedance.applog.InitConfig
import
com.bytedance.applog.util.UriConstants
import
com.bytedance.hume.readapk.HumeSDK
import
com.duben.happyplayletu.BuildConfig
import
com.duben.happyplayletu.MintsApplication
import
com.duben.happyplayletu.utils.LogUtil
import
com.duben.happyplayletu.utils.MateUtils.getAppMetaData
import
org.json.JSONObject
/**
* CsjAppLogManager
*/
object
CsjAppLogManager
{
// 获取方式,穿山甲平台-Adspark-免费广告监测-应用管理创建
const
val
APP_LOG_ID
=
"643002"
fun
init
(
application
:
Application
)
{
// 第一个参数APPID: 参考2.1节获取
// 第二个参数CHANNEL: 填写渠道信息,请注意不能为空
val
config
=
InitConfig
(
APP_LOG_ID
,
createChannel
())
// 设置数据上送地址
config
.
setUriConfig
(
UriConstants
.
DEFAULT
)
config
.
isImeiEnable
=
false
//建议关停获取IMEI(出于合规考虑)
config
.
isAutoTrackEnabled
=
false
// 全埋点开关,true开启,false关闭
config
.
isLogEnable
=
BuildConfig
.
LOG_DEBUG
// true:开启日志,参考4.3节设置logger,false:关闭日志
AppLog
.
setEncryptAndCompress
(
true
)
// 加密开关,true开启,false关闭
config
.
setEnablePlay
(
true
)
// 配置心跳事件(时长统计)
/**
* 用于获取用户唯一性bd_did
* @description
*/
AppLog
.
addDataObserver
(
object
:
IDataObserver
{
/**
* 本地的id数据加载结果通知
* @param did device id
* @param iid install id
* @param ssid ssid
*/
override
fun
onIdLoaded
(
s
:
String
,
s1
:
String
,
s2
:
String
)
{}
/**
* 通知注册结果,以及id变化情况
* 仅主进程会被调用
* @param changed 是否和本地缓存有所不同
* @param oldDid 原device id
* @param newDid server返回新的device id
* @param oldIid 原install id
* @param newIid server返回新install id
* @param oldSsid 原ssid
* @param newSsid server返回新ssid
*/
override
fun
onRemoteIdGet
(
b
:
Boolean
,
s
:
String
?,
s1
:
String
,
s2
:
String
,
s3
:
String
,
s4
:
String
,
s5
:
String
)
{
val
bd_did
=
AppLog
.
getDid
()
LogUtil
.
d
(
"mcg --> 用户唯一性bd_did="
+
bd_did
)
}
/**
* Config拉取数据,和本地数据对比有变化的通知
* 仅主进程会被调用
* @param changed 是否和本地缓存有所不同
* @param config server返回新config内容
*/
override
fun
onRemoteConfigGet
(
b
:
Boolean
,
jsonObject
:
JSONObject
?)
{}
/**
* server拉取AbConfig数据,和本地数据对比有变化的通知
* 仅主进程会被调用
* @param changed 是否和本地缓存有所不同
* @param abConfig server返回新abConfig内容
*/
override
fun
onRemoteAbConfigGet
(
b
:
Boolean
,
jsonObject
:
JSONObject
)
{
LogUtil
.
d
(
"mcg -->---测试---返回全部进组信息"
,
""
+
jsonObject
.
toString
())
}
/**
* Vid变化通知
*/
override
fun
onAbVidsChange
(
s
:
String
,
s1
:
String
)
{}
})
//SDK会采集OAID、ANDROID_ID和其他的设备特征字段,请遵循相关合规要求在隐私弹窗后采集
//传入需要init的AppLog实例,若没有多个AppLog实例,则传入AppLog.getInstance()即可
BDConvert
.
getInstance
().
init
(
application
,
AppLog
.
getInstance
())
// 如果在 onCreate 阶段初始化拿不到 XXXActivity 则不需要传递第三个参数
AppLog
.
init
(
application
,
config
)
// 请在用户授权后调用如下方法,start 开始实际采集用户信息+上报:
AppLog
.
start
()
// 在初始化后必须设置AppLog.setHeaderInfo("csj_attribution",1),否则会直接影响归因结果。
AppLog
.
setHeaderInfo
(
"csj_attribution"
,
1
)
}
/**
* 创建渠道
*
* @return
*/
private
fun
createChannel
():
String
{
var
channel
=
getAppMetaData
(
MintsApplication
.
getContext
(),
"CHANNEL_NAME"
)
try
{
// 穿山甲分包渠道
val
ttChannel
=
HumeSDK
.
getChannel
(
MintsApplication
.
getContext
())
if
(!
TextUtils
.
isEmpty
(
ttChannel
))
{
// 此处方式不能修改,已和后端约定
channel
=
channel
+
"_"
+
ttChannel
}
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
return
channel
}
object
GrownEventType
{
//注册
const
val
REGISTER
=
"grown_attribution_event_register"
//付费
const
val
PURCHASE
=
"grown_attribution_event_purchase"
//关键行为
const
val
KEY_BEHAVIOR
=
"grown_attribution_event_key_behavior"
//下单
const
val
ORDER
=
"grown_attribution_event_order"
//下载
const
val
DOWNLOAD
=
"grown_attribution_event_download"
//应用内拉起
const
val
DEEPLINK
=
"grown_attribution_event_deelink"
//授权
const
val
AUTHORIZATION
=
"grown_attribution_event_authorization"
//广告变现
const
val
AD_PURCHASE
=
"grown_attribution_event_ad_purchase"
//次留
const
val
RETENTION_2D
=
"grown_attribution_event_retention_2d"
//添加购物车
const
val
ADD_TO_CART
=
"grown_attribution_event_add_to_cart"
//表单提交
const
val
FORM_SUBMIT
=
"grown_attribution_event_form_submit"
//拉活
const
val
APP_RE_ACTIVE_WAKE_UP
=
"grown_attribution_event_app_re_active_wake_up"
//自定义激活
const
val
CUSTOM_ACTIVITION
=
"grown_attribution_event_custom_activition"
//自定义注册
const
val
CUSTOM_REGISTER
=
"grown_attribution_event_custom_register"
}
fun
event
(
v
:
String
)
{
//方式一,穿山甲
AppLog
.
onEventV3
(
v
)
// //方式二,自定义
// val paramsObj = JSONObject()
//package com.duben.happyplayletu.manager
//
//import android.app.Application
//import android.text.TextUtils
//import com.bytedance.ads.convert.BDConvert
//import com.bytedance.applog.AppLog
//import com.bytedance.applog.IDataObserver
//import com.bytedance.applog.InitConfig
//import com.bytedance.applog.util.UriConstants
//import com.bytedance.hume.readapk.HumeSDK
//import com.duben.happyplayletu.BuildConfig
//import com.duben.happyplayletu.MintsApplication
//import com.duben.happyplayletu.utils.LogUtil
//import com.duben.happyplayletu.utils.MateUtils.getAppMetaData
//import org.json.JSONObject
//
//
///**
// * CsjAppLogManager
// */
//object CsjAppLogManager {
//
// // 获取方式,穿山甲平台-Adspark-免费广告监测-应用管理创建
// const val APP_LOG_ID = "643002"
//
// fun init(application: Application) {
// // 第一个参数APPID: 参考2.1节获取
// // 第二个参数CHANNEL: 填写渠道信息,请注意不能为空
// val config = InitConfig(APP_LOG_ID, createChannel())
// // 设置数据上送地址
// config.setUriConfig(UriConstants.DEFAULT)
// config.isImeiEnable = false //建议关停获取IMEI(出于合规考虑)
// config.isAutoTrackEnabled = false // 全埋点开关,true开启,false关闭
// config.isLogEnable = BuildConfig.LOG_DEBUG // true:开启日志,参考4.3节设置logger,false:关闭日志
// AppLog.setEncryptAndCompress(true) // 加密开关,true开启,false关闭
// config.setEnablePlay(true) // 配置心跳事件(时长统计)
// /**
// * 用于获取用户唯一性bd_did
// * @description
// */
// AppLog.addDataObserver(object : IDataObserver {
// /**
// * 本地的id数据加载结果通知
// * @param did device id
// * @param iid install id
// * @param ssid ssid
// */
// override fun onIdLoaded(s: String, s1: String, s2: String) {}
//
// /**
// * 通知注册结果,以及id变化情况
// * 仅主进程会被调用
// * @param changed 是否和本地缓存有所不同
// * @param oldDid 原device id
// * @param newDid server返回新的device id
// * @param oldIid 原install id
// * @param newIid server返回新install id
// * @param oldSsid 原ssid
// * @param newSsid server返回新ssid
// */
// override fun onRemoteIdGet(
// b: Boolean,
// s: String?,
// s1: String,
// s2: String,
// s3: String,
// s4: String,
// s5: String
// ) {
// val bd_did = AppLog.getDid()
// LogUtil.d("mcg --> 用户唯一性bd_did=" + bd_did)
// }
//
// /**
// * Config拉取数据,和本地数据对比有变化的通知
// * 仅主进程会被调用
// * @param changed 是否和本地缓存有所不同
// * @param config server返回新config内容
// */
// override fun onRemoteConfigGet(b: Boolean, jsonObject: JSONObject?) {}
//
// /**
// * server拉取AbConfig数据,和本地数据对比有变化的通知
// * 仅主进程会被调用
// * @param changed 是否和本地缓存有所不同
// * @param abConfig server返回新abConfig内容
// */
// override fun onRemoteAbConfigGet(b: Boolean, jsonObject: JSONObject) {
// LogUtil.d("mcg -->---测试---返回全部进组信息", "" + jsonObject.toString())
// }
//
// /**
// * Vid变化通知
// */
// override fun onAbVidsChange(s: String, s1: String) {}
// })
// //SDK会采集OAID、ANDROID_ID和其他的设备特征字段,请遵循相关合规要求在隐私弹窗后采集
// //传入需要init的AppLog实例,若没有多个AppLog实例,则传入AppLog.getInstance()即可
// BDConvert.getInstance().init(application, AppLog.getInstance())
// // 如果在 onCreate 阶段初始化拿不到 XXXActivity 则不需要传递第三个参数
// AppLog.init(application, config)
// // 请在用户授权后调用如下方法,start 开始实际采集用户信息+上报:
// AppLog.start()
// // 在初始化后必须设置AppLog.setHeaderInfo("csj_attribution",1),否则会直接影响归因结果。
// AppLog.setHeaderInfo("csj_attribution", 1)
// }
//
//
// /**
// * 创建渠道
// *
// * @return
// */
// private fun createChannel(): String {
// var channel = getAppMetaData(MintsApplication.getContext(), "CHANNEL_NAME")
// try {
// paramsObj.put("key_string", "value_string")
// paramsObj.put("key_int", 10)
// // 穿山甲分包渠道
// val ttChannel = HumeSDK.getChannel(MintsApplication.getContext())
// if (!TextUtils.isEmpty(ttChannel)) {
// // 此处方式不能修改,已和后端约定
// channel = channel + "_" + ttChannel
// }
// } catch (e: Exception) {
// e.printStackTrace()
// }
// AppLog.onEventV3(GrownEventType.PURCHASE, paramsObj)
}
}
\ No newline at end of file
// return channel
// }
//
//
// object GrownEventType {
// //注册
// const val REGISTER = "grown_attribution_event_register"
//
// //付费
// const val PURCHASE = "grown_attribution_event_purchase"
//
// //关键行为
// const val KEY_BEHAVIOR = "grown_attribution_event_key_behavior"
//
// //下单
// const val ORDER = "grown_attribution_event_order"
//
// //下载
// const val DOWNLOAD = "grown_attribution_event_download"
//
// //应用内拉起
// const val DEEPLINK = "grown_attribution_event_deelink"
//
// //授权
// const val AUTHORIZATION = "grown_attribution_event_authorization"
//
// //广告变现
// const val AD_PURCHASE = "grown_attribution_event_ad_purchase"
//
// //次留
// const val RETENTION_2D = "grown_attribution_event_retention_2d"
//
// //添加购物车
// const val ADD_TO_CART = "grown_attribution_event_add_to_cart"
//
// //表单提交
// const val FORM_SUBMIT = "grown_attribution_event_form_submit"
//
// //拉活
// const val APP_RE_ACTIVE_WAKE_UP = "grown_attribution_event_app_re_active_wake_up"
//
// //自定义激活
// const val CUSTOM_ACTIVITION = "grown_attribution_event_custom_activition"
//
// //自定义注册
// const val CUSTOM_REGISTER = "grown_attribution_event_custom_register"
// }
//
// fun event(v: String) {
// //方式一,穿山甲
// AppLog.onEventV3(v)
//
//// //方式二,自定义
//// val paramsObj = JSONObject()
//// try {
//// paramsObj.put("key_string", "value_string")
//// paramsObj.put("key_int", 10)
//// } catch (e: Exception) {
//// e.printStackTrace()
//// }
//// AppLog.onEventV3(GrownEventType.PURCHASE, paramsObj)
// }
//}
\ No newline at end of file
video/app/src/main/java/com/duben/happyplayletu/manager/GravityEngineManager.kt
0 → 100644
View file @
472989d0
package
com.duben.happyplayletu.manager
import
android.app.Application
import
cn.gravity.android.GEConfig
import
cn.gravity.android.GravityEngineSDK
import
cn.gravity.android.InitializeCallback
import
com.duben.happyplayletu.MintsApplication
import
com.duben.happyplayletu.utils.DeviceUuidFactory
import
com.duben.happyplayletu.utils.LogUtil
import
com.duben.happyplayletu.utils.MateUtils.getAppMetaData
import
com.duben.library.utils.json.JsonUtil
import
org.json.JSONObject
/**
* 描述:引力引擎SDK
* 作者:孟崔广
*/
object
GravityEngineManager
{
private
const
val
ACCESS_TOKEN
=
"T9ycxLEd4outVfGnr2cmpFhpuizklKqA"
private
const
val
ENABLE_SYNC_ATTRIBUTION
=
false
/**
* 初始化
*
* ACCESS_TOKEN : 项目通行证,同启动 SDK 时保持一致
USER_CLIENT_ID : 用户唯一 ID(例如 UID 或者设备 ID)
USER_CLIENT_NAME : 用户昵称
CHANNEL : 用户初始化渠道(例如 xiaomi、huawei 等)
ENABLE_SYNC_ATTRIBUTION : 是否开启同步获取归因信息,具体请参考同步归因
*/
fun
initGravityEngine
(
application
:
Application
)
{
try
{
// 在主线程中配置并启动SDK
val
config
:
GEConfig
=
GEConfig
.
getInstance
(
application
,
ACCESS_TOKEN
)
// 保存此实例,后续调用方法均需要用到
val
gravityEngineSDKInstance
=
GravityEngineSDK
.
setupAndStart
(
config
)
val
channel
=
getAppMetaData
(
MintsApplication
.
getContext
(),
"CHANNEL_NAME"
)
gravityEngineSDKInstance
.
initialize
(
ACCESS_TOKEN
,
DeviceUuidFactory
().
deviceUuid
.
toString
(),
DeviceUuidFactory
().
deviceUuid
.
toString
(),
channel
,
object
:
InitializeCallback
{
override
fun
onFailed
(
errorMsg
:
String
,
initializeBody
:
JSONObject
?)
{
LogUtil
.
d
(
"mcg --> gravityEngineSDKInstance onFailed="
+
errorMsg
)
}
override
fun
onSuccess
(
responseJson
:
JSONObject
?,
initializeBody
:
JSONObject
?)
{
LogUtil
.
d
(
"mcg --> gravityEngineSDKInstance onSuccess="
+
JsonUtil
.
toJson
(
responseJson
)
)
}
},
ENABLE_SYNC_ATTRIBUTION
)
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
}
}
\ No newline at end of file
video/build.gradle
View file @
472989d0
...
...
@@ -17,6 +17,14 @@ buildscript {
url
"https://artifact.bytedance.com/repository/pangle"
}
// 引力引擎 SDK
maven
{
url
'https://nexus.gravity-engine.com/repository/maven-releases/'
}
maven
{
url
'https://nexus.gravity-engine.com/repository/maven-snapshots/'
}
}
dependencies
{
classpath
'com.android.tools.build:gradle:7.1.1'
...
...
@@ -40,6 +48,14 @@ allprojects {
maven
{
url
"https://artifact.bytedance.com/repository/pangle"
}
// 引力引擎 SDK
maven
{
url
'https://nexus.gravity-engine.com/repository/maven-releases/'
}
maven
{
url
'https://nexus.gravity-engine.com/repository/maven-snapshots/'
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment