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

Commit 40f14ac2 authored by Rubin Xu's avatar Rubin Xu
Browse files

Suppress FileNotFoundException in LockSettingsService

Remove log spam resulted from LockSettingsStorage looking for user credential hashes
on the disk by trying several possible paths.

Bug: 62410009
Test: boot device, check there is no exception log from LSS
Change-Id: I1530c381316dce21d862f82244cc99cc45a8774a
parent f963e0d5
Loading
Loading
Loading
Loading
+5 −11
Original line number Original line Diff line number Diff line
@@ -47,6 +47,7 @@ import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
import java.nio.channels.FileChannel;
@@ -325,23 +326,16 @@ class LockSettingsStorage {
            version = mCache.getVersion();
            version = mCache.getVersion();
        }
        }


        RandomAccessFile raf = null;
        byte[] stored = null;
        byte[] stored = null;
        try {
        try (RandomAccessFile raf = new RandomAccessFile(name, "r")) {
            raf = new RandomAccessFile(name, "r");
            stored = new byte[(int) raf.length()];
            stored = new byte[(int) raf.length()];
            raf.readFully(stored, 0, stored.length);
            raf.readFully(stored, 0, stored.length);
            raf.close();
            raf.close();
        } catch (FileNotFoundException suppressed) {
            // readFile() is also called by hasFile() to check the existence of files, in this
            // case FileNotFoundException is expected.
        } catch (IOException e) {
        } catch (IOException e) {
            Slog.e(TAG, "Cannot read file " + e);
            Slog.e(TAG, "Cannot read file " + e);
        } finally {
            if (raf != null) {
                try {
                    raf.close();
                } catch (IOException e) {
                    Slog.e(TAG, "Error closing file " + e);
                }
            }
        }
        }
        mCache.putFileIfUnchanged(name, stored, version);
        mCache.putFileIfUnchanged(name, stored, version);
        return stored;
        return stored;