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

Commit b4a032fd authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use buffered DataInputStream vs RandomAccessFile" into oc-dev

parents 8d4f9d8e 98b8d31a
Loading
Loading
Loading
Loading
+13 −13
Original line number Diff line number Diff line
@@ -1397,23 +1397,22 @@ public class BackupManagerService {
        // Remember our ancestral dataset
        mTokenFile = new File(mBaseStateDir, "ancestral");
        try {
            RandomAccessFile tf = new RandomAccessFile(mTokenFile, "r");
            int version = tf.readInt();
        try (DataInputStream tokenStream = new DataInputStream(new BufferedInputStream(
                new FileInputStream(mTokenFile)))) {
            int version = tokenStream.readInt();
            if (version == CURRENT_ANCESTRAL_RECORD_VERSION) {
                mAncestralToken = tf.readLong();
                mCurrentToken = tf.readLong();
                mAncestralToken = tokenStream.readLong();
                mCurrentToken = tokenStream.readLong();
                int numPackages = tf.readInt();
                int numPackages = tokenStream.readInt();
                if (numPackages >= 0) {
                    mAncestralPackages = new HashSet<String>();
                    mAncestralPackages = new HashSet<>();
                    for (int i = 0; i < numPackages; i++) {
                        String pkgName = tf.readUTF();
                        String pkgName = tokenStream.readUTF();
                        mAncestralPackages.add(pkgName);
                    }
                }
            }
            tf.close();
        } catch (FileNotFoundException fnf) {
            // Probably innocuous
            Slog.v(TAG, "No ancestral data");
@@ -1437,12 +1436,13 @@ public class BackupManagerService {
        // If there are previous contents, parse them out then start a new
        // file to continue the recordkeeping.
        if (mEverStored.exists()) {
            RandomAccessFile temp = null;
            RandomAccessFile in = null;
            DataOutputStream temp = null;
            DataInputStream in = null;
            try {
                temp = new RandomAccessFile(tempProcessedFile, "rws");
                in = new RandomAccessFile(mEverStored, "r");
                temp = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(
                        tempProcessedFile)));
                in = new DataInputStream(new BufferedInputStream(new FileInputStream(mEverStored)));
                // Loop until we hit EOF
                while (true) {