Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions AlwaysAllowChargingSounds/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# AlwaysAllowChargingSounds

Always allow charging sounds and vibration,
even when the device is in Do-not-Disturb mode.
15 changes: 15 additions & 0 deletions AlwaysAllowChargingSounds/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
plugins {
alias(libs.plugins.buildlogic.android.application)
alias(libs.plugins.buildlogic.kotlin.android)
}

android {
namespace = "de.binarynoise.AlwaysAllowChargingSounds"

defaultConfig {
minSdk = 28
targetSdk = 36
}
}

dependencies {}
24 changes: 24 additions & 0 deletions AlwaysAllowChargingSounds/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android">

<application android:label="AlwaysAllowChargingSounds">
<meta-data
android:name="xposedmodule"
android:value="true"
/>
<meta-data
android:name="xposeddescription"
android:value="Always allow charging sounds, even in DnD mode."
/>
<meta-data
android:name="xposedminversion"
android:value="53"
/>
<meta-data
android:name="xposedscope"
android:resource="@array/scope"
/>
</application>

</manifest>
1 change: 1 addition & 0 deletions AlwaysAllowChargingSounds/src/main/assets/xposed_init
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
de.binarynoise.AlwaysAllowChargingSounds.Hook
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package de.binarynoise.AlwaysAllowChargingSounds

import android.content.Context
import android.provider.Settings
import de.robv.android.xposed.IXposedHookLoadPackage
import de.robv.android.xposed.XC_MethodReplacement
import de.robv.android.xposed.XposedHelpers
import de.robv.android.xposed.callbacks.XC_LoadPackage

class Hook : IXposedHookLoadPackage {

override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
val NotifierClass = XposedHelpers.findClass("com.android.server.power.Notifier", lpparam.classLoader)
XposedHelpers.findAndHookMethod(NotifierClass, "isChargingFeedbackEnabled", Int::class.java, object : XC_MethodReplacement() {
override fun replaceHookedMethod(param: MethodHookParam): Boolean {
val userId = param.args[0] as Int
val context = XposedHelpers.getObjectField(param.thisObject, "mContext") as Context
return XposedHelpers.callStaticMethod(
Settings.Secure::class.java, "getIntForUser", context.contentResolver, "charging_sounds_enabled", 1, userId
) != 0
}
})
}
}
6 changes: 6 additions & 0 deletions AlwaysAllowChargingSounds/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="scope">
<item>android</item>
</string-array>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Always allow charging sound and vibration,
even when the device is set into Do-not-Disturb mode.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Always allow charging sounds, even in DnD mode.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AlwaysAllowChargingSounds
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dependencyResolutionManagement {
rootProject.name = "XposedModulets"

enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
include(":AlwaysAllowChargingSounds")
include(":AlwaysAllowMultiInstanceSplit")
include(":AnimationScaleMod")
include(":AntiBrightnessChange")
Expand Down