Merge "Remove customized SettingsRippleTheme" into main
diff --git a/core/api/current.txt b/core/api/current.txt
index e8894a81..0c5b606 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -22036,6 +22036,19 @@
method public void onJetUserIdUpdate(android.media.JetPlayer, int, int);
}
+ @FlaggedApi("android.media.audio.loudness_configurator_api") public class LoudnessCodecConfigurator {
+ method @FlaggedApi("android.media.audio.loudness_configurator_api") public void addMediaCodec(@NonNull android.media.MediaCodec);
+ method @FlaggedApi("android.media.audio.loudness_configurator_api") @NonNull public static android.media.LoudnessCodecConfigurator create();
+ method @FlaggedApi("android.media.audio.loudness_configurator_api") @NonNull public static android.media.LoudnessCodecConfigurator create(@NonNull java.util.concurrent.Executor, @NonNull android.media.LoudnessCodecConfigurator.OnLoudnessCodecUpdateListener);
+ method @FlaggedApi("android.media.audio.loudness_configurator_api") @NonNull public android.os.Bundle getLoudnessCodecParams(@NonNull android.media.AudioTrack, @NonNull android.media.MediaCodec);
+ method @FlaggedApi("android.media.audio.loudness_configurator_api") public void removeMediaCodec(@NonNull android.media.MediaCodec);
+ method @FlaggedApi("android.media.audio.loudness_configurator_api") public void setAudioTrack(@Nullable android.media.AudioTrack);
+ }
+
+ @FlaggedApi("android.media.audio.loudness_configurator_api") public static interface LoudnessCodecConfigurator.OnLoudnessCodecUpdateListener {
+ method @FlaggedApi("android.media.audio.loudness_configurator_api") @NonNull public default android.os.Bundle onLoudnessCodecUpdate(@NonNull android.media.MediaCodec, @NonNull android.os.Bundle);
+ }
+
public class MediaActionSound {
ctor public MediaActionSound();
method public void load(int);
diff --git a/core/java/android/appwidget/AppWidgetManager.java b/core/java/android/appwidget/AppWidgetManager.java
index 51a7f1c..6e45147 100644
--- a/core/java/android/appwidget/AppWidgetManager.java
+++ b/core/java/android/appwidget/AppWidgetManager.java
@@ -558,7 +558,7 @@
}
}).toArray(ComponentName[]::new));
} catch (Exception e) {
- Log.e(TAG, "Nofity service of inheritance info", e);
+ Log.e(TAG, "Notify service of inheritance info", e);
}
});
}
diff --git a/core/java/android/window/TaskFragmentOperation.java b/core/java/android/window/TaskFragmentOperation.java
index 4e0f9a5..0ec9ffe 100644
--- a/core/java/android/window/TaskFragmentOperation.java
+++ b/core/java/android/window/TaskFragmentOperation.java
@@ -108,6 +108,18 @@
*/
public static final int OP_TYPE_REORDER_TO_TOP_OF_TASK = 13;
+ /**
+ * Creates a decor surface in the parent Task of the TaskFragment. The created decor surface
+ * will be provided in {@link TaskFragmentTransaction#TYPE_TASK_FRAGMENT_PARENT_INFO_CHANGED}
+ * event callback.
+ */
+ public static final int OP_TYPE_CREATE_TASK_FRAGMENT_DECOR_SURFACE = 14;
+
+ /**
+ * Removes the decor surface in the parent Task of the TaskFragment.
+ */
+ public static final int OP_TYPE_REMOVE_TASK_FRAGMENT_DECOR_SURFACE = 15;
+
@IntDef(prefix = { "OP_TYPE_" }, value = {
OP_TYPE_UNKNOWN,
OP_TYPE_CREATE_TASK_FRAGMENT,
@@ -124,6 +136,8 @@
OP_TYPE_SET_ISOLATED_NAVIGATION,
OP_TYPE_REORDER_TO_BOTTOM_OF_TASK,
OP_TYPE_REORDER_TO_TOP_OF_TASK,
+ OP_TYPE_CREATE_TASK_FRAGMENT_DECOR_SURFACE,
+ OP_TYPE_REMOVE_TASK_FRAGMENT_DECOR_SURFACE,
})
@Retention(RetentionPolicy.SOURCE)
public @interface OperationType {}
diff --git a/core/java/android/window/TaskFragmentParentInfo.java b/core/java/android/window/TaskFragmentParentInfo.java
index e6eeca4..a77c234 100644
--- a/core/java/android/window/TaskFragmentParentInfo.java
+++ b/core/java/android/window/TaskFragmentParentInfo.java
@@ -22,6 +22,9 @@
import android.content.res.Configuration;
import android.os.Parcel;
import android.os.Parcelable;
+import android.view.SurfaceControl;
+
+import java.util.Objects;
/**
* The information about the parent Task of a particular TaskFragment
@@ -37,12 +40,15 @@
private final boolean mHasDirectActivity;
+ @Nullable private final SurfaceControl mDecorSurface;
+
public TaskFragmentParentInfo(@NonNull Configuration configuration, int displayId,
- boolean visible, boolean hasDirectActivity) {
+ boolean visible, boolean hasDirectActivity, @Nullable SurfaceControl decorSurface) {
mConfiguration.setTo(configuration);
mDisplayId = displayId;
mVisible = visible;
mHasDirectActivity = hasDirectActivity;
+ mDecorSurface = decorSurface;
}
public TaskFragmentParentInfo(@NonNull TaskFragmentParentInfo info) {
@@ -50,6 +56,7 @@
mDisplayId = info.mDisplayId;
mVisible = info.mVisible;
mHasDirectActivity = info.mHasDirectActivity;
+ mDecorSurface = info.mDecorSurface;
}
/** The {@link Configuration} of the parent Task */
@@ -92,7 +99,13 @@
return false;
}
return getWindowingMode() == that.getWindowingMode() && mDisplayId == that.mDisplayId
- && mVisible == that.mVisible && mHasDirectActivity == that.mHasDirectActivity;
+ && mVisible == that.mVisible && mHasDirectActivity == that.mHasDirectActivity
+ && mDecorSurface == that.mDecorSurface;
+ }
+
+ @Nullable
+ public SurfaceControl getDecorSurface() {
+ return mDecorSurface;
}
@WindowConfiguration.WindowingMode
@@ -107,6 +120,7 @@
+ ", displayId=" + mDisplayId
+ ", visible=" + mVisible
+ ", hasDirectActivity=" + mHasDirectActivity
+ + ", decorSurface=" + mDecorSurface
+ "}";
}
@@ -128,7 +142,8 @@
return mConfiguration.equals(that.mConfiguration)
&& mDisplayId == that.mDisplayId
&& mVisible == that.mVisible
- && mHasDirectActivity == that.mHasDirectActivity;
+ && mHasDirectActivity == that.mHasDirectActivity
+ && mDecorSurface == that.mDecorSurface;
}
@Override
@@ -137,6 +152,7 @@
result = 31 * result + mDisplayId;
result = 31 * result + (mVisible ? 1 : 0);
result = 31 * result + (mHasDirectActivity ? 1 : 0);
+ result = 31 * result + Objects.hashCode(mDecorSurface);
return result;
}
@@ -146,6 +162,7 @@
dest.writeInt(mDisplayId);
dest.writeBoolean(mVisible);
dest.writeBoolean(mHasDirectActivity);
+ dest.writeTypedObject(mDecorSurface, flags);
}
private TaskFragmentParentInfo(Parcel in) {
@@ -153,6 +170,7 @@
mDisplayId = in.readInt();
mVisible = in.readBoolean();
mHasDirectActivity = in.readBoolean();
+ mDecorSurface = in.readTypedObject(SurfaceControl.CREATOR);
}
public static final Creator<TaskFragmentParentInfo> CREATOR =
diff --git a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/OverlayPresentationTest.java b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/OverlayPresentationTest.java
index 50cfd94..4c2433f 100644
--- a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/OverlayPresentationTest.java
+++ b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/OverlayPresentationTest.java
@@ -443,7 +443,8 @@
assertThat(taskContainer.getTaskFragmentContainers()).containsExactly(overlayContainer);
taskContainer.updateTaskFragmentParentInfo(new TaskFragmentParentInfo(Configuration.EMPTY,
- DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */));
+ DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */,
+ null /* decorSurface */));
mSplitController.updateOverlayContainer(mTransaction, overlayContainer);
diff --git a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/SplitControllerTest.java b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/SplitControllerTest.java
index 02031a6..8c274a2 100644
--- a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/SplitControllerTest.java
+++ b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/SplitControllerTest.java
@@ -1139,7 +1139,8 @@
public void testOnTransactionReady_taskFragmentParentInfoChanged() {
final TaskFragmentTransaction transaction = new TaskFragmentTransaction();
final TaskFragmentParentInfo parentInfo = new TaskFragmentParentInfo(Configuration.EMPTY,
- DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */);
+ DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */,
+ null /* decorSurface */);
transaction.addChange(new TaskFragmentTransaction.Change(
TYPE_TASK_FRAGMENT_PARENT_INFO_CHANGED)
.setTaskId(TASK_ID)
diff --git a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/TaskContainerTest.java b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/TaskContainerTest.java
index e56c8ab..7b77235 100644
--- a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/TaskContainerTest.java
+++ b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/TaskContainerTest.java
@@ -79,14 +79,16 @@
configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN);
taskContainer.updateTaskFragmentParentInfo(new TaskFragmentParentInfo(configuration,
- DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */));
+ DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */,
+ null /* decorSurface */));
assertEquals(WINDOWING_MODE_MULTI_WINDOW,
taskContainer.getWindowingModeForSplitTaskFragment(splitBounds));
configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM);
taskContainer.updateTaskFragmentParentInfo(new TaskFragmentParentInfo(configuration,
- DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */));
+ DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */,
+ null /* decorSurface */));
assertEquals(WINDOWING_MODE_FREEFORM,
taskContainer.getWindowingModeForSplitTaskFragment(splitBounds));
@@ -106,13 +108,15 @@
configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN);
taskContainer.updateTaskFragmentParentInfo(new TaskFragmentParentInfo(configuration,
- DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */));
+ DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */,
+ null /* decorSurface */));
assertFalse(taskContainer.isInPictureInPicture());
configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_PINNED);
taskContainer.updateTaskFragmentParentInfo(new TaskFragmentParentInfo(configuration,
- DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */));
+ DEFAULT_DISPLAY, true /* visible */, false /* hasDirectActivity */,
+ null /* decorSurface */));
assertTrue(taskContainer.isInPictureInPicture());
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java
index 271a3b2..63afd3e 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java
@@ -627,7 +627,8 @@
&& mRecentsTask.equals(change.getContainer());
hasTaskChange = hasTaskChange || isRootTask;
final boolean isLeafTask = leafTaskFilter.test(change);
- if (TransitionUtil.isOpeningType(change.getMode())) {
+ if (TransitionUtil.isOpeningType(change.getMode())
+ || TransitionUtil.isOrderOnly(change)) {
if (isRecentsTask) {
recentsOpening = change;
} else if (isRootTask || isLeafTask) {
diff --git a/media/java/android/media/LoudnessCodecConfigurator.java b/media/java/android/media/LoudnessCodecConfigurator.java
index c879179..de9d87c0 100644
--- a/media/java/android/media/LoudnessCodecConfigurator.java
+++ b/media/java/android/media/LoudnessCodecConfigurator.java
@@ -33,6 +33,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.Executor;
@@ -46,9 +47,6 @@
* parameter updates are defined by the CTA-2075 standard.
* <p>A new object should be instantiated for each {@link AudioTrack} with the help
* of {@link #create()} or {@link #create(Executor, OnLoudnessCodecUpdateListener)}.
- *
- * TODO: remove hide once API is final
- * @hide
*/
@FlaggedApi(FLAG_LOUDNESS_CONFIGURATOR_API)
public class LoudnessCodecConfigurator {
@@ -56,9 +54,6 @@
/**
* Listener used for receiving asynchronous loudness metadata updates.
- *
- * TODO: remove hide once API is final
- * @hide
*/
@FlaggedApi(FLAG_LOUDNESS_CONFIGURATOR_API)
public interface OnLoudnessCodecUpdateListener {
@@ -75,9 +70,6 @@
* @return a Bundle which contains the original computed codecValues
* aggregated with user edits. The platform will configure the associated
* MediaCodecs with the returned Bundle params.
- *
- * TODO: remove hide once API is final
- * @hide
*/
@FlaggedApi(FLAG_LOUDNESS_CONFIGURATOR_API)
@NonNull
@@ -111,9 +103,6 @@
* Otherwise, use {@link #create(Executor, OnLoudnessCodecUpdateListener)}.
*
* @return the {@link LoudnessCodecConfigurator} instance
- *
- * TODO: remove hide once API is final
- * @hide
*/
@FlaggedApi(FLAG_LOUDNESS_CONFIGURATOR_API)
public static @NonNull LoudnessCodecConfigurator create() {
@@ -132,9 +121,6 @@
* @param listener used for receiving updates
*
* @return the {@link LoudnessCodecConfigurator} instance
- *
- * TODO: remove hide once API is final
- * @hide
*/
@FlaggedApi(FLAG_LOUDNESS_CONFIGURATOR_API)
public static @NonNull LoudnessCodecConfigurator create(
@@ -199,12 +185,9 @@
* method will have the effect of clearing the existing set
* {@link AudioTrack} and will stop receiving asynchronous
* loudness updates
- *
- * TODO: remove hide once API is final
- * @hide
*/
@FlaggedApi(FLAG_LOUDNESS_CONFIGURATOR_API)
- public void setAudioTrack(AudioTrack audioTrack) {
+ public void setAudioTrack(@Nullable AudioTrack audioTrack) {
List<LoudnessCodecInfo> codecInfos;
int piid = PLAYER_PIID_INVALID;
int oldPiid = PLAYER_PIID_INVALID;
@@ -249,10 +232,11 @@
* previously added.
*
* @param mediaCodec the codec to start receiving asynchronous loudness
- * updates
- *
- * TODO: remove hide once API is final
- * @hide
+ * updates. The codec has to be in a configured or started
+ * state in order to add it for loudness updates.
+ * @throws IllegalArgumentException if the {@code mediaCodec} was not configured,
+ * does not contain loudness metadata or if it
+ * was already added before
*/
@FlaggedApi(FLAG_LOUDNESS_CONFIGURATOR_API)
public void addMediaCodec(@NonNull MediaCodec mediaCodec) {
@@ -261,30 +245,31 @@
int piid = PLAYER_PIID_INVALID;
final LoudnessCodecInfo mcInfo = getCodecInfo(mc);
- if (mcInfo != null) {
- synchronized (mConfiguratorLock) {
- final AtomicBoolean containsCodec = new AtomicBoolean(false);
- Set<MediaCodec> newSet = mMediaCodecs.computeIfPresent(mcInfo, (info, codecSet) -> {
- containsCodec.set(!codecSet.add(mc));
- return codecSet;
- });
- if (newSet == null) {
- newSet = new HashSet<>();
- newSet.add(mc);
- mMediaCodecs.put(mcInfo, newSet);
- }
- if (containsCodec.get()) {
- Log.v(TAG, "Loudness configurator already added media codec " + mediaCodec);
- return;
- }
- if (mAudioTrack != null) {
- piid = mAudioTrack.getPlayerIId();
- }
+ if (mcInfo == null) {
+ throw new IllegalArgumentException("Could not extract codec loudness information");
+ }
+ synchronized (mConfiguratorLock) {
+ final AtomicBoolean containsCodec = new AtomicBoolean(false);
+ Set<MediaCodec> newSet = mMediaCodecs.computeIfPresent(mcInfo, (info, codecSet) -> {
+ containsCodec.set(!codecSet.add(mc));
+ return codecSet;
+ });
+ if (newSet == null) {
+ newSet = new HashSet<>();
+ newSet.add(mc);
+ mMediaCodecs.put(mcInfo, newSet);
}
+ if (containsCodec.get()) {
+ throw new IllegalArgumentException(
+ "Loudness configurator already added " + mediaCodec);
+ }
+ if (mAudioTrack != null) {
+ piid = mAudioTrack.getPlayerIId();
+ }
+ }
- if (piid != PLAYER_PIID_INVALID) {
- mLcDispatcher.addLoudnessCodecInfo(piid, mediaCodec.hashCode(), mcInfo);
- }
+ if (piid != PLAYER_PIID_INVALID) {
+ mLcDispatcher.addLoudnessCodecInfo(piid, mediaCodec.hashCode(), mcInfo);
}
}
@@ -296,38 +281,44 @@
* <p>No elements will be removed if the passed mediaCodec was not added before.
*
* @param mediaCodec the element to remove for receiving asynchronous updates
- *
- * TODO: remove hide once API is final
- * @hide
+ * @throws IllegalArgumentException if the {@code mediaCodec} was not configured,
+ * does not contain loudness metadata or if it
+ * was not added before
*/
@FlaggedApi(FLAG_LOUDNESS_CONFIGURATOR_API)
public void removeMediaCodec(@NonNull MediaCodec mediaCodec) {
int piid = PLAYER_PIID_INVALID;
LoudnessCodecInfo mcInfo;
+ AtomicBoolean removedMc = new AtomicBoolean(false);
AtomicBoolean removeInfo = new AtomicBoolean(false);
mcInfo = getCodecInfo(Objects.requireNonNull(mediaCodec,
"MediaCodec for removeMediaCodec cannot be null"));
- if (mcInfo != null) {
- synchronized (mConfiguratorLock) {
- if (mAudioTrack != null) {
- piid = mAudioTrack.getPlayerIId();
+ if (mcInfo == null) {
+ throw new IllegalArgumentException("Could not extract codec loudness information");
+ }
+ synchronized (mConfiguratorLock) {
+ if (mAudioTrack != null) {
+ piid = mAudioTrack.getPlayerIId();
+ }
+ mMediaCodecs.computeIfPresent(mcInfo, (format, mcs) -> {
+ removedMc.set(mcs.remove(mediaCodec));
+ if (mcs.isEmpty()) {
+ // remove the entry
+ removeInfo.set(true);
+ return null;
}
- mMediaCodecs.computeIfPresent(mcInfo, (format, mcs) -> {
- mcs.remove(mediaCodec);
- if (mcs.isEmpty()) {
- // remove the entry
- removeInfo.set(true);
- return null;
- }
- return mcs;
- });
+ return mcs;
+ });
+ if (!removedMc.get()) {
+ throw new IllegalArgumentException(
+ "Loudness configurator does not contain " + mediaCodec);
}
+ }
- if (piid != PLAYER_PIID_INVALID && removeInfo.get()) {
- mLcDispatcher.removeLoudnessCodecInfo(piid, mcInfo);
- }
+ if (piid != PLAYER_PIID_INVALID && removeInfo.get()) {
+ mLcDispatcher.removeLoudnessCodecInfo(piid, mcInfo);
}
}
@@ -342,9 +333,6 @@
*
* @return the {@link Bundle} containing the current loudness parameters. Caller is
* responsible to update the {@link MediaCodec}
- *
- * TODO: remove hide once API is final
- * @hide
*/
@FlaggedApi(FLAG_LOUDNESS_CONFIGURATOR_API)
@NonNull
@@ -375,7 +363,7 @@
}
/** @hide */
- /*package*/ HashMap<LoudnessCodecInfo, Set<MediaCodec>> getRegisteredMediaCodecs() {
+ /*package*/ Map<LoudnessCodecInfo, Set<MediaCodec>> getRegisteredMediaCodecs() {
synchronized (mConfiguratorLock) {
return mMediaCodecs;
}
@@ -397,38 +385,43 @@
return null;
}
- final MediaFormat inputFormat = mediaCodec.getInputFormat();
- final String mimeType = inputFormat.getString(MediaFormat.KEY_MIME);
- if (MediaFormat.MIMETYPE_AUDIO_AAC.equalsIgnoreCase(mimeType)) {
- // check both KEY_AAC_PROFILE and KEY_PROFILE as some codecs may only recognize one of
- // these two keys
- int aacProfile = -1;
- int profile = -1;
- try {
- aacProfile = inputFormat.getInteger(MediaFormat.KEY_AAC_PROFILE);
- } catch (NullPointerException e) {
- // does not contain KEY_AAC_PROFILE. do nothing
- }
- try {
- profile = inputFormat.getInteger(MediaFormat.KEY_PROFILE);
- } catch (NullPointerException e) {
- // does not contain KEY_PROFILE. do nothing
- }
- if (aacProfile == MediaCodecInfo.CodecProfileLevel.AACObjectXHE
- || profile == MediaCodecInfo.CodecProfileLevel.AACObjectXHE) {
- lci.metadataType = CODEC_METADATA_TYPE_MPEG_D;
+ try {
+ final MediaFormat inputFormat = mediaCodec.getInputFormat();
+ final String mimeType = inputFormat.getString(MediaFormat.KEY_MIME);
+ if (MediaFormat.MIMETYPE_AUDIO_AAC.equalsIgnoreCase(mimeType)) {
+ // check both KEY_AAC_PROFILE and KEY_PROFILE as some codecs may only recognize
+ // one of these two keys
+ int aacProfile = -1;
+ int profile = -1;
+ try {
+ aacProfile = inputFormat.getInteger(MediaFormat.KEY_AAC_PROFILE);
+ } catch (NullPointerException e) {
+ // does not contain KEY_AAC_PROFILE. do nothing
+ }
+ try {
+ profile = inputFormat.getInteger(MediaFormat.KEY_PROFILE);
+ } catch (NullPointerException e) {
+ // does not contain KEY_PROFILE. do nothing
+ }
+ if (aacProfile == MediaCodecInfo.CodecProfileLevel.AACObjectXHE
+ || profile == MediaCodecInfo.CodecProfileLevel.AACObjectXHE) {
+ lci.metadataType = CODEC_METADATA_TYPE_MPEG_D;
+ } else {
+ lci.metadataType = CODEC_METADATA_TYPE_MPEG_4;
+ }
} else {
- lci.metadataType = CODEC_METADATA_TYPE_MPEG_4;
+ Log.w(TAG, "MediaCodec mime type not supported for loudness annotation");
+ return null;
}
- } else {
- Log.w(TAG, "MediaCodec mime type not supported for loudness annotation");
+
+ final MediaFormat outputFormat = mediaCodec.getOutputFormat();
+ lci.isDownmixing = outputFormat.getInteger(MediaFormat.KEY_CHANNEL_COUNT)
+ < inputFormat.getInteger(MediaFormat.KEY_CHANNEL_COUNT);
+ } catch (IllegalStateException e) {
+ Log.e(TAG, "MediaCodec is not configured", e);
return null;
}
- final MediaFormat outputFormat = mediaCodec.getOutputFormat();
- lci.isDownmixing = outputFormat.getInteger(MediaFormat.KEY_CHANNEL_COUNT)
- < inputFormat.getInteger(MediaFormat.KEY_CHANNEL_COUNT);
-
return lci;
}
}
diff --git a/media/java/android/media/LoudnessCodecDispatcher.java b/media/java/android/media/LoudnessCodecDispatcher.java
index 0da1a49..b546a81 100644
--- a/media/java/android/media/LoudnessCodecDispatcher.java
+++ b/media/java/android/media/LoudnessCodecDispatcher.java
@@ -33,6 +33,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
@@ -81,7 +82,7 @@
mConfiguratorListener.computeIfPresent(listener, (l, lcConfig) -> {
// send the appropriate bundle for the user to update
if (lcConfig.getAssignedTrackPiid() == piid) {
- final HashMap<LoudnessCodecInfo, Set<MediaCodec>> mediaCodecsMap =
+ final Map<LoudnessCodecInfo, Set<MediaCodec>> mediaCodecsMap =
lcConfig.getRegisteredMediaCodecs();
for (LoudnessCodecInfo codecInfo : mediaCodecsMap.keySet()) {
final String infoKey = Integer.toString(codecInfo.hashCode());
diff --git a/media/java/android/media/LoudnessCodecInfo.aidl b/media/java/android/media/LoudnessCodecInfo.aidl
index d9fb962..0ac5646 100644
--- a/media/java/android/media/LoudnessCodecInfo.aidl
+++ b/media/java/android/media/LoudnessCodecInfo.aidl
@@ -23,7 +23,7 @@
*
* {@hide}
*/
-@JavaDerive(equals = true)
+@JavaDerive(equals = true, toString = true)
parcelable LoudnessCodecInfo {
/** Supported codec metadata types for loudness updates. */
@Backing(type="int")
diff --git a/packages/SettingsLib/src/com/android/settingslib/PrimarySwitchPreference.java b/packages/SettingsLib/src/com/android/settingslib/PrimarySwitchPreference.java
index 0a2d9fc..e41126f 100644
--- a/packages/SettingsLib/src/com/android/settingslib/PrimarySwitchPreference.java
+++ b/packages/SettingsLib/src/com/android/settingslib/PrimarySwitchPreference.java
@@ -140,12 +140,6 @@
}
}
- @Override
- public void setEnabled(boolean enabled) {
- super.setEnabled(enabled);
- setSwitchEnabled(enabled);
- }
-
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
public boolean isSwitchEnabled() {
return mEnableSwitch;
diff --git a/packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java b/packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java
index 8b0f19d..29ea25e 100644
--- a/packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java
+++ b/packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java
@@ -22,7 +22,6 @@
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.UserHandle;
import android.text.TextUtils;
@@ -237,15 +236,13 @@
}
private void updateDisabledState() {
- boolean isEnabled = !(mDisabledByAdmin || mDisabledByAppOps);
if (!(mPreference instanceof RestrictedTopLevelPreference)) {
- mPreference.setEnabled(isEnabled);
+ mPreference.setEnabled(!(mDisabledByAdmin || mDisabledByAppOps));
}
- Drawable icon = mPreference.getIcon();
- if (!isEnabled && icon != null) {
- Utils.convertToGrayscale(icon);
- mPreference.setIcon(icon);
+ if (mPreference instanceof PrimarySwitchPreference) {
+ ((PrimarySwitchPreference) mPreference)
+ .setSwitchEnabled(!(mDisabledByAdmin || mDisabledByAppOps));
}
}
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/Utils.java b/packages/SettingsLib/src/com/android/settingslib/Utils.java
index f03263b..107d5f8 100644
--- a/packages/SettingsLib/src/com/android/settingslib/Utils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/Utils.java
@@ -728,14 +728,4 @@
return false;
}
- /**
- * Convert a drawable to grayscale drawable
- */
- public static void convertToGrayscale(@NonNull Drawable drawable) {
- ColorMatrix matrix = new ColorMatrix();
- matrix.setSaturation(0.0f);
-
- ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
- drawable.setColorFilter(filter);
- }
}
diff --git a/packages/SystemUI/aconfig/OWNERS b/packages/SystemUI/aconfig/OWNERS
index e1a7a0f..902ba90 100644
--- a/packages/SystemUI/aconfig/OWNERS
+++ b/packages/SystemUI/aconfig/OWNERS
@@ -1 +1,2 @@
per-file accessibility.aconfig = file:/core/java/android/view/accessibility/OWNERS
+per-file biometrics_framework.aconfig = file:/services/core/java/com/android/server/biometrics/OWNERS
diff --git a/packages/SystemUI/aconfig/biometrics_framework.aconfig b/packages/SystemUI/aconfig/biometrics_framework.aconfig
new file mode 100644
index 0000000..5fd3b48
--- /dev/null
+++ b/packages/SystemUI/aconfig/biometrics_framework.aconfig
@@ -0,0 +1,10 @@
+package: "com.android.systemui"
+
+# NOTE: Keep alphabetized to help limit merge conflicts from multiple simultaneous editors.
+
+flag {
+ name: "bp_talkback"
+ namespace: "biometrics_framework"
+ description: "Adds talkback directional guidance when using UDFPS with biometric prompt"
+ bug: "310044658"
+}
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java
index 6d8ec44..c615887 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java
@@ -67,6 +67,7 @@
private final UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
private boolean mIsStatusBarExpanded = false;
+ private boolean mIsSceneContainerVisible = false;
private boolean mShouldAdjustInsets = false;
private View mNotificationShadeWindowView;
private View mNotificationPanelView;
@@ -128,11 +129,14 @@
});
mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
- javaAdapter.alwaysCollectFlow(shadeInteractor.isAnyExpanded(), this::onShadeOrQsExpanded);
if (sceneContainerFlags.isEnabled()) {
javaAdapter.alwaysCollectFlow(
sceneInteractor.get().isVisible(),
+ this::onSceneContainerVisibilityChanged);
+ } else {
+ javaAdapter.alwaysCollectFlow(
+ shadeInteractor.isAnyExpanded(),
this::onShadeOrQsExpanded);
}
@@ -164,6 +168,17 @@
}
}
+ private void onSceneContainerVisibilityChanged(Boolean isVisible) {
+ if (isVisible != mIsSceneContainerVisible) {
+ mIsSceneContainerVisible = isVisible;
+ if (isVisible) {
+ // make sure our state is sensible
+ mForceCollapsedUntilLayout = false;
+ }
+ updateTouchableRegion();
+ }
+ }
+
/**
* Calculates the touch region needed for heads up notifications, taking into consideration
* any existing display cutouts (notch)
@@ -267,6 +282,7 @@
// since we don't want stray touches to go through the light reveal scrim to whatever is
// underneath.
return mIsStatusBarExpanded
+ || mIsSceneContainerVisible
|| mPrimaryBouncerInteractor.isShowing().getValue()
|| mAlternateBouncerInteractor.isVisibleState()
|| mUnlockedScreenOffAnimationController.isAnimationPlaying();
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 5b6f919..5d47e35 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -11372,6 +11372,8 @@
static final int LOG_NB_EVENTS_SPATIAL = 30;
static final int LOG_NB_EVENTS_SOUND_DOSE = 30;
+ static final int LOG_NB_EVENTS_LOUDNESS_CODEC = 30;
+
static final EventLogger
sLifecycleLogger = new EventLogger(LOG_NB_EVENTS_LIFECYCLE,
"audio services lifecycle");
@@ -11571,6 +11573,10 @@
mSpatializerHelper.dump(pw);
sSpatialLogger.dump(pw);
+ pw.println("\n");
+ pw.println("\nLoudness alignment:");
+ mLoudnessCodecHelper.dump(pw);
+
mAudioSystem.dump(pw);
}
diff --git a/services/core/java/com/android/server/audio/AudioServiceEvents.java b/services/core/java/com/android/server/audio/AudioServiceEvents.java
index f69b9f6..de89011 100644
--- a/services/core/java/com/android/server/audio/AudioServiceEvents.java
+++ b/services/core/java/com/android/server/audio/AudioServiceEvents.java
@@ -622,6 +622,55 @@
}
}
+ static final class LoudnessEvent extends EventLogger.Event {
+ static final int START_PIID = 0;
+
+ static final int STOP_PIID = 1;
+
+ static final int CLIENT_DIED = 2;
+
+ final int mEventType;
+ final int mIntValue1;
+ final int mIntValue2;
+
+ private LoudnessEvent(int event, int i1, int i2) {
+ mEventType = event;
+ mIntValue1 = i1;
+ mIntValue2 = i2;
+ }
+
+ static LoudnessEvent getStartPiid(int piid, int pid) {
+ return new LoudnessEvent(START_PIID, piid, pid);
+ }
+
+ static LoudnessEvent getStopPiid(int piid, int pid) {
+ return new LoudnessEvent(STOP_PIID, piid, pid);
+ }
+
+ static LoudnessEvent getClientDied(int pid) {
+ return new LoudnessEvent(CLIENT_DIED, 0 /* ignored */, pid);
+ }
+
+
+ @Override
+ public String eventToString() {
+ switch (mEventType) {
+ case START_PIID:
+ return String.format(
+ "Start loudness updates for piid %d for client pid %d",
+ mIntValue1, mIntValue2);
+ case STOP_PIID:
+ return String.format(
+ "Stop loudness updates for piid %d for client pid %d",
+ mIntValue1, mIntValue2);
+ case CLIENT_DIED:
+ return String.format("Loudness client with pid %d died", mIntValue2);
+
+ }
+ return new StringBuilder("FIXME invalid event type:").append(mEventType).toString();
+ }
+ }
+
/**
* Class to log stream type mute/unmute events
*/
diff --git a/services/core/java/com/android/server/audio/LoudnessCodecHelper.java b/services/core/java/com/android/server/audio/LoudnessCodecHelper.java
index 31c0d4f..bbe819f 100644
--- a/services/core/java/com/android/server/audio/LoudnessCodecHelper.java
+++ b/services/core/java/com/android/server/audio/LoudnessCodecHelper.java
@@ -47,7 +47,10 @@
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.server.audio.AudioServiceEvents.LoudnessEvent;
+import com.android.server.utils.EventLogger;
+import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
@@ -56,6 +59,7 @@
import java.util.List;
import java.util.Objects;
import java.util.Set;
+import java.util.stream.Collectors;
/**
* Class to handle the updates in loudness parameters and responsible to generate parameters that
@@ -109,12 +113,19 @@
pid = (Integer) cookie;
}
if (pid != null) {
- mLoudnessCodecHelper.removePid(pid);
+ if (DEBUG) {
+ Log.d(TAG, "Client with pid " + pid + " died, removing from receiving updates");
+ }
+ sLogger.enqueue(LoudnessEvent.getClientDied(pid));
+ mLoudnessCodecHelper.onClientPidDied(pid);
}
super.onCallbackDied(callback, cookie);
}
}
+ private static final EventLogger sLogger = new EventLogger(
+ AudioService.LOG_NB_EVENTS_LOUDNESS_CODEC, "Loudness updates");
+
private final LoudnessRemoteCallbackList mLoudnessUpdateDispatchers =
new LoudnessRemoteCallbackList(this);
@@ -290,7 +301,10 @@
Set<LoudnessCodecInfo> infoSet = new HashSet<>(codecInfoList);
mStartedPiids.put(piid, infoSet);
- mPiidToPidCache.put(piid, Binder.getCallingPid());
+ int pid = Binder.getCallingPid();
+ mPiidToPidCache.put(piid, pid);
+
+ sLogger.enqueue(LoudnessEvent.getStartPiid(piid, pid));
}
try (SafeCloseable ignored = ClearCallingIdentityContext.create()) {
@@ -304,12 +318,15 @@
if (DEBUG) {
Log.d(TAG, "stopLoudnessCodecUpdates: piid " + piid);
}
+
synchronized (mLock) {
if (!mStartedPiids.contains(piid)) {
Log.w(TAG, "Loudness updates are already stopped for piid " + piid);
return;
}
mStartedPiids.remove(piid);
+
+ sLogger.enqueue(LoudnessEvent.getStopPiid(piid, mPiidToPidCache.get(piid, -1)));
mPiidToDeviceIdCache.delete(piid);
mPiidToPidCache.delete(piid);
}
@@ -366,24 +383,6 @@
}
}
- void removePid(int pid) {
- if (DEBUG) {
- Log.d(TAG, "Removing pid " + pid + " from receiving updates");
- }
- synchronized (mLock) {
- for (int i = 0; i < mPiidToPidCache.size(); ++i) {
- int piid = mPiidToPidCache.keyAt(i);
- if (mPiidToPidCache.get(piid) == pid) {
- if (DEBUG) {
- Log.d(TAG, "Removing piid " + piid);
- }
- mStartedPiids.delete(piid);
- mPiidToDeviceIdCache.delete(piid);
- }
- }
- }
- }
-
PersistableBundle getLoudnessParams(int piid, LoudnessCodecInfo codecInfo) {
if (DEBUG) {
Log.d(TAG, "getLoudnessParams: piid " + piid + " codecInfo " + codecInfo);
@@ -452,7 +451,43 @@
updateApcList.forEach(apc -> updateCodecParametersForConfiguration(apc));
}
- /** Updates and dispatches the new loudness parameters for all its registered codecs.
+ /** Updates and dispatches the new loudness parameters for all its registered codecs. */
+ void dump(PrintWriter pw) {
+ // Registered clients
+ pw.println("\nRegistered clients:\n");
+ synchronized (mLock) {
+ for (int i = 0; i < mStartedPiids.size(); ++i) {
+ int piid = mStartedPiids.keyAt(i);
+ int pid = mPiidToPidCache.get(piid, -1);
+ final Set<LoudnessCodecInfo> codecInfos = mStartedPiids.get(piid);
+ pw.println(String.format("Player piid %d pid %d active codec types %s\n", piid,
+ pid, codecInfos.stream().map(Object::toString).collect(
+ Collectors.joining(", "))));
+ }
+ pw.println();
+ }
+
+ sLogger.dump(pw);
+ pw.println();
+ }
+
+ private void onClientPidDied(int pid) {
+ synchronized (mLock) {
+ for (int i = 0; i < mPiidToPidCache.size(); ++i) {
+ int piid = mPiidToPidCache.keyAt(i);
+ if (mPiidToPidCache.get(piid) == pid) {
+ if (DEBUG) {
+ Log.d(TAG, "Removing piid " + piid);
+ }
+ mStartedPiids.delete(piid);
+ mPiidToDeviceIdCache.delete(piid);
+ }
+ }
+ }
+ }
+
+ /**
+ * Updates and dispatches the new loudness parameters for the {@code codecInfos} set.
*
* @param apc the player configuration for which the loudness parameters are updated.
*/
diff --git a/services/core/java/com/android/server/power/hint/HintManagerService.java b/services/core/java/com/android/server/power/hint/HintManagerService.java
index dd39fb0..c17d6ab 100644
--- a/services/core/java/com/android/server/power/hint/HintManagerService.java
+++ b/services/core/java/com/android/server/power/hint/HintManagerService.java
@@ -51,6 +51,7 @@
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.List;
+import java.util.NoSuchElementException;
import java.util.Objects;
/** An hint service implementation that runs in System Server process. */
@@ -544,7 +545,11 @@
if (mHalSessionPtr == 0) return;
mNativeWrapper.halCloseHintSession(mHalSessionPtr);
mHalSessionPtr = 0;
- mToken.unlinkToDeath(this, 0);
+ try {
+ mToken.unlinkToDeath(this, 0);
+ } catch (NoSuchElementException ignored) {
+ Slogf.d(TAG, "Death link does not exist for session with UID " + mUid);
+ }
}
synchronized (mLock) {
ArrayMap<IBinder, ArraySet<AppHintSession>> tokenMap = mActiveSessions.get(mUid);
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index de802b9..5f08212 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -422,6 +422,11 @@
// TODO: remove this once the recents animation is moved to the Shell
SurfaceControl mLastRecentsAnimationOverlay;
+ // A surface that is used by TaskFragmentOrganizer to place content on top of own activities and
+ // trusted TaskFragments.
+ @Nullable
+ DecorSurfaceContainer mDecorSurfaceContainer;
+
static final int LAYER_RANK_INVISIBLE = -1;
// Ranking (from top) of this task among all visible tasks. (-1 means it's not visible)
// This number will be assigned when we evaluate OOM scores for all visible tasks.
@@ -1540,6 +1545,11 @@
mAtmService.getTaskChangeNotificationController().notifyTaskStackChanged();
}
+ if (mDecorSurfaceContainer != null && r == mDecorSurfaceContainer.mOwnerTaskFragment) {
+ // Remove the decor surface if the owner TaskFragment is removed;
+ removeDecorSurface();
+ }
+
if (hasChild()) {
updateEffectiveIntent();
@@ -2638,6 +2648,9 @@
}
// If applicable let the TaskOrganizer know the Task is vanishing.
setTaskOrganizer(null);
+ if (mDecorSurfaceContainer != null) {
+ mDecorSurfaceContainer.release();
+ }
super.removeImmediately();
mRemoving = false;
@@ -3644,7 +3657,8 @@
*/
TaskFragmentParentInfo getTaskFragmentParentInfo() {
return new TaskFragmentParentInfo(getConfiguration(), getDisplayId(),
- shouldBeVisible(null /* starting */), hasNonFinishingDirectActivity());
+ shouldBeVisible(null /* starting */), hasNonFinishingDirectActivity(),
+ getDecorSurface());
}
@Override
@@ -3666,6 +3680,62 @@
}
}
+ @Override
+ void assignChildLayers(@NonNull SurfaceControl.Transaction t) {
+ int layer = 0;
+ boolean decorSurfacePlaced = false;
+
+ // We use two passes as a way to promote children which
+ // need Z-boosting to the end of the list.
+ for (int j = 0; j < mChildren.size(); ++j) {
+ final WindowContainer wc = mChildren.get(j);
+ wc.assignChildLayers(t);
+ if (!wc.needsZBoost()) {
+ // Place the decor surface under any untrusted content.
+ if (mDecorSurfaceContainer != null && !decorSurfacePlaced
+ && shouldPlaceDecorSurfaceBelowContainer(wc)) {
+ mDecorSurfaceContainer.assignLayer(t, layer++);
+ decorSurfacePlaced = true;
+ }
+ wc.assignLayer(t, layer++);
+
+ // Place the decor surface just above the owner TaskFragment.
+ if (mDecorSurfaceContainer != null && !decorSurfacePlaced
+ && wc == mDecorSurfaceContainer.mOwnerTaskFragment) {
+ mDecorSurfaceContainer.assignLayer(t, layer++);
+ decorSurfacePlaced = true;
+ }
+ }
+ }
+
+ // If not placed yet, the decor surface should be on top of all non-boosted children.
+ if (mDecorSurfaceContainer != null && !decorSurfacePlaced) {
+ mDecorSurfaceContainer.assignLayer(t, layer++);
+ decorSurfacePlaced = true;
+ }
+
+ for (int j = 0; j < mChildren.size(); ++j) {
+ final WindowContainer wc = mChildren.get(j);
+ if (wc.needsZBoost()) {
+ wc.assignLayer(t, layer++);
+ }
+ }
+ if (mOverlayHost != null) {
+ mOverlayHost.setLayer(t, layer++);
+ }
+ }
+
+ boolean shouldPlaceDecorSurfaceBelowContainer(@NonNull WindowContainer wc) {
+ boolean isOwnActivity =
+ wc.asActivityRecord() != null
+ && wc.asActivityRecord().isUid(effectiveUid);
+ boolean isTrustedTaskFragment =
+ wc.asTaskFragment() != null
+ && wc.asTaskFragment().isEmbedded()
+ && wc.asTaskFragment().isAllowedToBeEmbeddedInTrustedMode();
+ return !isOwnActivity && !isTrustedTaskFragment;
+ }
+
boolean isTaskId(int taskId) {
return mTaskId == taskId;
}
@@ -6673,4 +6743,77 @@
mOverlayHost.dispatchInsetsChanged(s, mTmpRect);
}
}
+
+ /**
+ * Associates the decor surface with the given TF, or create one if there
+ * isn't one in the Task yet. The surface will be removed with the TF,
+ * and become invisible if the TF is invisible. */
+ void moveOrCreateDecorSurfaceFor(TaskFragment taskFragment) {
+ if (mDecorSurfaceContainer != null) {
+ mDecorSurfaceContainer.mOwnerTaskFragment = taskFragment;
+ } else {
+ mDecorSurfaceContainer = new DecorSurfaceContainer(taskFragment);
+ assignChildLayers();
+ sendTaskFragmentParentInfoChangedIfNeeded();
+ }
+ }
+
+ void removeDecorSurface() {
+ if (mDecorSurfaceContainer == null) {
+ return;
+ }
+ mDecorSurfaceContainer.release();
+ mDecorSurfaceContainer = null;
+ sendTaskFragmentParentInfoChangedIfNeeded();
+ }
+
+ @Nullable SurfaceControl getDecorSurface() {
+ return mDecorSurfaceContainer != null ? mDecorSurfaceContainer.mDecorSurface : null;
+ }
+
+ /**
+ * A decor surface that is requested by a {@code TaskFragmentOrganizer} which will be placed
+ * below children windows except for own Activities and TaskFragment in fully trusted mode.
+ */
+ @VisibleForTesting
+ class DecorSurfaceContainer {
+ @VisibleForTesting
+ @NonNull final SurfaceControl mContainerSurface;
+
+ @VisibleForTesting
+ @NonNull final SurfaceControl mDecorSurface;
+
+ // The TaskFragment that requested the decor surface. If it is destroyed, the decor surface
+ // is also released.
+ @VisibleForTesting
+ @NonNull TaskFragment mOwnerTaskFragment;
+
+ private DecorSurfaceContainer(@NonNull TaskFragment initialOwner) {
+ mOwnerTaskFragment = initialOwner;
+ mContainerSurface = makeSurface().setContainerLayer()
+ .setParent(mSurfaceControl)
+ .setName(mSurfaceControl + " - decor surface container")
+ .setEffectLayer()
+ .setHidden(false)
+ .setCallsite("Task.DecorSurfaceContainer")
+ .build();
+
+ mDecorSurface = makeSurface()
+ .setParent(mContainerSurface)
+ .setName(mSurfaceControl + " - decor surface")
+ .setHidden(false)
+ .setCallsite("Task.DecorSurfaceContainer")
+ .build();
+ }
+
+ private void assignLayer(@NonNull SurfaceControl.Transaction t, int layer) {
+ t.setLayer(mContainerSurface, layer);
+ t.setVisibility(mContainerSurface, mOwnerTaskFragment.isVisible());
+ }
+
+ private void release() {
+ mDecorSurface.release();
+ mContainerSurface.release();
+ }
+ }
}
diff --git a/services/core/java/com/android/server/wm/TaskFragment.java b/services/core/java/com/android/server/wm/TaskFragment.java
index 8bc461f..39b4480 100644
--- a/services/core/java/com/android/server/wm/TaskFragment.java
+++ b/services/core/java/com/android/server/wm/TaskFragment.java
@@ -316,7 +316,8 @@
/** Organizer that organizing this TaskFragment. */
@Nullable
private ITaskFragmentOrganizer mTaskFragmentOrganizer;
- private int mTaskFragmentOrganizerUid = INVALID_UID;
+ @VisibleForTesting
+ int mTaskFragmentOrganizerUid = INVALID_UID;
private @Nullable String mTaskFragmentOrganizerProcessName;
/** Client assigned unique token for this TaskFragment if this is created by an organizer. */
diff --git a/services/core/java/com/android/server/wm/TaskFragmentOrganizerController.java b/services/core/java/com/android/server/wm/TaskFragmentOrganizerController.java
index e7a1cf1..707f9fc 100644
--- a/services/core/java/com/android/server/wm/TaskFragmentOrganizerController.java
+++ b/services/core/java/com/android/server/wm/TaskFragmentOrganizerController.java
@@ -762,6 +762,8 @@
.setTask(task)
.build());
}
+ // Make sure the parent info changed event will be dispatched if there are no other changes.
+ mAtmService.mWindowManager.mWindowPlacerLocked.requestTraversal();
}
boolean isSystemOrganizer(@NonNull IBinder organizerToken) {
diff --git a/services/core/java/com/android/server/wm/WindowOrganizerController.java b/services/core/java/com/android/server/wm/WindowOrganizerController.java
index 208df6c7..2af6569 100644
--- a/services/core/java/com/android/server/wm/WindowOrganizerController.java
+++ b/services/core/java/com/android/server/wm/WindowOrganizerController.java
@@ -23,7 +23,9 @@
import static android.view.Display.DEFAULT_DISPLAY;
import static android.window.TaskFragmentOperation.OP_TYPE_CLEAR_ADJACENT_TASK_FRAGMENTS;
import static android.window.TaskFragmentOperation.OP_TYPE_CREATE_TASK_FRAGMENT;
+import static android.window.TaskFragmentOperation.OP_TYPE_CREATE_TASK_FRAGMENT_DECOR_SURFACE;
import static android.window.TaskFragmentOperation.OP_TYPE_DELETE_TASK_FRAGMENT;
+import static android.window.TaskFragmentOperation.OP_TYPE_REMOVE_TASK_FRAGMENT_DECOR_SURFACE;
import static android.window.TaskFragmentOperation.OP_TYPE_REORDER_TO_BOTTOM_OF_TASK;
import static android.window.TaskFragmentOperation.OP_TYPE_REORDER_TO_FRONT;
import static android.window.TaskFragmentOperation.OP_TYPE_REORDER_TO_TOP_OF_TASK;
@@ -1468,6 +1470,16 @@
}
break;
}
+ case OP_TYPE_CREATE_TASK_FRAGMENT_DECOR_SURFACE: {
+ final Task task = taskFragment.getTask();
+ task.moveOrCreateDecorSurfaceFor(taskFragment);
+ break;
+ }
+ case OP_TYPE_REMOVE_TASK_FRAGMENT_DECOR_SURFACE: {
+ final Task task = taskFragment.getTask();
+ task.removeDecorSurface();
+ break;
+ }
}
return effects;
}
@@ -1507,6 +1519,19 @@
return false;
}
+ // TODO (b/293654166) remove the decor surface checks once we clear security reviews
+ if ((opType == OP_TYPE_CREATE_TASK_FRAGMENT_DECOR_SURFACE
+ || opType == OP_TYPE_REMOVE_TASK_FRAGMENT_DECOR_SURFACE)
+ && !mTaskFragmentOrganizerController.isSystemOrganizer(organizer.asBinder())) {
+ final Throwable exception = new SecurityException(
+ "Only a system organizer can perform OP_TYPE_CREATE_TASK_FRAGMENT_DECOR_SURFACE"
+ + " or OP_TYPE_REMOVE_TASK_FRAGMENT_DECOR_SURFACE."
+ );
+ sendTaskFragmentOperationFailure(organizer, errorCallbackToken, taskFragment,
+ opType, exception);
+ return false;
+ }
+
final IBinder secondaryFragmentToken = operation.getSecondaryFragmentToken();
return secondaryFragmentToken == null
|| validateTaskFragment(mLaunchTaskFragments.get(secondaryFragmentToken), opType,
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskFragmentOrganizerControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/TaskFragmentOrganizerControllerTest.java
index 8a90f12..06f29c2 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskFragmentOrganizerControllerTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskFragmentOrganizerControllerTest.java
@@ -25,7 +25,9 @@
import static android.view.WindowManager.TRANSIT_NONE;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.window.TaskFragmentOperation.OP_TYPE_CREATE_TASK_FRAGMENT;
+import static android.window.TaskFragmentOperation.OP_TYPE_CREATE_TASK_FRAGMENT_DECOR_SURFACE;
import static android.window.TaskFragmentOperation.OP_TYPE_DELETE_TASK_FRAGMENT;
+import static android.window.TaskFragmentOperation.OP_TYPE_REMOVE_TASK_FRAGMENT_DECOR_SURFACE;
import static android.window.TaskFragmentOperation.OP_TYPE_REORDER_TO_BOTTOM_OF_TASK;
import static android.window.TaskFragmentOperation.OP_TYPE_REORDER_TO_FRONT;
import static android.window.TaskFragmentOperation.OP_TYPE_REORDER_TO_TOP_OF_TASK;
@@ -1759,6 +1761,40 @@
}
@Test
+ public void testApplyTransaction_createTaskFragmentDecorSurface() {
+ // TODO(b/293654166) remove system organizer requirement once security review is cleared.
+ mController.unregisterOrganizer(mIOrganizer);
+ mController.registerOrganizerInternal(mIOrganizer, true /* isSystemOrganizer */);
+ final Task task = createTask(mDisplayContent);
+
+ final TaskFragment tf = createTaskFragment(task);
+ final TaskFragmentOperation operation = new TaskFragmentOperation.Builder(
+ OP_TYPE_CREATE_TASK_FRAGMENT_DECOR_SURFACE).build();
+ mTransaction.addTaskFragmentOperation(tf.getFragmentToken(), operation);
+
+ assertApplyTransactionAllowed(mTransaction);
+
+ verify(task).moveOrCreateDecorSurfaceFor(tf);
+ }
+
+ @Test
+ public void testApplyTransaction_removeTaskFragmentDecorSurface() {
+ // TODO(b/293654166) remove system organizer requirement once security review is cleared.
+ mController.unregisterOrganizer(mIOrganizer);
+ mController.registerOrganizerInternal(mIOrganizer, true /* isSystemOrganizer */);
+ final Task task = createTask(mDisplayContent);
+ final TaskFragment tf = createTaskFragment(task);
+
+ final TaskFragmentOperation operation = new TaskFragmentOperation.Builder(
+ OP_TYPE_REMOVE_TASK_FRAGMENT_DECOR_SURFACE).build();
+ mTransaction.addTaskFragmentOperation(tf.getFragmentToken(), operation);
+
+ assertApplyTransactionAllowed(mTransaction);
+
+ verify(task).removeDecorSurface();
+ }
+
+ @Test
public void testApplyTransaction_reorderToBottomOfTask_failsIfNotSystemOrganizer() {
testApplyTransaction_reorder_failsIfNotSystemOrganizer_common(
OP_TYPE_REORDER_TO_BOTTOM_OF_TASK);
@@ -1966,7 +2002,8 @@
/** Setups the mock Task as the parent of the given TaskFragment. */
private static void setupMockParent(TaskFragment taskFragment, Task mockParent) {
doReturn(mockParent).when(taskFragment).getTask();
- doReturn(new TaskFragmentParentInfo(new Configuration(), DEFAULT_DISPLAY, true, true))
+ doReturn(new TaskFragmentParentInfo(
+ new Configuration(), DEFAULT_DISPLAY, true, true, null /* decorSurface */))
.when(mockParent).getTaskFragmentParentInfo();
// Task needs to be visible
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
index 5e531b4..da7612b 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
@@ -63,6 +63,7 @@
import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.clearInvocations;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import android.app.ActivityManager;
@@ -82,6 +83,7 @@
import android.util.Xml;
import android.view.Display;
import android.view.DisplayInfo;
+import android.view.SurfaceControl;
import android.window.TaskFragmentOrganizer;
import androidx.test.filters.MediumTest;
@@ -1619,6 +1621,185 @@
assertFalse(task.isDragResizing());
}
+ @Test
+ public void testMoveOrCreateDecorSurface() {
+ final TaskFragmentOrganizer organizer = new TaskFragmentOrganizer(Runnable::run);
+ final Task task = new TaskBuilder(mSupervisor).setCreateActivity(true).build();
+ final ActivityRecord activity = task.getTopMostActivity();
+ final TaskFragment fragment = createTaskFragmentWithEmbeddedActivity(task, organizer);
+ doNothing().when(task).sendTaskFragmentParentInfoChangedIfNeeded();
+
+ // Decor surface should not be present initially.
+ assertNull(task.mDecorSurfaceContainer);
+ assertNull(task.getDecorSurface());
+ assertNull(task.getTaskFragmentParentInfo().getDecorSurface());
+
+ // Decor surface should be created.
+ clearInvocations(task);
+ task.moveOrCreateDecorSurfaceFor(fragment);
+
+ assertNotNull(task.mDecorSurfaceContainer);
+ assertNotNull(task.getDecorSurface());
+ verify(task).sendTaskFragmentParentInfoChangedIfNeeded();
+ assertNotNull(task.getTaskFragmentParentInfo().getDecorSurface());
+ assertEquals(fragment, task.mDecorSurfaceContainer.mOwnerTaskFragment);
+
+ // Decor surface should be removed.
+ clearInvocations(task);
+ task.removeDecorSurface();
+
+ assertNull(task.mDecorSurfaceContainer);
+ assertNull(task.getDecorSurface());
+ verify(task).sendTaskFragmentParentInfoChangedIfNeeded();
+ assertNull(task.getTaskFragmentParentInfo().getDecorSurface());
+ }
+
+ @Test
+ public void testMoveOrCreateDecorSurface_whenOwnerTaskFragmentRemoved() {
+ final TaskFragmentOrganizer organizer = new TaskFragmentOrganizer(Runnable::run);
+ final Task task = new TaskBuilder(mSupervisor).setCreateActivity(true).build();
+ final ActivityRecord activity = task.getTopMostActivity();
+ final TaskFragment fragment1 = createTaskFragmentWithEmbeddedActivity(task, organizer);
+ final TaskFragment fragment2 = createTaskFragmentWithEmbeddedActivity(task, organizer);
+ doNothing().when(task).sendTaskFragmentParentInfoChangedIfNeeded();
+
+ task.moveOrCreateDecorSurfaceFor(fragment1);
+
+ assertNotNull(task.mDecorSurfaceContainer);
+ assertNotNull(task.getDecorSurface());
+ assertEquals(fragment1, task.mDecorSurfaceContainer.mOwnerTaskFragment);
+
+ // Transfer ownership
+ task.moveOrCreateDecorSurfaceFor(fragment2);
+
+ assertNotNull(task.mDecorSurfaceContainer);
+ assertNotNull(task.getDecorSurface());
+ assertEquals(fragment2, task.mDecorSurfaceContainer.mOwnerTaskFragment);
+
+ // Safe surface should be removed when the owner TaskFragment is removed.
+ task.removeChild(fragment2);
+
+ verify(task).removeDecorSurface();
+ assertNull(task.mDecorSurfaceContainer);
+ assertNull(task.getDecorSurface());
+ }
+
+ @Test
+ public void testAssignChildLayers_decorSurfacePlacement() {
+ final TaskFragmentOrganizer organizer = new TaskFragmentOrganizer(Runnable::run);
+ final Task task = new TaskBuilder(mSupervisor).setCreateActivity(true).build();
+ final ActivityRecord unembeddedActivity = task.getTopMostActivity();
+
+ final TaskFragment fragment1 = createTaskFragmentWithEmbeddedActivity(task, organizer);
+ final TaskFragment fragment2 = createTaskFragmentWithEmbeddedActivity(task, organizer);
+ final SurfaceControl.Transaction t = mock(SurfaceControl.Transaction.class);
+
+ doNothing().when(task).sendTaskFragmentParentInfoChangedIfNeeded();
+ spyOn(unembeddedActivity);
+ spyOn(fragment1);
+ spyOn(fragment2);
+
+ // Initially, the decor surface should not be placed.
+ task.assignChildLayers(t);
+ verify(unembeddedActivity).assignLayer(t, 0);
+ verify(fragment1).assignLayer(t, 1);
+ verify(fragment2).assignLayer(t, 2);
+
+ clearInvocations(t);
+ clearInvocations(unembeddedActivity);
+ clearInvocations(fragment1);
+ clearInvocations(fragment2);
+
+ // The decor surface should be placed just above the owner TaskFragment.
+ doReturn(true).when(unembeddedActivity).isUid(task.effectiveUid);
+ doReturn(true).when(fragment1).isAllowedToBeEmbeddedInTrustedMode();
+ doReturn(true).when(fragment2).isAllowedToBeEmbeddedInTrustedMode();
+ doReturn(true).when(fragment1).isVisible();
+
+ task.moveOrCreateDecorSurfaceFor(fragment1);
+ task.assignChildLayers(t);
+
+ verify(unembeddedActivity).assignLayer(t, 0);
+ verify(fragment1).assignLayer(t, 1);
+ verify(t).setLayer(task.mDecorSurfaceContainer.mContainerSurface, 2);
+ verify(fragment2).assignLayer(t, 3);
+ verify(t).setVisibility(task.mDecorSurfaceContainer.mContainerSurface, true);
+ verify(t, never()).setLayer(eq(task.getDecorSurface()), anyInt());
+
+ clearInvocations(t);
+ clearInvocations(unembeddedActivity);
+ clearInvocations(fragment1);
+ clearInvocations(fragment2);
+
+ // The decor surface should be invisible if the owner TaskFragment is invisible.
+ doReturn(true).when(unembeddedActivity).isUid(task.effectiveUid);
+ doReturn(true).when(fragment1).isAllowedToBeEmbeddedInTrustedMode();
+ doReturn(true).when(fragment2).isAllowedToBeEmbeddedInTrustedMode();
+ doReturn(false).when(fragment1).isVisible();
+
+ task.assignChildLayers(t);
+
+ verify(unembeddedActivity).assignLayer(t, 0);
+ verify(fragment1).assignLayer(t, 1);
+ verify(t).setLayer(task.mDecorSurfaceContainer.mContainerSurface, 2);
+ verify(fragment2).assignLayer(t, 3);
+ verify(t).setVisibility(task.mDecorSurfaceContainer.mContainerSurface, false);
+ verify(t, never()).setLayer(eq(task.getDecorSurface()), anyInt());
+
+ clearInvocations(t);
+ clearInvocations(unembeddedActivity);
+ clearInvocations(fragment1);
+ clearInvocations(fragment2);
+
+ // The decor surface should be placed on below activity from a different UID.
+ doReturn(false).when(unembeddedActivity).isUid(task.effectiveUid);
+ doReturn(true).when(fragment1).isAllowedToBeEmbeddedInTrustedMode();
+ doReturn(true).when(fragment2).isAllowedToBeEmbeddedInTrustedMode();
+ doReturn(true).when(fragment1).isVisible();
+
+ task.assignChildLayers(t);
+
+ verify(t).setLayer(task.mDecorSurfaceContainer.mContainerSurface, 0);
+ verify(unembeddedActivity).assignLayer(t, 1);
+ verify(fragment1).assignLayer(t, 2);
+ verify(fragment2).assignLayer(t, 3);
+ verify(t).setVisibility(task.mDecorSurfaceContainer.mContainerSurface, true);
+ verify(t, never()).setLayer(eq(task.getDecorSurface()), anyInt());
+
+ clearInvocations(t);
+ clearInvocations(unembeddedActivity);
+ clearInvocations(fragment1);
+ clearInvocations(fragment2);
+
+ // The decor surface should be placed below untrusted embedded TaskFragment.
+ doReturn(true).when(unembeddedActivity).isUid(task.effectiveUid);
+ doReturn(true).when(fragment1).isAllowedToBeEmbeddedInTrustedMode();
+ doReturn(false).when(fragment2).isAllowedToBeEmbeddedInTrustedMode();
+ doReturn(true).when(fragment1).isVisible();
+
+ task.assignChildLayers(t);
+
+ verify(unembeddedActivity).assignLayer(t, 0);
+ verify(fragment1).assignLayer(t, 1);
+ verify(t).setLayer(task.mDecorSurfaceContainer.mContainerSurface, 2);
+ verify(fragment2).assignLayer(t, 3);
+ verify(t).setVisibility(task.mDecorSurfaceContainer.mContainerSurface, true);
+ verify(t, never()).setLayer(eq(task.getDecorSurface()), anyInt());
+
+ clearInvocations(t);
+ clearInvocations(unembeddedActivity);
+ clearInvocations(fragment1);
+ clearInvocations(fragment2);
+
+ // The decor surface should not be placed after removal.
+ task.removeDecorSurface();
+ task.assignChildLayers(t);
+
+ verify(unembeddedActivity).assignLayer(t, 0);
+ verify(fragment1).assignLayer(t, 1);
+ verify(fragment2).assignLayer(t, 2);
+ }
+
private Task getTestTask() {
return new TaskBuilder(mSupervisor).setCreateActivity(true).build();
}