Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e59ae90b authored by Chris Li's avatar Chris Li Committed by Baligh Uddin
Browse files

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
parent b9034aba
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -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
+9 −0
Original line number Diff line number Diff line
@@ -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.
     */
+8 −2
Original line number Diff line number Diff line
@@ -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) {
+3 −1
Original line number Diff line number Diff line
@@ -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;
    }
+1 −6
Original line number Diff line number Diff line
@@ -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<>();
Loading