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

Commit c4eb87d5 authored by sandeepbandaru's avatar sandeepbandaru Committed by Sandeep Bandaru
Browse files

Add support to read from directories other the files dir

Test: cts
Change-Id: I18585b7eb0f6197b3162c5d268f2b3bf3386b96b
parent a269ed0b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -451,12 +451,16 @@ public abstract class OnDeviceIntelligenceService extends Service {
            Slog.v(TAG,
                    "onGetReadOnlyFileDescriptor: " + fileName + " under internal app storage.");
            File f = new File(getBaseContext().getFilesDir(), fileName);
            if (!f.exists()) {
                f = new File(fileName);
            }
            ParcelFileDescriptor pfd = null;
            try {
                pfd = ParcelFileDescriptor.open(f, ParcelFileDescriptor.MODE_READ_ONLY);
                Slog.d(TAG, "Successfully opened a file with ParcelFileDescriptor.");
            } catch (FileNotFoundException e) {
                Slog.e(TAG, "Cannot open file. No ParcelFileDescriptor returned.");
                future.completeExceptionally(e);
            } finally {
                future.complete(pfd);
                if (pfd != null) {