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

Commit c7c204b3 authored by Shuo Qian's avatar Shuo Qian
Browse files

Reload the default file partition while caching it

Reload the default file partition while caching it, if the OTA file
 partition was not load in the initial time.

Test: Manual; didn't see Stream close issue in the bugreport
Bug: 152897869
Change-Id: I08a51efc8c509373161e117d6d58d8f176a558a3
parent b07db11f
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -494,6 +494,11 @@ public class EmergencyNumberTracker extends Handler {
        // Read the OTA emergency number database
        List<EmergencyNumber> updatedOtaEmergencyNumberList = new ArrayList<>();
        try {
            // If OTA File partition is not available, try to reload the default one.
            if (mEmergencyNumberDbOtaFileInputStream == null) {
                mEmergencyNumberDbOtaFileInputStream = new FileInputStream(
                      new File(Environment.getDataDirectory(), EMERGENCY_NUMBER_DB_OTA_FILE_PATH));
            }
            inputStream = new BufferedInputStream(mEmergencyNumberDbOtaFileInputStream);
            allEccMessages = ProtobufEccData.AllInfo.parseFrom(readInputStreamToByteArray(
                    new GZIPInputStream(inputStream)));
@@ -509,7 +514,7 @@ public class EmergencyNumberTracker extends Handler {
            }
            EmergencyNumber.mergeSameNumbersInEmergencyNumberList(updatedOtaEmergencyNumberList);
        } catch (IOException ex) {
            loge("Cache ota emergency database failure: " + ex);
            loge("Cache ota emergency database IOException: " + ex);
        } finally {
            // close quietly by catching non-runtime exceptions.
            if (inputStream != null) {