The template GameActivity.java is in Engine/Build/Android/Java/src/com/epicgames/ue4 but a new version is generated any time you package or launch on. This one ends up in Intermediate/Android/APK/src/com/epicgames/ue4.
The best way to make changes to GameActivity.java is to use UPL (Unreal Plugin Language). There are sections within GameActivity which you may insert code documented in UnrealPluginLanguage.cs. All you need to do is register your UPL XML file in a Build.cs for the Android target. Look at GearVR.Build.cs and GearVR_APL.xml for examples.
Just for anyone looking. GameActivity in ue5 (unreal 5) is in \Engine\Build\Android\Java\src\com\epicgames\unreal
so if you have java code (e.g. android) using the package import you need to change the line import com.epicgames.ue4.GameActivity;
with import com.epicgames.unreal.GameActivity;
Also note that that file has an issue, on line 3369 it references the function OnThermalStatusChangedListener which was added only in api level 29 so you need to target 29 or higher.
Either you would need to patch it (beware it’s a template so it will replace modifications on your project), or target 29+. (setting target-sdk on project settings > android, and ndk api level on project settings > android sdk to 30 worked for me).