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

Commit 274498e5 authored by Shubham Ajmera's avatar Shubham Ajmera
Browse files

Replace RandomAccessFile with BufferedInputStream

com.android.server.backup.BackupManagerService#parseLeftoverJournals
uses input stream to read UTF. The method used RandomAccessFile to
perform the operation. The change replace the RandomAccessFile with
a Buffered InputStream.

Bug: 32866032
Test: `make`
Change-Id: I6594cecc49cb6efcfdf73beb5e425688cf890722
parent cb48c485
Loading
Loading
Loading
Loading
+19 −15
Original line number Diff line number Diff line
@@ -1535,10 +1535,14 @@ public class BackupManagerService {
                // This isn't the current journal, so it must be a leftover.  Read
                // out the package names mentioned there and schedule them for
                // backup.
                RandomAccessFile in = null;
                DataInputStream in = null;
                try {
                    Slog.i(TAG, "Found stale backup journal, scheduling");
                    in = new RandomAccessFile(f, "r");
                    // Journals will tend to be on the order of a few kilobytes(around 4k), hence,
                    // setting the buffer size to 8192.
                    InputStream bufferedInputStream = new BufferedInputStream(
                            new FileInputStream(f), 8192);
                    in = new DataInputStream(bufferedInputStream);
                    while (true) {
                        String packageName = in.readUTF();
                        if (MORE_DEBUG) Slog.i(TAG, "  " + packageName);