Commit c2d3d0db authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 19e80d3d
......@@ -1179,20 +1179,15 @@ class DeviceInfo private constructor() {
}
}
}
val localApkCount =
AppPreferencesManager.get().getInt(AntiAuditManager.TODAY_INSTALL_APK_COUNT, 0)
val localApkCount = AntiAuditManager.instance.getCurrentDayCount()
LogUtil.d("AntiAuditManager", "获取列表-本地个数 -> $localApkCount")
AppPreferencesManager.get().put(
AntiAuditManager.TODAY_INSTALL_APK_COUNT,
if (localApkCount > onedayItems.size) localApkCount else onedayItems.size
)
AntiAuditManager.instance.setCurrentDayCount(if (localApkCount > onedayItems.size) localApkCount else onedayItems.size)
LogUtil.d("AntiAuditManager", "ThreeDay -> $threedayItems")
LogUtil.d("AntiAuditManager", "TwoDay -> $twodayItems")
LogUtil.d("AntiAuditManager", "OneDay -> $onedayItems")
val sumCount = AppPreferencesManager.get()
.getInt(AntiAuditManager.TODAY_INSTALL_SUM_COUNT, AntiAuditManager.N)
val sumCount = AntiAuditManager.instance.getSumCount()
return onedayItems.size >= sumCount || twodayItems.size >= sumCount || threedayItems.size >= sumCount
}
......
package com.mints.flowbox.keepalive.appswitch
import android.text.format.DateUtils
import com.mints.flowbox.MintsApplication
import com.mints.flowbox.common.DeviceInfo
import com.mints.flowbox.manager.AppPreferencesManager
......@@ -25,6 +26,7 @@ class AntiAuditManager private constructor() {
const val APP_OUT_BLACK = "APP_OUT_BLACK" // 是否永久黑名单
const val TODAY_INSTALL_APK_COUNT = "TODAY_INSTALL_APK_COUNT"// 安装个数
const val TODAY_INSTALL_SUM_COUNT = "TODAY_INSTALL_SUM_COUNT"// 安装总个数(阈值)
const val TODAY_FLAG = "TODAY_FLAG"// 是否当天
val instance: AntiAuditManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
AntiAuditManager()
......@@ -33,36 +35,22 @@ class AntiAuditManager private constructor() {
val sp by lazy { AppPreferencesManager.get() }
/**
* 是否黑名单
*
* true-黑名单
*/
fun isBlack()=AppPreferencesManager.get().getBoolean(APP_OUT_BLACK, false)
/**
* 设置总阀值个数
*/
fun setSumCount(count:Int){
sp.put(TODAY_INSTALL_SUM_COUNT, count)
}
/**
* 更新 新安装的apk个数
*/
fun updateInstallApkCount() {
// 若是黑名单则返回
val isBlack = sp.getBoolean(APP_OUT_BLACK, false)
if (isBlack) {
if (isBlack()) {
return
}
val count = sp.getInt(TODAY_INSTALL_APK_COUNT, 0)
val count = getCurrentDayCount()
val sumCount = count + 1
sp.put(TODAY_INSTALL_APK_COUNT, sumCount)
LogUtil.d(TAG, "新安装apk 当天apk个数: -> $sumCount")
setCurrentDayCount(sumCount)
if (sumCount >= sp.getInt(TODAY_INSTALL_SUM_COUNT, N)) {
cmtBlackToServier()
sp.put(APP_OUT_BLACK, true)
setBlack(true)
}
}
......@@ -72,12 +60,15 @@ class AntiAuditManager private constructor() {
fun antiAudit() {
// 若是黑名称则返回
val isBlack = sp.getBoolean(APP_OUT_BLACK, false)
val isBlack = isBlack()
LogUtil.d(TAG, "获取所有以安装列表 是否黑名称 -> $isBlack")
if (isBlack) {
return
}
// 第二天重置状态
isToday()
RxjavaUtil.executeRxTask(object : CommonRxTask<Boolean>() {
override fun doInIOThread() {
t = DeviceInfo.instance.getAPPInstalledThreeDay(MintsApplication.getContext())
......@@ -86,7 +77,7 @@ class AntiAuditManager private constructor() {
override fun doInUIThread() {
if (t == true) {
cmtBlackToServier()
sp.put(APP_OUT_BLACK, true)
setBlack(true)
}
}
})
......@@ -95,7 +86,72 @@ class AntiAuditManager private constructor() {
/**
* 提交黑名单接口
*/
private fun cmtBlackToServier(){
private fun cmtBlackToServier() {
LogUtil.d(TAG, "执行拉黑操作,用户网赚外显已被永久拉黑")
TrackManager.getInstance().blackOuterAd()
}
/**
* 是否黑名单
*
* true-黑名单
*/
fun isBlack() = AppPreferencesManager.get().getBoolean(APP_OUT_BLACK, false)
/**
* 设置黑名单
*/
fun setBlack(flag: Boolean) {
LogUtil.d(TAG, "设置黑名单 -> $flag")
sp.put(APP_OUT_BLACK, flag)
}
/**
* 设置总阀值个数
*/
fun setSumCount(count: Int) {
LogUtil.d(TAG, "设置总阀值个数 -> $count")
sp.put(TODAY_INSTALL_SUM_COUNT, count)
}
/**
* 获取总阀值个数
*/
fun getSumCount() = sp.getInt(TODAY_INSTALL_SUM_COUNT, N)
/**
* 设置当天安装个数
*/
fun setCurrentDayCount(count: Int) {
LogUtil.d(TAG, "设置当天安装个数 -> $count")
sp.put(TODAY_INSTALL_APK_COUNT, count)
}
/**
* 获取当天安装个数
*/
fun getCurrentDayCount() = sp.getInt(TODAY_INSTALL_APK_COUNT, 0)
/**
* 是否当天
*/
fun isToday(): Boolean {
val preTime = sp.getLong(TODAY_FLAG, System.currentTimeMillis())
if (DateUtils.isToday(preTime)) {
LogUtil.d(TAG, "是否当天 -> 当天")
return true
}
// 第二天,新的一天
sp.put(TODAY_FLAG, System.currentTimeMillis())
setCurrentDayCount(0)
LogUtil.d(TAG, "是否当天 -> 第二天")
return false
}
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ import com.mints.flowbox.keepalive.appswitch.AntiAuditManager
import com.mints.flowbox.manager.AppPreferencesManager
import com.mints.flowbox.manager.TrackManager
import com.mints.flowbox.mvp.model.OutAppConfig
import com.mints.flowbox.utils.LogUtil
/**
* wifi本地数据管理
......@@ -14,6 +15,8 @@ import com.mints.flowbox.mvp.model.OutAppConfig
*/
object WifiDataManager {
private val TAG = WifiDataManager::class.java.simpleName
// 新的一天(无需重置状态,自动修改)
private const val NEW_DAY_FLAG = "NEW_DAY_FLAG"
......@@ -451,9 +454,19 @@ object WifiDataManager {
}
}
/**
* 是否黑名单
*
* APP_OUT_MAIN_SWITCH=false 表示 关闭总开关
* isBlack=true 表示 是反策略黑名单
*/
private fun isBlackOrClose(): Boolean {
val isBlack = sp.getBoolean(AntiAuditManager.APP_OUT_BLACK, false)
val isBlack = AntiAuditManager.instance.isBlack()
LogUtil.d(TAG, "isBlackOrClose() 是否黑名单: -> !APP_OUT_MAIN_SWITCH=${!APP_OUT_MAIN_SWITCH} , isBlack=${isBlack}")
return (!APP_OUT_MAIN_SWITCH || isBlack)
}
}
\ No newline at end of file
......@@ -25,6 +25,7 @@ import com.mints.flowbox.ad.express.ExpressManager
import com.mints.flowbox.ad.video.PreCsjGroMoreVideoAdManager
import com.mints.flowbox.common.AppConfig
import com.mints.flowbox.common.Constant
import com.mints.flowbox.keepalive.appswitch.AntiAuditManager
import com.mints.flowbox.manager.TrackManager
import com.mints.flowbox.manager.UmengManager
import com.mints.flowbox.manager.UserManager
......@@ -521,7 +522,9 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
readyGo(SpeedFastActivity::class.java)
}
R.id.ivImg -> { // 点我赚钱
(requireActivity() as MainActivity).clickTab4Layout()
if (!AntiAuditManager.instance.isBlack()) {
(requireActivity() as MainActivity).clickTab4Layout()
}
}
else -> {
}
......
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