blob: 457827117f865e98d9b70cac63b5a3c36b546e2e [file] [log] [blame]
Wale Ogunwale568f9f412020-03-21 22:27:35 -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
Wale Ogunwaleadf116e2020-03-27 16:36:01 -070019import android.annotation.NonNull;
Wale Ogunwale568f9f412020-03-21 22:27:35 -070020import android.annotation.RequiresPermission;
Wale Ogunwaleadf116e2020-03-27 16:36:01 -070021import android.annotation.TestApi;
Wale Ogunwale568f9f412020-03-21 22:27:35 -070022import android.app.ActivityTaskManager;
23import android.os.RemoteException;
24import android.util.Singleton;
25
Wale Ogunwale568f9f412020-03-21 22:27:35 -070026/**
Wale Ogunwaleadf116e2020-03-27 16:36:01 -070027 * Base class for organizing specific types of windows like Tasks and DisplayAreas
Wale Ogunwale568f9f412020-03-21 22:27:35 -070028 *
29 * @hide
30 */
Wale Ogunwaleadf116e2020-03-27 16:36:01 -070031@TestApi
Wale Ogunwale568f9f412020-03-21 22:27:35 -070032public class WindowOrganizer {
33
34 /**
35 * Apply multiple WindowContainer operations at once.
36 * @param t The transaction to apply.
Wale Ogunwale568f9f412020-03-21 22:27:35 -070037 */
38 @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
Wale Ogunwaleadf116e2020-03-27 16:36:01 -070039 public static void applyTransaction(@NonNull WindowContainerTransaction t) {
40 try {
41 getWindowOrganizerController().applyTransaction(t);
42 } catch (RemoteException e) {
43 throw e.rethrowFromSystemServer();
44 }
Wale Ogunwale568f9f412020-03-21 22:27:35 -070045 }
46
47 /**
48 * Apply multiple WindowContainer operations at once.
49 * @param t The transaction to apply.
50 * @param callback This transaction will use the synchronization scheme described in
51 * BLASTSyncEngine.java. The SurfaceControl transaction containing the effects of this
52 * WindowContainer transaction will be passed to this callback when ready.
53 * @return An ID for the sync operation which will later be passed to transactionReady callback.
54 * This lets the caller differentiate overlapping sync operations.
Wale Ogunwale568f9f412020-03-21 22:27:35 -070055 */
56 @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
Wale Ogunwaleadf116e2020-03-27 16:36:01 -070057 public int applySyncTransaction(@NonNull WindowContainerTransaction t,
58 @NonNull WindowContainerTransactionCallback callback) {
59 try {
60 return getWindowOrganizerController().applySyncTransaction(t, callback.mInterface);
61 } catch (RemoteException e) {
62 throw e.rethrowFromSystemServer();
63 }
Wale Ogunwale568f9f412020-03-21 22:27:35 -070064 }
65
Wale Ogunwale568f9f412020-03-21 22:27:35 -070066 @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
Wale Ogunwaleadf116e2020-03-27 16:36:01 -070067 static IWindowOrganizerController getWindowOrganizerController() {
Wale Ogunwale568f9f412020-03-21 22:27:35 -070068 return IWindowOrganizerControllerSingleton.get();
69 }
70
71 private static final Singleton<IWindowOrganizerController> IWindowOrganizerControllerSingleton =
72 new Singleton<IWindowOrganizerController>() {
73 @Override
74 protected IWindowOrganizerController create() {
75 try {
76 return ActivityTaskManager.getService().getWindowOrganizerController();
77 } catch (RemoteException e) {
78 return null;
79 }
80 }
81 };
Wale Ogunwale568f9f412020-03-21 22:27:35 -070082}