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; |
| 24 | |
| 25 | /** |
| 26 | * Interface for WindowManager to delegate control of display areas. |
| 27 | * @hide |
| 28 | */ |
| 29 | @TestApi |
| 30 | public class DisplayAreaOrganizer extends WindowOrganizer { |
| 31 | |
| 32 | public static final int FEATURE_UNDEFINED = -1; |
| 33 | public static final int FEATURE_SYSTEM_FIRST = 0; |
| 34 | // The Root display area on a display |
| 35 | public static final int FEATURE_ROOT = FEATURE_SYSTEM_FIRST; |
Andrii Kulian | 44b3c56 | 2020-04-01 12:49:56 -0700 | [diff] [blame] | 36 | // Display area hosting the default task container. |
| 37 | public static final int FEATURE_DEFAULT_TASK_CONTAINER = FEATURE_SYSTEM_FIRST + 1; |
Wale Ogunwale | adf116e | 2020-03-27 16:36:01 -0700 | [diff] [blame] | 38 | // Display area hosting non-activity window tokens. |
| 39 | public static final int FEATURE_WINDOW_TOKENS = FEATURE_SYSTEM_FIRST + 2; |
| 40 | |
| 41 | public static final int FEATURE_SYSTEM_LAST = 10_000; |
| 42 | |
| 43 | // Vendor specific display area definition can start with this value. |
| 44 | public static final int FEATURE_VENDOR_FIRST = FEATURE_SYSTEM_LAST + 1; |
| 45 | |
| 46 | @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) |
| 47 | public void registerOrganizer(int displayAreaFeature) { |
| 48 | try { |
| 49 | getController().registerOrganizer(mInterface, displayAreaFeature); |
| 50 | } catch (RemoteException e) { |
| 51 | throw e.rethrowFromSystemServer(); |
| 52 | } |
| 53 | } |
| 54 | |
chaviw | 9d07e62 | 2020-04-21 09:16:57 -0700 | [diff] [blame^] | 55 | /** |
| 56 | * @hide |
| 57 | */ |
| 58 | @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) |
| 59 | public void unregisterOrganizer() { |
| 60 | try { |
| 61 | getController().unregisterOrganizer(mInterface); |
| 62 | } catch (RemoteException e) { |
| 63 | throw e.rethrowFromSystemServer(); |
| 64 | } |
| 65 | } |
| 66 | |
chaviw | d1a2393 | 2020-04-20 17:53:10 -0700 | [diff] [blame] | 67 | public void onDisplayAreaAppeared(@NonNull DisplayAreaInfo displayAreaInfo) {} |
Wale Ogunwale | adf116e | 2020-03-27 16:36:01 -0700 | [diff] [blame] | 68 | |
chaviw | d1a2393 | 2020-04-20 17:53:10 -0700 | [diff] [blame] | 69 | public void onDisplayAreaVanished(@NonNull DisplayAreaInfo displayAreaInfo) {} |
Wale Ogunwale | adf116e | 2020-03-27 16:36:01 -0700 | [diff] [blame] | 70 | |
chaviw | 9d07e62 | 2020-04-21 09:16:57 -0700 | [diff] [blame^] | 71 | /** |
| 72 | * @hide |
| 73 | */ |
| 74 | public void onDisplayAreaInfoChanged(@NonNull DisplayAreaInfo displayAreaInfo) {} |
| 75 | |
Wale Ogunwale | adf116e | 2020-03-27 16:36:01 -0700 | [diff] [blame] | 76 | private final IDisplayAreaOrganizer mInterface = new IDisplayAreaOrganizer.Stub() { |
| 77 | |
| 78 | @Override |
chaviw | d1a2393 | 2020-04-20 17:53:10 -0700 | [diff] [blame] | 79 | public void onDisplayAreaAppeared(@NonNull DisplayAreaInfo displayAreaInfo) { |
| 80 | DisplayAreaOrganizer.this.onDisplayAreaAppeared(displayAreaInfo); |
Wale Ogunwale | adf116e | 2020-03-27 16:36:01 -0700 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | @Override |
chaviw | d1a2393 | 2020-04-20 17:53:10 -0700 | [diff] [blame] | 84 | public void onDisplayAreaVanished(@NonNull DisplayAreaInfo displayAreaInfo) { |
| 85 | DisplayAreaOrganizer.this.onDisplayAreaVanished(displayAreaInfo); |
Wale Ogunwale | adf116e | 2020-03-27 16:36:01 -0700 | [diff] [blame] | 86 | } |
chaviw | 9d07e62 | 2020-04-21 09:16:57 -0700 | [diff] [blame^] | 87 | |
| 88 | @Override |
| 89 | public void onDisplayAreaInfoChanged(@NonNull DisplayAreaInfo displayAreaInfo) { |
| 90 | DisplayAreaOrganizer.this.onDisplayAreaInfoChanged(displayAreaInfo); |
| 91 | } |
Wale Ogunwale | adf116e | 2020-03-27 16:36:01 -0700 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | private static IDisplayAreaOrganizerController getController() { |
| 95 | return IDisplayAreaOrganizerControllerSingleton.get(); |
| 96 | } |
| 97 | |
| 98 | private static final Singleton<IDisplayAreaOrganizerController> |
| 99 | IDisplayAreaOrganizerControllerSingleton = |
| 100 | new Singleton<IDisplayAreaOrganizerController>() { |
| 101 | @Override |
| 102 | protected IDisplayAreaOrganizerController create() { |
| 103 | try { |
| 104 | return getWindowOrganizerController() |
| 105 | .getDisplayAreaOrganizerController(); |
| 106 | } catch (RemoteException e) { |
| 107 | return null; |
| 108 | } |
| 109 | } |
| 110 | }; |
| 111 | |
| 112 | } |