Add new option to exclude the target app installation source spoofing, ignore invalid requests

This commit is contained in:
frknkrc44 2025-09-04 02:55:40 +03:00
commit 040fd51765
No known key found for this signature in database
GPG key ID: 784AE1CC0DCFD34F
5 changed files with 31 additions and 2 deletions

View file

@ -108,6 +108,7 @@ class AppSettingsFragment : Fragment(R.layout.fragment_settings) {
"useWhiteList" -> pack.config.useWhitelist
"excludeSystemApps" -> pack.config.excludeSystemApps
"hideInstallationSource" -> pack.config.hideInstallationSource
"excludeTargetInstallationSource" -> pack.config.excludeTargetInstallationSource
else -> throw IllegalArgumentException("Invalid key: $key")
}
}
@ -118,6 +119,7 @@ class AppSettingsFragment : Fragment(R.layout.fragment_settings) {
"useWhiteList" -> pack.config.useWhitelist = value
"excludeSystemApps" -> pack.config.excludeSystemApps = value
"hideInstallationSource" -> pack.config.hideInstallationSource = value
"excludeTargetInstallationSource" -> pack.config.excludeTargetInstallationSource = value
else -> throw IllegalArgumentException("Invalid key: $key")
}
}
@ -163,6 +165,11 @@ class AppSettingsFragment : Fragment(R.layout.fragment_settings) {
R.string.app_force_stop_warning, Toast.LENGTH_LONG).show()
true
}
findPreference<SwitchPreferenceCompat>("excludeTargetInstallationSource")?.setOnPreferenceChangeListener { _, newValue ->
Toast.makeText(requireContext(),
R.string.app_force_stop_warning, Toast.LENGTH_LONG).show()
true
}
findPreference<SwitchPreferenceCompat>("useWhiteList")?.setOnPreferenceChangeListener { _, newValue ->
pack.config.applyTemplates.clear()
pack.config.extraAppList.clear()

View file

@ -93,8 +93,10 @@
<string name="app_extra_apps_invisible_count">%d additional apps invisible</string>
<string name="app_warning_risky_package_title">Risky package</string>
<string name="app_warning_risky_package_desc">This package is marked as risky and you can cause issues on hidden apps. Do you want to continue?</string>
<string name="app_hide_installation_source">Spoof installation sources to Play Store</string>
<string name="app_spoof">Spoofing</string>
<string name="app_hide_installation_source">Spoof installation sources</string>
<string name="app_hide_installation_source_desc">All of user apps will be spoofed as installed over Play Store for this application</string>
<string name="app_exclude_target_installation_source">Exclude the target app</string>
<string name="app_force_stop_warning">Don\'t forget to force stop the target app after saving the configuration</string>
<!-- Preset names -->

View file

@ -11,12 +11,20 @@
<PreferenceCategory
android:dependency="enableHide"
android:title="@string/preferences">
android:title="@string/app_spoof">
<SwitchPreferenceCompat
android:icon="@drawable/outline_shop_24"
android:key="hideInstallationSource"
android:summary="@string/app_hide_installation_source_desc"
android:title="@string/app_hide_installation_source" />
<SwitchPreferenceCompat
android:key="excludeTargetInstallationSource"
android:title="@string/app_exclude_target_installation_source" />
</PreferenceCategory>
<PreferenceCategory
android:dependency="enableHide"
android:title="@string/preferences">
<SwitchPreferenceCompat
android:icon="@drawable/outline_settings_24"
android:key="useWhiteList"

View file

@ -32,6 +32,7 @@ data class JsonConfig(
var useWhitelist: Boolean = false,
var excludeSystemApps: Boolean = true,
var hideInstallationSource: Boolean = false,
var excludeTargetInstallationSource: Boolean = false,
var applyTemplates: MutableSet<String> = mutableSetOf(),
var applyPresets: MutableSet<String> = mutableSetOf(),
var applySettingsPresets: MutableSet<String> = mutableSetOf(),

View file

@ -194,6 +194,17 @@ class HMAService(val pms: IPackageManager) : IHMAService.Stub() {
if (caller == null || query == null) return false
val appConfig = config.scope[caller] ?: return false
if (query in systemApps) return false
logD(TAG, "@shouldHideInstallationSource $caller -> $query")
if (caller == query && appConfig.excludeTargetInstallationSource) return false
try {
val uid = Utils.getPackageUidCompat(pms, query, 0L, 0)
if (uid < 0) return false // invalid package installation source request
// logD(TAG, "@shouldHideInstallationSource UID for $query: $uid")
} catch (e: Throwable) {
// logD(TAG, "@shouldHideInstallationSource UID error", e)
return false
}
return appConfig.hideInstallationSource
}