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 com.android.wm.shell;
18 
19 import static android.view.Display.DEFAULT_DISPLAY;
20 
21 import android.os.RemoteException;
22 
23 import com.android.wm.shell.common.ShellExecutor;
24 import com.android.wm.shell.pip.PinnedStackListenerForwarder;
25 import com.android.wm.shell.pip.PinnedStackListenerForwarder.PinnedTaskListener;
26 
27 /**
28  * The singleton wrapper to communicate between WindowManagerService and WMShell features
29  * (e.g: PIP, SplitScreen, Bubble, OneHandedMode...etc)
30  * TODO: Remove once PinnedStackListenerForwarder can be removed
31  */
32 public class WindowManagerShellWrapper {
33     private static final String TAG = WindowManagerShellWrapper.class.getSimpleName();
34 
35     /**
36      * Forwarder to which we can add multiple pinned stack listeners. Each listener will receive
37      * updates from the window manager service.
38      */
39     private final PinnedStackListenerForwarder mPinnedStackListenerForwarder;
40 
WindowManagerShellWrapper(ShellExecutor mainExecutor)41     public WindowManagerShellWrapper(ShellExecutor mainExecutor) {
42         mPinnedStackListenerForwarder = new PinnedStackListenerForwarder(mainExecutor);
43     }
44 
45     /**
46      * Adds a pinned stack listener, which will receive updates from the window manager service
47      * along with any other pinned stack listeners that were added via this method.
48      */
addPinnedStackListener(PinnedTaskListener listener)49     public void addPinnedStackListener(PinnedTaskListener listener)
50             throws RemoteException {
51         mPinnedStackListenerForwarder.addListener(listener);
52         mPinnedStackListenerForwarder.register(DEFAULT_DISPLAY);
53     }
54 
55     /**
56      * Removes a pinned stack listener.
57      */
removePinnedStackListener(PinnedTaskListener listener)58     public void removePinnedStackListener(PinnedTaskListener listener) {
59         mPinnedStackListenerForwarder.removeListener(listener);
60     }
61 
62 }
63