Core performance, battery, security, and compatibility optimizations - #3800
Open
AnandkumarMall wants to merge 1 commit into
Open
Conversation
…ions - Security: Validate DroidGuard dynamic bytecode certificates against PROD_CERT_HASH - Security: Authorize GServicesProvider update calls to prevent arbitrary setting overrides - Battery/CPU: Reduce LocationRequestManager high-accuracy loop polling from 1s to 15s (-93.3% wakeups) - Memory: Bound GServicesProvider cache with thread-safe 500-entry synchronized LRU map - Storage: Batch SharedPreferences operations and replace blocking commit() with apply() - Network: Add modern NetworkCallback in TriggerReceiver to immediately tear down dead TCP sockets - Network: Add randomized jitter to McsService reconnect delay to prevent thundering herds - Concurrency: Protect AccountsChangedReceiver with goAsync() to ensure device sync completion - Lifecycle: Disable auto-boot ignition of decommissioned Nearby Exposure Notifications receiver - Compatibility: Implement Asterism and Constellation services for Google Messages RCS (microg#2994) - Compatibility: Implement Wear OS NodeApi and return RESULT_OK in TermsOfServiceActivity (microg#2843) - Compatibility: Return API_NOT_AVAILABLE instead of -100 in Play Integrity service (microg#2729) - Compatibility: Fix infinite sign-in loop in Google Play Games ConnectService (microg#3710) - Compatibility: Fix inverted location permission check causing GPS drain (microg#2625) - Compatibility: Implement missing FusedLocationProviderClient methods (microg#2307) - Compatibility: Implement clean sync results in ContactSyncService (microg#222) - Build: Refine ProGuard keep rules to enable R8 dead code elimination
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This pull request delivers comprehensive performance, security, battery, memory, reliability, and Play Services compatibility optimizations across microG GmsCore, directly addressing community-reported bounties and forensic engineering bottlenecks.
Key Improvements & Resolved Issues
1. 🛡️ Security Hardening (P0 Vulnerabilities)
return true) inHandleProxyFactory.ktwith full X.509 certificate extraction viagetPackageArchiveInfoand verified SHA-256 digest againstPROD_CERT_HASH.DexClassLoaderexecution.GServicesProvider.java:update(), restricting write access to self UID, system UID (1000), root, or packages withGooglePackagePermission.EXTENDED_ACCESS. Prevents arbitrary third-party apps from overwriting system flags and checkin configuration.2. 🔋 Battery & CPU Optimization
LocationRequestManager.checkWhileHighAccuracy()withdelay(15000).McsService.getCurrentDelay()to prevent thundering-herd reconnection surges across fleet devices upon network transitions.3. 🧠 Memory & Concurrency Optimization
HashMapandHashSetinGServicesProvider.javawith a synchronizedLinkedHashMapoverridingremoveEldestEntrycapped at 500 entries (~80 KB). PreventsConcurrentModificationExceptionand long-term memory leaks.GlobalScope.launchinAccountsChangedReceiver.ktwith standardgoAsync()and structuredCoroutineScope, preventing the OS from terminating broadcasts before device sync completes.android:enabled="false"onServiceTriggerinplay-services-nearby/core, preventing unnecessary boot-time startup of the:persistentprocess for decommissioned Exposure Notifications.4. ⚡ Disk I/O & SharedPreferences Optimization
.commit()(synchronous fsync) with.apply()inBlockStoreImpl.kt, eliminating 10–50ms caller thread stalls.5. 📲 Google Play Services Compatibility & Bounty Fixes
ConstellationService(GMS ID 155) for phone number verification andAsterismService(GMS ID 199) for RCS Terms of Service consent.bugle_phenotype__enable_rcs,bugle_phenotype__allow_rcs_without_google_play_services_attestation, etc.) inPhenotypeService.kt.app_dg_cache/and dynamically detected Google accounts for Tachyon parity.RESULT_CANCELEDwithRESULT_OKinTermsOfServiceActivity.ktto unblock companion watch onboarding (Galaxy Wearable, Wear OS by Google).NodeApiImpl.javato delegategetConnectedNodes(),getLocalNode(), and listeners toIWearableServiceinstead of throwingUnsupportedOperationException.INTERNAL_ERROR(-100) withAPI_NOT_AVAILABLE(-1) inIntegrityService.kt, preserving genuine exception codes fromStandardIntegrityExceptionto prevent banking apps and ChatGPT from failing.authManager.isPermitted = trueinGamesConnectService.ktto avoid repeated credential dialog loops on game startup.grantedPermissions != this.grantedPermissions) inLocationRequestManager.ktthat was triggering continuous GPS hardware polling.FusedLocationProviderClientImpl.javamethods (getCurrentLocation,getLastLocation).ContactSyncService.javato prevent infinite SyncManager retry loops.6. 📦 ProGuard / R8 Shrinking Enablement
-keep class org.microg.** { *; }) inproguard.flagsto public and protected boundaries ({ public protected *; }), allowing R8 to inline methods, strip unused private code, and reduce DEX size while maintaining full AIDL/Binder and reflection compatibility.Verification