blob: 79999bbe812e203dd0bfbf302a1eb62865005a81 [file] [log] [blame]
Wale Ogunwaleadf116e2020-03-27 16:36:01 -07001/*
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
17package android.window;
18
19import android.annotation.NonNull;
20import android.annotation.RequiresPermission;
21import android.annotation.TestApi;
22import android.os.RemoteException;
23import android.util.Singleton;
24
25/**
26 * Interface for WindowManager to delegate control of display areas.
27 * @hide
28 */
29@TestApi
30public 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 Kulian44b3c562020-04-01 12:49:56 -070036 // Display area hosting the default task container.
37 public static final int FEATURE_DEFAULT_TASK_CONTAINER = FEATURE_SYSTEM_FIRST + 1;
Wale Ogunwaleadf116e2020-03-27 16:36:01 -070038 // 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
chaviwd1a23932020-04-20 17:53:10 -070055 public void onDisplayAreaAppeared(@NonNull DisplayAreaInfo displayAreaInfo) {}
Wale Ogunwaleadf116e2020-03-27 16:36:01 -070056
chaviwd1a23932020-04-20 17:53:10 -070057 public void onDisplayAreaVanished(@NonNull DisplayAreaInfo displayAreaInfo) {}
Wale Ogunwaleadf116e2020-03-27 16:36:01 -070058
59 private final IDisplayAreaOrganizer mInterface = new IDisplayAreaOrganizer.Stub() {
60
61 @Override
chaviwd1a23932020-04-20 17:53:10 -070062 public void onDisplayAreaAppeared(@NonNull DisplayAreaInfo displayAreaInfo) {
63 DisplayAreaOrganizer.this.onDisplayAreaAppeared(displayAreaInfo);
Wale Ogunwaleadf116e2020-03-27 16:36:01 -070064 }
65
66 @Override
chaviwd1a23932020-04-20 17:53:10 -070067 public void onDisplayAreaVanished(@NonNull DisplayAreaInfo displayAreaInfo) {
68 DisplayAreaOrganizer.this.onDisplayAreaVanished(displayAreaInfo);
Wale Ogunwaleadf116e2020-03-27 16:36:01 -070069 }
70 };
71
72 private static IDisplayAreaOrganizerController getController() {
73 return IDisplayAreaOrganizerControllerSingleton.get();
74 }
75
76 private static final Singleton<IDisplayAreaOrganizerController>
77 IDisplayAreaOrganizerControllerSingleton =
78 new Singleton<IDisplayAreaOrganizerController>() {
79 @Override
80 protected IDisplayAreaOrganizerController create() {
81 try {
82 return getWindowOrganizerController()
83 .getDisplayAreaOrganizerController();
84 } catch (RemoteException e) {
85 return null;
86 }
87 }
88 };
89
90}