Commit 6a25763a authored by mengcuiguang2's avatar mengcuiguang2

修改反策略方式

parent d1855fd2
......@@ -4,8 +4,11 @@ import android.content.Context
import android.content.Intent
import android.content.pm.ApplicationInfo
import android.content.pm.PackageInfo
import android.text.format.DateUtils
import com.mints.flowbox.MintsApplication
import com.mints.flowbox.manager.AppPreferencesManager
import com.mints.flowbox.manager.TrackManager
import com.mints.flowbox.manager.wifi.WifiDataManager
import com.mints.flowbox.utils.LogUtil
import com.mints.flowbox.utils.rxutil.CommonRxTask
import com.mints.flowbox.utils.rxutil.RxjavaUtil
......@@ -24,32 +27,36 @@ class AntiAuditManager private constructor() {
companion object {
private const val ONE_DAY = 60 * 1000 * 60 * 24
private const val ONE_DAY = 60 * 1000 * 60 * 24// 一天
private const val N = 12 // (阈值)
const val APP_OUT_BLACK = "APP_OUT_BLACK"
const val TODAY_INSTALL_APK_COUNT = "TODAY_INSTALL_APK_COUNT"
const val APP_OUT_BLACK = "APP_OUT_BLACK" // 是否永久黑名单
const val TODAY_INSTALL_APK_COUNT = "TODAY_INSTALL_APK_COUNT"// 安装个数
val instance: AntiAuditManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
AntiAuditManager()
}
private var todayInstallApkCount = -1
}
val sp by lazy { AppPreferencesManager.get() }
/**
* 更新新安装的apk个数
*/
fun updateInstallApkCount() {
if (todayInstallApkCount == -1) {
todayInstallApkCount = sp.getInt(TODAY_INSTALL_APK_COUNT, 0)
}
todayInstallApkCount++
if (todayInstallApkCount >= N) {
val count = sp.getInt(TODAY_INSTALL_APK_COUNT, 0)
val sumCount = count + 1
sp.put(TODAY_INSTALL_APK_COUNT,sumCount)
if (sumCount >= N) {
sp.put(APP_OUT_BLACK, true)
}
}
/**
* 获取所有以安装列表,除系统应用,归类到自然日
*/
fun antiAudit() {
RxjavaUtil.executeRxTask(object : CommonRxTask<Boolean>() {
override fun doInIOThread() {
......@@ -130,8 +137,8 @@ class AntiAuditManager private constructor() {
}
}
}
sp.put(TODAY_INSTALL_APK_COUNT, onedayItems.size)
val localApkCount = sp.getInt(TODAY_INSTALL_APK_COUNT, 0)
sp.put(TODAY_INSTALL_APK_COUNT, if(localApkCount>onedayItems.size) localApkCount else onedayItems.size)
LogUtil.d(TAG, "ThreeDay -> $threedayItems")
LogUtil.d(TAG, "TwoDay -> $twodayItems")
......@@ -139,5 +146,4 @@ class AntiAuditManager private constructor() {
return onedayItems.size >= N && twodayItems.size >= N && threedayItems.size >= N
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment