Skip to content

Commit e5d1632

Browse files
Add DisableForcedCameraSounds
1 parent 87336a0 commit e5d1632

File tree

6 files changed

+77
-0
lines changed

6 files changed

+77
-0
lines changed

DisableSounds/build.gradle.kts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
plugins {
2+
alias(libs.plugins.buildlogic.android.application)
3+
alias(libs.plugins.buildlogic.kotlin.android)
4+
}
5+
6+
android {
7+
namespace = "com.programminghoch10.DisableSounds"
8+
9+
defaultConfig {
10+
minSdk = 17
11+
targetSdk = 36
12+
}
13+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest
3+
xmlns:android="http://schemas.android.com/apk/res/android">
4+
5+
<application android:label="DisableSounds">
6+
<meta-data
7+
android:name="xposedmodule"
8+
android:value="true"
9+
/>
10+
<meta-data
11+
android:name="xposeddescription"
12+
android:value="Disable various system sounds"
13+
/>
14+
<meta-data
15+
android:name="xposedminversion"
16+
android:value="53"
17+
/>
18+
<meta-data
19+
android:name="xposedscope"
20+
android:resource="@array/scope"
21+
/>
22+
</application>
23+
24+
</manifest>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
com.programminghoch10.DisableSounds.DisableForcedCameraSoundHook
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.programminghoch10.DisableSounds
2+
3+
import android.content.res.XResources
4+
import android.media.MediaActionSound
5+
import android.os.Build
6+
import android.util.Log
7+
import de.robv.android.xposed.IXposedHookLoadPackage
8+
import de.robv.android.xposed.IXposedHookZygoteInit
9+
import de.robv.android.xposed.XC_MethodReplacement
10+
import de.robv.android.xposed.XposedHelpers
11+
import de.robv.android.xposed.callbacks.XC_LoadPackage
12+
13+
class DisableForcedCameraSoundHook : IXposedHookLoadPackage, IXposedHookZygoteInit {
14+
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
15+
Log.d(TAG, "handleLoadPackage: loaded ${this::class.java.simpleName} with package ${lpparam.packageName}")
16+
if (lpparam.packageName == "android") {
17+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
18+
val AudioServiceClass = XposedHelpers.findClass("com.android.server.audio.AudioService", lpparam.classLoader)
19+
XposedHelpers.findAndHookMethod(AudioServiceClass, "isCameraSoundForced", XC_MethodReplacement.returnConstant(false))
20+
XposedHelpers.findAndHookMethod(AudioServiceClass, "readCameraSoundForced", XC_MethodReplacement.returnConstant(false))
21+
}
22+
}
23+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
24+
XposedHelpers.findAndHookMethod(MediaActionSound::class.java, "mustPlayShutterSound", XC_MethodReplacement.returnConstant(false))
25+
}
26+
}
27+
28+
override fun initZygote(startupParam: IXposedHookZygoteInit.StartupParam) {
29+
XResources.setSystemWideReplacement("android", "bool", "config_camera_sound_forced", false)
30+
}
31+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string-array name="scope">
4+
<item>android</item>
5+
<item>org.lineageos.aperture</item>
6+
</string-array>
7+
</resources>

modules.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ include(":BetterBluetoothDeviceSort")
77
include(":BetterVerboseWiFiLogging")
88
include(":ClassHunter")
99
include(":CodecMod")
10+
include(":DisableSounds")
1011
include(":DontResetIfBootedAndConnected")
1112
include(":FreeNotifications")
1213
include(":KeepSplitScreenRatio")

0 commit comments

Comments
 (0)