fix(YouTube - GmsCore support): Prompt to disable battery optimizations, if not done already (#2958)

Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
LisoUseInAIKyrios 2024-04-06 22:45:59 +04:00 committed by GitHub
parent d9c5057d76
commit 82acb84b5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 11 deletions

View File

@ -5,7 +5,6 @@ import app.revanced.patches.music.misc.gms.Constants.REVANCED_MUSIC_PACKAGE_NAME
import app.revanced.patches.music.misc.gms.GmsCoreSupportResourcePatch.gmsCoreVendorGroupIdOption import app.revanced.patches.music.misc.gms.GmsCoreSupportResourcePatch.gmsCoreVendorGroupIdOption
import app.revanced.patches.music.misc.gms.fingerprints.* import app.revanced.patches.music.misc.gms.fingerprints.*
import app.revanced.patches.music.misc.integrations.IntegrationsPatch import app.revanced.patches.music.misc.integrations.IntegrationsPatch
import app.revanced.patches.music.misc.integrations.fingerprints.ApplicationInitFingerprint
import app.revanced.patches.shared.fingerprints.CastContextFetchFingerprint import app.revanced.patches.shared.fingerprints.CastContextFetchFingerprint
import app.revanced.patches.shared.misc.gms.BaseGmsCoreSupportPatch import app.revanced.patches.shared.misc.gms.BaseGmsCoreSupportPatch
@ -21,7 +20,7 @@ object GmsCoreSupportPatch : BaseGmsCoreSupportPatch(
CastDynamiteModuleV2Fingerprint, CastDynamiteModuleV2Fingerprint,
CastContextFetchFingerprint, CastContextFetchFingerprint,
), ),
mainActivityOnCreateFingerprint = ApplicationInitFingerprint, mainActivityOnCreateFingerprint = MusicActivityOnCreateFingerprint,
integrationsPatchDependency = IntegrationsPatch::class, integrationsPatchDependency = IntegrationsPatch::class,
gmsCoreSupportResourcePatch = GmsCoreSupportResourcePatch, gmsCoreSupportResourcePatch = GmsCoreSupportResourcePatch,
compatiblePackages = setOf(CompatiblePackage("com.google.android.apps.youtube.music")), compatiblePackages = setOf(CompatiblePackage("com.google.android.apps.youtube.music")),

View File

@ -0,0 +1,11 @@
package app.revanced.patches.music.misc.gms.fingerprints
import app.revanced.patcher.fingerprint.MethodFingerprint
internal object MusicActivityOnCreateFingerprint : MethodFingerprint(
returnType = "V",
parameters = listOf("Landroid/os/Bundle;"),
customFingerprint = { methodDef, classDef ->
methodDef.name == "onCreate" && classDef.type.endsWith("/MusicActivity;")
}
)

View File

@ -98,9 +98,9 @@ abstract class BaseGmsCoreSupportPatch(
// Verify GmsCore is installed and whitelisted for power optimizations and background usage. // Verify GmsCore is installed and whitelisted for power optimizations and background usage.
mainActivityOnCreateFingerprint.result?.mutableMethod?.addInstructions( mainActivityOnCreateFingerprint.result?.mutableMethod?.addInstructions(
1, // Hack to not disturb other patches (such as the YTMusic integrations patch). 0,
"invoke-static/range { p0 .. p0 }, Lapp/revanced/integrations/shared/GmsCoreSupport;->" + "invoke-static/range { p0 .. p0 }, Lapp/revanced/integrations/shared/GmsCoreSupport;->" +
"checkGmsCore(Landroid/content/Context;)V", "checkGmsCore(Landroid/app/Activity;)V",
) ?: throw mainActivityOnCreateFingerprint.exception ) ?: throw mainActivityOnCreateFingerprint.exception
// Change the vendor of GmsCore in ReVanced Integrations. // Change the vendor of GmsCore in ReVanced Integrations.

View File

@ -42,13 +42,12 @@
</patch> </patch>
<patch id="misc.gms.BaseGmsCoreSupportResourcePatch"> <patch id="misc.gms.BaseGmsCoreSupportResourcePatch">
<!-- Translations of this should not be longer than the original English text, otherwise the text can be clipped and not entirely shown. --> <!-- Translations of this should not be longer than the original English text, otherwise the text can be clipped and not entirely shown. -->
<string name="gms_core_toast_not_installed_message">GmsCore is not installed. Install it.</string> <string name="gms_core_toast_not_installed_message">MicroG GmsCore is not installed. Install it.</string>
<!-- Translations of this should not be longer than the original English text, otherwise the text can be clipped and not entirely shown. -->
<string name="gms_core_toast_not_whitelisted_message">Follow the \"Don\'t kill my app\" guide for GmsCore.</string>
<string name="gms_core_dialog_title">Action needed</string> <string name="gms_core_dialog_title">Action needed</string>
<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> <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>
<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> <string name="gms_core_dialog_open_website_text">Open website</string>
<string name="gms_core_dialog_ok_button_text">Open website</string> <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>
<string name="gms_core_dialog_continue_text">Continue</string>
</patch> </patch>
</app> </app>
<app id="youtube"> <app id="youtube">
@ -573,7 +572,7 @@
<string name="revanced_hide_shorts_subscribe_button_paused_title">Hide subscribe button when paused</string> <string name="revanced_hide_shorts_subscribe_button_paused_title">Hide subscribe button when paused</string>
<string name="revanced_hide_shorts_subscribe_button_paused_summary_on">Subscribe button is hidden</string> <string name="revanced_hide_shorts_subscribe_button_paused_summary_on">Subscribe button is hidden</string>
<string name="revanced_hide_shorts_subscribe_button_paused_summary_off">Subscribe button is shown</string> <string name="revanced_hide_shorts_subscribe_button_paused_summary_off">Subscribe button is shown</string>
<!-- 'thanks' should be translated using the same localized wording YouTube displays for the button. <!-- 'thanks' should be translated using the same localized wording YouTube displays for the button.
If the button never shows up, then translate the button name normally. --> If the button never shows up, then translate the button name normally. -->
<string name="revanced_hide_shorts_thanks_button_title">Hide thanks button</string> <string name="revanced_hide_shorts_thanks_button_title">Hide thanks button</string>
<string name="revanced_hide_shorts_thanks_button_summary_on">Thanks button is hidden</string> <string name="revanced_hide_shorts_thanks_button_summary_on">Thanks button is hidden</string>