Wale Ogunwale | adf116e | 2020-03-27 16:36:01 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.window; |
| 18 | |
| 19 | import android.annotation.NonNull; |
| 20 | import android.annotation.RequiresPermission; |
| 21 | import android.annotation.TestApi; |
| 22 | import android.os.RemoteException; |
| 23 | import android.util.Singleton; |
chaviw | 7de5000 | 2020-04-27 12:33:30 -0700 | [diff] [blame] | 24 | import android.view.SurfaceControl; |
Wale Ogunwale | adf116e | 2020-03-27 16:36:01 -0700 | [diff] [blame] | 25 | |
| 26 | /** |
| 27 | * Interface for WindowManager to delegate control of display areas. |
| 28 | * @hide |
| 29 | */ |
| 30 | @TestApi |
| 31 | public class DisplayAreaOrganizer extends WindowOrganizer { |
| 32 | |
| 33 | public static final int FEATURE_UNDEFINED = -1; |
| 34 | public static final int FEATURE_SYSTEM_FIRST = 0; |
| 35 | // The Root display area on a display |
| 36 | public static final int FEATURE_ROOT = FEATURE_SYSTEM_FIRST; |
Andrii Kulian | 44b3c56 | 2020-04-01 12:49:56 -0700 | [diff] [blame] | 37 | // Display area hosting the default task container. |
| 38 | public static final int FEATURE_DEFAULT_TASK_CONTAINER = FEATURE_SYSTEM_FIRST + 1; |
Wale Ogunwale | adf116e | 2020-03-27 16:36:01 -0700 | [diff] [blame] | 39 | // Display area hosting non-activity window tokens. |
| 40 | public static final int FEATURE_WINDOW_TOKENS = FEATURE_SYSTEM_FIRST + 2; |
| 41 | |
| 42 | public static final int FEATURE_SYSTEM_LAST = 10_000; |
| 43 | |
| 44 | // Vendor specific display area definition can start with this value. |
| 45 | public static final int FEATURE_VENDOR_FIRST = FEATURE_SYSTEM_LAST + 1; |
| 46 | |
| 47 | @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) |
| 48 | public void registerOrganizer(int displayAreaFeature) { |
| 49 | try { |
| 50 | getController().registerOrganizer(mInterface, displayAreaFeature); |
| 51 | } catch (RemoteException e) { |
| 52 | throw e.rethrowFromSystemServer(); |
| 53 | } |
| 54 | } |
| 55 | |
chaviw | 9d07e62 | 2020-04-21 09:16:57 -0700 | [diff] [blame] | 56 | /** |
| 57 | * @hide |
| 58 | */ |
| 59 | @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) |
| 60 | public void unregisterOrganizer() { |
| 61 | try { |
| 62 | getController().unregisterOrganizer(mInterface); |
| 63 | } catch (RemoteException e) { |
| 64 | throw e.rethrowFromSystemServer(); |
| 65 | } |
| 66 | } |
| 67 | |
chaviw | 7de5000 | 2020-04-27 12:33:30 -0700 | [diff] [blame] | 68 | public void onDisplayAreaAppeared(@NonNull DisplayAreaInfo displayAreaInfo, |
| 69 | @NonNull SurfaceControl leash) {} |
Wale Ogunwale | adf116e | 2020-03-27 16:36:01 -0700 | [diff] [blame] | 70 | |
chaviw | d1a2393 | 2020-04-20 17:53:10 -0700 | [diff] [blame] | 71 | public void onDisplayAreaVanished(@NonNull DisplayAreaInfo displayAreaInfo) {} |
Wale Ogunwale | adf116e | 2020-03-27 16:36:01 -0700 | [diff] [blame] | 72 | |
chaviw | 9d07e62 | 2020-04-21 09:16:57 -0700 | [diff] [blame] | 73 | /** |
| 74 | * @hide |
| 75 | */ |
| 76 | public void onDisplayAreaInfoChanged(@NonNull DisplayAreaInfo displayAreaInfo) {} |
| 77 | |
Wale Ogunwale | adf116e | 2020-03-27 16:36:01 -0700 | [diff] [blame] | 78 | private final IDisplayAreaOrganizer mInterface = new IDisplayAreaOrganizer.Stub() { |
| 79 | |
| 80 | @Override |
chaviw | 7de5000 | 2020-04-27 12:33:30 -0700 | [diff] [blame] | 81 | public void onDisplayAreaAppeared(@NonNull DisplayAreaInfo displayAreaInfo, |
| 82 | @NonNull SurfaceControl leash) { |
| 83 | DisplayAreaOrganizer.this.onDisplayAreaAppeared(displayAreaInfo, leash); |
Wale Ogunwale | adf116e | 2020-03-27 16:36:01 -0700 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | @Override |
chaviw | d1a2393 | 2020-04-20 17:53:10 -0700 | [diff] [blame] | 87 | public void onDisplayAreaVanished(@NonNull DisplayAreaInfo displayAreaInfo) { |
| 88 | DisplayAreaOrganizer.this.onDisplayAreaVanished(displayAreaInfo); |
Wale Ogunwale | adf116e | 2020-03-27 16:36:01 -0700 | [diff] [blame] | 89 | } |
chaviw | 9d07e62 | 2020-04-21 09:16:57 -0700 | [diff] [blame] | 90 | |
| 91 | @Override |
| 92 | public void onDisplayAreaInfoChanged(@NonNull DisplayAreaInfo displayAreaInfo) { |
| 93 | DisplayAreaOrganizer.this.onDisplayAreaInfoChanged(displayAreaInfo); |
| 94 | } |
Wale Ogunwale | adf116e | 2020-03-27 16:36:01 -0700 | [diff] [blame] | 95 | }; |
| 96 | |
| 97 | private static IDisplayAreaOrganizerController getController() { |
| 98 | return IDisplayAreaOrganizerControllerSingleton.get(); |
| 99 | } |
| 100 | |
| 101 | private static final Singleton<IDisplayAreaOrganizerController> |
| 102 | IDisplayAreaOrganizerControllerSingleton = |
| 103 | new Singleton<IDisplayAreaOrganizerController>() { |
| 104 | @Override |
| 105 | protected IDisplayAreaOrganizerController create() { |
| 106 | try { |
| 107 | return getWindowOrganizerController() |
| 108 | .getDisplayAreaOrganizerController(); |
| 109 | } catch (RemoteException e) { |
| 110 | return null; |
| 111 | } |
| 112 | } |
| 113 | }; |
| 114 | |
| 115 | } |