Loading Android.bp +0 −4 Original line number Diff line number Diff line Loading @@ -701,7 +701,6 @@ filegroup { "core/java/com/android/internal/util/TrafficStatsConstants.java", "core/java/com/android/internal/util/WakeupMessage.java", "core/java/com/android/internal/util/TokenBucket.java", "core/java/android/net/shared/*.java", ], } Loading @@ -709,7 +708,6 @@ filegroup { name: "framework-services-net-module-wifi-shared-srcs", srcs: [ "core/java/android/net/DhcpResults.java", "core/java/android/net/shared/InetAddressUtils.java", "core/java/android/net/util/IpUtils.java", "core/java/android/util/LocalLog.java", ], Loading @@ -726,7 +724,6 @@ filegroup { "core/java/com/android/internal/util/State.java", "core/java/com/android/internal/util/StateMachine.java", "core/java/com/android/internal/util/TrafficStatsConstants.java", "core/java/android/net/shared/Inet4AddressUtils.java", ], } Loading Loading @@ -1163,7 +1160,6 @@ java_library { srcs: [ "core/java/android/content/pm/BaseParceledListSlice.java", "core/java/android/content/pm/ParceledListSlice.java", "core/java/android/net/shared/Inet4AddressUtils.java", "core/java/android/os/HandlerExecutor.java", "core/java/com/android/internal/util/AsyncChannel.java", "core/java/com/android/internal/util/AsyncService.java", Loading apex/blobstore/service/java/com/android/server/blob/BlobMetadata.java +5 −1 Original line number Diff line number Diff line Loading @@ -358,7 +358,11 @@ class BlobMetadata { throw e.rethrowAsIOException(); } try { if (BlobStoreConfig.shouldUseRevocableFdForReads()) { return createRevocableFd(fd, callingPackage); } else { return new ParcelFileDescriptor(fd); } } catch (IOException e) { IoUtils.closeQuietly(fd); throw e; Loading apex/blobstore/service/java/com/android/server/blob/BlobStoreConfig.java +22 −0 Original line number Diff line number Diff line Loading @@ -122,6 +122,15 @@ class BlobStoreConfig { public static long 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) { if (!NAMESPACE_BLOBSTORE.equals(properties.getNamespace())) { return; Loading Loading @@ -151,6 +160,10 @@ class BlobStoreConfig { COMMIT_COOL_OFF_DURATION_MS = properties.getLong(key, DEFAULT_COMMIT_COOL_OFF_DURATION_MS); break; case KEY_USE_REVOCABLE_FD_FOR_READS: USE_REVOCABLE_FD_FOR_READS = properties.getBoolean(key, DEFAULT_USE_REVOCABLE_FD_FOR_READS); break; default: 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, TimeUtils.formatDuration(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(); } /** * 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 public static File prepareBlobFile(long sessionId) { final File blobsDir = prepareBlobsDir(); Loading apex/blobstore/service/java/com/android/server/blob/BlobStoreSession.java +7 −1 Original line number Diff line number Diff line Loading @@ -268,6 +268,13 @@ class BlobStoreSession extends IBlobStoreSession.Stub { throw new IllegalStateException("Not allowed to read in state: " + stateToString(mState)); } if (!BlobStoreConfig.shouldUseRevocableFdForReads()) { try { return new ParcelFileDescriptor(openReadInternal()); } catch (IOException e) { throw ExceptionUtils.wrap(e); } } } FileDescriptor fd = null; Loading @@ -283,7 +290,6 @@ class BlobStoreSession extends IBlobStoreSession.Stub { trackRevocableFdLocked(revocableFd); return revocableFd.getRevocableFileDescriptor(); } } catch (IOException e) { IoUtils.closeQuietly(fd); throw ExceptionUtils.wrap(e); Loading apex/media/framework/java/android/media/MediaParser.java +62 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.ParserException; import com.google.android.exoplayer2.drm.DrmInitData.SchemeData; import com.google.android.exoplayer2.extractor.ChunkIndex; import com.google.android.exoplayer2.extractor.DefaultExtractorInput; import com.google.android.exoplayer2.extractor.Extractor; import com.google.android.exoplayer2.extractor.ExtractorInput; Loading Loading @@ -817,6 +818,30 @@ public final class MediaParser { public static final String PARAMETER_EXPOSE_DUMMY_SEEKMAP = "android.media.mediaparser.exposeDummySeekMap"; /** * Sets whether chunk indices available in the extracted media should be exposed as {@link * MediaFormat MediaFormats}. {@code boolean} expected. Default value is {@link false}. * * <p>When set to true, any information about media segmentation will be exposed as a {@link * MediaFormat} (with track index 0) containing four {@link ByteBuffer} elements under the * following keys: * * <ul> * <li>"chunk-index-int-sizes": Contains {@code ints} representing the sizes in bytes of each * of the media segments. * <li>"chunk-index-long-offsets": Contains {@code longs} representing the byte offsets of * each segment in the stream. * <li>"chunk-index-long-us-durations": Contains {@code longs} representing the media duration * of each segment, in microseconds. * <li>"chunk-index-long-us-times": Contains {@code longs} representing the start time of each * segment, in microseconds. * </ul> * * @hide */ public static final String PARAMETER_EXPOSE_CHUNK_INDEX_AS_MEDIA_FORMAT = "android.media.mediaParser.exposeChunkIndexAsMediaFormat"; // Private constants. private static final String TAG = "MediaParser"; Loading Loading @@ -980,6 +1005,7 @@ public final class MediaParser { private boolean mIgnoreTimestampOffset; private boolean mEagerlyExposeTrackType; private boolean mExposeDummySeekMap; private boolean mExposeChunkIndexAsMediaFormat; private String mParserName; private Extractor mExtractor; private ExtractorInput mExtractorInput; Loading Loading @@ -1042,6 +1068,9 @@ public final class MediaParser { if (PARAMETER_EXPOSE_DUMMY_SEEKMAP.equals(parameterName)) { mExposeDummySeekMap = (boolean) value; } if (PARAMETER_EXPOSE_CHUNK_INDEX_AS_MEDIA_FORMAT.equals(parameterName)) { mExposeChunkIndexAsMediaFormat = (boolean) value; } mParserParameters.put(parameterName, value); return this; } Loading Loading @@ -1436,6 +1465,19 @@ public final class MediaParser { @Override public void seekMap(com.google.android.exoplayer2.extractor.SeekMap exoplayerSeekMap) { if (mExposeChunkIndexAsMediaFormat && exoplayerSeekMap instanceof ChunkIndex) { ChunkIndex chunkIndex = (ChunkIndex) exoplayerSeekMap; MediaFormat mediaFormat = new MediaFormat(); mediaFormat.setByteBuffer("chunk-index-int-sizes", toByteBuffer(chunkIndex.sizes)); mediaFormat.setByteBuffer( "chunk-index-long-offsets", toByteBuffer(chunkIndex.offsets)); mediaFormat.setByteBuffer( "chunk-index-long-us-durations", toByteBuffer(chunkIndex.durationsUs)); mediaFormat.setByteBuffer( "chunk-index-long-us-times", toByteBuffer(chunkIndex.timesUs)); mOutputConsumer.onTrackDataFound( /* trackIndex= */ 0, new TrackData(mediaFormat, /* drmInitData= */ null)); } mOutputConsumer.onSeekMapFound(new SeekMap(exoplayerSeekMap)); } } Loading Loading @@ -1823,6 +1865,24 @@ public final class MediaParser { return result; } private static ByteBuffer toByteBuffer(long[] longArray) { ByteBuffer byteBuffer = ByteBuffer.allocateDirect(longArray.length * Long.BYTES); for (long element : longArray) { byteBuffer.putLong(element); } byteBuffer.flip(); return byteBuffer; } private static ByteBuffer toByteBuffer(int[] intArray) { ByteBuffer byteBuffer = ByteBuffer.allocateDirect(intArray.length * Integer.BYTES); for (int element : intArray) { byteBuffer.putInt(element); } byteBuffer.flip(); return byteBuffer; } private static String toTypeString(int type) { switch (type) { case C.TRACK_TYPE_VIDEO: Loading Loading @@ -1979,6 +2039,8 @@ public final class MediaParser { expectedTypeByParameterName.put(PARAMETER_IGNORE_TIMESTAMP_OFFSET, Boolean.class); expectedTypeByParameterName.put(PARAMETER_EAGERLY_EXPOSE_TRACKTYPE, Boolean.class); expectedTypeByParameterName.put(PARAMETER_EXPOSE_DUMMY_SEEKMAP, Boolean.class); expectedTypeByParameterName.put( PARAMETER_EXPOSE_CHUNK_INDEX_AS_MEDIA_FORMAT, Boolean.class); EXPECTED_TYPE_BY_PARAMETER_NAME = Collections.unmodifiableMap(expectedTypeByParameterName); } } Loading
Android.bp +0 −4 Original line number Diff line number Diff line Loading @@ -701,7 +701,6 @@ filegroup { "core/java/com/android/internal/util/TrafficStatsConstants.java", "core/java/com/android/internal/util/WakeupMessage.java", "core/java/com/android/internal/util/TokenBucket.java", "core/java/android/net/shared/*.java", ], } Loading @@ -709,7 +708,6 @@ filegroup { name: "framework-services-net-module-wifi-shared-srcs", srcs: [ "core/java/android/net/DhcpResults.java", "core/java/android/net/shared/InetAddressUtils.java", "core/java/android/net/util/IpUtils.java", "core/java/android/util/LocalLog.java", ], Loading @@ -726,7 +724,6 @@ filegroup { "core/java/com/android/internal/util/State.java", "core/java/com/android/internal/util/StateMachine.java", "core/java/com/android/internal/util/TrafficStatsConstants.java", "core/java/android/net/shared/Inet4AddressUtils.java", ], } Loading Loading @@ -1163,7 +1160,6 @@ java_library { srcs: [ "core/java/android/content/pm/BaseParceledListSlice.java", "core/java/android/content/pm/ParceledListSlice.java", "core/java/android/net/shared/Inet4AddressUtils.java", "core/java/android/os/HandlerExecutor.java", "core/java/com/android/internal/util/AsyncChannel.java", "core/java/com/android/internal/util/AsyncService.java", Loading
apex/blobstore/service/java/com/android/server/blob/BlobMetadata.java +5 −1 Original line number Diff line number Diff line Loading @@ -358,7 +358,11 @@ class BlobMetadata { throw e.rethrowAsIOException(); } try { if (BlobStoreConfig.shouldUseRevocableFdForReads()) { return createRevocableFd(fd, callingPackage); } else { return new ParcelFileDescriptor(fd); } } catch (IOException e) { IoUtils.closeQuietly(fd); throw e; Loading
apex/blobstore/service/java/com/android/server/blob/BlobStoreConfig.java +22 −0 Original line number Diff line number Diff line Loading @@ -122,6 +122,15 @@ class BlobStoreConfig { public static long 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) { if (!NAMESPACE_BLOBSTORE.equals(properties.getNamespace())) { return; Loading Loading @@ -151,6 +160,10 @@ class BlobStoreConfig { COMMIT_COOL_OFF_DURATION_MS = properties.getLong(key, DEFAULT_COMMIT_COOL_OFF_DURATION_MS); break; case KEY_USE_REVOCABLE_FD_FOR_READS: USE_REVOCABLE_FD_FOR_READS = properties.getBoolean(key, DEFAULT_USE_REVOCABLE_FD_FOR_READS); break; default: 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, TimeUtils.formatDuration(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(); } /** * 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 public static File prepareBlobFile(long sessionId) { final File blobsDir = prepareBlobsDir(); Loading
apex/blobstore/service/java/com/android/server/blob/BlobStoreSession.java +7 −1 Original line number Diff line number Diff line Loading @@ -268,6 +268,13 @@ class BlobStoreSession extends IBlobStoreSession.Stub { throw new IllegalStateException("Not allowed to read in state: " + stateToString(mState)); } if (!BlobStoreConfig.shouldUseRevocableFdForReads()) { try { return new ParcelFileDescriptor(openReadInternal()); } catch (IOException e) { throw ExceptionUtils.wrap(e); } } } FileDescriptor fd = null; Loading @@ -283,7 +290,6 @@ class BlobStoreSession extends IBlobStoreSession.Stub { trackRevocableFdLocked(revocableFd); return revocableFd.getRevocableFileDescriptor(); } } catch (IOException e) { IoUtils.closeQuietly(fd); throw ExceptionUtils.wrap(e); Loading
apex/media/framework/java/android/media/MediaParser.java +62 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.ParserException; import com.google.android.exoplayer2.drm.DrmInitData.SchemeData; import com.google.android.exoplayer2.extractor.ChunkIndex; import com.google.android.exoplayer2.extractor.DefaultExtractorInput; import com.google.android.exoplayer2.extractor.Extractor; import com.google.android.exoplayer2.extractor.ExtractorInput; Loading Loading @@ -817,6 +818,30 @@ public final class MediaParser { public static final String PARAMETER_EXPOSE_DUMMY_SEEKMAP = "android.media.mediaparser.exposeDummySeekMap"; /** * Sets whether chunk indices available in the extracted media should be exposed as {@link * MediaFormat MediaFormats}. {@code boolean} expected. Default value is {@link false}. * * <p>When set to true, any information about media segmentation will be exposed as a {@link * MediaFormat} (with track index 0) containing four {@link ByteBuffer} elements under the * following keys: * * <ul> * <li>"chunk-index-int-sizes": Contains {@code ints} representing the sizes in bytes of each * of the media segments. * <li>"chunk-index-long-offsets": Contains {@code longs} representing the byte offsets of * each segment in the stream. * <li>"chunk-index-long-us-durations": Contains {@code longs} representing the media duration * of each segment, in microseconds. * <li>"chunk-index-long-us-times": Contains {@code longs} representing the start time of each * segment, in microseconds. * </ul> * * @hide */ public static final String PARAMETER_EXPOSE_CHUNK_INDEX_AS_MEDIA_FORMAT = "android.media.mediaParser.exposeChunkIndexAsMediaFormat"; // Private constants. private static final String TAG = "MediaParser"; Loading Loading @@ -980,6 +1005,7 @@ public final class MediaParser { private boolean mIgnoreTimestampOffset; private boolean mEagerlyExposeTrackType; private boolean mExposeDummySeekMap; private boolean mExposeChunkIndexAsMediaFormat; private String mParserName; private Extractor mExtractor; private ExtractorInput mExtractorInput; Loading Loading @@ -1042,6 +1068,9 @@ public final class MediaParser { if (PARAMETER_EXPOSE_DUMMY_SEEKMAP.equals(parameterName)) { mExposeDummySeekMap = (boolean) value; } if (PARAMETER_EXPOSE_CHUNK_INDEX_AS_MEDIA_FORMAT.equals(parameterName)) { mExposeChunkIndexAsMediaFormat = (boolean) value; } mParserParameters.put(parameterName, value); return this; } Loading Loading @@ -1436,6 +1465,19 @@ public final class MediaParser { @Override public void seekMap(com.google.android.exoplayer2.extractor.SeekMap exoplayerSeekMap) { if (mExposeChunkIndexAsMediaFormat && exoplayerSeekMap instanceof ChunkIndex) { ChunkIndex chunkIndex = (ChunkIndex) exoplayerSeekMap; MediaFormat mediaFormat = new MediaFormat(); mediaFormat.setByteBuffer("chunk-index-int-sizes", toByteBuffer(chunkIndex.sizes)); mediaFormat.setByteBuffer( "chunk-index-long-offsets", toByteBuffer(chunkIndex.offsets)); mediaFormat.setByteBuffer( "chunk-index-long-us-durations", toByteBuffer(chunkIndex.durationsUs)); mediaFormat.setByteBuffer( "chunk-index-long-us-times", toByteBuffer(chunkIndex.timesUs)); mOutputConsumer.onTrackDataFound( /* trackIndex= */ 0, new TrackData(mediaFormat, /* drmInitData= */ null)); } mOutputConsumer.onSeekMapFound(new SeekMap(exoplayerSeekMap)); } } Loading Loading @@ -1823,6 +1865,24 @@ public final class MediaParser { return result; } private static ByteBuffer toByteBuffer(long[] longArray) { ByteBuffer byteBuffer = ByteBuffer.allocateDirect(longArray.length * Long.BYTES); for (long element : longArray) { byteBuffer.putLong(element); } byteBuffer.flip(); return byteBuffer; } private static ByteBuffer toByteBuffer(int[] intArray) { ByteBuffer byteBuffer = ByteBuffer.allocateDirect(intArray.length * Integer.BYTES); for (int element : intArray) { byteBuffer.putInt(element); } byteBuffer.flip(); return byteBuffer; } private static String toTypeString(int type) { switch (type) { case C.TRACK_TYPE_VIDEO: Loading Loading @@ -1979,6 +2039,8 @@ public final class MediaParser { expectedTypeByParameterName.put(PARAMETER_IGNORE_TIMESTAMP_OFFSET, Boolean.class); expectedTypeByParameterName.put(PARAMETER_EAGERLY_EXPOSE_TRACKTYPE, Boolean.class); expectedTypeByParameterName.put(PARAMETER_EXPOSE_DUMMY_SEEKMAP, Boolean.class); expectedTypeByParameterName.put( PARAMETER_EXPOSE_CHUNK_INDEX_AS_MEDIA_FORMAT, Boolean.class); EXPECTED_TYPE_BY_PARAMETER_NAME = Collections.unmodifiableMap(expectedTypeByParameterName); } }