Loading apex/blobstore/framework/java/android/app/blob/BlobStoreManager.java +22 −0 Original line number Diff line number Diff line Loading @@ -322,6 +322,28 @@ public class BlobStoreManager { } } /** * Opens a file descriptor to read the blob content already written into this session. * * @return a {@link ParcelFileDescriptor} for reading from the blob file. * * @throws IOException when there is an I/O error while opening the file to read. * @throws SecurityException when the caller is not the owner of the session. * @throws IllegalStateException when the caller tries to read the file after it is * abandoned (using {@link #abandon()}) * or closed (using {@link #close()}). */ public @NonNull ParcelFileDescriptor openRead() throws IOException { try { return mSession.openRead(); } catch (ParcelableException e) { e.maybeRethrow(IOException.class); throw new RuntimeException(e); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Gets the size of the blob file that was written to the session so far. * Loading apex/blobstore/framework/java/android/app/blob/IBlobStoreSession.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.os.ParcelFileDescriptor; /** {@hide} */ interface IBlobStoreSession { ParcelFileDescriptor openWrite(long offsetBytes, long lengthBytes); ParcelFileDescriptor openRead(); void allowPackageAccess(in String packageName, in byte[] certificate); void allowSameSignatureAccess(); Loading apex/blobstore/service/java/com/android/server/blob/BlobStoreSession.java +35 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.blob; import static android.app.blob.BlobStoreManager.COMMIT_RESULT_ERROR; import static android.system.OsConstants.O_CREAT; import static android.system.OsConstants.O_RDONLY; import static android.system.OsConstants.O_RDWR; import static android.system.OsConstants.SEEK_SET; Loading Loading @@ -186,6 +187,40 @@ public class BlobStoreSession extends IBlobStoreSession.Stub { return createRevocableFdLocked(fd); } @Override @NonNull public ParcelFileDescriptor openRead() { assertCallerIsOwner(); synchronized (mSessionLock) { if (mState != STATE_OPENED) { throw new IllegalStateException("Not allowed to read in state: " + stateToString(mState)); } try { return openReadLocked(); } catch (IOException e) { throw ExceptionUtils.wrap(e); } } } @GuardedBy("mSessionLock") @NonNull private ParcelFileDescriptor openReadLocked() throws IOException { FileDescriptor fd = null; try { final File sessionFile = getSessionFile(); if (sessionFile == null) { throw new IllegalStateException("Couldn't get the file for this session"); } fd = Os.open(sessionFile.getPath(), O_RDONLY, 0); } catch (ErrnoException e) { e.rethrowAsIOException(); } return createRevocableFdLocked(fd); } @Override @BytesLong public long getSize() { Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -7547,6 +7547,7 @@ package android.app.blob { method public boolean isPackageAccessAllowed(@NonNull String, @NonNull byte[]) throws java.io.IOException; method public boolean isPublicAccessAllowed() throws java.io.IOException; method public boolean isSameSignatureAccessAllowed() throws java.io.IOException; method @NonNull public android.os.ParcelFileDescriptor openRead() throws java.io.IOException; method @NonNull public android.os.ParcelFileDescriptor openWrite(long, long) throws java.io.IOException; } Loading
apex/blobstore/framework/java/android/app/blob/BlobStoreManager.java +22 −0 Original line number Diff line number Diff line Loading @@ -322,6 +322,28 @@ public class BlobStoreManager { } } /** * Opens a file descriptor to read the blob content already written into this session. * * @return a {@link ParcelFileDescriptor} for reading from the blob file. * * @throws IOException when there is an I/O error while opening the file to read. * @throws SecurityException when the caller is not the owner of the session. * @throws IllegalStateException when the caller tries to read the file after it is * abandoned (using {@link #abandon()}) * or closed (using {@link #close()}). */ public @NonNull ParcelFileDescriptor openRead() throws IOException { try { return mSession.openRead(); } catch (ParcelableException e) { e.maybeRethrow(IOException.class); throw new RuntimeException(e); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Gets the size of the blob file that was written to the session so far. * Loading
apex/blobstore/framework/java/android/app/blob/IBlobStoreSession.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.os.ParcelFileDescriptor; /** {@hide} */ interface IBlobStoreSession { ParcelFileDescriptor openWrite(long offsetBytes, long lengthBytes); ParcelFileDescriptor openRead(); void allowPackageAccess(in String packageName, in byte[] certificate); void allowSameSignatureAccess(); Loading
apex/blobstore/service/java/com/android/server/blob/BlobStoreSession.java +35 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.blob; import static android.app.blob.BlobStoreManager.COMMIT_RESULT_ERROR; import static android.system.OsConstants.O_CREAT; import static android.system.OsConstants.O_RDONLY; import static android.system.OsConstants.O_RDWR; import static android.system.OsConstants.SEEK_SET; Loading Loading @@ -186,6 +187,40 @@ public class BlobStoreSession extends IBlobStoreSession.Stub { return createRevocableFdLocked(fd); } @Override @NonNull public ParcelFileDescriptor openRead() { assertCallerIsOwner(); synchronized (mSessionLock) { if (mState != STATE_OPENED) { throw new IllegalStateException("Not allowed to read in state: " + stateToString(mState)); } try { return openReadLocked(); } catch (IOException e) { throw ExceptionUtils.wrap(e); } } } @GuardedBy("mSessionLock") @NonNull private ParcelFileDescriptor openReadLocked() throws IOException { FileDescriptor fd = null; try { final File sessionFile = getSessionFile(); if (sessionFile == null) { throw new IllegalStateException("Couldn't get the file for this session"); } fd = Os.open(sessionFile.getPath(), O_RDONLY, 0); } catch (ErrnoException e) { e.rethrowAsIOException(); } return createRevocableFdLocked(fd); } @Override @BytesLong public long getSize() { Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -7547,6 +7547,7 @@ package android.app.blob { method public boolean isPackageAccessAllowed(@NonNull String, @NonNull byte[]) throws java.io.IOException; method public boolean isPublicAccessAllowed() throws java.io.IOException; method public boolean isSameSignatureAccessAllowed() throws java.io.IOException; method @NonNull public android.os.ParcelFileDescriptor openRead() throws java.io.IOException; method @NonNull public android.os.ParcelFileDescriptor openWrite(long, long) throws java.io.IOException; }