Disable explicit gc method invocation in V
Disable the gc() method explicit invocation due to the new policy in the android to avoid android.os.strictmode.ExplicitGcViolation Test: presubmit Fix: 345577704 Flag: EXEMPT strictmode fix Change-Id: I6ec7dac6735499c40a7ab6d135108e4c5013a4a4
This commit is contained in:
@@ -66,10 +66,10 @@ import java.util.stream.Collectors;
|
|||||||
public final class DatabaseUtils {
|
public final class DatabaseUtils {
|
||||||
private static final String TAG = "DatabaseUtils";
|
private static final String TAG = "DatabaseUtils";
|
||||||
private static final String SHARED_PREFS_FILE = "battery_usage_shared_prefs";
|
private static final String SHARED_PREFS_FILE = "battery_usage_shared_prefs";
|
||||||
|
private static final boolean EXPLICIT_CLEAR_MEMORY_ENABLED = false;
|
||||||
|
|
||||||
/** Clear memory threshold for device booting phase. */
|
/** Clear memory threshold for device booting phase. */
|
||||||
private static final long CLEAR_MEMORY_THRESHOLD_MS = Duration.ofMinutes(5).toMillis();
|
private static final long CLEAR_MEMORY_THRESHOLD_MS = Duration.ofMinutes(5).toMillis();
|
||||||
|
|
||||||
private static final long CLEAR_MEMORY_DELAYED_MS = Duration.ofSeconds(2).toMillis();
|
private static final long CLEAR_MEMORY_DELAYED_MS = Duration.ofSeconds(2).toMillis();
|
||||||
private static final long INVALID_TIMESTAMP = 0L;
|
private static final long INVALID_TIMESTAMP = 0L;
|
||||||
|
|
||||||
@@ -975,7 +975,8 @@ public final class DatabaseUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void clearMemory() {
|
private static void clearMemory() {
|
||||||
if (SystemClock.uptimeMillis() > CLEAR_MEMORY_THRESHOLD_MS) {
|
if (!EXPLICIT_CLEAR_MEMORY_ENABLED
|
||||||
|
|| SystemClock.uptimeMillis() > CLEAR_MEMORY_THRESHOLD_MS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Handler mainHandler = new Handler(Looper.getMainLooper());
|
final Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
|
Reference in New Issue
Block a user