Loading apex/blobstore/service/java/com/android/server/blob/BlobMetadata.java +5 −1 Original line number Original line Diff line number Diff line Loading @@ -358,7 +358,11 @@ class BlobMetadata { throw e.rethrowAsIOException(); throw e.rethrowAsIOException(); } } try { try { if (BlobStoreConfig.shouldUseRevocableFdForReads()) { return createRevocableFd(fd, callingPackage); return createRevocableFd(fd, callingPackage); } else { return new ParcelFileDescriptor(fd); } } catch (IOException e) { } catch (IOException e) { IoUtils.closeQuietly(fd); IoUtils.closeQuietly(fd); throw e; throw e; Loading apex/blobstore/service/java/com/android/server/blob/BlobStoreConfig.java +22 −0 Original line number Original line Diff line number Diff line Loading @@ -122,6 +122,15 @@ class BlobStoreConfig { public static long COMMIT_COOL_OFF_DURATION_MS = public static long COMMIT_COOL_OFF_DURATION_MS = DEFAULT_COMMIT_COOL_OFF_DURATION_MS; DEFAULT_COMMIT_COOL_OFF_DURATION_MS; /** * Denotes whether to use RevocableFileDescriptor when apps try to read session/blob data. */ public static final String KEY_USE_REVOCABLE_FD_FOR_READS = "use_revocable_fd_for_reads"; public static final boolean DEFAULT_USE_REVOCABLE_FD_FOR_READS = true; public static boolean USE_REVOCABLE_FD_FOR_READS = DEFAULT_USE_REVOCABLE_FD_FOR_READS; static void refresh(Properties properties) { static void refresh(Properties properties) { if (!NAMESPACE_BLOBSTORE.equals(properties.getNamespace())) { if (!NAMESPACE_BLOBSTORE.equals(properties.getNamespace())) { return; return; Loading Loading @@ -151,6 +160,10 @@ class BlobStoreConfig { COMMIT_COOL_OFF_DURATION_MS = properties.getLong(key, COMMIT_COOL_OFF_DURATION_MS = properties.getLong(key, DEFAULT_COMMIT_COOL_OFF_DURATION_MS); DEFAULT_COMMIT_COOL_OFF_DURATION_MS); break; break; case KEY_USE_REVOCABLE_FD_FOR_READS: USE_REVOCABLE_FD_FOR_READS = properties.getBoolean(key, DEFAULT_USE_REVOCABLE_FD_FOR_READS); break; default: default: Slog.wtf(TAG, "Unknown key in device config properties: " + key); Slog.wtf(TAG, "Unknown key in device config properties: " + key); } } Loading Loading @@ -178,6 +191,8 @@ class BlobStoreConfig { fout.println(String.format(dumpFormat, KEY_COMMIT_COOL_OFF_DURATION_MS, fout.println(String.format(dumpFormat, KEY_COMMIT_COOL_OFF_DURATION_MS, TimeUtils.formatDuration(COMMIT_COOL_OFF_DURATION_MS), TimeUtils.formatDuration(COMMIT_COOL_OFF_DURATION_MS), TimeUtils.formatDuration(DEFAULT_COMMIT_COOL_OFF_DURATION_MS))); TimeUtils.formatDuration(DEFAULT_COMMIT_COOL_OFF_DURATION_MS))); fout.println(String.format(dumpFormat, KEY_USE_REVOCABLE_FD_FOR_READS, USE_REVOCABLE_FD_FOR_READS, DEFAULT_USE_REVOCABLE_FD_FOR_READS)); } } } } Loading Loading @@ -242,6 +257,13 @@ class BlobStoreConfig { < System.currentTimeMillis(); < System.currentTimeMillis(); } } /** * Return whether to use RevocableFileDescriptor when apps try to read session/blob data. */ public static boolean shouldUseRevocableFdForReads() { return DeviceConfigProperties.USE_REVOCABLE_FD_FOR_READS; } @Nullable @Nullable public static File prepareBlobFile(long sessionId) { public static File prepareBlobFile(long sessionId) { final File blobsDir = prepareBlobsDir(); final File blobsDir = prepareBlobsDir(); Loading apex/blobstore/service/java/com/android/server/blob/BlobStoreSession.java +7 −1 Original line number Original line Diff line number Diff line Loading @@ -268,6 +268,13 @@ class BlobStoreSession extends IBlobStoreSession.Stub { throw new IllegalStateException("Not allowed to read in state: " throw new IllegalStateException("Not allowed to read in state: " + stateToString(mState)); + stateToString(mState)); } } if (!BlobStoreConfig.shouldUseRevocableFdForReads()) { try { return new ParcelFileDescriptor(openReadInternal()); } catch (IOException e) { throw ExceptionUtils.wrap(e); } } } } FileDescriptor fd = null; FileDescriptor fd = null; Loading @@ -283,7 +290,6 @@ class BlobStoreSession extends IBlobStoreSession.Stub { trackRevocableFdLocked(revocableFd); trackRevocableFdLocked(revocableFd); return revocableFd.getRevocableFileDescriptor(); return revocableFd.getRevocableFileDescriptor(); } } } catch (IOException e) { } catch (IOException e) { IoUtils.closeQuietly(fd); IoUtils.closeQuietly(fd); throw ExceptionUtils.wrap(e); throw ExceptionUtils.wrap(e); Loading Loading
apex/blobstore/service/java/com/android/server/blob/BlobMetadata.java +5 −1 Original line number Original line Diff line number Diff line Loading @@ -358,7 +358,11 @@ class BlobMetadata { throw e.rethrowAsIOException(); throw e.rethrowAsIOException(); } } try { try { if (BlobStoreConfig.shouldUseRevocableFdForReads()) { return createRevocableFd(fd, callingPackage); return createRevocableFd(fd, callingPackage); } else { return new ParcelFileDescriptor(fd); } } catch (IOException e) { } catch (IOException e) { IoUtils.closeQuietly(fd); IoUtils.closeQuietly(fd); throw e; throw e; Loading
apex/blobstore/service/java/com/android/server/blob/BlobStoreConfig.java +22 −0 Original line number Original line Diff line number Diff line Loading @@ -122,6 +122,15 @@ class BlobStoreConfig { public static long COMMIT_COOL_OFF_DURATION_MS = public static long COMMIT_COOL_OFF_DURATION_MS = DEFAULT_COMMIT_COOL_OFF_DURATION_MS; DEFAULT_COMMIT_COOL_OFF_DURATION_MS; /** * Denotes whether to use RevocableFileDescriptor when apps try to read session/blob data. */ public static final String KEY_USE_REVOCABLE_FD_FOR_READS = "use_revocable_fd_for_reads"; public static final boolean DEFAULT_USE_REVOCABLE_FD_FOR_READS = true; public static boolean USE_REVOCABLE_FD_FOR_READS = DEFAULT_USE_REVOCABLE_FD_FOR_READS; static void refresh(Properties properties) { static void refresh(Properties properties) { if (!NAMESPACE_BLOBSTORE.equals(properties.getNamespace())) { if (!NAMESPACE_BLOBSTORE.equals(properties.getNamespace())) { return; return; Loading Loading @@ -151,6 +160,10 @@ class BlobStoreConfig { COMMIT_COOL_OFF_DURATION_MS = properties.getLong(key, COMMIT_COOL_OFF_DURATION_MS = properties.getLong(key, DEFAULT_COMMIT_COOL_OFF_DURATION_MS); DEFAULT_COMMIT_COOL_OFF_DURATION_MS); break; break; case KEY_USE_REVOCABLE_FD_FOR_READS: USE_REVOCABLE_FD_FOR_READS = properties.getBoolean(key, DEFAULT_USE_REVOCABLE_FD_FOR_READS); break; default: default: Slog.wtf(TAG, "Unknown key in device config properties: " + key); Slog.wtf(TAG, "Unknown key in device config properties: " + key); } } Loading Loading @@ -178,6 +191,8 @@ class BlobStoreConfig { fout.println(String.format(dumpFormat, KEY_COMMIT_COOL_OFF_DURATION_MS, fout.println(String.format(dumpFormat, KEY_COMMIT_COOL_OFF_DURATION_MS, TimeUtils.formatDuration(COMMIT_COOL_OFF_DURATION_MS), TimeUtils.formatDuration(COMMIT_COOL_OFF_DURATION_MS), TimeUtils.formatDuration(DEFAULT_COMMIT_COOL_OFF_DURATION_MS))); TimeUtils.formatDuration(DEFAULT_COMMIT_COOL_OFF_DURATION_MS))); fout.println(String.format(dumpFormat, KEY_USE_REVOCABLE_FD_FOR_READS, USE_REVOCABLE_FD_FOR_READS, DEFAULT_USE_REVOCABLE_FD_FOR_READS)); } } } } Loading Loading @@ -242,6 +257,13 @@ class BlobStoreConfig { < System.currentTimeMillis(); < System.currentTimeMillis(); } } /** * Return whether to use RevocableFileDescriptor when apps try to read session/blob data. */ public static boolean shouldUseRevocableFdForReads() { return DeviceConfigProperties.USE_REVOCABLE_FD_FOR_READS; } @Nullable @Nullable public static File prepareBlobFile(long sessionId) { public static File prepareBlobFile(long sessionId) { final File blobsDir = prepareBlobsDir(); final File blobsDir = prepareBlobsDir(); Loading
apex/blobstore/service/java/com/android/server/blob/BlobStoreSession.java +7 −1 Original line number Original line Diff line number Diff line Loading @@ -268,6 +268,13 @@ class BlobStoreSession extends IBlobStoreSession.Stub { throw new IllegalStateException("Not allowed to read in state: " throw new IllegalStateException("Not allowed to read in state: " + stateToString(mState)); + stateToString(mState)); } } if (!BlobStoreConfig.shouldUseRevocableFdForReads()) { try { return new ParcelFileDescriptor(openReadInternal()); } catch (IOException e) { throw ExceptionUtils.wrap(e); } } } } FileDescriptor fd = null; FileDescriptor fd = null; Loading @@ -283,7 +290,6 @@ class BlobStoreSession extends IBlobStoreSession.Stub { trackRevocableFdLocked(revocableFd); trackRevocableFdLocked(revocableFd); return revocableFd.getRevocableFileDescriptor(); return revocableFd.getRevocableFileDescriptor(); } } } catch (IOException e) { } catch (IOException e) { IoUtils.closeQuietly(fd); IoUtils.closeQuietly(fd); throw ExceptionUtils.wrap(e); throw ExceptionUtils.wrap(e); Loading