• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include "aemu/base/c_header.h"
18 
19 #include <stdbool.h>
20 #include <stdint.h>
21 // #include "android/settings-agent.h"
22 // #include "android/skin/rect.h"
23 // #include "android/utils/compiler.h"
24 
25 #ifndef USING_ANDROID_BP
26 ANDROID_BEGIN_HEADER
27 #endif
28 
29 // Window agent's possible message types
30 typedef enum {
31     WINDOW_MESSAGE_GENERIC,
32     WINDOW_MESSAGE_INFO,
33     WINDOW_MESSAGE_WARNING,
34     WINDOW_MESSAGE_ERROR,
35     WINDOW_MESSAGE_OK,
36 } WindowMessageType;
37 
38 typedef struct {} MultiDisplayPageChangeEvent;
39 typedef struct SkinLayout SkinLayout;
40 typedef struct QFrame QFrame;
41 typedef struct SkinEvent SKinEvent;
42 
43 static const int kWindowMessageTimeoutInfinite = -1;
44 
45 typedef struct EmulatorWindow EmulatorWindow;
46 
47 typedef void (*UiUpdateFunc)(void* data);
48 
49 typedef struct QAndroidEmulatorWindowAgent {
50     // Initialize the UI, e.g. load and apply settings from all windows
51     void (*initUI)();
52 
53     // Get a pointer to the emulator window structure.
54     EmulatorWindow* (*getEmulatorWindow)(void);
55 
56     // Rotate the screen clockwise by 90 degrees.
57     // Returns true on success, false otherwise.
58     bool (*rotate90Clockwise)(void);
59 
60     // Rotate to specific |rotation|
61     bool (*rotate)(int skinRotation);
62 
63     // Returns the current rotation.
64     int (*getRotation)(void);
65 
66     // Shows a message to the user.
67     void (*showMessage)(const char* message,
68                         WindowMessageType type,
69                         int timeoutMs);
70 
71     // Shows a message to the user + custom dismiss op.
72     void (*showMessageWithDismissCallback)(const char* message,
73                                            WindowMessageType type,
74                                            const char* dismissText,
75                                            void* context,
76                                            void (*func)(void*),
77                                            int timeoutMs);
78     // Fold/Unfold device
79     bool (*fold)(bool is_fold);
80     // Query folded state
81     bool (*isFolded)(void);
82     bool (*getFoldedArea)(int* x, int* y, int* w, int* h);
83 
84     // Update UI indicator which shows which foldable posture device is in
85     void (*updateFoldablePostureIndicator)(bool confirmFoldedArea);
86     // Set foldable device posture
87     bool (*setPosture)(int posture);
88 
89     // Set the UI display region
90     void (*setUIDisplayRegion)(int, int, int, int, bool);
91     bool (*getMultiDisplay)(uint32_t,
92                             int32_t*,
93                             int32_t*,
94                             uint32_t*,
95                             uint32_t*,
96                             uint32_t*,
97                             uint32_t*,
98                             bool*);
99     void (*setNoSkin)(void);
100     void (*restoreSkin)(void);
101     void (*updateUIMultiDisplayPage)(uint32_t);
102     bool (*addMultiDisplayWindow)(uint32_t, bool, uint32_t, uint32_t);
103     bool (*paintMultiDisplayWindow)(uint32_t, uint32_t);
104     bool (*getMonitorRect)(uint32_t*, uint32_t*);
105     // moves the extended window to the given position if the window was never displayed. This does nothing
106     // if the window has been show once during the lifetime of the avd.
107     void (*moveExtendedWindow)(uint32_t x, uint32_t y, int horizonalAnchor, int verticalAnchor);
108     // start extended window and switch to the pane specified by the index.
109     // return true if extended controls window's visibility has changed.
110     // The window is not necessarily visible when this method returns.
111     bool (*startExtendedWindow)(int index);
112 
113     // Closes the extended window. At some point in time it will be gone.
114     bool (*quitExtendedWindow)(void);
115 
116     // This will wait until the state of the visibility of the window has
117     // changed to the given value. Calling show or close does not make
118     // a qt frame immediately visible. Instead a series of events will be
119     // fired when the frame is actually added to, or removed from the display.
120     // so usually the pattern is showWindow, wait for visibility..
121     //
122     // Be careful to:
123     //   - Not run this on a looper thread. The ui controls can post actions
124     //     to the looper thread which can result in a deadlock
125     //   - Not to run this on the Qt Message pump. You will deadlock.
126     void (*waitForExtendedWindowVisibility)(bool);
127     bool (*setUiTheme)(int type);
128     void (*runOnUiThread)(UiUpdateFunc f, void* data, bool wait);
129     bool (*isRunningInUiThread)(void);
130     bool (*changeResizableDisplay)(int presetSize);
131     void* (*getLayout)(void);
132     bool (*resizableEnabled)(void);
133     void (*show_virtual_scene_controls)(bool);
134     void (*quit_request)(void);
135     void (*getWindowPosition)(int*, int*);
136     bool (*hasWindow)();
137 
138     bool (*userSettingIsDontSaveSnapshot)(void);
139     void (*setUserSettingIsDontSaveSnapshot)(bool);
140 } QAndroidEmulatorWindowAgent;
141 
142 #ifndef USING_ANDROID_BP
143 ANDROID_END_HEADER
144 #endif
145