Remove unsued legacy clearMemory() method
Test: atest Bug: 373544647 Flag: EXEMPT for simple fix Change-Id: I0efff624a0d05ec3b6b1ff34ba15db7a2abac031
This commit is contained in:
@@ -31,8 +31,6 @@ import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.BatteryUsageStats;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.RemoteException;
|
||||
import android.os.SystemClock;
|
||||
import android.os.UserManager;
|
||||
@@ -66,12 +64,6 @@ import java.util.stream.Collectors;
|
||||
public final class DatabaseUtils {
|
||||
private static final String TAG = "DatabaseUtils";
|
||||
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. */
|
||||
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 INVALID_TIMESTAMP = 0L;
|
||||
|
||||
static final int DATA_RETENTION_INTERVAL_DAY = 9;
|
||||
@@ -593,7 +585,6 @@ public final class DatabaseUtils {
|
||||
String.format(
|
||||
"sendAppUsageEventData() size=%d in %d/ms",
|
||||
size, (System.currentTimeMillis() - startTime)));
|
||||
clearMemory();
|
||||
return valuesList;
|
||||
}
|
||||
|
||||
@@ -613,7 +604,6 @@ public final class DatabaseUtils {
|
||||
String.format(
|
||||
"sendBatteryEventData() in %d/ms",
|
||||
(System.currentTimeMillis() - startTime)));
|
||||
clearMemory();
|
||||
return contentValues;
|
||||
}
|
||||
|
||||
@@ -647,7 +637,6 @@ public final class DatabaseUtils {
|
||||
String.format(
|
||||
"sendBatteryEventData() size=%d in %d/ms",
|
||||
size, (System.currentTimeMillis() - startTime)));
|
||||
clearMemory();
|
||||
return valuesList;
|
||||
}
|
||||
|
||||
@@ -681,7 +670,6 @@ public final class DatabaseUtils {
|
||||
String.format(
|
||||
"sendBatteryUsageSlotData() size=%d in %d/ms",
|
||||
size, (System.currentTimeMillis() - startTime)));
|
||||
clearMemory();
|
||||
return valuesList;
|
||||
}
|
||||
|
||||
@@ -695,7 +683,6 @@ public final class DatabaseUtils {
|
||||
final Intent intent = BatteryUtils.getBatteryIntent(context);
|
||||
if (intent == null) {
|
||||
Log.e(TAG, "sendBatteryEntryData(): cannot fetch battery intent");
|
||||
clearMemory();
|
||||
return null;
|
||||
}
|
||||
final int batteryLevel = BatteryStatus.getBatteryLevel(intent);
|
||||
@@ -796,7 +783,6 @@ public final class DatabaseUtils {
|
||||
if (isFullChargeStart) {
|
||||
recordDateTime(context, KEY_LAST_UPLOAD_FULL_CHARGE_TIME);
|
||||
}
|
||||
clearMemory();
|
||||
return valuesList;
|
||||
}
|
||||
|
||||
@@ -992,20 +978,4 @@ public final class DatabaseUtils {
|
||||
writer.println(String.format("\t\t%s: %s", prefix, results.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static void clearMemory() {
|
||||
if (!EXPLICIT_CLEAR_MEMORY_ENABLED
|
||||
|| SystemClock.uptimeMillis() > CLEAR_MEMORY_THRESHOLD_MS) {
|
||||
return;
|
||||
}
|
||||
final Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
mainHandler.postDelayed(
|
||||
() -> {
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
System.gc();
|
||||
Log.w(TAG, "invoke clearMemory()");
|
||||
},
|
||||
CLEAR_MEMORY_DELAYED_MS);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user