diff options
| author | Chris Li <lihongyu@google.com> | 2020-10-27 11:17:34 -0700 |
|---|---|---|
| committer | Chris Li <lihongyu@google.com> | 2020-10-28 12:09:09 -0700 |
| commit | a9e67cd9aa43668ef0883569f6e6993fc77ea6b4 (patch) | |
| tree | b79f4e14a1c07dc071e2e3c4aa12df55f260fdcd /core/java | |
| parent | fe094ec08582de293d1b2e850c6ce15456169312 (diff) | |
Return the existing DisplayAreas when registering an organizer
A list of existing DisplayAreas of the given feature are returned when
registering the organizer, and the organizer will not receive
onDisplayAreaAppeared() for these DisplayAreas.
Fix: 162028888
Test: atest WmTests:DisplayAreaOrganizerTest
Test: atest OneHandedDisplayAreaOrganizerTest
Change-Id: I3f4c5921a31c06e5b6c0040397df15cdee6ebcdd
Diffstat (limited to 'core/java')
4 files changed, 139 insertions, 4 deletions
diff --git a/core/java/android/window/DisplayAreaAppearedInfo.aidl b/core/java/android/window/DisplayAreaAppearedInfo.aidl new file mode 100644 index 000000000000..365f3e56d968 --- /dev/null +++ b/core/java/android/window/DisplayAreaAppearedInfo.aidl @@ -0,0 +1,24 @@ +/* + * 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; + +/** + * Data object for the DisplayArea info provided when a DisplayArea is presented to an organizer. + * + * @hide + */ +parcelable DisplayAreaAppearedInfo; diff --git a/core/java/android/window/DisplayAreaAppearedInfo.java b/core/java/android/window/DisplayAreaAppearedInfo.java new file mode 100644 index 000000000000..d33d77d54031 --- /dev/null +++ b/core/java/android/window/DisplayAreaAppearedInfo.java @@ -0,0 +1,88 @@ +/* + * 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.os.Parcel; +import android.os.Parcelable; +import android.view.SurfaceControl; + +/** + * Data object for the DisplayArea info provided when a DisplayArea is presented to an organizer. + * + * @hide + */ +@TestApi +public final class DisplayAreaAppearedInfo implements Parcelable { + + @NonNull + private final DisplayAreaInfo mDisplayAreaInfo; + + @NonNull + private final SurfaceControl mLeash; + + @NonNull + public static final Creator<DisplayAreaAppearedInfo> CREATOR = + new Creator<DisplayAreaAppearedInfo>() { + @Override + public DisplayAreaAppearedInfo createFromParcel(Parcel source) { + final DisplayAreaInfo displayAreaInfo = source.readTypedObject(DisplayAreaInfo.CREATOR); + final SurfaceControl leash = source.readTypedObject(SurfaceControl.CREATOR); + return new DisplayAreaAppearedInfo(displayAreaInfo, leash); + } + + @Override + public DisplayAreaAppearedInfo[] newArray(int size) { + return new DisplayAreaAppearedInfo[size]; + } + + }; + + public DisplayAreaAppearedInfo(@NonNull DisplayAreaInfo displayAreaInfo, + @NonNull SurfaceControl leash) { + mDisplayAreaInfo = displayAreaInfo; + mLeash = leash; + } + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + dest.writeTypedObject(mDisplayAreaInfo, flags); + dest.writeTypedObject(mLeash, flags); + } + + @Override + public int describeContents() { + return 0; + } + + /** + * @return the DisplayArea info. + */ + @NonNull + public DisplayAreaInfo getDisplayAreaInfo() { + return mDisplayAreaInfo; + } + + /** + * @return the leash for the DisplayArea. + */ + @NonNull + public SurfaceControl getLeash() { + return mLeash; + } +} diff --git a/core/java/android/window/DisplayAreaOrganizer.java b/core/java/android/window/DisplayAreaOrganizer.java index 38b2190a57f3..6ec093e045fa 100644 --- a/core/java/android/window/DisplayAreaOrganizer.java +++ b/core/java/android/window/DisplayAreaOrganizer.java @@ -16,12 +16,15 @@ package android.window; +import android.annotation.CallSuper; import android.annotation.NonNull; import android.annotation.RequiresPermission; import android.annotation.TestApi; import android.os.RemoteException; import android.view.SurfaceControl; +import java.util.List; + /** * Interface for WindowManager to delegate control of display areas. * @hide @@ -84,10 +87,17 @@ public class DisplayAreaOrganizer extends WindowOrganizer { */ public static final int FEATURE_VENDOR_FIRST = FEATURE_SYSTEM_LAST + 1; + /** + * Registers a DisplayAreaOrganizer to manage display areas for a given feature. + * + * @return a list of display areas that should be managed by the organizer. + */ @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) - public void registerOrganizer(int displayAreaFeature) { + @CallSuper + @NonNull + public List<DisplayAreaAppearedInfo> registerOrganizer(int displayAreaFeature) { try { - getController().registerOrganizer(mInterface, displayAreaFeature); + return getController().registerOrganizer(mInterface, displayAreaFeature).getList(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -97,6 +107,7 @@ public class DisplayAreaOrganizer extends WindowOrganizer { * @hide */ @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) + @CallSuper public void unregisterOrganizer() { try { getController().unregisterOrganizer(mInterface); @@ -105,6 +116,11 @@ public class DisplayAreaOrganizer extends WindowOrganizer { } } + /** + * Called when a DisplayArea of the registered window type can be controlled by this organizer. + * It will not be called for the DisplayAreas that exist when {@link #registerOrganizer(int)} is + * called. + */ public void onDisplayAreaAppeared(@NonNull DisplayAreaInfo displayAreaInfo, @NonNull SurfaceControl leash) {} diff --git a/core/java/android/window/IDisplayAreaOrganizerController.aidl b/core/java/android/window/IDisplayAreaOrganizerController.aidl index 41b9d027344e..8943847073c7 100644 --- a/core/java/android/window/IDisplayAreaOrganizerController.aidl +++ b/core/java/android/window/IDisplayAreaOrganizerController.aidl @@ -16,13 +16,20 @@ package android.window; +import android.content.pm.ParceledListSlice; +import android.window.DisplayAreaAppearedInfo; import android.window.IDisplayAreaOrganizer; /** @hide */ interface IDisplayAreaOrganizerController { - /** Register a DisplayAreaOrganizer to manage display areas for a given feature. */ - void registerOrganizer(in IDisplayAreaOrganizer organizer, int displayAreaFeature); + /** + * Registers a DisplayAreaOrganizer to manage display areas for a given feature. + * + * @return a list of display areas that should be managed by the organizer. + */ + ParceledListSlice<DisplayAreaAppearedInfo> registerOrganizer(in IDisplayAreaOrganizer organizer, + int displayAreaFeature); /** * Unregisters a previously registered display area organizer. |
