日志采集 采集启动页,登录页,首页网络请求日志
This commit is contained in:
parent
20cd429db0
commit
ac3d72343a
|
|
@ -17,7 +17,6 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.*
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
|
|
@ -51,6 +50,7 @@ import java.io.File
|
|||
import androidx.core.graphics.toColorInt
|
||||
import androidx.core.net.toUri
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import com.yingmao.clash.levellog.AppLog
|
||||
|
||||
class LoginActivity : BaseActivity(), View.OnClickListener {
|
||||
private lateinit var loginViewMode: LoginAtyVM
|
||||
|
|
@ -114,7 +114,7 @@ class LoginActivity : BaseActivity(), View.OnClickListener {
|
|||
super.httpSuccess(httpStatus)
|
||||
if (httpStatus.reqType == HttpReqType.LOGIN) {
|
||||
val rsp = httpStatus.rsp
|
||||
com.cncat.vpn.common.log.Log.d("HttpReqType.LOGIN rsp==>${rsp}")
|
||||
AppLog.i("SplashActivity", "httpSuccess HttpReqType.LOGIN ${rsp}")
|
||||
if (rsp is LoginRsp) {
|
||||
if (rsp.code == "1000") {
|
||||
val mmkv = MMKV.defaultMMKV()
|
||||
|
|
@ -135,6 +135,7 @@ class LoginActivity : BaseActivity(), View.OnClickListener {
|
|||
} else if (httpStatus.reqType == HttpReqType.CHECK_LOGIN) {
|
||||
hideLoadingDialog()
|
||||
val rsp = httpStatus.rsp
|
||||
AppLog.i("SplashActivity", "httpSuccess HttpReqType.CHECK_LOGIN ${rsp}")
|
||||
if (rsp is CheckLoginRsp) {
|
||||
if (rsp.code == 0) {
|
||||
rsp.data?.let { MainApplication.setUserInfo(it) }
|
||||
|
|
@ -161,6 +162,7 @@ class LoginActivity : BaseActivity(), View.OnClickListener {
|
|||
} else if (httpStatus.reqType == HttpReqType.GETAPPVERION) {
|
||||
(httpStatus.rsp as AppVersionCheckRsp).let { aver ->
|
||||
com.cncat.vpn.common.log.Log.i("appVersionCheck ==>$aver")
|
||||
AppLog.i("SplashActivity", "httpSuccess HttpReqType.GETAPPVERION ${aver}")
|
||||
if (aver.code == 200) {
|
||||
aver.data?.let { md ->
|
||||
if (md.isForce) { //强制更新
|
||||
|
|
@ -182,6 +184,7 @@ class LoginActivity : BaseActivity(), View.OnClickListener {
|
|||
override fun httpFailure(httpStatus: HttpStatus.Failure) {
|
||||
super.httpFailure(httpStatus)
|
||||
if (httpStatus.reqType == HttpReqType.LOGIN) {
|
||||
AppLog.i("SplashActivity", "httpFailure HttpReqType.LOGIN ${httpStatus.msg}")
|
||||
SplashHelper(splashAtyVM).getHostWithFallback { success ->
|
||||
MainScope().launch {
|
||||
if (success) {
|
||||
|
|
@ -229,6 +232,7 @@ class LoginActivity : BaseActivity(), View.OnClickListener {
|
|||
}
|
||||
}
|
||||
} else if (httpStatus.reqType == HttpReqType.CHECK_LOGIN) {
|
||||
AppLog.i("SplashActivity", "httpFailure HttpReqType.CHECK_LOGIN ${httpStatus.msg}")
|
||||
if (::rxDialogShapeLoading.isInitialized && rxDialogShapeLoading.isShowing) {
|
||||
rxDialogShapeLoading.cancel()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ import com.yingmao.clash.conf.BZYConstants
|
|||
import com.yingmao.clash.conf.Conf
|
||||
import com.yingmao.clash.entity.CheckLoginRsp
|
||||
import com.yingmao.clash.fragment.home.HomeFragment
|
||||
import com.yingmao.clash.fragment.home.HomeFragment.Companion.clashRunning
|
||||
import com.yingmao.clash.fragment.setting.SettingFragment
|
||||
import com.yingmao.clash.fragment.vip.vipFragment
|
||||
import com.yingmao.clash.levellog.AppLog
|
||||
|
|
@ -89,9 +90,6 @@ import java.util.UUID
|
|||
class MainActivity : BaseActivity() {
|
||||
private lateinit var mainAtyVM: MainAtyVM
|
||||
private var payResultLoading: RxDialogShapeLoading? = null
|
||||
private val clashRunning: Boolean
|
||||
get() = Remote.broadcasts.clashRunning
|
||||
|
||||
private var timer: Timer? = null
|
||||
private var uTimerTask: TimerTask? = null
|
||||
private var newMainActGlo: Boolean = false
|
||||
|
|
@ -298,6 +296,7 @@ class MainActivity : BaseActivity() {
|
|||
aivHome.setImageResource(R.drawable.yjl_home_page)
|
||||
aivCenter.setImageResource(R.drawable.yjl_user_page_choose)
|
||||
aivVip.setImageResource(R.drawable.yjl_vip_page)
|
||||
Log.i("AAAAAAAAAAAAAAAAAAA clashRunning${clashRunning}")
|
||||
if(clashRunning){
|
||||
checkVPN()
|
||||
}
|
||||
|
|
@ -342,6 +341,7 @@ class MainActivity : BaseActivity() {
|
|||
when (httpStatus.reqType) {
|
||||
HttpReqType.GET_AIRNODES -> {
|
||||
val data = httpStatus.rsp as SubscriptionRsp
|
||||
AppLog.i("SplashActivity", "httpSuccess HttpReqType.GET_AIRNODES ${data}")
|
||||
if (data.code != "1000") {
|
||||
RxToast.error(resources.getString(R.string.NodeAcquisitionFailed) + "${data.msg}")
|
||||
AppLog.i("MainActivity", "httpSuccess GET_AIRNODES===>${data.msg}")
|
||||
|
|
@ -373,6 +373,7 @@ class MainActivity : BaseActivity() {
|
|||
|
||||
HttpReqType.GetActivity -> {
|
||||
val data = httpStatus.rsp as GetActivityRsp
|
||||
AppLog.i("SplashActivity", "httpSuccess HttpReqType.GetActivity ${data}")
|
||||
if (data.code == 200) {
|
||||
if (data.data.data.list.isNotEmpty()) {
|
||||
data.data.data.list[0].redirectLink.let {
|
||||
|
|
@ -400,6 +401,7 @@ class MainActivity : BaseActivity() {
|
|||
|
||||
HttpReqType.CHECK_LOGIN -> {
|
||||
(httpStatus.rsp as CheckLoginRsp).let { checkLoginRsp ->
|
||||
AppLog.i("SplashActivity", "httpSuccess HttpReqType.CHECK_LOGIN ${checkLoginRsp}")
|
||||
if (checkLoginRsp.code == 0) {
|
||||
val mmkv = MMKV.defaultMMKV()
|
||||
val oldExpireTime =
|
||||
|
|
@ -433,6 +435,7 @@ class MainActivity : BaseActivity() {
|
|||
|
||||
HttpReqType.PHDOWNLOADURL -> {
|
||||
(httpStatus.rsp as PhDownloadUrlRsp).let {
|
||||
AppLog.i("SplashActivity", "httpSuccess HttpReqType.PHDOWNLOADURL ${it}")
|
||||
if (it.code == 1000) {
|
||||
val lastNotice =
|
||||
MMKV.defaultMMKV().decodeString(BZYConstants.MMKV_KEY_NOTICE_READ, "")
|
||||
|
|
@ -467,6 +470,7 @@ class MainActivity : BaseActivity() {
|
|||
HttpReqType.EXPENSES_RECORD ->{
|
||||
if(httpStatus.rsp is ExpensesRecordRsp){
|
||||
httpStatus.rsp.let { expensesRecordRsp ->
|
||||
AppLog.i("SplashActivity", "httpSuccess HttpReqType.EXPENSES_RECORD ${expensesRecordRsp}")
|
||||
if(expensesRecordRsp.code == "1000"){
|
||||
if(expensesRecordRsp.data != null) {
|
||||
val expensesRecordList = expensesRecordRsp.data.expensesRecords
|
||||
|
|
@ -504,6 +508,7 @@ class MainActivity : BaseActivity() {
|
|||
}
|
||||
HttpReqType.Report->{
|
||||
(httpStatus.rsp as AppVersionCheckRsp).let {
|
||||
AppLog.i("SplashActivity", "httpSuccess HttpReqType.Report ${it}")
|
||||
android.util.Log.i("reqType:","data:::"+it.code)
|
||||
if(it.code==200){
|
||||
//上报百度支付功能
|
||||
|
|
@ -816,19 +821,14 @@ class MainActivity : BaseActivity() {
|
|||
aivVip.setImageResource(R.drawable.yjl_vip_page_choose)
|
||||
}
|
||||
fun checkVPN(){
|
||||
val behaviorLogSwitch =
|
||||
MMKV.defaultMMKV().decodeBool(BZYConstants.BehaviorLogSwitch, true)
|
||||
if(behaviorLogSwitch){
|
||||
launch(Dispatchers.IO) {
|
||||
val isVPN =Utils.isVpnActive(this@MainActivity)
|
||||
AppLog.i("NewMainActivity", "VPN是否打开::::${isVPN}")
|
||||
val vpnCheChek =Utils.checkHttpOk("https://www.youtube.com")
|
||||
AppLog.i("NewMainActivity", "校验访问https://www.youtube.com::${vpnCheChek}")
|
||||
launch(Dispatchers.IO) {
|
||||
val isVPN =Utils.isVpnActive(this@MainActivity)
|
||||
AppLog.i("NewMainActivity", "VPN是否打开::::${isVPN}")
|
||||
val vpnCheChek =Utils.checkHttpOk("https://www.youtube.com")
|
||||
AppLog.i("NewMainActivity", "校验访问https://www.youtube.com::${vpnCheChek}")
|
||||
|
||||
val vpnCheChekGoogle =Utils.checkHttpOk("https://www.google.com")
|
||||
AppLog.i("NewMainActivity", "校验访问https://www.google.com::${vpnCheChekGoogle}")
|
||||
}
|
||||
val vpnCheChekGoogle =Utils.checkHttpOk("https://www.google.com")
|
||||
AppLog.i("NewMainActivity", "校验访问https://www.google.com::${vpnCheChekGoogle}")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -44,6 +44,7 @@ import com.yingmao.clash.conf.BZYConstants.Companion.MMKV_KEY_NOTE_DEFAULT_PSW
|
|||
import com.yingmao.clash.conf.BZYConstants.Companion.MMKV_KEY_REMEMBER_PASSWORD
|
||||
import com.yingmao.clash.conf.BZYConstants.Companion.MMKV_KEY_REMEMBER_USERNAME
|
||||
import com.yingmao.clash.entity.CheckLoginRsp
|
||||
import com.yingmao.clash.levellog.AppLog
|
||||
import com.yingmao.clash.listener.DownLoadListener
|
||||
import com.yingmao.clash.net.http.HttpReqType
|
||||
import com.yingmao.clash.net.http.HttpStatus
|
||||
|
|
@ -388,6 +389,7 @@ class SplashActivity : BaseActivity() {
|
|||
HttpReqType.REGISTER -> {
|
||||
dialogDoMainChoose?.dismiss()
|
||||
with(httpStatus.rsp as RegisterRsp) {
|
||||
AppLog.i("SplashActivity", "注册请求接口code:${code}")
|
||||
if (code == "10000" || code == "200") {
|
||||
if (data != null) {
|
||||
if (!data.phoneNumber.isNullOrEmpty()) {
|
||||
|
|
@ -414,6 +416,7 @@ class SplashActivity : BaseActivity() {
|
|||
if (decodeBool) {
|
||||
MMKV.defaultMMKV().encode(BZYConstants.INITIALIZATION, true)
|
||||
}
|
||||
AppLog.i("SplashActivity", "注册接口调用登录前: phoneNumber${data?.phoneNumber} defaultPassword${BZYConstants.defaultPassword}")
|
||||
splashAtyVM.login(encryName, encryPsw)
|
||||
} else if (code == "20062") {
|
||||
message?.let {
|
||||
|
|
@ -429,16 +432,19 @@ class SplashActivity : BaseActivity() {
|
|||
} else {
|
||||
MMKV.defaultMMKV().encode(MMKV_KEY_REMEMBER_USERNAME, username)
|
||||
}
|
||||
AppLog.i("SplashActivity", "注册接口调用返回20062: message${message}")
|
||||
val intent = Intent(this@SplashActivity, LoginActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
} else if (code == "403") {
|
||||
AppLog.i("SplashActivity", "注册接口调用返回403: message${message}")
|
||||
pbWeb.visibility = View.INVISIBLE
|
||||
message?.let {
|
||||
RxToast.error(it)
|
||||
}
|
||||
webView?.setOnTouchListener { _, _ -> false }
|
||||
} else {
|
||||
AppLog.i("SplashActivity", "注册接口调用返回未知数据: code:${code}")
|
||||
MaterialDialog(this@SplashActivity).show {
|
||||
message(text = initErrMsg)
|
||||
positiveButton(R.string.retry) {
|
||||
|
|
@ -456,6 +462,7 @@ class SplashActivity : BaseActivity() {
|
|||
HttpReqType.LOGIN -> {
|
||||
val rsp = httpStatus.rsp
|
||||
if (rsp is LoginRsp) {
|
||||
AppLog.i("SplashActivity", "HttpReqType.LOGIN rsp.code ${rsp.code }")
|
||||
if (rsp.code == "1000") {
|
||||
val mmkv = MMKV.defaultMMKV()
|
||||
com.cncat.vpn.common.log.Log.i(" HttpReqType.LOGIN token ==> ${rsp.data.vpnToken}")
|
||||
|
|
@ -487,6 +494,8 @@ class SplashActivity : BaseActivity() {
|
|||
HttpReqType.CHECK_LOGIN -> {
|
||||
dialogDoMainChoose?.dismiss()
|
||||
(httpStatus.rsp as CheckLoginRsp).let { checkLoginRsp ->
|
||||
|
||||
AppLog.i("SplashActivity", "HttpReqType.CHECK_LOGIN checkLoginRsp ${checkLoginRsp.code }")
|
||||
if (checkLoginRsp.code == 0) {
|
||||
com.cncat.vpn.common.log.Log.d("splash CHECK_LOGIN==>")
|
||||
checkLoginRsp.data?.let { MainApplication.setUserInfo(it) }
|
||||
|
|
@ -511,6 +520,7 @@ class SplashActivity : BaseActivity() {
|
|||
}
|
||||
HttpReqType.App_VERION_CHECK -> {
|
||||
(httpStatus.rsp as AppVersionCheckRsp).let { avcr ->
|
||||
AppLog.i("SplashActivity", " HttpReqType.App_VERION_CHECK avcr ${avcr}")
|
||||
com.cncat.vpn.common.log.Log.i("App_VERION_CHECK ==>$avcr")
|
||||
if (avcr.code == 200) {
|
||||
avcr.data?.let { md ->
|
||||
|
|
@ -548,6 +558,7 @@ class SplashActivity : BaseActivity() {
|
|||
rlPb.visibility = View.GONE
|
||||
pbWeb.visibility = View.INVISIBLE
|
||||
com.cncat.vpn.common.log.Log.d("httpFailure HttpReqType.REGISTER")
|
||||
AppLog.i("SplashActivity", "httpFailure HttpReqType.REGISTER ${httpStatus.msg}")
|
||||
if (super.switchServer2()) {//切换服务器并直接重试
|
||||
doRegisterByEncryption()
|
||||
} else {
|
||||
|
|
@ -565,6 +576,7 @@ class SplashActivity : BaseActivity() {
|
|||
}
|
||||
|
||||
HttpReqType.LOGIN -> {
|
||||
AppLog.i("SplashActivity", "httpFailure HttpReqType.LOGIN ${httpStatus.msg}")
|
||||
MaterialDialog(this@SplashActivity).show {
|
||||
message(text = initErrMsg)
|
||||
positiveButton(R.string.confirm) {
|
||||
|
|
@ -585,6 +597,7 @@ class SplashActivity : BaseActivity() {
|
|||
|
||||
HttpReqType.CHECK_LOGIN -> {
|
||||
com.cncat.vpn.common.log.Log.d("httpFailure HttpReqType.CHECK_LOGIN")
|
||||
AppLog.i("SplashActivity", "httpFailure HttpReqType.CHECK_LOGIN ${httpStatus.msg}")
|
||||
RxToast.error("检测到网络异常,请尝试切换其他地址.")
|
||||
if (super.switchServer2()) {
|
||||
splashAtyVM.checkLogin()
|
||||
|
|
|
|||
|
|
@ -70,6 +70,5 @@ class BZYConstants {
|
|||
const val applicationMode = "ApplicationMode"
|
||||
const val is_splash_first = "is_splash_first"
|
||||
const val ScreenFlag="screenshotFlag"
|
||||
const val BehaviorLogSwitch = "BehaviorLogSwitch"
|
||||
}
|
||||
}
|
||||
|
|
@ -41,6 +41,7 @@ import com.google.gson.Gson
|
|||
import com.google.gson.JsonParser
|
||||
import com.orhanobut.logger.Logger
|
||||
import com.tencent.mmkv.MMKV
|
||||
import com.yingmao.clash.BuildConfig
|
||||
import com.yingmao.clash.R
|
||||
import com.yingmao.clash.act.ChangeNodeActivity.ProxyMode
|
||||
import com.yingmao.clash.act.MainActivity
|
||||
|
|
@ -187,6 +188,17 @@ open class HomeFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispa
|
|||
observe(this, accelerateViewModel)
|
||||
initSS()
|
||||
accelerateViewModel.getSelectNodeInfo()
|
||||
val selectedName =
|
||||
MMKV.defaultMMKV().decodeString(MMKV_KEY_REMEMBER_USERNAME, "")
|
||||
val equipmentModel = Utils.getEquipmentModel()
|
||||
val validPeriod = MMKV.defaultMMKV().decodeLong(BZYConstants.MMKV_KEY_VPN_VALID_PERIOD)
|
||||
AppLog.i("HomeFragment", "用户账号===>${selectedName}")
|
||||
AppLog.i("HomeFragment", "版本号===>${requireActivity().resources.getString(R.string.currentVersionNumber) + "${BuildConfig.VERSION_NAME}." + BuildConfig.productId}")
|
||||
AppLog.i("HomeFragment", "用户有效时长===>${validPeriod}")
|
||||
AppLog.i("HomeFragment", "用户是否过期===>${checkExpire()}")
|
||||
AppLog.i("HomeFragment", "机型数据===>${equipmentModel}")
|
||||
AppLog.i("HomeFragment", "订阅连接地址===>${subUrl}")
|
||||
AppLog.i("HomeFragment", "OAID===>${MainApplication.Companion.OAID}")
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1117,18 +1129,7 @@ open class HomeFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispa
|
|||
return mList
|
||||
}
|
||||
fun behaviorLog(){
|
||||
//开启采集之后点击采集
|
||||
MMKV.defaultMMKV().encode(BZYConstants.BehaviorLogSwitch, true)
|
||||
val selectedName =
|
||||
MMKV.defaultMMKV().decodeString(MMKV_KEY_REMEMBER_USERNAME, "")
|
||||
val equipmentModel = Utils.getEquipmentModel()
|
||||
val validPeriod = MMKV.defaultMMKV().decodeLong(BZYConstants.MMKV_KEY_VPN_VALID_PERIOD)
|
||||
AppLog.i("HomeFragment", "selectedName===>${selectedName}")
|
||||
AppLog.i("HomeFragment", "用户有效时长===>${validPeriod}")
|
||||
AppLog.i("HomeFragment", "用户是否过期===>${checkExpire()}")
|
||||
AppLog.i("HomeFragment", "机型数据===>${equipmentModel}")
|
||||
AppLog.i("HomeFragment", "订阅连接地址===>${subUrl}")
|
||||
AppLog.i("HomeFragment", "OAID===>${MainApplication.Companion.OAID}")
|
||||
AppLog.i("HomeFragment", "加速开启前 订阅连接地址 behaviorLog===>${subUrl}")
|
||||
requireContext().startService(LogcatService::class.intent)
|
||||
}
|
||||
}
|
||||
|
|
@ -65,6 +65,7 @@ import com.yingmao.clash.util.CommonUtils
|
|||
import com.yingmao.clash.util.DataUtils
|
||||
import com.yingmao.clash.util.DataUtils.getAllFilePath
|
||||
import com.yingmao.clash.util.PayUtils
|
||||
import com.yingmao.clash.util.Utils
|
||||
import com.yingmao.clash.view.RxToast
|
||||
import com.yingmao.clash.view.dialog.DialogBandChoose
|
||||
import com.yingmao.clash.view.dialog.DialogDoMainChoose
|
||||
|
|
@ -278,7 +279,9 @@ class SettingFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatc
|
|||
if(clashRunning&&getIsGlo){
|
||||
RxToast.info("全局模式暂不支持上传日志,请切换到智能模式或关闭加速!")
|
||||
}else{
|
||||
|
||||
if(clashRunning){
|
||||
checkVPN()
|
||||
}
|
||||
val logDirParent = "applogs"
|
||||
val logDir = File(requireActivity().filesDir, logDirParent)
|
||||
val processName =getProcessName()
|
||||
|
|
@ -844,7 +847,6 @@ class SettingFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatc
|
|||
hideLoading()
|
||||
val deleteFile = DataUtils.deleteFile(filePath)
|
||||
Log.i("PutObjectRequest deleteFile ${deleteFile}")
|
||||
MMKV.defaultMMKV().encode(BZYConstants.BehaviorLogSwitch, false)
|
||||
RxToast.info(resources.getString(R.string.BehaviorLogSuccessfully))
|
||||
}
|
||||
}else{
|
||||
|
|
@ -878,4 +880,15 @@ class SettingFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatc
|
|||
|
||||
|
||||
}
|
||||
fun checkVPN(){
|
||||
launch(Dispatchers.IO) {
|
||||
val isVPN =Utils.isVpnActive(requireActivity())
|
||||
AppLog.i("NewMainActivity", "VPN是否打开::::${isVPN}")
|
||||
val vpnCheChek =Utils.checkHttpOk("https://www.youtube.com")
|
||||
AppLog.i("NewMainActivity", "校验访问https://www.youtube.com::${vpnCheChek}")
|
||||
|
||||
val vpnCheChekGoogle =Utils.checkHttpOk("https://www.google.com")
|
||||
AppLog.i("NewMainActivity", "校验访问https://www.google.com::${vpnCheChekGoogle}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,19 +27,14 @@ object AppLog {
|
|||
msg: String,
|
||||
tr: Throwable?
|
||||
) {
|
||||
val behaviorLogSwitch =
|
||||
MMKV.defaultMMKV().decodeBool(BZYConstants.BehaviorLogSwitch, true)
|
||||
if(behaviorLogSwitch){
|
||||
LogDispatcher.enqueue(
|
||||
LogEvent(
|
||||
time = System.currentTimeMillis(),
|
||||
level = level,
|
||||
tag = tag,
|
||||
message = msg,
|
||||
throwable = tr
|
||||
)
|
||||
LogDispatcher.enqueue(
|
||||
LogEvent(
|
||||
time = System.currentTimeMillis(),
|
||||
level = level,
|
||||
tag = tag,
|
||||
message = msg,
|
||||
throwable = tr
|
||||
)
|
||||
}
|
||||
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue