Skip to content

Commit

Permalink
1.3 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-TSNG committed Apr 14, 2021
1 parent c06ea09 commit 1d65421
Show file tree
Hide file tree
Showing 19 changed files with 172 additions and 247 deletions.
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ Attension: Xposed API version lower than 93 is NOT supported due to a permission
## Compilation
This project uses Hidden API, so you should replace android.jar in Android Studio. [Reference](https://github.com/anggrayudi/android-hidden-api)
## Update Log
V1.2
+ Add new detection methods
+ Add System Hook mode
V1.3
+ Downgrade minSdkVersion
+ Add new detection methods and interception methods
+ Modifying templates takes effect in real time without restarting target apps (except for file detections)
+ UI redesign with more help information in about page
+ Bug fixes ~with adding new bugs~
+ Due to the big changes to V1.1, if there are problems please uninstall and reinstall the module
+ Remove old hook mode and abandon trying to support virtual frameworks

V1.1
+ Add exclude self support
Expand All @@ -25,11 +27,13 @@ V1.1
同时可作为Xposed模块用于隐藏应用列表或特定应用,保护你的隐私。
注意:由于一个权限问题,Xposed API至少为93才能正常使用该模块
## 更新日志
V1.2
+ 增加新的检测方式
+ 增加System Hook工作模式,无需将目标应用放入模块作用域或是白名单
V1.3
+ 支持更低Android版本
+ 增加新的检测方式和拦截方式
+ 修改模板实时生效,无需重启目标应用(除File detections)
+ UI重修,关于页面添加更多使用帮助
+ 修复了一些bug,~引入了新的bug~
+ 由于较V1.1改动大,遇到问题请卸载重装模块
+ 移除旧的工作模式,放弃支持虚拟框架

V1.1
+ 增加了排除自身功能
Expand Down
68 changes: 43 additions & 25 deletions app/src/main/java/com/tsng/hidemyapplist/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.tsng.hidemyapplist

import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
import android.view.View
import android.widget.Toast
Expand All @@ -11,28 +12,46 @@ import com.tsng.hidemyapplist.ui.*
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity(), View.OnClickListener {
private var permissionError = false

private fun getXposedStatus(): Int { return -1 }
private fun isModuleActivated(): Boolean { return false }
private fun isHookSelf(): Boolean { return getSharedPreferences("Settings", MODE_WORLD_READABLE).getBoolean("HookSelf", false) }
private fun isServiceWorking(): Boolean {
return try {
packageManager.getPackageUid("checkHMAServiceStatus", 0)
true
} catch (e : PackageManager.NameNotFoundException) { false }
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
if (getXposedStatus() != -1) {
xposed_status.setCardBackgroundColor(getColor(R.color.teal))
xposed_status_icon.setImageDrawable(getDrawable(R.drawable.ic_activited))
xposed_status_text.text = getString(R.string.xposed_activated)
xposed_status_sub_text.text = when (getXposedStatus()) {
0b00 -> getString(R.string.xposed_hook_mode_not_selected)
0b01 -> getString(R.string.xposed_hook_mode_individual)
0b10 -> getString(R.string.xposed_hook_mode_system)
0b11 -> getString(R.string.xposed_hook_mode_mixed)
else -> "Unknown hook mode"
try {
getSharedPreferences("Settings", MODE_WORLD_READABLE)
if (isModuleActivated()) {
if (isServiceWorking()) {
xposed_status.setCardBackgroundColor(getColor(R.color.teal))
xposed_status_icon.setImageDrawable(getDrawable(R.drawable.ic_activited))
xposed_status_text.text = getString(R.string.xposed_activated)
xposed_status_sub_text.text = getString(R.string.xposed_service_on)
} else {
xposed_status.setCardBackgroundColor(getColor(R.color.info))
xposed_status_icon.setImageDrawable(getDrawable(R.drawable.ic_activited))
xposed_status_text.text = getString(R.string.xposed_activated)
xposed_status_sub_text.text = getString(R.string.xposed_service_off)
}
} else {
xposed_status.setCardBackgroundColor(getColor(R.color.gray))
xposed_status_icon.setImageDrawable(getDrawable(R.drawable.ic_not_activated))
xposed_status_text.text = getString(R.string.xposed_not_activated)
xposed_status_sub_text.text = getString(if(isServiceWorking())R.string.xposed_service_on else R.string.xposed_service_off)
}
} else {
xposed_status.setCardBackgroundColor(getColor(R.color.gray))
} catch (e : SecurityException) {
permissionError = true
xposed_status.setCardBackgroundColor(getColor(R.color.error))
xposed_status_icon.setImageDrawable(getDrawable(R.drawable.ic_not_activated))
xposed_status_text.text = getString(R.string.xposed_not_activated)
xposed_status_sub_text.text = getString(R.string.xposed_hook_disabled)
xposed_status_text.text = getString(R.string.xposed_permition_error)
xposed_status_sub_text.text = getString(R.string.xposed_permition_error_i)
}
makeUpdateAlert()
menu_detection_test.setOnClickListener(this)
Expand All @@ -43,20 +62,19 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
}

override fun onClick(v: View) {
val isHookSelf = getSharedPreferences("Settings", MODE_WORLD_READABLE).getBoolean("HookSelf", false)
when (v.id) {
R.id.menu_detection_test -> startActivity(Intent(this, DetectionActivity::class.java))
R.id.menu_template_manage ->
if (isHookSelf)
Toast.makeText(this, R.string.xposed_disable_hook_self_first, Toast.LENGTH_SHORT).show()
else
startActivity(Intent(this, TemplateManageActivity::class.java))
if (permissionError) Toast.makeText(this, R.string.xposed_permition_error_i, Toast.LENGTH_SHORT).show()
else if (isHookSelf()) Toast.makeText(this, R.string.xposed_disable_hook_self_first, Toast.LENGTH_SHORT).show()
else startActivity(Intent(this, TemplateManageActivity::class.java))
R.id.menu_scope_manage ->
if (isHookSelf)
Toast.makeText(this, R.string.xposed_disable_hook_self_first, Toast.LENGTH_SHORT).show()
else
startActivity(Intent(this, ScopeManageActivity::class.java))
R.id.menu_settings -> startActivity(Intent(this, SettingsActivity::class.java))
if (permissionError) Toast.makeText(this, R.string.xposed_permition_error_i, Toast.LENGTH_SHORT).show()
else if (isHookSelf()) Toast.makeText(this, R.string.xposed_disable_hook_self_first, Toast.LENGTH_SHORT).show()
else startActivity(Intent(this, ScopeManageActivity::class.java))
R.id.menu_settings ->
if (permissionError) Toast.makeText(this, R.string.xposed_permition_error_i, Toast.LENGTH_SHORT).show()
else startActivity(Intent(this, SettingsActivity::class.java))
R.id.menu_about -> startActivity(Intent(this, AboutActivity::class.java))
}
}
Expand Down
7 changes: 2 additions & 5 deletions app/src/main/java/com/tsng/hidemyapplist/ui/AboutActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,14 @@ class AboutActivity : AbsAboutActivity() {
items.add(Card(getString(R.string.about_how_to_use_description_1)))
items.add(Line())
items.add(Card(getString(R.string.about_how_to_use_description_2)))

items.add(Category(getString(R.string.about_mode_differences_title)))
items.add(Card(getString(R.string.about_mode_differences_description_1)))
items.add(Line())
items.add(Card(getString(R.string.about_mode_differences_description_2)))
items.add(Card(getString(R.string.about_how_to_use_description_3)))

items.add(Category(getString(R.string.about_hook_differences_title)))
items.add(Card(getString(R.string.about_hook_differences_description)))

items.add(Category(getString(R.string.about_developer)))
items.add(Contributor(0, "Dr.TSNG", "Developer", "https://github.com/Dr-TSNG"))
items.add(Contributor(R.drawable.avatar, "Dr.TSNG", "Developer", "https://github.com/Dr-TSNG"))

items.add(Category(getString(R.string.about_support)))
items.add(Card("Github Page\nhttps://github.com/Dr-TSNG/Hide-My-Applist"))
Expand Down
50 changes: 0 additions & 50 deletions app/src/main/java/com/tsng/hidemyapplist/xposed/XposedBase.kt

This file was deleted.

18 changes: 6 additions & 12 deletions app/src/main/java/com/tsng/hidemyapplist/xposed/XposedEntry.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tsng.hidemyapplist.xposed

import com.tsng.hidemyapplist.xposed.XposedUtils.Companion.APPNAME
import com.tsng.hidemyapplist.xposed.hooks.IndividualHooks
import com.tsng.hidemyapplist.xposed.hooks.PackageManagerService
import de.robv.android.xposed.IXposedHookLoadPackage
Expand All @@ -8,23 +9,16 @@ import de.robv.android.xposed.XSharedPreferences
import de.robv.android.xposed.XposedHelpers
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam

class XposedEntry : IXposedHookLoadPackage, XposedBase() {
class XposedEntry : IXposedHookLoadPackage {
override fun handleLoadPackage(lpp: LoadPackageParam) {
if (lpp.packageName == APPNAME) {
XposedHelpers.findAndHookMethod("com.tsng.hidemyapplist.MainActivity", lpp.classLoader, "getXposedStatus", object : XC_MethodHook() {
XposedHelpers.findAndHookMethod("com.tsng.hidemyapplist.MainActivity", lpp.classLoader, "isModuleActivated", object : XC_MethodHook() {
override fun afterHookedMethod(param: MethodHookParam) {
param.result = if (getHookMode() == "Individual Hook") 0b01 else 0b10
param.result = true
}
})
}
if (getHookMode() == "Individual Hook")
IndividualHooks().handleLoadPackage(lpp)
else
PackageManagerService().handleLoadPackage(lpp)
XSharedPreferences(APPNAME, "Settings").makeWorldReadable()
}

fun getHookMode(): String {
return XSharedPreferences(APPNAME, "Settings").getString("HookMode", "Individual Hook")
PackageManagerService().handleLoadPackage(lpp)
IndividualHooks().handleLoadPackage(lpp)
}
}
66 changes: 66 additions & 0 deletions app/src/main/java/com/tsng/hidemyapplist/xposed/XposedUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.tsng.hidemyapplist.xposed

import android.util.Log
import com.tsng.hidemyapplist.BuildConfig
import de.robv.android.xposed.XSharedPreferences
import de.robv.android.xposed.XposedBridge
import de.robv.android.xposed.XposedHelpers

class XposedUtils {
companion object {
const val LOG = "hma_log"
const val APPNAME = BuildConfig.APPLICATION_ID

@JvmStatic
fun getTemplatePref(pkg: String?): XSharedPreferences? {
val pref = XSharedPreferences(APPNAME, "Scope")
if (!pref.file.exists()) return null
val str = pref.getString(pkg, null) ?: return null
return XSharedPreferences(APPNAME, "tpl_$str")
}

@JvmStatic
fun isUseHook(pref: XSharedPreferences?, callerName: String?, hook: String): Boolean {
if (pref == null) return false
if (callerName == APPNAME)
if (!XSharedPreferences(APPNAME, "Settings").getBoolean("HookSelf", false))
return false
val enableAllHooks = pref.getBoolean("EnableAllHooks", false)
val enabled = pref.getStringSet("ApplyHooks", HashSet())
return enableAllHooks or enabled.contains(hook)
}

@JvmStatic
fun isToHide(pref: XSharedPreferences?, callerName: String, pkgstr: String?): Boolean {
if (pref == null || pkgstr == null) return false
if (pref.getBoolean("ExcludeSelf", false) && pkgstr.contains(callerName)) return false
if (pref.getBoolean("HideAllApps", false)) return true
val set = pref.getStringSet("HideApps", HashSet())
for (pkg in set) if (pkgstr.contains(pkg)) {
ld("HIDE $pkgstr")
return true
}
return false
}

@JvmStatic
fun getRecursiveField(entry: Any, list: List<String>) : Any? {
var field : Any? = entry
for (it in list)
field = XposedHelpers.getObjectField(field, it) ?: return null
return field
}

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

@JvmStatic
fun le(log: String) {
XposedBridge.log("[HMA ERROR] $log")
Log.e(LOG, log)
}
}
}
Loading

0 comments on commit 1d65421

Please sign in to comment.