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

Commit 8ef50fc6 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Close the FileStream to avoid resource leak" am: c54117c7 am:...

Merge "Close the FileStream to avoid resource leak" am: c54117c7 am: 3a3001fe am: 2422cbb8 am: 58c6f71a

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1710968

Change-Id: If343279d4abacfb46d5151116604ff4bca93bafb
parents 6b1d0ff7 58c6f71a
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -2859,8 +2859,7 @@ public class InputManagerService extends IInputManager.Stub
        };
        for (File baseDir: baseDirs) {
            File confFile = new File(baseDir, EXCLUDED_DEVICES_PATH);
            try {
                InputStream stream = new FileInputStream(confFile);
            try (InputStream stream = new FileInputStream(confFile)) {
                names.addAll(ConfigurationProcessor.processExcludedDeviceNames(stream));
            } catch (FileNotFoundException e) {
                // It's ok if the file does not exist.
@@ -2893,8 +2892,7 @@ public class InputManagerService extends IInputManager.Stub
        final File baseDir = Environment.getVendorDirectory();
        final File confFile = new File(baseDir, PORT_ASSOCIATIONS_PATH);

        try {
            final InputStream stream = new FileInputStream(confFile);
        try (final InputStream stream = new FileInputStream(confFile)) {
            return ConfigurationProcessor.processInputPortAssociations(stream);
        } catch (FileNotFoundException e) {
            // Most of the time, file will not exist, which is expected.
@@ -3015,10 +3013,10 @@ public class InputManagerService extends IInputManager.Stub
            @Override
            public void visitKeyboardLayout(Resources resources,
                    int keyboardLayoutResId, KeyboardLayout layout) {
                try {
                try (final InputStreamReader stream = new InputStreamReader(
                               resources.openRawResource(keyboardLayoutResId))) {
                    result[0] = layout.getDescriptor();
                    result[1] = Streams.readFully(new InputStreamReader(
                            resources.openRawResource(keyboardLayoutResId)));
                    result[1] = Streams.readFully(stream);
                } catch (IOException ex) {
                } catch (NotFoundException ex) {
                }