Move media/apex to apex/media
And fix some lint warnings. Test: build & boot Change-Id: Ib59aa788b02e5bf77dd1355766adbb57860cf737
This commit is contained in:
@@ -284,6 +284,7 @@ java_defaults {
|
||||
name: "framework-aidl-export-defaults",
|
||||
aidl: {
|
||||
export_include_dirs: [
|
||||
"apex/media/java",
|
||||
"core/java",
|
||||
"drm/java",
|
||||
"graphics/java",
|
||||
@@ -291,7 +292,6 @@ java_defaults {
|
||||
"location/java",
|
||||
"lowpan/java",
|
||||
"media/java",
|
||||
"media/apex/java",
|
||||
"media/mca/effect/java",
|
||||
"media/mca/filterfw/java",
|
||||
"media/mca/filterpacks/java",
|
||||
|
||||
120
apex/media/Android.bp
Normal file
120
apex/media/Android.bp
Normal file
@@ -0,0 +1,120 @@
|
||||
// Copyright (C) 2020 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
java_library {
|
||||
name: "updatable-media",
|
||||
|
||||
srcs: [
|
||||
":updatable-media-srcs",
|
||||
],
|
||||
|
||||
aidl: {
|
||||
export_include_dirs: [
|
||||
"java",
|
||||
],
|
||||
|
||||
// It would be great if we don't need to add include_dirs for public
|
||||
// parcelable classes. Find a better way.
|
||||
include_dirs: [
|
||||
// To refer:
|
||||
// android.os.Bundle
|
||||
// android.os.ResultReceiver
|
||||
"frameworks/base/core/java",
|
||||
],
|
||||
},
|
||||
|
||||
permitted_packages: [
|
||||
"android.media",
|
||||
],
|
||||
|
||||
installable: true,
|
||||
|
||||
// TODO: build against stable API surface. Use core_platform for now to avoid
|
||||
// link-check failure with exoplayer building against "current".
|
||||
sdk_version: "core_platform",
|
||||
libs: [
|
||||
// The order matters. android_system_* library should come later.
|
||||
"framework_media_annotation",
|
||||
"android_system_stubs_current",
|
||||
],
|
||||
|
||||
static_libs: [
|
||||
"exoplayer2-core"
|
||||
],
|
||||
jarjar_rules: "jarjar_rules.txt",
|
||||
|
||||
plugins: ["java_api_finder"],
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "updatable-media-srcs",
|
||||
srcs: [
|
||||
":mediaparser-srcs",
|
||||
":mediasession2-srcs",
|
||||
],
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "mediasession2-srcs",
|
||||
srcs: [
|
||||
"java/android/media/Controller2Link.java",
|
||||
"java/android/media/IMediaController2.aidl",
|
||||
"java/android/media/IMediaSession2.aidl",
|
||||
"java/android/media/IMediaSession2Service.aidl",
|
||||
"java/android/media/MediaConstants.java",
|
||||
"java/android/media/MediaController2.java",
|
||||
"java/android/media/MediaSession2.java",
|
||||
"java/android/media/MediaSession2Service.java",
|
||||
"java/android/media/Session2Command.java",
|
||||
"java/android/media/Session2CommandGroup.java",
|
||||
"java/android/media/Session2Link.java",
|
||||
"java/android/media/Session2Token.java",
|
||||
],
|
||||
path: "java",
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "mediaparser-srcs",
|
||||
srcs: [
|
||||
"java/android/media/MediaParser.java"
|
||||
],
|
||||
path: "java"
|
||||
}
|
||||
|
||||
droidstubs {
|
||||
name: "updatable-media-stubs",
|
||||
srcs: [
|
||||
":updatable-media-srcs",
|
||||
":framework-media-annotation-srcs",
|
||||
],
|
||||
defaults: [ "framework-module-stubs-defaults-systemapi" ],
|
||||
aidl: {
|
||||
// TODO(b/135922046) remove this
|
||||
include_dirs: ["frameworks/base/core/java"],
|
||||
},
|
||||
sdk_version: "system_current",
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "updatable_media_stubs",
|
||||
srcs: [":updatable-media-stubs"],
|
||||
sdk_version: "system_current",
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "framework_media_annotation",
|
||||
srcs: [":framework-media-annotation-srcs"],
|
||||
installable: false,
|
||||
sdk_version: "core_current",
|
||||
}
|
||||
4
apex/media/OWNERS
Normal file
4
apex/media/OWNERS
Normal file
@@ -0,0 +1,4 @@
|
||||
andrewlewis@google.com
|
||||
dwkang@google.com
|
||||
marcone@google.com
|
||||
sungsoo@google.com
|
||||
@@ -16,13 +16,9 @@
|
||||
|
||||
package android.media;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* Structure for source buffering management params.
|
||||
*
|
||||
@@ -38,8 +38,8 @@ import java.util.Set;
|
||||
public final class Session2CommandGroup implements Parcelable {
|
||||
private static final String TAG = "Session2CommandGroup";
|
||||
|
||||
public static final @android.annotation.NonNull Parcelable.Creator<Session2CommandGroup> CREATOR =
|
||||
new Parcelable.Creator<Session2CommandGroup>() {
|
||||
public static final @android.annotation.NonNull Parcelable.Creator<Session2CommandGroup>
|
||||
CREATOR = new Parcelable.Creator<Session2CommandGroup>() {
|
||||
@Override
|
||||
public Session2CommandGroup createFromParcel(Parcel in) {
|
||||
return new Session2CommandGroup(in);
|
||||
@@ -52,17 +52,18 @@ import java.util.Objects;
|
||||
public final class Session2Token implements Parcelable {
|
||||
private static final String TAG = "Session2Token";
|
||||
|
||||
public static final @android.annotation.NonNull Creator<Session2Token> CREATOR = new Creator<Session2Token>() {
|
||||
@Override
|
||||
public Session2Token createFromParcel(Parcel p) {
|
||||
return new Session2Token(p);
|
||||
}
|
||||
public static final @android.annotation.NonNull Creator<Session2Token> CREATOR =
|
||||
new Creator<Session2Token>() {
|
||||
@Override
|
||||
public Session2Token createFromParcel(Parcel p) {
|
||||
return new Session2Token(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Session2Token[] newArray(int size) {
|
||||
return new Session2Token[size];
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public Session2Token[] newArray(int size) {
|
||||
return new Session2Token[size];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @hide
|
||||
107
media/Android.bp
107
media/Android.bp
@@ -1,110 +1,3 @@
|
||||
java_library {
|
||||
name: "updatable-media",
|
||||
|
||||
srcs: [
|
||||
":updatable-media-srcs",
|
||||
],
|
||||
|
||||
aidl: {
|
||||
export_include_dirs: [
|
||||
"apex/java",
|
||||
],
|
||||
|
||||
// It would be great if we don't need to add include_dirs for public
|
||||
// parcelable classes. Find a better way.
|
||||
include_dirs: [
|
||||
// To refer:
|
||||
// android.os.Bundle
|
||||
// android.os.ResultReceiver
|
||||
"frameworks/base/core/java",
|
||||
],
|
||||
},
|
||||
|
||||
permitted_packages: [
|
||||
"android.media",
|
||||
],
|
||||
|
||||
installable: true,
|
||||
|
||||
// TODO: build against stable API surface. Use core_platform for now to avoid
|
||||
// link-check failure with exoplayer building against "current".
|
||||
sdk_version: "core_platform",
|
||||
libs: [
|
||||
// The order matters. android_system_* library should come later.
|
||||
"framework_media_annotation",
|
||||
"android_system_stubs_current",
|
||||
],
|
||||
|
||||
static_libs: [
|
||||
"exoplayer2-core"
|
||||
],
|
||||
jarjar_rules: "jarjar_rules.txt",
|
||||
|
||||
plugins: ["java_api_finder"],
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "updatable-media-srcs",
|
||||
srcs: [
|
||||
":mediaparser-srcs",
|
||||
":mediasession2-srcs",
|
||||
],
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "mediasession2-srcs",
|
||||
srcs: [
|
||||
"apex/java/android/media/Controller2Link.java",
|
||||
"apex/java/android/media/IMediaController2.aidl",
|
||||
"apex/java/android/media/IMediaSession2.aidl",
|
||||
"apex/java/android/media/IMediaSession2Service.aidl",
|
||||
"apex/java/android/media/MediaConstants.java",
|
||||
"apex/java/android/media/MediaController2.java",
|
||||
"apex/java/android/media/MediaSession2.java",
|
||||
"apex/java/android/media/MediaSession2Service.java",
|
||||
"apex/java/android/media/Session2Command.java",
|
||||
"apex/java/android/media/Session2CommandGroup.java",
|
||||
"apex/java/android/media/Session2Link.java",
|
||||
"apex/java/android/media/Session2Token.java",
|
||||
],
|
||||
path: "apex/java",
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "mediaparser-srcs",
|
||||
srcs: [
|
||||
"apex/java/android/media/MediaParser.java"
|
||||
],
|
||||
path: "apex/java"
|
||||
}
|
||||
|
||||
droidstubs {
|
||||
name: "updatable-media-stubs",
|
||||
srcs: [
|
||||
":updatable-media-srcs",
|
||||
":framework-media-annotation-srcs",
|
||||
],
|
||||
defaults: [ "framework-module-stubs-defaults-systemapi" ],
|
||||
aidl: {
|
||||
// TODO(b/135922046) remove this
|
||||
include_dirs: ["frameworks/base/core/java"],
|
||||
},
|
||||
sdk_version: "system_current",
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "updatable_media_stubs",
|
||||
srcs: [":updatable-media-stubs"],
|
||||
sdk_version: "system_current",
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "framework_media_annotation",
|
||||
srcs: [":framework-media-annotation-srcs"],
|
||||
installable: false,
|
||||
sdk_version: "core_current",
|
||||
}
|
||||
|
||||
aidl_interface {
|
||||
name: "audio_common-aidl",
|
||||
local_include_dir: "java",
|
||||
|
||||
@@ -1,308 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.media;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Note: This file is copied from dalvik.system package with the following modifications:
|
||||
* - Remove @CorePlatformApi, @IntraCoreApi and @UnsupportedAppUsage annotations.
|
||||
* - Replace System.logW() with android.util.Log.w().
|
||||
* This file should be used only within media mainline module.
|
||||
* TODO: Remove this file and use dalvik.system.CloseGuard once
|
||||
* @CorePlatformApi becomes stable or we have a replacement in SDK API.
|
||||
* b/120419300
|
||||
*
|
||||
* CloseGuard is a mechanism for flagging implicit finalizer cleanup of
|
||||
* resources that should have been cleaned up by explicit close
|
||||
* methods (aka "explicit termination methods" in Effective Java).
|
||||
* <p>
|
||||
* A simple example: <pre> {@code
|
||||
* class Foo {
|
||||
*
|
||||
* {@literal @}ReachabilitySensitive
|
||||
* private final CloseGuard guard = CloseGuard.get();
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* public Foo() {
|
||||
* ...;
|
||||
* guard.open("cleanup");
|
||||
* }
|
||||
*
|
||||
* public void cleanup() {
|
||||
* guard.close();
|
||||
* ...;
|
||||
* }
|
||||
*
|
||||
* protected void finalize() throws Throwable {
|
||||
* try {
|
||||
* // Note that guard could be null if the constructor threw.
|
||||
* if (guard != null) {
|
||||
* guard.warnIfOpen();
|
||||
* }
|
||||
* cleanup();
|
||||
* } finally {
|
||||
* super.finalize();
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
* In usage where the resource to be explicitly cleaned up is
|
||||
* allocated after object construction, CloseGuard protection can
|
||||
* be deferred. For example: <pre> {@code
|
||||
* class Bar {
|
||||
*
|
||||
* {@literal @}ReachabilitySensitive
|
||||
* private final CloseGuard guard = CloseGuard.get();
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* public Bar() {
|
||||
* ...;
|
||||
* }
|
||||
*
|
||||
* public void connect() {
|
||||
* ...;
|
||||
* guard.open("cleanup");
|
||||
* }
|
||||
*
|
||||
* public void cleanup() {
|
||||
* guard.close();
|
||||
* ...;
|
||||
* }
|
||||
*
|
||||
* protected void finalize() throws Throwable {
|
||||
* try {
|
||||
* // Note that guard could be null if the constructor threw.
|
||||
* if (guard != null) {
|
||||
* guard.warnIfOpen();
|
||||
* }
|
||||
* cleanup();
|
||||
* } finally {
|
||||
* super.finalize();
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
* When used in a constructor, calls to {@code open} should occur at
|
||||
* the end of the constructor since an exception that would cause
|
||||
* abrupt termination of the constructor will mean that the user will
|
||||
* not have a reference to the object to cleanup explicitly. When used
|
||||
* in a method, the call to {@code open} should occur just after
|
||||
* resource acquisition.
|
||||
*
|
||||
* The @ReachabilitySensitive annotation ensures that finalize() cannot be
|
||||
* called during the explicit call to cleanup(), prior to the guard.close call.
|
||||
* There is an extremely small chance that, for code that neglects to call
|
||||
* cleanup(), finalize() and thus cleanup() will be called while a method on
|
||||
* the object is still active, but the "this" reference is no longer required.
|
||||
* If missing cleanup() calls are expected, additional @ReachabilitySensitive
|
||||
* annotations or reachabilityFence() calls may be required.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
final class CloseGuard {
|
||||
|
||||
/**
|
||||
* True if collection of call-site information (the expensive operation
|
||||
* here) and tracking via a Tracker (see below) are enabled.
|
||||
* Enabled by default so we can diagnose issues early in VM startup.
|
||||
* Note, however, that Android disables this early in its startup,
|
||||
* but enables it with DropBoxing for system apps on debug builds.
|
||||
*/
|
||||
private static volatile boolean stackAndTrackingEnabled = true;
|
||||
|
||||
/**
|
||||
* Hook for customizing how CloseGuard issues are reported.
|
||||
* Bypassed if stackAndTrackingEnabled was false when open was called.
|
||||
*/
|
||||
private static volatile Reporter reporter = new DefaultReporter();
|
||||
|
||||
/**
|
||||
* Hook for customizing how CloseGuard issues are tracked.
|
||||
*/
|
||||
private static volatile Tracker currentTracker = null; // Disabled by default.
|
||||
|
||||
/**
|
||||
* Returns a CloseGuard instance. {@code #open(String)} can be used to set
|
||||
* up the instance to warn on failure to close.
|
||||
*/
|
||||
public static CloseGuard get() {
|
||||
return new CloseGuard();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables/disables stack capture and tracking. A call stack is captured
|
||||
* during open(), and open/close events are reported to the Tracker, only
|
||||
* if enabled is true. If a stack trace was captured, the {@link
|
||||
* #getReporter() reporter} is informed of unclosed resources; otherwise a
|
||||
* one-line warning is logged.
|
||||
*/
|
||||
public static void setEnabled(boolean enabled) {
|
||||
CloseGuard.stackAndTrackingEnabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if CloseGuard stack capture and tracking are enabled.
|
||||
*/
|
||||
public static boolean isEnabled() {
|
||||
return stackAndTrackingEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to replace default Reporter used to warn of CloseGuard
|
||||
* violations when stack tracking is enabled. Must be non-null.
|
||||
*/
|
||||
public static void setReporter(Reporter rep) {
|
||||
if (rep == null) {
|
||||
throw new NullPointerException("reporter == null");
|
||||
}
|
||||
CloseGuard.reporter = rep;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns non-null CloseGuard.Reporter.
|
||||
*/
|
||||
public static Reporter getReporter() {
|
||||
return reporter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link Tracker} that is notified when resources are allocated and released.
|
||||
* The Tracker is invoked only if CloseGuard {@link #isEnabled()} held when {@link #open()}
|
||||
* was called. A null argument disables tracking.
|
||||
*
|
||||
* <p>This is only intended for use by {@code dalvik.system.CloseGuardSupport} class and so
|
||||
* MUST NOT be used for any other purposes.
|
||||
*/
|
||||
public static void setTracker(Tracker tracker) {
|
||||
currentTracker = tracker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link #setTracker(Tracker) last Tracker that was set}, or null to indicate
|
||||
* there is none.
|
||||
*
|
||||
* <p>This is only intended for use by {@code dalvik.system.CloseGuardSupport} class and so
|
||||
* MUST NOT be used for any other purposes.
|
||||
*/
|
||||
public static Tracker getTracker() {
|
||||
return currentTracker;
|
||||
}
|
||||
|
||||
private CloseGuard() {}
|
||||
|
||||
/**
|
||||
* {@code open} initializes the instance with a warning that the caller
|
||||
* should have explicitly called the {@code closer} method instead of
|
||||
* relying on finalization.
|
||||
*
|
||||
* @param closer non-null name of explicit termination method. Printed by warnIfOpen.
|
||||
* @throws NullPointerException if closer is null.
|
||||
*/
|
||||
public void open(String closer) {
|
||||
// always perform the check for valid API usage...
|
||||
if (closer == null) {
|
||||
throw new NullPointerException("closer == null");
|
||||
}
|
||||
// ...but avoid allocating an allocation stack if "disabled"
|
||||
if (!stackAndTrackingEnabled) {
|
||||
closerNameOrAllocationInfo = closer;
|
||||
return;
|
||||
}
|
||||
String message = "Explicit termination method '" + closer + "' not called";
|
||||
Throwable stack = new Throwable(message);
|
||||
closerNameOrAllocationInfo = stack;
|
||||
Tracker tracker = currentTracker;
|
||||
if (tracker != null) {
|
||||
tracker.open(stack);
|
||||
}
|
||||
}
|
||||
|
||||
// We keep either an allocation stack containing the closer String or, when
|
||||
// in disabled state, just the closer String.
|
||||
// We keep them in a single field only to minimize overhead.
|
||||
private Object /* String or Throwable */ closerNameOrAllocationInfo;
|
||||
|
||||
/**
|
||||
* Marks this CloseGuard instance as closed to avoid warnings on
|
||||
* finalization.
|
||||
*/
|
||||
public void close() {
|
||||
Tracker tracker = currentTracker;
|
||||
if (tracker != null && closerNameOrAllocationInfo instanceof Throwable) {
|
||||
// Invoke tracker on close only if we invoked it on open. Tracker may have changed.
|
||||
tracker.close((Throwable) closerNameOrAllocationInfo);
|
||||
}
|
||||
closerNameOrAllocationInfo = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a warning if the caller did not properly cleanup by calling an
|
||||
* explicit close method before finalization. If CloseGuard was enabled
|
||||
* when the CloseGuard was created, passes the stacktrace associated with
|
||||
* the allocation to the current reporter. If it was not enabled, it just
|
||||
* directly logs a brief message.
|
||||
*/
|
||||
public void warnIfOpen() {
|
||||
if (closerNameOrAllocationInfo != null) {
|
||||
if (closerNameOrAllocationInfo instanceof String) {
|
||||
Log.w("CloseGuard", "A resource failed to call "
|
||||
+ (String) closerNameOrAllocationInfo + ". ");
|
||||
} else {
|
||||
String message =
|
||||
"A resource was acquired at attached stack trace but never released. ";
|
||||
message += "See java.io.Closeable for information on avoiding resource leaks.";
|
||||
Throwable stack = (Throwable) closerNameOrAllocationInfo;
|
||||
reporter.report(message, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface to allow customization of tracking behaviour.
|
||||
*
|
||||
* <p>This is only intended for use by {@code dalvik.system.CloseGuardSupport} class and so
|
||||
* MUST NOT be used for any other purposes.
|
||||
*/
|
||||
public interface Tracker {
|
||||
void open(Throwable allocationSite);
|
||||
void close(Throwable allocationSite);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface to allow customization of reporting behavior.
|
||||
* @hide
|
||||
*/
|
||||
public interface Reporter {
|
||||
void report(String message, Throwable allocationSite);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default Reporter which reports CloseGuard violations to the log.
|
||||
*/
|
||||
private static final class DefaultReporter implements Reporter {
|
||||
private DefaultReporter() {}
|
||||
|
||||
@Override public void report (String message, Throwable allocationSite) {
|
||||
Log.w("CloseGuard", message, allocationSite);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user