新增设置日志上传周期,默认是一天传一次
This commit is contained in:
parent
71c6f658fd
commit
057c386556
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="1.8" />
|
||||
<bytecodeTargetLevel target="11" />
|
||||
</component>
|
||||
</project>
|
|
@ -9,7 +9,7 @@
|
|||
</map>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -60,6 +60,7 @@ android {
|
|||
26.3.9.96 播放时长为广告素材的播放时长
|
||||
26.3.9.98 记录taxiApp当天的运行时间
|
||||
26.3.9.99 优化日志上传,改为一天只传一次昨天的播放记录。
|
||||
优化定点广告频繁切换会出现黑屏问题
|
||||
**/
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
|
|
@ -418,6 +418,18 @@ public class Configurations {
|
|||
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putLong("firstRunTime", runTime).apply();
|
||||
}
|
||||
|
||||
/**
|
||||
* 日志概要上传的周期,默认一天传一次,单位分钟
|
||||
* @return
|
||||
*/
|
||||
public int logInterval(){
|
||||
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getInt("logInterval", 0);
|
||||
}
|
||||
|
||||
public void logIntervalSave(int x){
|
||||
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putInt("screenSizeX", x).apply();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -68,6 +68,8 @@ class TaxiApp:Application() {
|
|||
var gpsTimer: Timer? = null
|
||||
//播放日志定时器
|
||||
var playerLogTimer: Timer? = null
|
||||
//播放日志摘要定时器
|
||||
var playerLogSummaryTimer: Timer? = null
|
||||
|
||||
var testCount = 0
|
||||
val TAG = "TaxiApp"
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package cn.trans88.taxiappkotlin.logic.model;
|
||||
|
||||
/**
|
||||
* @Author: LJH
|
||||
* @Time: 2023/12/13
|
||||
* @description:
|
||||
*/
|
||||
public class LogInterval {
|
||||
|
||||
private String id;
|
||||
private String task_id;
|
||||
private int interval;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTask_id() {
|
||||
return task_id;
|
||||
}
|
||||
|
||||
public void setTask_id(String task_id) {
|
||||
this.task_id = task_id;
|
||||
}
|
||||
|
||||
public int getInterval() {
|
||||
return interval;
|
||||
}
|
||||
|
||||
public void setInterval(int interval) {
|
||||
this.interval = interval;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package cn.trans88.taxiappkotlin.logic.model;
|
||||
|
||||
/**
|
||||
* @Author: LJH
|
||||
* @Time: 2023/12/13
|
||||
* @description:
|
||||
*/
|
||||
public class LogIntervalResponse extends SanleResponse{
|
||||
|
||||
private int interval;
|
||||
|
||||
public int getInterval() {
|
||||
return interval;
|
||||
}
|
||||
|
||||
public void setInterval(int interval) {
|
||||
this.interval = interval;
|
||||
}
|
||||
}
|
|
@ -730,6 +730,7 @@ object ConnManger {
|
|||
it.cancel()
|
||||
it.purge()
|
||||
}
|
||||
logsSummaryTimer = null
|
||||
logsSummaryTimer = Timer()
|
||||
logsSummaryTimer?.schedule(object :TimerTask(){
|
||||
override fun run() {
|
||||
|
@ -750,6 +751,7 @@ object ConnManger {
|
|||
it.cancel()
|
||||
it.purge()
|
||||
}
|
||||
logsSummaryTimer = null
|
||||
logsSummaryTimer = Timer()
|
||||
logsSummaryTimer?.schedule(object :TimerTask(){
|
||||
override fun run() {
|
||||
|
@ -784,7 +786,7 @@ object ConnManger {
|
|||
logsGroup.keys.forEach {
|
||||
val adId = it
|
||||
logsGroup.get(it)?.let { playLoggers ->
|
||||
val beginPlayTime = playLoggers.map { it.begin_play_ts }.min() ?: 0L
|
||||
val beginPlayTime = playLoggers.map { it.begin_play_ts }.filter { it > 1702192270 }.min() ?: 0L
|
||||
val endPlayTime = playLoggers.map { it.end_play_ts }.max() ?: 0L
|
||||
val playNums = playLoggers.size
|
||||
val playLogger = playLoggers.get(0)
|
||||
|
@ -890,6 +892,28 @@ object ConnManger {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时发送播放日志摘要
|
||||
*/
|
||||
fun sendLogSummaryByInterval(interval:Int) {
|
||||
taxiApp.playerLogSummaryTimer?.let {
|
||||
it.cancel()
|
||||
it.purge()
|
||||
}
|
||||
//if (Settings.loggerSwitch) {
|
||||
taxiApp.playerLogSummaryTimer = Timer()
|
||||
taxiApp.playerLogSummaryTimer?.schedule(object :TimerTask(){
|
||||
override fun run() {
|
||||
val playLoggers = DaoUtil.getPlayLoggers()
|
||||
"定时上传日志摘要,playLoggers size: ${playLoggers.size}".logd()
|
||||
val requestJson = getLogSummaryJson(playLoggers)
|
||||
if (requestJson.isNotEmpty() && logsSummaryTimer == null){
|
||||
sendLogsSummaryToWeb(requestJson)
|
||||
}
|
||||
}
|
||||
},interval*60*1000L,interval*60*1000L)
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送运行日志
|
||||
*/
|
||||
|
|
|
@ -84,6 +84,9 @@ object ProcessingCommands {
|
|||
"update_gps_log_switch" -> gpsSwitch(task,baseTask.type)
|
||||
//获取播放日志开关状态
|
||||
"get_player_log_state" -> getLoggerSwitch(task,baseTask.type)
|
||||
//设置日志上传间隔
|
||||
"set_log_interval" -> setLogInterval(task,baseTask.type)
|
||||
"get_log_interval" -> getLogInterval(task,baseTask.type)
|
||||
//获取gps日志开关状态
|
||||
"get_gps_state" -> getGpsSwitch(task,baseTask.type)
|
||||
"get_today_runtime" -> getTodayRuntime(task,baseTask.type)
|
||||
|
@ -176,6 +179,26 @@ object ProcessingCommands {
|
|||
sanleResponse.turn_on = turn_on
|
||||
val response = gson.toJson(sanleResponse)
|
||||
send(response)
|
||||
|
||||
//测试日志上传
|
||||
ConnManger.sendLogsSummary()
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取日志上传间隔
|
||||
*/
|
||||
private fun getLogInterval(task: String, type: String) {
|
||||
val baseResponse = gson.fromJson<BaseResponse>(task)
|
||||
val intervalResponse = LogIntervalResponse()
|
||||
val interval = Configurations.config(TaxiApp.instance()).logInterval()
|
||||
"getLogInterval-->日志上传间隔:$interval".logd()
|
||||
|
||||
intervalResponse.type = type
|
||||
intervalResponse.id = baseResponse.id
|
||||
intervalResponse.task_id = baseResponse.task_id
|
||||
intervalResponse.interval = interval
|
||||
val response = gson.toJson(intervalResponse)
|
||||
send(response)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -195,24 +218,24 @@ object ProcessingCommands {
|
|||
send(response)
|
||||
|
||||
//debug
|
||||
val lat2 = 22.665534200203726
|
||||
val lon2 = 113.91975187778473
|
||||
val lat3 = 23.665534200203726
|
||||
val lon3 = 114.91975187778473
|
||||
var isRun = true
|
||||
Timer().schedule(object :TimerTask(){
|
||||
override fun run() {
|
||||
if (isRun){
|
||||
"进圈".loge()
|
||||
taxiApp.activity?.getViewModel()?.onLocationChanged(lon2,lat2,2.0f,66.0f,1)
|
||||
isRun = false
|
||||
} else {
|
||||
"出圈".loge()
|
||||
taxiApp.activity?.getViewModel()?.onLocationChanged(lon3,lat3,2.0f,66.0f,1)
|
||||
isRun = true
|
||||
}
|
||||
}
|
||||
},0,3000L)
|
||||
// val lat2 = 22.665534200203726
|
||||
// val lon2 = 113.91975187778473
|
||||
// val lat3 = 23.665534200203726
|
||||
// val lon3 = 114.91975187778473
|
||||
// var isRun = true
|
||||
// Timer().schedule(object :TimerTask(){
|
||||
// override fun run() {
|
||||
// if (isRun){
|
||||
// "进圈".loge()
|
||||
// taxiApp.activity?.getViewModel()?.onLocationChanged(lon2,lat2,2.0f,66.0f,1)
|
||||
// isRun = false
|
||||
// } else {
|
||||
// "出圈".loge()
|
||||
// taxiApp.activity?.getViewModel()?.onLocationChanged(lon3,lat3,2.0f,66.0f,1)
|
||||
// isRun = true
|
||||
// }
|
||||
// }
|
||||
// },0,3000L)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -257,6 +280,25 @@ object ProcessingCommands {
|
|||
send(response)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置日志上传周期
|
||||
*/
|
||||
private fun setLogInterval(task: String, type: String) {
|
||||
val baseResponse = gson.fromJson<BaseResponse>(task)
|
||||
val loggerInterval = gson.fromJson<LogInterval>(task)
|
||||
"设置上传日志周期:${loggerInterval.interval}".logd()
|
||||
//edit by yzd @20211201
|
||||
//Settings.loggerSwitch = loggerSwitch.isTurn_on
|
||||
Configurations.config(TaxiApp.instance()).loggerSwitchSave(true)
|
||||
if (loggerInterval.interval>0){
|
||||
ConnManger.sendLogSummaryByInterval(loggerInterval.interval)
|
||||
}
|
||||
|
||||
baseResponse.type = type
|
||||
val response = gson.toJson(baseResponse)
|
||||
send(response)
|
||||
}
|
||||
|
||||
/**
|
||||
* 心跳应答检测
|
||||
*/
|
||||
|
@ -385,33 +427,6 @@ object ProcessingCommands {
|
|||
private fun clearAdvertiseOrder(task: String, type: String?) {
|
||||
val advertiseOrder = gson.fromJson<AdvertiseOrder>(task)
|
||||
"clearAdvertiseOrder".logd()
|
||||
//日志存卡里
|
||||
// taxiApp.saveLog("收到了清空排序指令...")
|
||||
//Settings.advertiseOrder = ""
|
||||
//edit by ljh @2023/8/9/1
|
||||
//三分钟内收到两次清除排序才会清除排序,防止排序被清除
|
||||
// taxiApp.isDoubleClearOrder += 1
|
||||
// if(taxiApp.isDoubleClearOrder < 2){
|
||||
// "没有点击两次清空排序,开始计时三分钟".logd()
|
||||
// taxiApp.clearOrderTimer.schedule(object :TimerTask(){
|
||||
// override fun run() {
|
||||
// try {
|
||||
// taxiApp.isDoubleClearOrder = 0
|
||||
// "三分钟时间到,isDoubleClearOrder重置".logd()
|
||||
// } catch (e:java.lang.Exception){
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// }
|
||||
// },3*60*1000L)
|
||||
// } else {
|
||||
// "点击了两次清空排序,取消三分钟计时并清空排序".logd()
|
||||
// taxiApp.clearOrderTimer.cancel()
|
||||
// taxiApp.clearOrderTimer.purge()
|
||||
// taxiApp.clearOrderTimer = Timer()
|
||||
// Configurations.config(TaxiApp.instance()).advertiseOrderSave("")
|
||||
// taxiApp.isDoubleClearOrder = 0
|
||||
// RefreshPlayer.refresh()
|
||||
// }
|
||||
|
||||
//edit by ljh @2023/8/22
|
||||
// taxiApp.saveLog("clearAdvertiseOrder,清除了广告排序")
|
||||
|
@ -427,7 +442,6 @@ object ProcessingCommands {
|
|||
|
||||
RefreshPlayer.refresh()
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -214,6 +214,7 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen
|
|||
configurations.logSummaryJsonStringSave("")
|
||||
Thread(Runnable { clearOverdueLogger() }).start()
|
||||
isSendedLog = false
|
||||
sendLogInterval()
|
||||
"startRunTime,endRunTime初始化为:$currentTime".loge()
|
||||
configurations.startRunTimeSave(currentTime)
|
||||
configurations.endRunTimeSave(currentTime)
|
||||
|
@ -223,16 +224,18 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen
|
|||
startRuntimeTimer()
|
||||
}
|
||||
DayType.IS_SAME_DAY.ordinal -> {//同一天重启
|
||||
//测试日志上传
|
||||
ConnManger.sendLogsSummary()
|
||||
|
||||
isSendedLog = false
|
||||
// val logSummaryJson = configurations.logSummaryJsonString()
|
||||
// if (!logSummaryJson.isNullOrEmpty()){
|
||||
// "同一天重启,之前的日志数据没传,重新上传".loge()
|
||||
// ConnManger.sendLogsSummary()
|
||||
// } else {
|
||||
// isSendedLog = false
|
||||
// }
|
||||
val logSummaryJson = configurations.logSummaryJsonString()
|
||||
if (!logSummaryJson.isNullOrEmpty()){
|
||||
"同一天重启,之前的日志数据没传,重新上传".loge()
|
||||
ConnManger.sendLogsSummary()
|
||||
} else {
|
||||
isSendedLog = false
|
||||
}
|
||||
|
||||
sendLogInterval()
|
||||
|
||||
//先计算上次重启前的运行时间
|
||||
val lastSumTime = configurations.sumRunTime()
|
||||
val lastStartRuntime = configurations.startRunTime()
|
||||
|
@ -258,7 +261,7 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen
|
|||
}
|
||||
DayType.IS_SECOND_DAY.ordinal -> {
|
||||
ConnManger.sendLogsSummary()
|
||||
|
||||
sendLogInterval()
|
||||
//先计算上次重启前的运行时间
|
||||
val lastSumTime = configurations.sumRunTime()
|
||||
val lastStartRuntime = configurations.startRunTime()
|
||||
|
@ -285,6 +288,7 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen
|
|||
configurations.endRunTimeSave(currentTime)
|
||||
configurations.firstRunTimeSave(currentTime)
|
||||
configurations.sumRunTimeSave(0L)
|
||||
sendLogInterval()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -297,8 +301,17 @@ class PlayActivity : AppCompatActivity(), NetworkCallback, BusCallback, OnScreen
|
|||
},30*1000L,30*1000L)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 定时传日志摘要
|
||||
*/
|
||||
private fun sendLogInterval(){
|
||||
val logInterval = configurations.logInterval()
|
||||
"logInterval:$logInterval".logd()
|
||||
if (logInterval > 0){
|
||||
ConnManger.sendLogSummaryByInterval(logInterval)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
# Location of the SDK. This is only used by Gradle.
|
||||
# For customization when using a Version Control System, please read the
|
||||
# header note.
|
||||
#Sat Dec 02 11:15:51 GMT+08:00 2023
|
||||
#Wed Dec 13 15:22:24 GMT+08:00 2023
|
||||
sdk.dir=D\:\\Android\\sdk
|
||||
|
|
Loading…
Reference in New Issue
Block a user