From 434a169a3e95826a3b7e169d21f3d71d48ea5387 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Fri, 2 Feb 2024 18:54:40 -0500 Subject: [PATCH] run full explicit GC in SystemUI and system_server after locking ART has special support for System.gc() and Android already uses this to purge memory after unlocking. It makes sense to purge as much as we can when locking too. --- .../com/android/systemui/keyguard/KeyguardViewMediator.java | 3 +++ .../server/policy/keyguard/KeyguardStateMonitor.java | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 56df8d003494..34595c07bc13 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -2769,6 +2769,9 @@ private void handleShow(Bundle options) { userActivity(); mUpdateMonitor.setKeyguardGoingAway(false); mKeyguardViewControllerLazy.get().setKeyguardGoingAwayState(false); + System.gc(); + System.runFinalization(); + System.gc(); mShowKeyguardWakeLock.release(); } mKeyguardDisplayManager.show(); diff --git a/services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java b/services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java index e1b506520eb8..a237a495bc95 100644 --- a/services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java +++ b/services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java @@ -97,6 +97,12 @@ public void onShowingStateChanged(boolean showing, int userId) { ExtSettings.DENY_NEW_USB_TRANSIENT_ENABLE : ExtSettings.DENY_NEW_USB_TRANSIENT_DISABLE); } + + if (showing) { + System.gc(); + System.runFinalization(); + System.gc(); + } } @Override // Binder interface