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

Commit ae9ee68f authored by Vincent Breitmoser's avatar Vincent Breitmoser
Browse files

openpgpapi: extract closeLoudly

parent 84c0e4c7
Loading
Loading
Loading
Loading
+12 −20
Original line number Diff line number Diff line
@@ -450,13 +450,7 @@ public class OpenPgpApi {
                    new OpenPgpError(OpenPgpError.CLIENT_SIDE_ERROR, e.getMessage()));
            return new OpenPgpDataResult<>(result, null);
        } finally {
            if (output != null) {
                try {
                    output.close();
                } catch (IOException e) {
                    Log.e(OpenPgpApi.TAG, "IOException when closing ParcelFileDescriptor!", e);
                }
            }
            closeLoudly(output);
        }
    }

@@ -493,13 +487,7 @@ public class OpenPgpApi {
                    new OpenPgpError(OpenPgpError.CLIENT_SIDE_ERROR, e.getMessage()));
            return result;
        } finally {
            if (output != null) {
                try {
                    output.close();
                } catch (IOException e) {
                    Log.e(OpenPgpApi.TAG, "IOException when closing ParcelFileDescriptor!", e);
                }
            }
            closeLoudly(output);
        }
    }

@@ -614,6 +602,11 @@ public class OpenPgpApi {
            return result;
        } finally {
            // close() is required to halt the TransferThread
            closeLoudly(input);
        }
    }

    private static void closeLoudly(ParcelFileDescriptor input) {
        if (input != null) {
            try {
                input.close();
@@ -622,7 +615,6 @@ public class OpenPgpApi {
            }
        }
    }
    }

    public interface PermissionPingCallback {
        void onPgpPermissionCheckResult(Intent result);