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

Commit 44f20f98 authored by cretin45's avatar cretin45
Browse files

Telephony: Close the FileReader when finished

Change-Id: I12865e8d974515d4f349d476bcf775e015008e16
parent 5619547b
Loading
Loading
Loading
Loading
+17 −9
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.telephony.uicc;

import java.io.Closeable;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
@@ -52,20 +53,13 @@ public class SpnOverride {
    }

    private void loadSpnOverrides() {
        FileReader spnReader;
        FileReader spnReader = null;

        final File spnFile = new File(Environment.getRootDirectory(),
                PARTNER_SPN_OVERRIDE_PATH);

        try {
            spnReader = new FileReader(spnFile);
        } catch (FileNotFoundException e) {
            Rlog.w(LOG_TAG, "Can not open " +
                    Environment.getRootDirectory() + "/" + PARTNER_SPN_OVERRIDE_PATH);
            return;
        }

        try {
            XmlPullParser parser = Xml.newPullParser();
            parser.setInput(spnReader);

@@ -84,10 +78,24 @@ public class SpnOverride {

                mCarrierSpnMap.put(numeric, data);
            }
        } catch (FileNotFoundException e) {
            Rlog.w(LOG_TAG, "Can not open " +
                    Environment.getRootDirectory() + "/" + PARTNER_SPN_OVERRIDE_PATH);
            return;
        } catch (XmlPullParserException e) {
            Rlog.w(LOG_TAG, "Exception in spn-conf parser " + e);
        } catch (IOException e) {
            Rlog.w(LOG_TAG, "Exception in spn-conf parser " + e);
        } finally {
            closeQuietly(spnReader);
        }
    }

    private void closeQuietly(Closeable closeable) {
        if (closeable != null) {
            try {
                closeable.close();
            } catch (IOException e) {}
        }
    }