Skip to content

Commit

Permalink
Fix a regex bug & Add clean logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-TSNG committed May 15, 2021
1 parent a94a247 commit 3c40821
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 17 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ android {
applicationId "com.tsng.hidemyapplist"
minSdkVersion 24
targetSdkVersion 30
versionCode 30
versionName "1.6.Beta4"
buildConfigField "int", "SERVICE_VERSION", "30"
versionCode 31
versionName "1.6.Beta5"
buildConfigField "int", "SERVICE_VERSION", "31"
}

android.applicationVariants.all {
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/com/tsng/hidemyapplist/ui/LogActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ class LogActivity : AppCompatActivity() {
startActivity(Intent.createChooser(intent, title))
true
}
R.id.toolbar_clean -> {
XposedUtils.cleanLogs(this)
rawLogs = null

replaceFragment(RawFragment())
// replaceFragment(if (showRawLogs) BuiltifulFragment() else RawFragment())
true
}
/*
R.id.toolbar_raw_logs -> {
item.isChecked = !item.isChecked
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ object XposedUtils {
}
}

@JvmStatic
fun cleanLogs(context: Context) {
try {
context.packageManager.getInstallerPackageName("cleanLogs")
} catch (e: IllegalArgumentException) { }
}

@JvmStatic
fun callServiceIsUseHook(context: Context, callerName: String?, hookMethod: String): Boolean {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,20 @@ class PackageManagerService : IXposedHookLoadPackage {
return template.WhiteList xor inList
}

private fun dealRegex(regex: Regex, matchResult: String): String {
val suf = Regex("(.*)/.*").find(matchResult)
return suf?.value ?: matchResult
}

private fun isHideFile(callerName: String?, path: String?): Boolean {
path ?: return false
val rules = setOf(
Regex("/storage/emulated/.*/Android/.*/(.*)"),
Regex("/storage/self/primary/Android/.*/(.*)"),
Regex("/sdcard/Android/.*/(.*)"),
Regex("/data/data/(.*)"),
Regex("/data/user/.*/(.*)")
Regex("/storage/emulated/.*?/Android/.*?/"),
Regex("/storage/self/primary/Android/.*?/"),
Regex("/sdcard/Android/.*?/"),
Regex("/data/data/"),
Regex("/data/user/.*?/")
)
for (regex in rules)
regex.find(path)?.let { return isToHide(callerName, dealRegex(regex, it.value)) }
regex.find(path)?.let {
val queryName = path.removePrefix(it.value).split("/")[0]
return isToHide(callerName, queryName)
}
return false
}

Expand Down Expand Up @@ -183,6 +181,10 @@ class PackageManagerService : IXposedHookLoadPackage {
arg == "getServeTimes" -> param.result = interceptionCount.toString()
arg == "getPreference" -> param.result = configStr
arg == "getLogs" -> param.result = provideLogs()
arg == "cleanLogs" -> {
synchronized(mLock) { File("$dataDir/runtime.log").let { it.delete(); it.createNewFile() } }
param.result = resultYes
}
arg.startsWith("addLog") -> addLog(arg.substring(7)).also { param.result = resultYes }
arg.startsWith("stopSystemService") -> {
val split = arg.split("#")
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_delete.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2L18,7L6,7v12zM8,9h8v10L8,19L8,9zM15.5,4l-1,-1h-5l-1,1L5,4v2h14L19,4z" />
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/menu/toolbar_logs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
android:icon="@drawable/ic_export"
android:title="@string/toolbar_export"
app:showAsAction="ifRoom" />
<item
android:id="@+id/toolbar_clean"
android:icon="@drawable/ic_delete"
android:title="@string/toolbar_clean"
app:showAsAction="ifRoom" />
<item
android:checked="true"

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings_toolbar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
<string name="toolbar_show_system_apps">显示系统应用</string>
<string name="toolbar_refresh">刷新</string>
<string name="toolbar_export">导出</string>
<string name="toolbar_clean">清理</string>
<string name="toolbar_raw_logs">显示文本日志</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings_toolbar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
<string name="toolbar_show_system_apps">Show system apps</string>
<string name="toolbar_refresh">Refresh</string>
<string name="toolbar_export">Export</string>
<string name="toolbar_clean">Clean</string>
<string name="toolbar_raw_logs">Show raw logs</string>
</resources>
3 changes: 3 additions & 0 deletions updates/beta-en.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<b>V1.6 Beta5</b>
<p>Fix regex bug</p>
<p>Add clean logs</p>
<b>V1.6 Beta4</b>
<p>Fix a whitelist bug</p>
<b>V1.6 Beta3</b>
Expand Down
3 changes: 3 additions & 0 deletions updates/beta-zh.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<b>V1.6 Beta5</b>
<p>修复正则bug</p>
<p>添加清理日志</p>
<b>V1.6 Beta4</b>
<p>修复白名单bug</p>
<b>V1.6 Beta3</b>
Expand Down
6 changes: 3 additions & 3 deletions updates/latest_version.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"DownloadURL": "https://github.com/Dr-TSNG/Hide-My-Applist/releases/tag/V1.5.4"
},
"Beta": {
"VersionCode": 30,
"VersionName": "V1.6.Beta4",
"DownloadURL": "https://github.com/Dr-TSNG/Hide-My-Applist/releases/tag/V1.6.Beta4"
"VersionCode": 31,
"VersionName": "V1.6.Beta5",
"DownloadURL": "https://github.com/Dr-TSNG/Hide-My-Applist/releases/tag/V1.6.Beta5"
}
}

0 comments on commit 3c40821

Please sign in to comment.