Skip to content

Commit c62b2de

Browse files
Add DisableForcedCameraSounds
1 parent c28f003 commit c62b2de

File tree

10 files changed

+102
-0
lines changed

10 files changed

+102
-0
lines changed

DisableSounds/Readme.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# DisableSounds
2+
3+
Disable various system sounds.
4+
5+
- Disable (regionally) forced camera sound
6+
7+
## Forced camera sound
8+
9+
In some regions the camera sounds
10+
for shutter, start/stop recording and focus
11+
are enforced by law.
12+
This module tells the system that disabling the sounds
13+
is allowed.
14+
The system and apps will then show/enable their options
15+
for disabling camera/shutter sounds.
16+
This hook is always enabled, since allowing the option to appear,
17+
does not change the option by default.
18+
Be aware that it might be illegal to disable camera sounds in your country.

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.DisableForcedCameraSoundsHook
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 DisableForcedCameraSoundsHook : IXposedHookLoadPackage, IXposedHookZygoteInit {
14+
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
15+
Log.d(this::class.java.simpleName, "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>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# DisableSounds
2+
3+
Disable various system sounds.
4+
5+
- Disable (regionally) forced camera sound
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Disable various system sounds.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DisableSounds

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(":EnableCallRecording")
1213
include(":FreeNotifications")

0 commit comments

Comments
 (0)