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

Commit bede0120 authored by Alex Naidis's avatar Alex Naidis Committed by android-build-merger
Browse files

Merge "StorageManager: Improve exception handling" am: cf3a4a68 am: 545cf378 am: edca8aa3

am: 32dfe8c6

Change-Id: I5faf99bd2b4425f1615419de43f247f78d74108b
parents 363e9f78 32dfe8c6
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import com.android.internal.util.Preconditions;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.ref.WeakReference;
@@ -974,8 +975,15 @@ public class StorageManager {
        try (final FileInputStream fis = new FileInputStream(path);
                final BufferedReader reader = new BufferedReader(new InputStreamReader(fis));) {
            return Long.parseLong(reader.readLine());
        } catch (FileNotFoundException e) {
            // This is expected since we are trying to parse multiple paths.
            Slog.i(TAG, "readLong(): Path doesn't exist: " + path + ": " + e);
            return 0;
        } catch (NumberFormatException e) {
            Slog.e(TAG, "readLong(): Could not parse " + path + ": " + e);
            return 0;
        } catch (Exception e) {
            Slog.w(TAG, "readLong(): could not read " + path + ": " + e);
            Slog.e(TAG, "readLong(): Unknown exception while opening " + path + ": " + e);
            return 0;
       }
    }