Add DisplayAreaInfo

Pass DisplayAreaInfo to the client to communicate information about a
specific DisplayArea.

Test: Builds
Bug: 152114574
Change-Id: Iec53ec57d1e5e892d66a1da0bd48b75f91965d20
This commit is contained in:
chaviw
2020-04-20 17:53:10 -07:00
parent 8650e9aa11
commit d1a2393f6c
7 changed files with 137 additions and 14 deletions

View File

@@ -5259,10 +5259,20 @@ package android.widget {
package android.window {
public final class DisplayAreaInfo implements android.os.Parcelable {
ctor public DisplayAreaInfo(@NonNull android.window.WindowContainerToken, int);
method public int describeContents();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.window.DisplayAreaInfo> CREATOR;
field @NonNull public final android.content.res.Configuration configuration;
field public final int displayId;
field @NonNull public final android.window.WindowContainerToken token;
}
public class DisplayAreaOrganizer extends android.window.WindowOrganizer {
ctor public DisplayAreaOrganizer();
method public void onDisplayAreaAppeared(@NonNull android.window.WindowContainerToken);
method public void onDisplayAreaVanished(@NonNull android.window.WindowContainerToken);
method public void onDisplayAreaAppeared(@NonNull android.window.DisplayAreaInfo);
method public void onDisplayAreaVanished(@NonNull android.window.DisplayAreaInfo);
method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public void registerOrganizer(int);
field public static final int FEATURE_DEFAULT_TASK_CONTAINER = 1; // 0x1
field public static final int FEATURE_ROOT = 0; // 0x0

View File

@@ -0,0 +1,18 @@
/**
* 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.
*/
package android.window;
parcelable DisplayAreaInfo;

View File

@@ -0,0 +1,87 @@
/*
* 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.
*/
package android.window;
import android.annotation.NonNull;
import android.annotation.TestApi;
import android.content.res.Configuration;
import android.os.Parcel;
import android.os.Parcelable;
/**
* Stores information about a particular {@link com.android.server.wm.DisplayArea}. This object will
* be sent to registered {@link DisplayAreaOrganizer} to provide information when the DisplayArea
* is added, removed, or changed.
*
* @hide
*/
@TestApi
public final class DisplayAreaInfo implements Parcelable {
@NonNull
public final WindowContainerToken token;
@NonNull
public final Configuration configuration = new Configuration();
/**
* The id of the display this display area is associated with.
*/
public final int displayId;
public DisplayAreaInfo(@NonNull WindowContainerToken token, int displayId) {
this.token = token;
this.displayId = displayId;
}
private DisplayAreaInfo(Parcel in) {
token = WindowContainerToken.CREATOR.createFromParcel(in);
configuration.readFromParcel(in);
displayId = in.readInt();
}
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
token.writeToParcel(dest, flags);
configuration.writeToParcel(dest, flags);
dest.writeInt(displayId);
}
@NonNull
public static final Creator<DisplayAreaInfo> CREATOR = new Creator<DisplayAreaInfo>() {
@Override
public DisplayAreaInfo createFromParcel(Parcel in) {
return new DisplayAreaInfo(in);
}
@Override
public DisplayAreaInfo[] newArray(int size) {
return new DisplayAreaInfo[size];
}
};
@Override
public String toString() {
return "DisplayAreaInfo{token=" + token
+ " config=" + configuration + "}";
}
@Override
public int describeContents() {
return 0;
}
}

View File

@@ -52,21 +52,20 @@ public class DisplayAreaOrganizer extends WindowOrganizer {
}
}
public void onDisplayAreaAppeared(@NonNull WindowContainerToken displayArea) {}
public void onDisplayAreaVanished(@NonNull WindowContainerToken displayArea) {}
public void onDisplayAreaAppeared(@NonNull DisplayAreaInfo displayAreaInfo) {}
public void onDisplayAreaVanished(@NonNull DisplayAreaInfo displayAreaInfo) {}
private final IDisplayAreaOrganizer mInterface = new IDisplayAreaOrganizer.Stub() {
@Override
public void onDisplayAreaAppeared(@NonNull WindowContainerToken displayArea) {
DisplayAreaOrganizer.this.onDisplayAreaAppeared(displayArea);
public void onDisplayAreaAppeared(@NonNull DisplayAreaInfo displayAreaInfo) {
DisplayAreaOrganizer.this.onDisplayAreaAppeared(displayAreaInfo);
}
@Override
public void onDisplayAreaVanished(@NonNull WindowContainerToken displayArea) {
DisplayAreaOrganizer.this.onDisplayAreaVanished(displayArea);
public void onDisplayAreaVanished(@NonNull DisplayAreaInfo displayAreaInfo) {
DisplayAreaOrganizer.this.onDisplayAreaVanished(displayAreaInfo);
}
};

View File

@@ -16,13 +16,13 @@
package android.window;
import android.window.WindowContainerToken;
import android.window.DisplayAreaInfo;
/**
* Interface for WindowManager to delegate control of display areas.
* {@hide}
*/
oneway interface IDisplayAreaOrganizer {
void onDisplayAreaAppeared(in WindowContainerToken displayArea);
void onDisplayAreaVanished(in WindowContainerToken displayArea);
void onDisplayAreaAppeared(in DisplayAreaInfo displayAreaInfo);
void onDisplayAreaVanished(in DisplayAreaInfo displayAreaInfo);
}

View File

@@ -33,6 +33,7 @@ import static com.android.server.wm.WindowContainerChildProto.DISPLAY_AREA;
import android.graphics.Rect;
import android.util.proto.ProtoOutputStream;
import android.window.DisplayAreaInfo;
import android.window.IDisplayAreaOrganizer;
import com.android.server.policy.WindowManagerPolicy;
@@ -158,6 +159,14 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
return mOrganizer != null;
}
DisplayAreaInfo getDisplayAreaInfo() {
DisplayAreaInfo info = new DisplayAreaInfo(mRemoteToken.toWindowContainerToken(),
getDisplayContent().getDisplayId());
info.configuration.setTo(getConfiguration());
return info;
}
/**
* DisplayArea that contains WindowTokens, and orders them according to their type.
*/

View File

@@ -94,7 +94,7 @@ public class DisplayAreaOrganizerController extends IDisplayAreaOrganizerControl
void onDisplayAreaAppeared(IDisplayAreaOrganizer organizer, DisplayArea da) {
try {
organizer.onDisplayAreaAppeared(da.mRemoteToken.toWindowContainerToken());
organizer.onDisplayAreaAppeared(da.getDisplayAreaInfo());
} catch (RemoteException e) {
// Oh well...
}
@@ -102,7 +102,7 @@ public class DisplayAreaOrganizerController extends IDisplayAreaOrganizerControl
void onDisplayAreaVanished(IDisplayAreaOrganizer organizer, DisplayArea da) {
try {
organizer.onDisplayAreaVanished(da.mRemoteToken.toWindowContainerToken());
organizer.onDisplayAreaVanished(da.getDisplayAreaInfo());
} catch (RemoteException e) {
// Oh well...
}