Skip to content

Commit

Permalink
1.4.0.1 -> add detail log
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-TSNG committed Apr 19, 2021
1 parent 746a10b commit d8b8535
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 17 deletions.
6 changes: 2 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ android {
applicationId "com.tsng.hidemyapplist"
minSdkVersion 24
targetSdkVersion 30
versionCode 14
versionName "1.4"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
versionCode 15
versionName "1.4.0.1"
}

buildTypes {
Expand Down
18 changes: 18 additions & 0 deletions app/debug/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": 2,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.tsng.hidemyapplist",
"variantName": "processDebugResources",
"elements": [
{
"type": "SINGLE",
"filters": [],
"versionCode": 15,
"versionName": "1.4.0.1",
"outputFile": "app-debug.apk"
}
]
}
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
android:enabled="true"
android:exported="true" />

<activity android:name=".ui.SettingsActivity" />
<activity
android:name=".ui.SettingsActivity"
android:label="@string/title_settings" />
<activity
android:name=".ui.AboutActivity"
android:theme="@style/AppTheme.About" />
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/tsng/hidemyapplist/JSONPreference.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class JSONPreference {
}

var HookSelf = false
var DetailLog = false
var Scope = mapOf<String, String>()
var Templates = mutableMapOf<String, Template>()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class ProvidePreferenceService : Service() {
while (true) {
val json = JSONPreference()
json.HookSelf = getSharedPreferences("Settings", MODE_PRIVATE).getBoolean("HookSelf", false)
json.DetailLog = getSharedPreferences("Settings", MODE_PRIVATE).getBoolean("DetailLog", false)
json.Scope = getSharedPreferences("Scope", MODE_PRIVATE).all as Map<String, String>
for (template in getSharedPreferences("Templates", MODE_PRIVATE).getStringSet("List", setOf())) {
val obj = getSharedPreferences("tpl_$template", MODE_PRIVATE).all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,19 @@ class XposedUtils {
return field
}

@JvmStatic
fun ld(log: String) {
XposedBridge.log("[HMA LOG] [DEBUG] $log")
}

@JvmStatic
fun li(log: String) {
XposedBridge.log("[HMA LOG] [INFO] $log")
Log.i(LOG, log)
}

@JvmStatic
fun le(log: String) {
XposedBridge.log("[HMA LOG] [ERROR] $log")
Log.e(LOG, log)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.tsng.hidemyapplist.BuildConfig
import com.tsng.hidemyapplist.JSONPreference
import com.tsng.hidemyapplist.xposed.XposedUtils.Companion.APPNAME
import com.tsng.hidemyapplist.xposed.XposedUtils.Companion.getRecursiveField
import com.tsng.hidemyapplist.xposed.XposedUtils.Companion.ld
import com.tsng.hidemyapplist.xposed.XposedUtils.Companion.li
import de.robv.android.xposed.IXposedHookLoadPackage
import de.robv.android.xposed.XC_MethodHook
Expand Down Expand Up @@ -75,10 +76,17 @@ class PackageManagerService : IXposedHookLoadPackage {
if (!isUseHook(callerName, hookName)) return
var isHidden = false
val iterator = (param.result as ParceledListSlice<*>).list.iterator()
while (iterator.hasNext())
if (isToHide(callerName, (getRecursiveField(iterator.next()!!, pkgNameObjList) as String?)))
iterator.remove().also { isHidden = true }
val removed = mutableListOf<String>()
while (iterator.hasNext()) {
val str = getRecursiveField(iterator.next(), pkgNameObjList) as String?
if (isToHide(callerName, str)) {
iterator.remove()
isHidden = true
if (data.DetailLog) removed.add(str!!)
}
}
if (isHidden) li("@Hide PKMS caller: $callerName method: ${param.method.name}")
if (isHidden && data.DetailLog) ld("removeList $removed")
}
})
}
Expand All @@ -92,7 +100,7 @@ class PackageManagerService : IXposedHookLoadPackage {
if (!isUseHook(callerName, hookName)) return
if (isToHide(callerName, param.args[0] as String)) {
param.result = result
li("@Hide PKMS caller: $callerName method: ${param.method.name}")
li("@Hide PKMS caller: $callerName method: ${param.method.name} param: ${param.args[0]}")
}
}
})
Expand Down Expand Up @@ -139,7 +147,7 @@ class PackageManagerService : IXposedHookLoadPackage {
if (!isUseHook(callerName, "ID detections")) return
if (isToHide(callerName, param.args[0] as String)) {
param.result = -1
li("@Hide PKMS caller: $callerName method: ${param.method.name}")
li("@Hide PKMS caller: $callerName method: ${param.method.name} param: ${param.args[0]}")
}
}
}
Expand All @@ -155,7 +163,8 @@ class PackageManagerService : IXposedHookLoadPackage {
context.startService(Intent().apply {
setClassName(BuildConfig.APPLICATION_ID, BuildConfig.APPLICATION_ID + ".ProvidePreferenceService")
})
} catch (e: Exception) { }
} catch (e: Exception) {
}
Thread.sleep(1000)
}
li("Preferences initialized")
Expand Down Expand Up @@ -188,12 +197,16 @@ class PackageManagerService : IXposedHookLoadPackage {
if (param.result != null) {
var change = false
val list = mutableListOf<String>()
val removed = mutableListOf<String>()
for (str in param.result as Array<String>)
if (isToHide(callerName, str)) change = true
else list.add(str)
if (isToHide(callerName, str)) {
change = true
if (data.DetailLog) removed.add(str)
} else list.add(str)
if (change) {
param.result = list.toTypedArray()
li("@Hide PKMS caller: $callerName method: ${param.method.name}")
if (data.DetailLog) ld("removeList $removed")
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-zh-rCN/strings_settings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="settings_hook_mode">工作模式</string>
<string name="settings_need_reboot">重启手机以应用更改</string>
<string name="settings_hook_self">Hook模块自身</string>
<string name="settings_hook_self_summary">记得先对模块自己启用一个模板</string>
<string name="settings_need_reboot">重启手机以应用更改</string>
<string name="settings_detail_log">记录详细日志(调试用)</string>
</resources>
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings_settings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="settings_hook_mode">Hook mode</string>
<string name="settings_need_reboot">Reboot to apply mode switch</string>
<string name="settings_hook_self">Hook self</string>
<string name="settings_hook_self_summary">Remember to apply a template to the module itself</string>
<string name="settings_need_reboot">Reboot to apply mode switch</string>
<string name="settings_detail_log">Detail log for debugging</string>
</resources>
4 changes: 4 additions & 0 deletions app/src/main/res/xml/settings_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@
android:key="HookSelf"
android:summary="@string/settings_hook_self_summary"
android:title="@string/settings_hook_self" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="DetailLog"
android:title="@string/settings_detail_log" />
</PreferenceScreen>

0 comments on commit d8b8535

Please sign in to comment.