Merge "media: document rotation and scaling issues for MediaCodec" into nyc-dev
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 3c3da78..7682af8 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -762,14 +762,13 @@
public Bundle extras = new Bundle();
/**
- * All pending intents in the notification extras (notification extras, actions extras,
- * and remote input extras) as the system needs to be able to access them but touching
- * the extras bundle in the system process is not safe because the bundle may contain
+ * All pending intents in the notification as the system needs to be able to access them but
+ * touching the extras bundle in the system process is not safe because the bundle may contain
* custom parcelable objects.
*
* @hide
*/
- public ArraySet<PendingIntent> extrasPendingIntents;
+ public ArraySet<PendingIntent> allPendingIntents;
/**
* {@link #extras} key: this is the title of the notification,
@@ -1569,7 +1568,7 @@
// intents in extras are always written as the last entry.
readFromParcelImpl(parcel);
// Must be read last!
- extrasPendingIntents = (ArraySet<PendingIntent>) parcel.readArraySet(null);
+ allPendingIntents = (ArraySet<PendingIntent>) parcel.readArraySet(null);
}
private void readFromParcelImpl(Parcel parcel)
@@ -1727,8 +1726,8 @@
}
}
- if (!ArrayUtils.isEmpty(extrasPendingIntents)) {
- that.extrasPendingIntents = new ArraySet<>(extrasPendingIntents);
+ if (!ArrayUtils.isEmpty(allPendingIntents)) {
+ that.allPendingIntents = new ArraySet<>(allPendingIntents);
}
if (this.actions != null) {
@@ -1854,15 +1853,15 @@
// cannot look into the extras as there may be parcelables there that
// the platform does not know how to handle. To go around that we have
// an explicit list of the pending intents in the extras bundle.
- final boolean collectPendingIntents = (extrasPendingIntents == null);
+ final boolean collectPendingIntents = (allPendingIntents == null);
if (collectPendingIntents) {
PendingIntent.setOnMarshaledListener(
(PendingIntent intent, Parcel out, int outFlags) -> {
if (parcel == out) {
- if (extrasPendingIntents == null) {
- extrasPendingIntents = new ArraySet<>();
+ if (allPendingIntents == null) {
+ allPendingIntents = new ArraySet<>();
}
- extrasPendingIntents.add(intent);
+ allPendingIntents.add(intent);
}
});
}
@@ -1871,7 +1870,7 @@
// want to intercept all pending events written to the pacel.
writeToParcelImpl(parcel, flags);
// Must be written last!
- parcel.writeArraySet(extrasPendingIntents);
+ parcel.writeArraySet(allPendingIntents);
} finally {
if (collectPendingIntents) {
PendingIntent.setOnMarshaledListener(null);
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index adf9fe6..4da77f4 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -1871,7 +1871,7 @@
sa = res.obtainAttributes(parser,
com.android.internal.R.styleable.AndroidManifestUsesSdk);
- int minVers = 0;
+ int minVers = 1;
String minCode = null;
int targetVers = 0;
String targetCode = null;
@@ -1898,9 +1898,6 @@
} else {
// If it's not a string, it's an integer.
targetVers = val.data;
- if (minVers == 0) {
- minVers = targetVers;
- }
}
}
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index 998eea5..a77b951 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -317,6 +317,7 @@
<item name="activityChooserViewStyle">@style/Widget.ActivityChooserView</item>
<item name="mediaRouteButtonStyle">@style/Widget.DeviceDefault.MediaRouteButton</item>
<item name="fragmentBreadCrumbsStyle">@style/Widget.FragmentBreadCrumbs</item>
+ <item name="contextPopupMenuStyle">?attr/popupMenuStyle</item>
<!-- Preference styles -->
<item name="preferenceScreenStyle">@style/Preference.PreferenceScreen</item>
diff --git a/media/java/android/media/MediaCodecInfo.java b/media/java/android/media/MediaCodecInfo.java
index 07d1f75..0bfeaed 100644
--- a/media/java/android/media/MediaCodecInfo.java
+++ b/media/java/android/media/MediaCodecInfo.java
@@ -541,6 +541,72 @@
* frame rate}. Use
* <code class=prettyprint>format.setString(MediaFormat.KEY_FRAME_RATE, null)</code>
* to clear any existing frame rate setting in the format.
+ * <p>
+ *
+ * The following table summarizes the format keys considered by this method.
+ *
+ * <table style="width: 0%">
+ * <thead>
+ * <tr>
+ * <th rowspan=3>OS Version(s)</th>
+ * <td colspan=3>{@code MediaFormat} keys considered for</th>
+ * </tr><tr>
+ * <th>Audio Codecs</th>
+ * <th>Video Codecs</th>
+ * <th>Encoders</th>
+ * </tr>
+ * </thead>
+ * <tbody>
+ * <tr>
+ * <td>{@link android.os.Build.VERSION_CODES#LOLLIPOP}</th>
+ * <td rowspan=3>{@link MediaFormat#KEY_MIME}<sup>*</sup>,<br>
+ * {@link MediaFormat#KEY_SAMPLE_RATE},<br>
+ * {@link MediaFormat#KEY_CHANNEL_COUNT},</td>
+ * <td>{@link MediaFormat#KEY_MIME}<sup>*</sup>,<br>
+ * {@link CodecCapabilities#FEATURE_AdaptivePlayback}<sup>D</sup>,<br>
+ * {@link CodecCapabilities#FEATURE_SecurePlayback}<sup>D</sup>,<br>
+ * {@link CodecCapabilities#FEATURE_TunneledPlayback}<sup>D</sup>,<br>
+ * {@link MediaFormat#KEY_WIDTH},<br>
+ * {@link MediaFormat#KEY_HEIGHT},<br>
+ * <strong>no</strong> {@code KEY_FRAME_RATE}</td>
+ * <td rowspan=4>{@link MediaFormat#KEY_BITRATE_MODE},<br>
+ * {@link MediaFormat#KEY_PROFILE}
+ * (and/or {@link MediaFormat#KEY_AAC_PROFILE}<sup>~</sup>),<br>
+ * <!-- {link MediaFormat#KEY_QUALITY},<br> -->
+ * {@link MediaFormat#KEY_COMPLEXITY}
+ * (and/or {@link MediaFormat#KEY_FLAC_COMPRESSION_LEVEL}<sup>~</sup>)</td>
+ * </tr><tr>
+ * <td>{@link android.os.Build.VERSION_CODES#LOLLIPOP_MR1}</th>
+ * <td rowspan=2>as above, plus<br>
+ * {@link MediaFormat#KEY_FRAME_RATE}</td>
+ * </tr><tr>
+ * <td>{@link android.os.Build.VERSION_CODES#M}</th>
+ * </tr><tr>
+ * <td>{@link android.os.Build.VERSION_CODES#N}</th>
+ * <td>as above, plus<br>
+ * {@link MediaFormat#KEY_PROFILE},<br>
+ * <!-- {link MediaFormat#KEY_MAX_BIT_RATE},<br> -->
+ * {@link MediaFormat#KEY_BIT_RATE}</td>
+ * <td>as above, plus<br>
+ * {@link MediaFormat#KEY_PROFILE},<br>
+ * {@link MediaFormat#KEY_LEVEL}<sup>+</sup>,<br>
+ * <!-- {link MediaFormat#KEY_MAX_BIT_RATE},<br> -->
+ * {@link MediaFormat#KEY_BIT_RATE},<br>
+ * {@link CodecCapabilities#FEATURE_IntraRefresh}<sup>E</sup></td>
+ * </tr>
+ * <tr>
+ * <td colspan=4>
+ * <p class=note><strong>Notes:</strong><br>
+ * *: must be specified; otherwise, method returns {@code false}.<br>
+ * +: method does not verify that the format parameters are supported
+ * by the specified level.<br>
+ * D: decoders only<br>
+ * E: encoders only<br>
+ * ~: if both keys are provided values must match
+ * </td>
+ * </tr>
+ * </tbody>
+ * </table>
*
* @param format media format with optional feature directives.
* @throws IllegalArgumentException if format is not a valid media format.
diff --git a/media/java/android/media/MediaCodecList.java b/media/java/android/media/MediaCodecList.java
index 42ce511..3cb4cbe 100644
--- a/media/java/android/media/MediaCodecList.java
+++ b/media/java/android/media/MediaCodecList.java
@@ -201,6 +201,9 @@
* <code class=prettyprint>format.setString(MediaFormat.KEY_FRAME_RATE, null)</code>
* to clear any existing frame rate setting in the format.
*
+ * @see MediaCodecList.CodecCapabilities.isFormatSupported for format keys
+ * considered per android versions when evaluating suitable codecs.
+ *
* @param format A decoder media format with optional feature directives.
* @throws IllegalArgumentException if format is not a valid media format.
* @throws NullPointerException if format is null.
@@ -222,6 +225,9 @@
* <code class=prettyprint>format.setString(MediaFormat.KEY_FRAME_RATE, null)</code>
* to clear any existing frame rate setting in the format.
*
+ * @see MediaCodecList.CodecCapabilities.isFormatSupported for format keys
+ * considered per android versions when evaluating suitable codecs.
+ *
* @param format An encoder media format with optional feature directives.
* @throws IllegalArgumentException if format is not a valid media format.
* @throws NullPointerException if format is null.
diff --git a/media/java/android/media/MediaExtractor.java b/media/java/android/media/MediaExtractor.java
index 24a400e4..6f5199b 100644
--- a/media/java/android/media/MediaExtractor.java
+++ b/media/java/android/media/MediaExtractor.java
@@ -333,7 +333,113 @@
/**
* Get the track format at the specified index.
+ *
* More detail on the representation can be found at {@link android.media.MediaCodec}
+ * <p>
+ * The following table summarizes support for format keys across android releases:
+ *
+ * <table style="width: 0%">
+ * <thead>
+ * <tr>
+ * <th rowspan=2>OS Version(s)</th>
+ * <td colspan=3>{@code MediaFormat} keys used for</th>
+ * </tr><tr>
+ * <th>All Tracks</th>
+ * <th>Audio Tracks</th>
+ * <th>Video Tracks</th>
+ * </tr>
+ * </thead>
+ * <tbody>
+ * <tr>
+ * <td>{@link android.os.Build.VERSION_CODES#JELLY_BEAN}</td>
+ * <td rowspan=8>{@link MediaFormat#KEY_MIME},<br>
+ * {@link MediaFormat#KEY_DURATION},<br>
+ * {@link MediaFormat#KEY_MAX_INPUT_SIZE}</td>
+ * <td rowspan=5>{@link MediaFormat#KEY_SAMPLE_RATE},<br>
+ * {@link MediaFormat#KEY_CHANNEL_COUNT},<br>
+ * {@link MediaFormat#KEY_CHANNEL_MASK},<br>
+ * gapless playback information<sup>.mp3, .mp4</sup>,<br>
+ * {@link MediaFormat#KEY_IS_ADTS}<sup>AAC if streaming</sup>,<br>
+ * codec-specific data<sup>AAC, Vorbis</sup></td>
+ * <td rowspan=2>{@link MediaFormat#KEY_WIDTH},<br>
+ * {@link MediaFormat#KEY_HEIGHT},<br>
+ * codec-specific data<sup>AVC, MPEG4</sup></td>
+ * </tr><tr>
+ * <td>{@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}</td>
+ * </tr><tr>
+ * <td>{@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}</td>
+ * <td rowspan=3>as above, plus<br>
+ * Pixel aspect ratio information<sup>AVC, *</sup></td>
+ * </tr><tr>
+ * <td>{@link android.os.Build.VERSION_CODES#KITKAT}</td>
+ * </tr><tr>
+ * <td>{@link android.os.Build.VERSION_CODES#KITKAT_WATCH}</td>
+ * </tr><tr>
+ * <td>{@link android.os.Build.VERSION_CODES#LOLLIPOP}</td>
+ * <td rowspan=2>as above, plus<br>
+ * {@link MediaFormat#KEY_BIT_RATE}<sup>AAC</sup>,<br>
+ * codec-specific data<sup>Opus</sup></td>
+ * <td rowspan=2>as above, plus<br>
+ * {@link MediaFormat#KEY_ROTATION}<sup>.mp4</sup>,<br>
+ * {@link MediaFormat#KEY_BIT_RATE}<sup>MPEG4</sup>,<br>
+ * codec-specific data<sup>HEVC</sup></td>
+ * </tr><tr>
+ * <td>{@link android.os.Build.VERSION_CODES#LOLLIPOP_MR1}</td>
+ * </tr><tr>
+ * <td>{@link android.os.Build.VERSION_CODES#M}</td>
+ * <td>as above, plus<br>
+ * gapless playback information<sup>Opus</sup></td>
+ * <td>as above, plus<br>
+ * {@link MediaFormat#KEY_FRAME_RATE} (integer)</td>
+ * </tr><tr>
+ * <td>{@link android.os.Build.VERSION_CODES#N}</td>
+ * <td>as above, plus<br>
+ * {@link MediaFormat#KEY_TRACK_ID},<br>
+ * <!-- {link MediaFormat#KEY_MAX_BIT_RATE}<sup>#, .mp4</sup>,<br> -->
+ * {@link MediaFormat#KEY_BIT_RATE}<sup>#, .mp4</sup></td>
+ * <td>as above, plus<br>
+ * {@link MediaFormat#KEY_PCM_ENCODING},<br>
+ * {@link MediaFormat#KEY_PROFILE}<sup>AAC</sup></td>
+ * <td>as above, plus<br>
+ * {@link MediaFormat#KEY_HDR_STATIC_INFO}<sup>#, .webm</sup>,<br>
+ * {@link MediaFormat#KEY_COLOR_STANDARD}<sup>#</sup>,<br>
+ * {@link MediaFormat#KEY_COLOR_TRANSFER}<sup>#</sup>,<br>
+ * {@link MediaFormat#KEY_COLOR_RANGE}<sup>#</sup>,<br>
+ * {@link MediaFormat#KEY_PROFILE}<sup>MPEG2, H.263, MPEG4, AVC, HEVC, VP9</sup>,<br>
+ * {@link MediaFormat#KEY_LEVEL}<sup>H.263, MPEG4, AVC, HEVC, VP9</sup>,<br>
+ * codec-specific data<sup>VP9</sup></td>
+ * </tr>
+ * <tr>
+ * <td colspan=4>
+ * <p class=note><strong>Notes:</strong><br>
+ * #: container-specified value only.<br>
+ * .mp4, .webm…: for listed containers<br>
+ * MPEG4, AAC…: for listed codecs
+ * </td>
+ * </tr><tr>
+ * <td colspan=4>
+ * <p class=note>Note that that level information contained in the container many times
+ * does not match the level of the actual bitstream. You may want to clear the level using
+ * {@code MediaFormat.setString(KEY_LEVEL, null)} before using the track format to find a
+ * decoder that can play back a particular track.
+ * </td>
+ * </tr><tr>
+ * <td colspan=4>
+ * <p class=note><strong>*Pixel (sample) aspect ratio</strong> is returned in the following
+ * keys. The display width can be calculated for example as:
+ * <p align=center>
+ * display-width = display-height * crop-width / crop-height * sar-width / sar-height
+ * </td>
+ * </tr><tr>
+ * <th>Format Key</th><th>Value Type</th><th colspan=2>Description</th>
+ * </tr><tr>
+ * <td>{@code "sar-width"}</td><td>Integer</td><td colspan=2>Pixel aspect ratio width</td>
+ * </tr><tr>
+ * <td>{@code "sar-height"}</td><td>Integer</td><td colspan=2>Pixel aspect ratio height</td>
+ * </tr>
+ * </tbody>
+ * </table>
+ *
*/
@NonNull
public MediaFormat getTrackFormat(int index) {
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java
index d914881..ee2fa51 100755
--- a/services/core/java/com/android/server/am/ActiveServices.java
+++ b/services/core/java/com/android/server/am/ActiveServices.java
@@ -1148,9 +1148,7 @@
if (r.binding.service.app != null) {
if (r.binding.service.app.whitelistManager) {
- // Must reset flag here because on computeOomAdjLocked() the service
- // connection will be gone...
- r.binding.service.app.whitelistManager = false;
+ updateWhitelistManagerLocked(r.binding.service.app);
}
// This could have made the service less important.
if ((r.flags&Context.BIND_TREAT_LIKE_ACTIVITY) != 0) {
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index d0bd981..11c65250 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -2563,7 +2563,22 @@
+ " id=" + id + " notification=" + notification);
}
- markAsSentFromNotification(notification);
+ // Whitelist pending intents.
+ if (notification.allPendingIntents != null) {
+ final int intentCount = notification.allPendingIntents.size();
+ if (intentCount > 0) {
+ final ActivityManagerInternal am = LocalServices
+ .getService(ActivityManagerInternal.class);
+ final long duration = LocalServices.getService(
+ DeviceIdleController.LocalService.class).getNotificationWhitelistDuration();
+ for (int i = 0; i < intentCount; i++) {
+ PendingIntent pendingIntent = notification.allPendingIntents.valueAt(i);
+ if (pendingIntent != null) {
+ am.setPendingIntentWhitelistDuration(pendingIntent.getTarget(), duration);
+ }
+ }
+ }
+ }
// Sanitize inputs
notification.priority = clamp(notification.priority, Notification.PRIORITY_MIN,
@@ -2579,40 +2594,6 @@
idOut[0] = id;
}
- private static void markAsSentFromNotification(Notification notification) {
- final ActivityManagerInternal am = LocalServices.getService(ActivityManagerInternal.class);
- final long duration = LocalServices.getService(DeviceIdleController.LocalService.class)
- .getNotificationWhitelistDuration();
-
- if (notification.contentIntent != null) {
- am.setPendingIntentWhitelistDuration(notification.contentIntent.getTarget(), duration);
- }
- if (notification.deleteIntent != null) {
- am.setPendingIntentWhitelistDuration(notification.deleteIntent.getTarget(), duration);
- }
- if (notification.fullScreenIntent != null) {
- am.setPendingIntentWhitelistDuration(notification.fullScreenIntent.getTarget(),
- duration);
- }
- if (notification.actions != null) {
- for (Notification.Action action: notification.actions) {
- if (action.actionIntent == null) {
- continue;
- }
- am.setPendingIntentWhitelistDuration(action.actionIntent.getTarget(), duration);
- }
- }
- if (notification.extrasPendingIntents != null) {
- final int intentCount = notification.extrasPendingIntents.size();
- for (int i = 0; i < intentCount; i++) {
- PendingIntent pendingIntent = notification.extrasPendingIntents.valueAt(i);
- if (pendingIntent != null) {
- am.setPendingIntentWhitelistDuration(pendingIntent.getTarget(), duration);
- }
- }
- }
- }
-
private class EnqueueNotificationRunnable implements Runnable {
private final NotificationRecord r;
private final int userId;