Include RootDisplayArea feature id in DisplayAreaInfo
With the RootDisplayArea id, one can create WindowContext with bundle that specifying the RootDisplayArea using KEY_ROOT_DISPLAY_AREA_ID to get the WindowContext associated with the DA. Bug: 176875245 Test: atest WmTests:DisplayAreaTest
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package android.window;
|
||||
|
||||
import static android.window.DisplayAreaOrganizer.FEATURE_UNDEFINED;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.TestApi;
|
||||
import android.content.res.Configuration;
|
||||
@@ -43,8 +45,17 @@ public final class DisplayAreaInfo implements Parcelable {
|
||||
*/
|
||||
public final int displayId;
|
||||
|
||||
/**
|
||||
* The feature id of this display area.
|
||||
*/
|
||||
public final int featureId;
|
||||
|
||||
/**
|
||||
* The feature id of the root display area this display area is associated with.
|
||||
* @hide
|
||||
*/
|
||||
public int rootDisplayAreaId = FEATURE_UNDEFINED;
|
||||
|
||||
public DisplayAreaInfo(@NonNull WindowContainerToken token, int displayId, int featureId) {
|
||||
this.token = token;
|
||||
this.displayId = displayId;
|
||||
@@ -56,6 +67,7 @@ public final class DisplayAreaInfo implements Parcelable {
|
||||
configuration.readFromParcel(in);
|
||||
displayId = in.readInt();
|
||||
featureId = in.readInt();
|
||||
rootDisplayAreaId = in.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,6 +76,7 @@ public final class DisplayAreaInfo implements Parcelable {
|
||||
configuration.writeToParcel(dest, flags);
|
||||
dest.writeInt(displayId);
|
||||
dest.writeInt(featureId);
|
||||
dest.writeInt(rootDisplayAreaId);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
@@ -33,6 +33,15 @@ import java.util.concurrent.Executor;
|
||||
@TestApi
|
||||
public class DisplayAreaOrganizer extends WindowOrganizer {
|
||||
|
||||
/**
|
||||
* Key to specify the {@link com.android.server.wm.RootDisplayArea} to attach a window to.
|
||||
* It will be used by the function passed in from
|
||||
* {@link com.android.server.wm.DisplayAreaPolicyBuilder#setSelectRootForWindowFunc(BiFunction)}
|
||||
* to find the Root DA to attach the window.
|
||||
* @hide
|
||||
*/
|
||||
public static final String KEY_ROOT_DISPLAY_AREA_ID = "root_display_area_id";
|
||||
|
||||
/**
|
||||
* The value in display area indicating that no value has been set.
|
||||
*/
|
||||
|
||||
@@ -57,8 +57,14 @@ public class WindowContext extends ContextWrapper {
|
||||
*
|
||||
* @param base Base {@link Context} for this new instance.
|
||||
* @param type Window type to be used with this context.
|
||||
* @param options A bundle used to pass window-related options.
|
||||
*
|
||||
* @param options A bundle used to pass window-related options. For example, on device with
|
||||
* multiple DisplayAreaGroups, one may specify the RootDisplayArea for the window
|
||||
* using {@link DisplayAreaOrganizer#KEY_ROOT_DISPLAY_AREA_ID} in the options.
|
||||
* Example usage:
|
||||
* Bundle options = new Bundle();
|
||||
* options.put(KEY_ROOT_DISPLAY_AREA_ID, displayAreaInfo.rootDisplayAreaId);
|
||||
* Context windowContext = context.createWindowContext(display, type, options);
|
||||
* @see DisplayAreaInfo#rootDisplayAreaId
|
||||
* @hide
|
||||
*/
|
||||
public WindowContext(@NonNull Context base, int type, @Nullable Bundle options) {
|
||||
|
||||
@@ -495,8 +495,10 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
|
||||
|
||||
|
||||
DisplayAreaInfo getDisplayAreaInfo() {
|
||||
DisplayAreaInfo info = new DisplayAreaInfo(mRemoteToken.toWindowContainerToken(),
|
||||
final DisplayAreaInfo info = new DisplayAreaInfo(mRemoteToken.toWindowContainerToken(),
|
||||
getDisplayContent().getDisplayId(), mFeatureId);
|
||||
final RootDisplayArea root = getRootDisplayArea();
|
||||
info.rootDisplayAreaId = root == null ? getDisplayContent().mFeatureId : root.mFeatureId;
|
||||
info.configuration.setTo(getConfiguration());
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY;
|
||||
import static android.view.WindowManagerPolicyConstants.APPLICATION_LAYER;
|
||||
import static android.window.DisplayAreaOrganizer.FEATURE_DEFAULT_TASK_CONTAINER;
|
||||
import static android.window.DisplayAreaOrganizer.FEATURE_VENDOR_LAST;
|
||||
import static android.window.DisplayAreaOrganizer.KEY_ROOT_DISPLAY_AREA_ID;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.os.Bundle;
|
||||
@@ -135,12 +136,6 @@ import java.util.function.BiFunction;
|
||||
*/
|
||||
class DisplayAreaPolicyBuilder {
|
||||
|
||||
/**
|
||||
* Key to specify the {@link RootDisplayArea} to attach the window to. Should be used by the
|
||||
* function passed in from {@link #setSelectRootForWindowFunc(BiFunction)}
|
||||
*/
|
||||
static final String KEY_ROOT_DISPLAY_AREA_ID = "root_display_area_id";
|
||||
|
||||
@Nullable private HierarchyBuilder mRootHierarchyBuilder;
|
||||
private final ArrayList<HierarchyBuilder> mDisplayAreaGroupHierarchyBuilders =
|
||||
new ArrayList<>();
|
||||
|
||||
@@ -20,6 +20,7 @@ import static android.app.ActivityManager.LOCK_TASK_MODE_LOCKED;
|
||||
import static android.app.ActivityManager.LOCK_TASK_MODE_NONE;
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
import static android.window.DisplayAreaOrganizer.FEATURE_UNDEFINED;
|
||||
import static android.window.DisplayAreaOrganizer.KEY_ROOT_DISPLAY_AREA_ID;
|
||||
|
||||
import android.animation.ArgbEvaluator;
|
||||
import android.animation.ValueAnimator;
|
||||
@@ -420,7 +421,7 @@ public class ImmersiveModeConfirmation {
|
||||
}
|
||||
|
||||
final Bundle options = new Bundle();
|
||||
options.putInt(DisplayAreaPolicyBuilder.KEY_ROOT_DISPLAY_AREA_ID, rootDisplayAreaId);
|
||||
options.putInt(KEY_ROOT_DISPLAY_AREA_ID, rootDisplayAreaId);
|
||||
return options;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,10 +35,10 @@ import static android.window.DisplayAreaOrganizer.FEATURE_ROOT;
|
||||
import static android.window.DisplayAreaOrganizer.FEATURE_VENDOR_FIRST;
|
||||
import static android.window.DisplayAreaOrganizer.FEATURE_VENDOR_LAST;
|
||||
import static android.window.DisplayAreaOrganizer.FEATURE_WINDOWED_MAGNIFICATION;
|
||||
import static android.window.DisplayAreaOrganizer.KEY_ROOT_DISPLAY_AREA_ID;
|
||||
|
||||
import static com.android.server.wm.DisplayArea.Type.ABOVE_TASKS;
|
||||
import static com.android.server.wm.DisplayAreaPolicyBuilder.Feature;
|
||||
import static com.android.server.wm.DisplayAreaPolicyBuilder.KEY_ROOT_DISPLAY_AREA_ID;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ import android.platform.test.annotations.Presubmit;
|
||||
import android.view.SurfaceControl;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.window.DisplayAreaInfo;
|
||||
import android.window.IDisplayAreaOrganizer;
|
||||
|
||||
import com.google.android.collect.Lists;
|
||||
@@ -566,6 +567,31 @@ public class DisplayAreaTest extends WindowTestsBase {
|
||||
.onDisplayAreaVanished(mockDisplayAreaOrganizer, displayArea);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDisplayAreaInfo() {
|
||||
final DisplayArea<WindowContainer> displayArea = new DisplayArea<>(
|
||||
mWm, BELOW_TASKS, "NewArea", FEATURE_VENDOR_FIRST);
|
||||
mDisplayContent.addChild(displayArea, 0);
|
||||
final DisplayAreaInfo info = displayArea.getDisplayAreaInfo();
|
||||
|
||||
assertThat(info.token).isEqualTo(displayArea.mRemoteToken.toWindowContainerToken());
|
||||
assertThat(info.configuration).isEqualTo(displayArea.getConfiguration());
|
||||
assertThat(info.displayId).isEqualTo(mDisplayContent.getDisplayId());
|
||||
assertThat(info.featureId).isEqualTo(displayArea.mFeatureId);
|
||||
assertThat(info.rootDisplayAreaId).isEqualTo(mDisplayContent.mFeatureId);
|
||||
|
||||
final TaskDisplayArea tda = mDisplayContent.getDefaultTaskDisplayArea();
|
||||
final int tdaIndex = tda.getParent().mChildren.indexOf(tda);
|
||||
final RootDisplayArea root =
|
||||
new DisplayAreaGroup(mWm, "TestRoot", FEATURE_VENDOR_FIRST + 1);
|
||||
mDisplayContent.addChild(root, tdaIndex + 1);
|
||||
displayArea.reparent(root, 0);
|
||||
|
||||
final DisplayAreaInfo info2 = displayArea.getDisplayAreaInfo();
|
||||
|
||||
assertThat(info2.rootDisplayAreaId).isEqualTo(root.mFeatureId);
|
||||
}
|
||||
|
||||
private static class TestDisplayArea<T extends WindowContainer> extends DisplayArea<T> {
|
||||
private TestDisplayArea(WindowManagerService wms, Rect bounds) {
|
||||
super(wms, ANY, "half display area");
|
||||
|
||||
Reference in New Issue
Block a user