Revert "Fix NPE in PartProvider."

This reverts commit 3b16a1d28c.
This commit is contained in:
Cody Henthorne 2022-05-17 11:00:52 -04:00
parent 8502badb6d
commit dbddb274db

View file

@ -102,7 +102,7 @@ public final class PartProvider extends BaseContentProvider {
public String getType(@NonNull Uri uri) { public String getType(@NonNull Uri uri) {
Log.i(TAG, "getType() called: " + uri); Log.i(TAG, "getType() called: " + uri);
if (uriMatcher.match(uri) == SINGLE_ROW && SignalDatabase.getInstance() != null) { if (uriMatcher.match(uri) == SINGLE_ROW) {
PartUriParser partUriParser = new PartUriParser(uri); PartUriParser partUriParser = new PartUriParser(uri);
DatabaseAttachment attachment = SignalDatabase.attachments().getAttachment(partUriParser.getPartId()); DatabaseAttachment attachment = SignalDatabase.attachments().getAttachment(partUriParser.getPartId());
@ -157,20 +157,9 @@ public final class PartProvider extends BaseContentProvider {
ParcelFileDescriptor[] reliablePipe = ParcelFileDescriptor.createReliablePipe(); ParcelFileDescriptor[] reliablePipe = ParcelFileDescriptor.createReliablePipe();
SignalExecutors.BOUNDED_IO.execute(() -> { SignalExecutors.BOUNDED_IO.execute(() -> {
SignalDatabase signalDatabase = SignalDatabase.getInstance();
if (signalDatabase == null) {
Log.w(TAG, "Database is not available");
try {
reliablePipe[1].closeWithError("Unable to access database");
} catch (IOException e) {
Log.w(TAG, "Unable to close pipe after no database", e);
}
return;
}
Throwable error = null; Throwable error = null;
try (OutputStream out = new FileOutputStream(reliablePipe[1].getFileDescriptor())) { try (OutputStream out = new FileOutputStream(reliablePipe[1].getFileDescriptor())) {
try (InputStream in = signalDatabase.getAttachments().getAttachmentStream(attachmentId, 0)) { try (InputStream in = SignalDatabase.attachments().getAttachmentStream(attachmentId, 0)) {
StreamUtil.copy(in, out); StreamUtil.copy(in, out);
} catch (IOException e) { } catch (IOException e) {
Log.w(TAG, "Error providing file", e); Log.w(TAG, "Error providing file", e);