Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5335d020 authored by Eric Biggers's avatar Eric Biggers Committed by Automerger Merge Worker
Browse files

Merge "Prevent GC requests from piling up in LockSettingsService" into main...

Merge "Prevent GC requests from piling up in LockSettingsService" into main am: 7dc33f35 am: 9e0155fb

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/3328586



Change-Id: I40540326d01aac69ff7f588aadc6c38b0c14be90
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents cb8845f0 9e0155fb
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -347,6 +347,8 @@ public class LockSettingsService extends ILockSettings.Stub {

    private final StorageManagerInternal mStorageManagerInternal;

    private final Object mGcWorkToken = new Object();

    // This class manages life cycle events for encrypted users on File Based Encryption (FBE)
    // devices. The most basic of these is to show/hide notifications about missing features until
    // the user unlocks the account and credential-encrypted storage is available.
@@ -3632,11 +3634,19 @@ public class LockSettingsService extends ILockSettings.Stub {
     * release references to the argument.
     */
    private void scheduleGc() {
        // Cancel any existing GC request first, so that GC requests don't pile up if lockscreen
        // credential operations are happening very quickly, e.g. as sometimes happens during tests.
        //
        // This delays the already-requested GC, but that is fine in practice where lockscreen
        // operations don't happen very quickly.  And the precise time that the sanitization happens
        // isn't very important; doing it within a minute can be fine, for example.
        mHandler.removeCallbacksAndMessages(mGcWorkToken);

        mHandler.postDelayed(() -> {
            System.gc();
            System.runFinalization();
            System.gc();
        }, 2000);
        }, mGcWorkToken, 2000);
    }

    private class DeviceProvisionedObserver extends ContentObserver {