Commit 9b72634a authored by liuyang's avatar liuyang

APK抓包>从频道1开始依次抓取, 增加手动清理图片缓存

#BYLSERVER-1693
parent 9e69c7e6
......@@ -88,6 +88,10 @@ class MainActivity : AppCompatActivity(), IAppBaseCallback {
this.appInfoAdapter.clear()
requestAppList()
}
clearBtn.setOnClickListener {
AppUtil.clearCache()
}
}
private fun start() {
......
......@@ -22,7 +22,7 @@ class AppConfigListItem(context: Context?) : RelativeLayout(context) {
else if (!apkInfo.monitoring)
tips = "(监播未启用)"
this.appName.text = apkInfo.name + tips
this.packageName.text = apkInfo.packageName
this.packageName.text = "包名:${apkInfo.packageName}\t\t版本:" + AppUtil.getVersionName(context, apkInfo.packageName)
}
fun setIcon(drawable: Drawable) {
......
......@@ -14,9 +14,13 @@ import android.os.Build
import android.os.Environment
import java.util.regex.Pattern
import android.app.ActivityManager.RunningAppProcessInfo
import java.net.HttpURLConnection
import java.nio.file.Files.delete
import java.net.HttpURLConnection.HTTP_OK
import java.net.HttpURLConnection.setFollowRedirects
import java.net.URL
import android.R.attr.versionName
import android.content.pm.PackageInfo
......@@ -224,4 +228,43 @@ object AppUtil {
e.printStackTrace()
}
}
fun exists(url: String): Boolean {
return try {
HttpURLConnection.setFollowRedirects(false)
val con = URL(url).openConnection() as HttpURLConnection
con.requestMethod = "HEAD"
con.responseCode == HttpURLConnection.HTTP_OK
} catch (e: Exception) {
e.printStackTrace()
false
}
}
fun getVersionName(context: Context, packageName: String): String {
val manager = context.packageManager
var name = ""
try {
val info = manager.getPackageInfo(packageName, 0)
name = info.versionName
} catch (e: PackageManager.NameNotFoundException) {
e.printStackTrace()
}
return name
}
fun clearCache() {
val path = getAbsoluteSdcardPath() + "/upload/"
val dir = File(path)
if (dir.exists()) {
for (subDir in dir.listFiles()) {
if (subDir.isDirectory) {
for (file in subDir.listFiles()) {
file.delete()
}
}
}
}
}
}
\ No newline at end of file
......@@ -40,6 +40,13 @@
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="刷新应用列表"/>
<Button
android:id="@+id/clearBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="清除缓存"/>
</LinearLayout>
<ListView
......
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