Skip to content

Commit 82acb84

Browse files
fix(YouTube - GmsCore support): Prompt to disable battery optimizations, if not done already (ReVanced#2958)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
1 parent d9c5057 commit 82acb84

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportPatch.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import app.revanced.patches.music.misc.gms.Constants.REVANCED_MUSIC_PACKAGE_NAME
55
import app.revanced.patches.music.misc.gms.GmsCoreSupportResourcePatch.gmsCoreVendorGroupIdOption
66
import app.revanced.patches.music.misc.gms.fingerprints.*
77
import app.revanced.patches.music.misc.integrations.IntegrationsPatch
8-
import app.revanced.patches.music.misc.integrations.fingerprints.ApplicationInitFingerprint
98
import app.revanced.patches.shared.fingerprints.CastContextFetchFingerprint
109
import app.revanced.patches.shared.misc.gms.BaseGmsCoreSupportPatch
1110

@@ -21,7 +20,7 @@ object GmsCoreSupportPatch : BaseGmsCoreSupportPatch(
2120
CastDynamiteModuleV2Fingerprint,
2221
CastContextFetchFingerprint,
2322
),
24-
mainActivityOnCreateFingerprint = ApplicationInitFingerprint,
23+
mainActivityOnCreateFingerprint = MusicActivityOnCreateFingerprint,
2524
integrationsPatchDependency = IntegrationsPatch::class,
2625
gmsCoreSupportResourcePatch = GmsCoreSupportResourcePatch,
2726
compatiblePackages = setOf(CompatiblePackage("com.google.android.apps.youtube.music")),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package app.revanced.patches.music.misc.gms.fingerprints
2+
3+
import app.revanced.patcher.fingerprint.MethodFingerprint
4+
5+
internal object MusicActivityOnCreateFingerprint : MethodFingerprint(
6+
returnType = "V",
7+
parameters = listOf("Landroid/os/Bundle;"),
8+
customFingerprint = { methodDef, classDef ->
9+
methodDef.name == "onCreate" && classDef.type.endsWith("/MusicActivity;")
10+
}
11+
)

src/main/kotlin/app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportPatch.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ abstract class BaseGmsCoreSupportPatch(
9898

9999
// Verify GmsCore is installed and whitelisted for power optimizations and background usage.
100100
mainActivityOnCreateFingerprint.result?.mutableMethod?.addInstructions(
101-
1, // Hack to not disturb other patches (such as the YTMusic integrations patch).
101+
0,
102102
"invoke-static/range { p0 .. p0 }, Lapp/revanced/integrations/shared/GmsCoreSupport;->" +
103-
"checkGmsCore(Landroid/content/Context;)V",
103+
"checkGmsCore(Landroid/app/Activity;)V",
104104
) ?: throw mainActivityOnCreateFingerprint.exception
105105

106106
// Change the vendor of GmsCore in ReVanced Integrations.

src/main/resources/addresources/values/strings.xml

+6-7
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,12 @@
4242
</patch>
4343
<patch id="misc.gms.BaseGmsCoreSupportResourcePatch">
4444
<!-- Translations of this should not be longer than the original English text, otherwise the text can be clipped and not entirely shown. -->
45-
<string name="gms_core_toast_not_installed_message">GmsCore is not installed. Install it.</string>
46-
<!-- Translations of this should not be longer than the original English text, otherwise the text can be clipped and not entirely shown. -->
47-
<string name="gms_core_toast_not_whitelisted_message">Follow the \"Don\'t kill my app\" guide for GmsCore.</string>
45+
<string name="gms_core_toast_not_installed_message">MicroG GmsCore is not installed. Install it.</string>
4846
<string name="gms_core_dialog_title">Action needed</string>
49-
<string name="gms_core_dialog_not_whitelisted_using_battery_optimizations_message">GmsCore is not whitelisted from battery optimization.\n\nFollow the \"Don\'t kill my app\" guide for GmsCore.</string>
50-
<string name="gms_core_dialog_not_whitelisted_not_allowed_in_background_message">GmsCore does not have permission to run in the background.\n\nFollow the \"Don\'t kill my app\" guide for GmsCore.</string>
51-
<string name="gms_core_dialog_ok_button_text">Open website</string>
47+
<string name="gms_core_dialog_not_whitelisted_not_allowed_in_background_message">MicroG GmsCore does not have permission to run in the background.\n\nFollow the \"Don\'t kill my app\" guide for your phone, and apply the instructions to your MicroG installation.\n\nThis is required for the app to work.</string>
48+
<string name="gms_core_dialog_open_website_text">Open website</string>
49+
<string name="gms_core_dialog_not_whitelisted_using_battery_optimizations_message">MicroG GmsCore battery optimizations must be disabled to prevent issues.\n\nTap on the continue button and disable battery optimizations.</string>
50+
<string name="gms_core_dialog_continue_text">Continue</string>
5251
</patch>
5352
</app>
5453
<app id="youtube">
@@ -573,7 +572,7 @@
573572
<string name="revanced_hide_shorts_subscribe_button_paused_title">Hide subscribe button when paused</string>
574573
<string name="revanced_hide_shorts_subscribe_button_paused_summary_on">Subscribe button is hidden</string>
575574
<string name="revanced_hide_shorts_subscribe_button_paused_summary_off">Subscribe button is shown</string>
576-
<!-- 'thanks' should be translated using the same localized wording YouTube displays for the button.
575+
<!-- 'thanks' should be translated using the same localized wording YouTube displays for the button.
577576
If the button never shows up, then translate the button name normally. -->
578577
<string name="revanced_hide_shorts_thanks_button_title">Hide thanks button</string>
579578
<string name="revanced_hide_shorts_thanks_button_summary_on">Thanks button is hidden</string>

0 commit comments

Comments
 (0)