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

Commit 841a92e9 authored by Rubin Xu's avatar Rubin Xu Committed by Automerger Merge Worker
Browse files

Merge "Delay gargabe collection during onDestroy()" into sc-dev am: 3e84dd27

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/15178137

Change-Id: I7d5f0798ef53751be363f2d8df44b14a8c7a3d7c
parents 5c297fa5 3e84dd27
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.settings.password;

import android.app.KeyguardManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.UserManager;
import android.util.Log;
import android.view.MenuItem;
@@ -163,11 +165,14 @@ public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivi
    @Override
    public void onDestroy() {
        super.onDestroy();
        // Force a garbage collection immediately to remove remnant of user password shards
        // from memory.
        // Force a garbage collection to remove remnant of user password shards from memory.
        // Execute this with a slight delay to allow the activity lifecycle to complete and
        // the instance to become gc-able.
        new Handler(Looper.myLooper()).postDelayed(() -> {
            System.gc();
            System.runFinalization();
            System.gc();
        }, 5000);
    }

    @Override
+10 −5
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import android.os.UserManager;
import android.os.storage.StorageManager;
@@ -216,11 +218,14 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
        public void onDestroy() {
            super.onDestroy();
            mPasswordEntry.setText(null);
            // Force a garbage collection immediately to remove remnant of user password shards
            // from memory.
            // Force a garbage collection to remove remnant of user password shards from memory.
            // Execute this with a slight delay to allow the activity lifecycle to complete and
            // the instance to become gc-able.
            new Handler(Looper.myLooper()).postDelayed(() -> {
                System.gc();
                System.runFinalization();
                System.gc();
            }, 5000);
        }

        private int getDefaultHeader() {