-
Notifications
You must be signed in to change notification settings - Fork 6
add AlwaysAllowChargingSounds #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bb56d34
add AlwaysAllowChargingSounds
programminghoch10 c2273b8
make AlwaysAllowChargingSounds respect the user settings
programminghoch10 118fbfe
restrict to android package only
binarynoise 7f252f0
add comment
binarynoise 7d2e3b2
docs
binarynoise 417ef0c
s/Sound/Feedback/g
binarynoise File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 {} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| de.binarynoise.AlwaysAllowChargingSounds.Hook |
24 changes: 24 additions & 0 deletions
24
AlwaysAllowChargingSounds/src/main/java/de/binarynoise/AlwaysAllowChargingSounds/Hook.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
binarynoise marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) != 0 | ||
| } | ||
| }) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
binarynoise marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </string-array> | ||
| </resources> | ||
2 changes: 2 additions & 0 deletions
2
metadata/de.binarynoise.AlwaysAllowChargingSounds/en-US/full_description.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
1 change: 1 addition & 0 deletions
1
metadata/de.binarynoise.AlwaysAllowChargingSounds/en-US/short_description.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Always allow charging sounds, even in DnD mode. |
1 change: 1 addition & 0 deletions
1
metadata/de.binarynoise.AlwaysAllowChargingSounds/en-US/title.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| AlwaysAllowChargingSounds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.