PluginMobileNativeCode icon indicating copy to clipboard operation
PluginMobileNativeCode copied to clipboard

Add WakeUp, Auto Start

Open quanghuynb123456789 opened this issue 7 months ago • 0 comments

Add WakeUp and AutoStart Features to MobileNativeCode Plugin

Description

This PR introduces two new features to the MobileNativeCode plugin for Unreal Engine on Android.

WakeUp

  • Prevents the Android device from entering Doze Mode
  • Keeps Wi-Fi alive even during screen-off or idle state
  • Ideal for real-time apps like VR multiplayer or persistent networking
  • Restrict:
    • Currently limited to run only while the app is active - this is an intentional design choice
    • To make it work even when the app is closed, simply remove the AppLifecycleObserver restriction, and let the background service run independently

AutoStart

  • Automatically launches the application right after device boot
  • Implements BroadcastReceiver to detect BOOT_COMPLETED
  • Starts a custom background Service to trigger app launch
  • Verified functionality on Meta Quest (Android VR device)

Testing

  • Tested on Meta Quest 2
  • Both features function reliably across multiple reboots and idle/wake cycles
  • No noticeable performance or battery issues during usage

Changes

  • Added new Java classes: WakeUpHelper.java, AutoStartReceiver.java, BootService.java
  • Modified plugin AndroidManifest.xml to declare permissions and services
  • Exposed native methods to Unreal via JNI for enabling these features

Notes

  • AutoStart requires RECEIVE_BOOT_COMPLETED and proper system permission
  • WakeLock is used carefully to avoid battery abuse; it's released appropriately
  • No changes were made to existing plugin logic

quanghuynb123456789 avatar Jun 19 '25 07:06 quanghuynb123456789