Skip to content

Commit

Permalink
1.3.3 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-TSNG committed Apr 15, 2021
1 parent cb543b3 commit bd86097
Show file tree
Hide file tree
Showing 16 changed files with 99 additions and 81 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId "com.tsng.hidemyapplist"
minSdkVersion 24
targetSdkVersion 30
versionCode 11
versionName "1.3.2"
versionCode 12
versionName "1.3.3"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -47,6 +47,7 @@ dependencies {
implementation 'com.google.android.material:material:1.3.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.crossbowffs.remotepreferences:remotepreferences:0.8'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ui.SettingsActivity"></activity>
<activity android:name=".ui.SettingsActivity" />
<activity
android:name=".ui.AboutActivity"
android:theme="@style/AppTheme.About" />
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/tsng/hidemyapplist/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
xposed_status_text.text = getString(R.string.xposed_not_activated)
}
if (serviceVersion != 0)
xposed_status_sub_text.text = getString(R.string.xposed_service_on) + "$serviceVersion]"
if (serviceVersion != BuildConfig.VERSION_CODE) xposed_status_sub_text.text = getString(R.string.xposed_service_old)
else xposed_status_sub_text.text = getString(R.string.xposed_service_on) + "$serviceVersion]"
else xposed_status_sub_text.text = getString(R.string.xposed_service_off)
} catch (e : SecurityException) {
permissionError = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ protected Void doInBackground(Void... voids) {
protected void onPostExecute(Void aVoid) {
dialog.dismiss();

IntFunction res = (int r) -> r == 1 ? "\uD83D\uDFE5" : r == 0 ? "\uD83D\uDFE9" : "\uD83D\uDFE8";
IntFunction res = (int r) -> r == 1 ? "[F] " : r == 0 ? "[N] " : "[D] ";
StringBuilder br = new StringBuilder();
br.append(getString(R.string.detection_color_means)).append("<br/>");
br.append("<h5><b>API requests</b><h5/>");
Expand Down
26 changes: 23 additions & 3 deletions app/src/main/java/com/tsng/hidemyapplist/xposed/XposedUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,27 @@ class XposedUtils {
fun callServiceUpdatePref(context: Context) {
try {
context.packageManager.getPackageUid("updatePreference", 0)
} catch (e: PackageManager.NameNotFoundException) { }
} catch (e: PackageManager.NameNotFoundException) {
le("callServiceUpdatePref: Service not found")
}
}

fun callServiceIsUseHook(context: Context, callerName: String?, hookMethod: String): Boolean {
return try {
context.packageManager.getPackageUid("callIsUseHook#$callerName#$hookMethod", 0) == 1
} catch (e: PackageManager.NameNotFoundException) {
le("callServiceIsUseHook: Service not found")
false
}
}

fun callServiceIsToHide(context: Context, callerName: String?, pkgstr: String?): Boolean {
return try {
context.packageManager.getPackageUid("callIsUseHook#$callerName#$pkgstr", 0) == 1
} catch (e: PackageManager.NameNotFoundException) {
le("callServiceIsUseHook: Service not found")
false
}
}

@JvmStatic
Expand All @@ -37,9 +57,9 @@ class XposedUtils {
}

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

@JvmStatic
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
package com.tsng.hidemyapplist.xposed.hooks

import com.tsng.hidemyapplist.xposed.XposedUtils.Companion.APPNAME
import com.tsng.hidemyapplist.xposed.XposedUtils.Companion.getTemplatePref
import android.app.Application
import android.content.Context
import com.tsng.hidemyapplist.xposed.XposedUtils
import com.tsng.hidemyapplist.xposed.XposedUtils.Companion.li
import de.robv.android.xposed.IXposedHookLoadPackage
import de.robv.android.xposed.XC_MethodHook
import de.robv.android.xposed.XSharedPreferences
import de.robv.android.xposed.XposedHelpers
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam
import java.io.*
import java.io.File

class IndividualHooks : IXposedHookLoadPackage {
override fun handleLoadPackage(lpp: LoadPackageParam) {
if (lpp.packageName == APPNAME)
if(!XSharedPreferences(APPNAME, "Settings").getBoolean("HookSelf", false))
return
val pref: XSharedPreferences = getTemplatePref(lpp.packageName) ?: return
val enableAllHooks = pref.getBoolean("EnableAllHooks", false)
val enabled = pref.getStringSet("ApplyHooks", null)
if (enableAllHooks || enabled.contains("File detections")) fileHook(lpp, pref)
if (lpp.appInfo.isSystemApp) return
XposedHelpers.findAndHookMethod(Application::class.java, "attach", Context::class.java, object : XC_MethodHook() {
override fun afterHookedMethod(param: MethodHookParam) {
val context = param.args[0] as Context
fileHook(context, lpp.packageName)
}
})
}

fun fileHook(lpp: LoadPackageParam, pref: XSharedPreferences) {
fun fileHook(context: Context, pkgName: String) {
XposedHelpers.findAndHookConstructor(File::class.java, String::class.java, object : XC_MethodHook() {
override fun beforeHookedMethod(param: MethodHookParam) {
val path = param.args[0] as String
if (path.contains(lpp.packageName)) return
if (pref.getBoolean("HideAllApps", false) && path.contains("Android/data/")) {
param.args[0] = "fuck/there/is/no/file"
return
}
for (pkg in pref.getStringSet("HideApps", null)) if (path.contains(pkg!!)) {
param.args[0] = "fuck/there/is/no/file"
break
}
if (path.contains("Android/data"))
if (XposedUtils.callServiceIsUseHook(context, pkgName, "File detections"))
if (XposedUtils.callServiceIsToHide(context, pkgName, path)) {
param.args[0] = "fuck/there/is/no/file"
li("@Hide javaFile caller: $pkgName")
}
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import android.os.Process
import com.tsng.hidemyapplist.BuildConfig
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.*
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam
import java.lang.reflect.Method
Expand All @@ -23,7 +23,6 @@ class PackageManagerService : IXposedHookLoadPackage {
val applyHooks = pref.getStringSet("ApplyHooks", setOf())
val hideAllApps = pref.getBoolean("HideAllApps", false)
val hideApps = pref.getStringSet("HideApps", setOf())
val excludeSelf = pref.getBoolean("ExcludeSelf", false)
}

var hookSelf = false
Expand All @@ -46,9 +45,9 @@ class PackageManagerService : IXposedHookLoadPackage {

fun isToHide(callerName: String?, pkgstr: String?): Boolean {
if (callerName == null || pkgstr == null) return false
if (pkgstr.contains(callerName)) return false
val tplName = scope[callerName] ?: return false
val template = templates[tplName] ?: return false
if (pkgstr.contains(callerName) && template.excludeSelf) return false
if (template.hideAllApps) return true
for (pkg in template.hideApps)
if (pkgstr.contains(pkg)) return true
Expand All @@ -63,12 +62,12 @@ class PackageManagerService : IXposedHookLoadPackage {
if (callerUid < Process.FIRST_APPLICATION_UID) return
val callerName = XposedHelpers.callMethod(param.thisObject, "getNameForUid", callerUid) as String
if (!isUseHook(callerName, hookName)) return
ld("PKMS caller: $callerName")
ld("PKMS method: ${param.method.name}")
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()
ld("PKMS dealt")
if (isToHide(callerName, (getRecursiveField(iterator.next()!!, pkgNameObjList) as String?)))
iterator.remove().also { isHidden = true }
if (isHidden) li("@Hide PKMS caller: $callerName method: ${param.method.name}")
}
})
}
Expand All @@ -80,11 +79,10 @@ class PackageManagerService : IXposedHookLoadPackage {
if (callerUid < Process.FIRST_APPLICATION_UID) return
val callerName = XposedHelpers.callMethod(param.thisObject, "getNameForUid", callerUid) as String
if (!isUseHook(callerName, hookName)) return
ld("PKMS caller: $callerName")
ld("PKMS method: ${param.method.name}")
if (isToHide(callerName, param.args[0] as String))
if (isToHide(callerName, param.args[0] as String)) {
param.result = result
ld("PKMS dealt")
li("@Hide PKMS caller: $callerName method: ${param.method.name}")
}
}
})
}
Expand All @@ -96,34 +94,44 @@ class PackageManagerService : IXposedHookLoadPackage {
if (callerUid < Process.FIRST_APPLICATION_UID) return
val callerName = XposedHelpers.callMethod(param.thisObject, "getNameForUid", callerUid) as String
/* 服务模式,执行自定义行为 */
if (callerName == APPNAME) when (param.args[0]) {
"checkHMAServiceVersion" -> {
val arg = param.args[0] as String
when {
arg == "checkHMAServiceVersion" -> {
param.result = BuildConfig.VERSION_CODE
return
}
"updatePreference" -> {
arg == "updatePreference" -> {
readPreference()
param.result = 1
return
}
arg.contains("callIsUseHook") -> {
val split = arg.split("#")
if (split.size != 3) param.result = 2
else param.result = if (isUseHook(split[1], split[2])) 1 else 2
}
arg.contains("callIsToHide") -> {
val split = arg.split("#")
if (split.size != 3) param.result = 2
else param.result = if (isToHide(split[1], split[2])) 1 else 2
}
}
/* 非服务模式,正常hook */
if (!isUseHook(callerName, "ID detections")) return
ld("PKMS caller: $callerName")
ld("PKMS method: ${param.method.name}")
if (isToHide(callerName, param.args[0] as String))
if (isToHide(callerName, param.args[0] as String)) {
param.result = -1
ld("PKMS dealt")
li("@Hide PKMS caller: $callerName method: ${param.method.name}")
}
}
}

/* 载入PackageManagerService */
override fun afterHookedMethod(param: MethodHookParam) {
ld("System hook loaded")
li("System hook installed")
thread {
while (true) {
readPreference()
Thread.sleep(1000)
Thread.sleep(2000)
}
}
for (method in PKMS.declaredMethods) when (method.name) {
Expand Down Expand Up @@ -151,17 +159,17 @@ class PackageManagerService : IXposedHookLoadPackage {
if (callerUid < Process.FIRST_APPLICATION_UID) return
val callerName = XposedHelpers.callMethod(param.thisObject, "getNameForUid", callerUid) as String
if (!isUseHook(callerName, "ID detections")) return
ld("PKMS caller: $callerName")
ld("PKMS method: ${param.method.name}")
if (param.result != null) {
var change = false
val list = mutableListOf<String>()
for (str in param.result as Array<String>)
if (isToHide(callerName, str)) change = true
else list.add(str)
if (change) param.result = list.toTypedArray()
if (change) {
param.result = list.toTypedArray()
li("@Hide PKMS caller: $callerName method: ${param.method.name}")
}
}
ld("PKMS dealt")
}
})
}
Expand Down
12 changes: 5 additions & 7 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
<string name="updates">新版本特性</string>
<string name="updates_log">
<b>请仔细阅读关于页面的使用帮助!</b>\n
<b>V1.3.3</b>\n
[+] 更改检测结果图示,因为部分设备无法显示emoji\n
[+] 删除“排除自身”按钮,因为不排除肯定闪退\n
[+] 现在所有模板修改都是实时生效的了\n
[+] 更改日志记录\n
<b>V1.3.2</b>\n
[+] 性能优化\n
<b>V1.3</b>\n
[+] 支持更低Android版本\n
[+] 增加新的检测方式和拦截方式\n
[+] 修改模板实时生效,无需重启目标应用(除File detections)\n
[+] UI重修,关于页面添加更多使用帮助\n
[+] 由于较V1.1改动大,遇到问题请卸载重装模块\n
[%] nativeFile拦截尚未完成\n
<b>目前已知的bug</b>\nEdXposed YAHFA后端无法进行file detection隐藏(测试版本:4683),请更换Sandhook后端或LSPosed。\n
</string>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values-zh-rCN/strings_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#激活和更新#\n&#12288;&#12288;安装/更新模块后需要重启。另外,本模块暂时不支持虚拟框架。
</string>
<string name="about_how_to_use_description_2">
#如何启用隐藏#\n&#12288;&#12288;首先在模板管理里创建一个模板,然后在选择生效应用里对目标应用启用模板。Xposed模块作用域需要勾选“Android 系统”,如需拦截文件检测还需要勾选目标APP。(不要勾多了,会卡!)
#如何启用隐藏#\n&#12288;&#12288;首先在模板管理里创建一个模板,然后在选择生效应用里对目标应用启用模板。Xposed模块作用域需要勾选“Android 系统”,如需拦截文件检测还需要勾选目标APP。
</string>
<string name="about_how_to_use_description_3">
#如何测试隐藏是否成功#\n&#12288;&#12288;对本模块自身启用一个模板,之后在设置里启用“Hook模块自身”,开始检测。
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-zh-rCN/strings_detection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<string name="detection_hint_input_name">输入要检测的包名</string>
<string name="detection_add_new_package">添加</string>
<string name="detection_start">开始检测</string>
<string name="detection_color_means">🟩:未找到目标 🟥:找到目标 🟨:拒绝访问</string>
<string name="detection_color_means">[N]:未找到目标 [F]:找到目标 [D]:拒绝访问</string>
<string name="detection_executing_detections">检测中</string>
<string name="detection_finished">检测结束</string>
<string name="detection_using_method">执行检测方法</string>
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/values-zh-rCN/strings_xposed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<string name="xposed_permition_error_i">不受支持的Xposed版本</string>
<string name="xposed_service_on">系统服务运行中 [版本 </string>
<string name="xposed_service_off">系统服务未运行</string>
<string name="xposed_service_old">模块已更新,请重启</string>
<string name="xposed_disable_hook_self_first">请先禁用Hook模块自身</string>
<string name="xposed_template_list">模板列表</string>
<string name="xposed_new_template">新建模板</string>
Expand All @@ -17,8 +18,6 @@
<string name="xposed_template_hide_apps">隐藏应用</string>
<string name="xposed_template_hide_all_apps">禁止读取应用列表</string>
<string name="xposed_template_hide_all_apps_summary">这会使目标应用无法获取到任何安装信息</string>
<string name="xposed_template_exclude_self">排除自身</string>
<string name="xposed_template_exclude_self_summary">这会避免应用无法检测到自己而导致闪退</string>
<string name="xposed_template_choose_apps_to_hide">选择要隐藏的应用</string>
<string name="xposed_teplate_select">选择一个模板</string>
</resources>
12 changes: 5 additions & 7 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
<string name="updates">New features</string>
<string name="updates_log">
<b>Please read the about page carefully!</b>\n
<b>V1.3.3</b>\n
[+] Change the text of Detection Test, for emojis not showing on some devices\n
[+] Remove Exclude Self button, since if not check, the target apps are sure to crash\n
[+] Now all template changes take effect in real time\n
[+] Change logging\n
<b>V1.3.2</b>\n
[+] Performance optimization\n
<b>V1.3</b>\n
[+] Downgrade minSdkVersion\n
[+] Add new detection methods and interception methods\n
[+] Modifying templates takes effect in real time without restarting target apps (except for file detections)\n
[+] UI redesign with more help information in about page\n
[+] Due to the big changes to V1.1, if there are problems please uninstall and reinstall the module\n
[@] nativeFile interception has not been completed, wait for next updates\n
<b>Known bugs</b>\nUnder Edxposed YAHFA file detection hide does not work. (test version: 4683), please switch to Sandhook or LSPosed instead.\n
</string>
</resources>
Loading

0 comments on commit bd86097

Please sign in to comment.