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

Commit 1a739692 authored by Siim Sammul's avatar Siim Sammul
Browse files

Stop adding large proto tombstones to dropbox.

Processing the large proto tombstones can cause OOM and there is no point adding tombstones larger than dropbox max capacity as they will not get uploaded.


Bug: 343135528
Change-Id: Ib308e48dcfc3282ae7ab0e9fa0827cc8fae97078
parent 921b1748
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -141,6 +141,10 @@ public class BootReceiver extends BroadcastReceiver {
    private static final int MAX_ERROR_REPORTS = 8;
    private static int sSentReports = 0;

    // Max tombstone file size to add to dropbox.
    private static final long MAX_TOMBSTONE_SIZE_BYTES =
            DropBoxManagerService.DEFAULT_QUOTA_KB * 1024;

    @Override
    public void onReceive(final Context context, Intent intent) {
        // Log boot events in the background to avoid blocking the main thread with I/O
@@ -390,6 +394,12 @@ public class BootReceiver extends BroadcastReceiver {
    private static void addAugmentedProtoToDropbox(
                File tombstone, DropBoxManager db,
                DropboxRateLimiter.RateLimitResult rateLimitResult) throws IOException {
        // Do not add proto files larger than 20Mb to DropBox as they can cause OOMs when
        // processing large tombstones. The text tombstone is still added to DropBox.
        if (tombstone.length() > MAX_TOMBSTONE_SIZE_BYTES) {
            Slog.w(TAG, "Tombstone too large to add to DropBox: " + tombstone.toPath());
            return;
        }
        // Read the proto tombstone file as bytes.
        final byte[] tombstoneBytes = Files.readAllBytes(tombstone.toPath());

+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ public final class DropBoxManagerService extends SystemService {
    private static final int DEFAULT_AGE_SECONDS = 3 * 86400;
    private static final int DEFAULT_MAX_FILES = 1000;
    private static final int DEFAULT_MAX_FILES_LOWRAM = 300;
    private static final int DEFAULT_QUOTA_KB = Build.IS_USERDEBUG ? 20 * 1024 : 10 * 1024;
    public static final int DEFAULT_QUOTA_KB = Build.IS_USERDEBUG ? 20 * 1024 : 10 * 1024;
    private static final int DEFAULT_QUOTA_PERCENT = 10;
    private static final int DEFAULT_RESERVE_PERCENT = 0;
    private static final int QUOTA_RESCAN_MILLIS = 5000;