Merge lp:~mir-team/platform-api/delete-deprecations into lp:platform-api
- delete-deprecations
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Alberto Aguirre |
Approved revision: | 316 |
Merged at revision: | 303 |
Proposed branch: | lp:~mir-team/platform-api/delete-deprecations |
Merge into: | lp:platform-api |
Diff against target: |
14012 lines (+63/-13059) 96 files modified
CMakeLists.txt (+2/-2) android/default/default_ubuntu_application.cpp (+0/-409) android/default/default_ubuntu_application_ui.cpp (+0/-465) android/default/default_ubuntu_ui.cpp (+0/-273) android/hybris/Android.mk (+2/-184) android/hybris/application_manager.cpp (+0/-900) android/hybris/application_manager.h (+0/-412) android/hybris/default_application_manager.cpp (+0/-1257) android/hybris/default_application_manager.h (+0/-255) android/hybris/default_application_manager_input_setup.h (+0/-452) android/hybris/default_application_manager_test.cpp (+0/-146) android/hybris/default_application_session.h (+0/-250) android/hybris/default_shell.h (+0/-46) android/hybris/lifecycle_helpers.h (+0/-63) android/hybris/shell.h (+0/-49) android/hybris/test.cpp (+0/-361) android/hybris/test_c_api.cpp (+0/-329) android/hybris/test_osk_visibility.cpp (+0/-38) android/hybris/test_session_c_api.cpp (+0/-229) android/hybris/test_trap.cpp (+0/-45) android/hybris/ubuntu_application_api_for_hybris.cpp (+0/-1132) android/include/private/application/ui/clipboard.h (+0/-91) android/include/private/application/ui/form_factor_hint.h (+0/-44) android/include/private/application/ui/init.h (+0/-35) android/include/private/application/ui/input/listener.h (+0/-53) android/include/private/application/ui/physical_display_info.h (+0/-77) android/include/private/application/ui/session.h (+0/-90) android/include/private/application/ui/session_credentials.h (+0/-90) android/include/private/application/ui/session_delegates.h (+0/-45) android/include/private/application/ui/setup.h (+0/-59) android/include/private/application/ui/stage_hint.h (+0/-42) android/include/private/application/ui/surface.h (+0/-76) android/include/private/application/ui/surface_factory.h (+0/-53) android/include/private/application/ui/surface_properties.h (+0/-63) android/include/private/application/ui/surface_role.h (+0/-49) android/include/private/application/ui/ubuntu_application_ui.h (+0/-375) android/include/private/application/ui/window_internal.h (+0/-130) android/include/private/ui/session_enumerator.h (+0/-127) android/include/private/ui/session_service.h (+0/-82) android/include/private/ui/session_snapshot.h (+0/-50) android/include/private/ui/well_known_applications.h (+0/-42) android/mock/CMakeLists.txt (+0/-13) android/mock/mock.cpp (+0/-212) debian/changelog (+6/-0) debian/control (+30/-30) debian/libubuntu-application-api-headers.install (+0/-1) debian/libubuntu-application-api3.symbols (+1/-34) debian/libubuntu-platform-hardware-api3.symbols (+1/-1) debian/ubuntu-application-api3-examples.install (+0/-2) doc/mainpage.md (+1/-6) examples/CMakeLists.txt (+0/-8) examples/test_c_api.cpp (+0/-329) examples/test_multiple_surfaces_event_delivery.cpp (+0/-351) examples/test_session_c_api.cpp (+0/-229) include/ubuntu/CMakeLists.txt (+1/-2) include/ubuntu/application/CMakeLists.txt (+0/-1) include/ubuntu/application/ui/CMakeLists.txt (+0/-27) include/ubuntu/application/ui/clipboard.h (+0/-64) include/ubuntu/application/ui/config.h.in (+0/-27) include/ubuntu/application/ui/display.h (+0/-57) include/ubuntu/application/ui/form_factor.h (+0/-35) include/ubuntu/application/ui/input/CMakeLists.txt (+0/-5) include/ubuntu/application/ui/input/event.h (+0/-226) include/ubuntu/application/ui/input/event_deprecated.h (+0/-88) include/ubuntu/application/ui/options.h (+0/-52) include/ubuntu/application/ui/session.h (+0/-70) include/ubuntu/application/ui/stage.h (+0/-38) include/ubuntu/application/ui/window.h (+0/-125) include/ubuntu/application/ui/window_orientation.h (+0/-32) include/ubuntu/application/ui/window_parent.h (+0/-81) include/ubuntu/application/ui/window_properties.h (+0/-114) include/ubuntu/application/ui/window_state.h (+0/-37) include/ubuntu/application/ui/window_type.h (+0/-39) include/ubuntu/ui/CMakeLists.txt (+0/-4) include/ubuntu/ui/ubuntu_ui_session_service.h (+0/-139) src/ubuntu/application/base_module.h (+2/-2) src/ubuntu/application/common/mirclient/CMakeLists.txt (+0/-2) src/ubuntu/application/common/mirclient/application_instance_mirclient_priv.h (+0/-16) src/ubuntu/application/common/mirclient/ubuntu_application_api_mirclient.cpp (+1/-214) src/ubuntu/application/common/mirclient/window_mirclient.cpp (+0/-233) src/ubuntu/application/common/mirclient/window_mirclient_priv.h (+0/-107) src/ubuntu/application/common/mirclient/window_properties_mirclient.cpp (+0/-101) src/ubuntu/application/common/mirclient/window_properties_mirclient_priv.h (+0/-88) src/ubuntu/application/common/mircommon/CMakeLists.txt (+0/-2) src/ubuntu/application/common/mircommon/application_options_mir.cpp (+1/-63) src/ubuntu/application/common/mircommon/application_options_mir_priv.h (+0/-3) src/ubuntu/application/common/mircommon/event_helpers_mir.cpp (+0/-174) src/ubuntu/application/common/mircommon/event_helpers_mir.h (+0/-44) src/ubuntu/application/common/mircommon/session_mir.cpp (+0/-51) src/ubuntu/application/common/mirserver/ubuntu_application_api_mirserver.cpp (+0/-155) src/ubuntu/application/desktop/module_version.h (+2/-2) src/ubuntu/application/testbackend/module_version.h (+2/-2) src/ubuntu/application/testbackend/test_stubs.cpp (+5/-162) src/ubuntu/application/touch/hybris/ubuntu_application_api_hybris.cpp (+0/-136) src/ubuntu/application/touch/module_version.h (+2/-2) src/ubuntu/application/ubuntu_application_api.cpp (+4/-51) |
To merge this branch: | bzr merge lp:~mir-team/platform-api/delete-deprecations |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Ricardo Mendoza (community) | Approve | ||
Alberto Aguirre (community) | Approve | ||
Gerry Boland (community) | build | Approve | |
Review via email: mp+254170@code.launchpad.net |
Commit message
Delete deprecated mir functions.
Why now? https:/
The old mir-event is being made private and the new event does not have many fields corresponding to legacy in the UbuntuEvent (i.e. "is_system_key"). Thus it seems like rather than update unused code (qtubuntu is already ported) to build but be broken its a good time to delete it all.
Update major version to 3.
Description of the change
Delete deprecated mir functions.
Why now? https:/
The old mir-event is being made private and the new event does not have many fields corresponding to legacy in the UbuntuEvent (i.e. "is_system_key"). Thus it seems like rather than update unused code (qtubuntu is already ported) to build but be broken its a good time to delete it all.
Update major version to 3.
PS Jenkins bot (ps-jenkins) wrote : | # |
Gerry Boland (gerboland) wrote : | # |
Lots'o red, yum. Need ricmm or something with deeper knowledge of these APIs to comment. My 2 cents:
=== modified file 'debian/changelog'
+platform-api (3.0.0+
no need to fill in the "+15.04..." in the package version string, the CI train does that for us.
=== modified file 'debian/control'
Do we plan to keep the old 2.* series around, or can we just have the 2.x series completely replaced? The package migration path will require care.
- test_android_
- test_android_
These look useful for device bring-up, can they not be ported to use mirclient?
Robert Carr (robertcarr) wrote : | # |
>>=== modified file 'debian/changelog'
>> +platform-api (3.0.0+
>> no need to fill in the "+15.04..." in the package version string, the CI train does that
>> for us.
Fixed
>> === modified file 'debian/control'
>> Do we plan to keep the old 2.* series around, or can we just have the 2.x series
>> completely replaced? The package migration path will require care.
I think I've updated things to replace the old 2.* series. I guess we need input from someone else.
>> - test_android_
>> - test_android_
>> These look useful for device bring-up, can they not be ported to use mirclient?
mir already has so many examples though...
Ricardo Salveti (rsalveti) wrote : | # |
Please also build the android image with these platform-api changes, so we know it doesn't break anything before pushing it.
Robert Carr (robertcarr) wrote : | # |
What is the android image and how do I build it? I've never actually understood that. What would have been wrong with building this as part of a Mir release silo?
Ricardo Salveti (rsalveti) wrote : | # |
On Tue, May 26, 2015 at 2:58 PM, Robert Carr <email address hidden> wrote:
> What is the android image and how do I build it? I've never actually understood that. What would have been wrong with building this as part of a Mir release silo?
One easy way is following
https:/
Nothing wrong about building this as part of the Mir release silo, my
question is what happened that it wasn't.
Robert Carr (robertcarr) wrote : | # |
Talked a bit on IRC :) I'll test building an image soon.
Robert Carr (robertcarr) wrote : | # |
Had to make some more changes to get android build working (more deletions) but all is good now! tested emulator build and image runs.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:308
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Gerry Boland (gerboland) wrote : | # |
FTBFS in my wily chroot:
[ 5%] Building CXX object src/ubuntu/
cd /«PKGBUILDDIR»
/ubuntu_
/«PKGBUILDDIR»
#include <ubuntu/
compilation terminated.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:308
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Robert Carr (robertcarr) wrote : | # |
I see! It turns out platform api will build using system installed headers and so I was able to build some code locally that wont work in sbuild...so there was even more code to delete! I've deleted it.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:311
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Gerry Boland (gerboland) wrote : | # |
I can confirm it builds in vivid+overlay & wily. So yay for that. Who will land it?
Alberto Aguirre (albaguirre) wrote : | # |
Version should be updated in src/ubuntu/
Robert Carr (robertcarr) wrote : | # |
Good catch! fixed all three module_version.h are correct now.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:312
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Alberto Aguirre (albaguirre) wrote : | # |
Looks ok, haven't tested.
I should probably rebase this: https:/
Alberto Aguirre (albaguirre) wrote : | # |
Looking at the rdpends, looks like this is the list to rebuild (hopefully no-change rebuilds) when attempting to land this:
qtubuntu-android
qtubuntu-desktop
powerd
libubuntu-
qtubuntu-sensors
cameraplugin-aal
Any other packages missing from that list?
Gerry Boland (gerboland) wrote : | # |
based on https:/
Iain Lane (laney) wrote : | # |
Any chance we can try to get this uploaded?
Ricardo Mendoza (ricmm) wrote : | # |
Some indicators consume this as well, please make sure that the rdepends list is well walked before landing this.
Robert, I take your word for it fully building correctly on Android.
I've done a quick code review and it seems sane, I'll approve from my end but bear in mind I can't do a full tested-
Alberto Aguirre (albaguirre) wrote : | # |
> Some indicators consume this as well, please make sure that the rdepends list
> is well walked before landing this.
I could only find indicator-datetime, which has since removed the platform-api dependency as of version: 13.10.0+
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:313
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:314
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:315
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2015-03-18 10:03:52 +0000 | |||
3 | +++ CMakeLists.txt 2015-07-06 16:10:44 +0000 | |||
4 | @@ -2,8 +2,8 @@ | |||
5 | 2 | 2 | ||
6 | 3 | project(ubuntu-platform-api) | 3 | project(ubuntu-platform-api) |
7 | 4 | 4 | ||
10 | 5 | set(UBUNTU_PLATFORM_API_VERSION_MAJOR 2) | 5 | set(UBUNTU_PLATFORM_API_VERSION_MAJOR 3) |
11 | 6 | set(UBUNTU_PLATFORM_API_VERSION_MINOR 9) | 6 | set(UBUNTU_PLATFORM_API_VERSION_MINOR 0) |
12 | 7 | set(UBUNTU_PLATFORM_API_VERSION_PATCH 0) | 7 | set(UBUNTU_PLATFORM_API_VERSION_PATCH 0) |
13 | 8 | 8 | ||
14 | 9 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") | 9 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") |
15 | 10 | 10 | ||
16 | === removed file 'android/default/default_ubuntu_application.cpp' | |||
17 | --- android/default/default_ubuntu_application.cpp 2013-05-30 01:08:53 +0000 | |||
18 | +++ android/default/default_ubuntu_application.cpp 1970-01-01 00:00:00 +0000 | |||
19 | @@ -1,409 +0,0 @@ | |||
20 | 1 | /* | ||
21 | 2 | * Copyright © 2013 Canonical Ltd. | ||
22 | 3 | * | ||
23 | 4 | * This program is free software: you can redistribute it and/or modify | ||
24 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
25 | 6 | * published by the Free Software Foundation. | ||
26 | 7 | * | ||
27 | 8 | * This program is distributed in the hope that it will be useful, | ||
28 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
29 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
30 | 11 | * GNU Lesser General Public License for more details. | ||
31 | 12 | * | ||
32 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
33 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
34 | 15 | * | ||
35 | 16 | * Authored by: Thomas Voß <thomas.voss@canonical.com> | ||
36 | 17 | * Ricardo Mendoza <ricardo.mendoza@canonical.com> | ||
37 | 18 | */ | ||
38 | 19 | |||
39 | 20 | // Private | ||
40 | 21 | #include <private/application/ui/init.h> | ||
41 | 22 | #include <private/application/ui/setup.h> | ||
42 | 23 | #include <private/application/ui/ubuntu_application_ui.h> | ||
43 | 24 | |||
44 | 25 | // Public C apis | ||
45 | 26 | #include <ubuntu/application/id.h> | ||
46 | 27 | #include <ubuntu/application/instance.h> | ||
47 | 28 | #include <ubuntu/application/lifecycle_delegate.h> | ||
48 | 29 | #include <ubuntu/application/ui/options.h> | ||
49 | 30 | |||
50 | 31 | // ver2.0 Private | ||
51 | 32 | |||
52 | 33 | #include <private/ui/session_service.h> | ||
53 | 34 | #include <private/application/application.h> | ||
54 | 35 | |||
55 | 36 | #include <utils/Log.h> | ||
56 | 37 | |||
57 | 38 | // C APIs | ||
58 | 39 | namespace | ||
59 | 40 | { | ||
60 | 41 | struct IUApplicationLifecycleDelegate : public ubuntu::application::LifecycleDelegate | ||
61 | 42 | { | ||
62 | 43 | IUApplicationLifecycleDelegate(void *context) : | ||
63 | 44 | application_resumed_cb(NULL), | ||
64 | 45 | application_about_to_stop_cb(NULL), | ||
65 | 46 | context(context), | ||
66 | 47 | refcount(1) | ||
67 | 48 | { | ||
68 | 49 | } | ||
69 | 50 | |||
70 | 51 | void on_application_resumed() | ||
71 | 52 | { | ||
72 | 53 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
73 | 54 | |||
74 | 55 | if (!application_resumed_cb) | ||
75 | 56 | return; | ||
76 | 57 | |||
77 | 58 | application_resumed_cb(NULL, this->context); | ||
78 | 59 | } | ||
79 | 60 | |||
80 | 61 | void on_application_about_to_stop() | ||
81 | 62 | { | ||
82 | 63 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
83 | 64 | |||
84 | 65 | if (!application_about_to_stop_cb) | ||
85 | 66 | return; | ||
86 | 67 | |||
87 | 68 | application_about_to_stop_cb(NULL, this->context); | ||
88 | 69 | } | ||
89 | 70 | |||
90 | 71 | u_on_application_resumed application_resumed_cb; | ||
91 | 72 | u_on_application_about_to_stop application_about_to_stop_cb; | ||
92 | 73 | void *context; | ||
93 | 74 | |||
94 | 75 | unsigned refcount; | ||
95 | 76 | }; | ||
96 | 77 | |||
97 | 78 | template<typename T> | ||
98 | 79 | struct Holder | ||
99 | 80 | { | ||
100 | 81 | Holder(const T&value = T()) : value(value) | ||
101 | 82 | { | ||
102 | 83 | } | ||
103 | 84 | |||
104 | 85 | T value; | ||
105 | 86 | }; | ||
106 | 87 | |||
107 | 88 | template<typename T> | ||
108 | 89 | Holder<T>* make_holder(const T& value) | ||
109 | 90 | { | ||
110 | 91 | return new Holder<T>(value); | ||
111 | 92 | } | ||
112 | 93 | } | ||
113 | 94 | |||
114 | 95 | /* | ||
115 | 96 | * Application Lifecycle | ||
116 | 97 | */ | ||
117 | 98 | |||
118 | 99 | UApplicationLifecycleDelegate* | ||
119 | 100 | u_application_lifecycle_delegate_new() | ||
120 | 101 | { | ||
121 | 102 | ALOGI("%s()", __PRETTY_FUNCTION__); | ||
122 | 103 | |||
123 | 104 | ubuntu::application::LifecycleDelegate::Ptr p(new IUApplicationLifecycleDelegate(NULL)); | ||
124 | 105 | |||
125 | 106 | return make_holder(p); | ||
126 | 107 | } | ||
127 | 108 | |||
128 | 109 | void | ||
129 | 110 | u_application_lifecycle_delegate_destroy(UApplicationLifecycleDelegate *delegate) | ||
130 | 111 | { | ||
131 | 112 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
132 | 113 | |||
133 | 114 | auto s = static_cast<Holder<IUApplicationLifecycleDelegate*>*>(delegate); | ||
134 | 115 | |||
135 | 116 | if (s->value->refcount) | ||
136 | 117 | return; | ||
137 | 118 | |||
138 | 119 | delete s; | ||
139 | 120 | } | ||
140 | 121 | |||
141 | 122 | void | ||
142 | 123 | u_application_lifecycle_delegate_ref(UApplicationLifecycleDelegate *delegate) | ||
143 | 124 | { | ||
144 | 125 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
145 | 126 | |||
146 | 127 | auto s = static_cast<Holder<IUApplicationLifecycleDelegate*>*>(delegate); | ||
147 | 128 | s->value->refcount++; | ||
148 | 129 | } | ||
149 | 130 | |||
150 | 131 | void | ||
151 | 132 | u_application_lifecycle_delegate_unref(UApplicationLifecycleDelegate *delegate) | ||
152 | 133 | { | ||
153 | 134 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
154 | 135 | |||
155 | 136 | auto s = static_cast<Holder<IUApplicationLifecycleDelegate*>*>(delegate); | ||
156 | 137 | if (s->value->refcount) | ||
157 | 138 | s->value->refcount--; | ||
158 | 139 | } | ||
159 | 140 | |||
160 | 141 | void | ||
161 | 142 | u_application_lifecycle_delegate_set_application_resumed_cb( | ||
162 | 143 | UApplicationLifecycleDelegate *delegate, | ||
163 | 144 | u_on_application_resumed cb) | ||
164 | 145 | { | ||
165 | 146 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
166 | 147 | |||
167 | 148 | auto s = static_cast<Holder<IUApplicationLifecycleDelegate*>*>(delegate); | ||
168 | 149 | s->value->application_resumed_cb = cb; | ||
169 | 150 | } | ||
170 | 151 | |||
171 | 152 | u_on_application_resumed | ||
172 | 153 | u_application_lifecycle_delegate_get_application_resumed_cb( | ||
173 | 154 | UApplicationLifecycleDelegate *delegate) | ||
174 | 155 | { | ||
175 | 156 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
176 | 157 | |||
177 | 158 | auto s = static_cast<Holder<IUApplicationLifecycleDelegate*>*>(delegate); | ||
178 | 159 | return s->value->application_resumed_cb; | ||
179 | 160 | } | ||
180 | 161 | |||
181 | 162 | void | ||
182 | 163 | u_application_lifecycle_delegate_set_application_about_to_stop_cb( | ||
183 | 164 | UApplicationLifecycleDelegate *delegate, | ||
184 | 165 | u_on_application_about_to_stop cb) | ||
185 | 166 | { | ||
186 | 167 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
187 | 168 | |||
188 | 169 | auto s = static_cast<Holder<IUApplicationLifecycleDelegate*>*>(delegate); | ||
189 | 170 | s->value->application_about_to_stop_cb = cb; | ||
190 | 171 | } | ||
191 | 172 | |||
192 | 173 | u_on_application_about_to_stop | ||
193 | 174 | u_application_lifecycle_delegate_get_application_about_to_stop_cb( | ||
194 | 175 | UApplicationLifecycleDelegate *delegate) | ||
195 | 176 | { | ||
196 | 177 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
197 | 178 | |||
198 | 179 | auto s = static_cast<Holder<IUApplicationLifecycleDelegate*>*>(delegate); | ||
199 | 180 | return s->value->application_about_to_stop_cb; | ||
200 | 181 | } | ||
201 | 182 | |||
202 | 183 | void | ||
203 | 184 | u_application_lifecycle_delegate_set_context( | ||
204 | 185 | UApplicationLifecycleDelegate *delegate, | ||
205 | 186 | void *context) | ||
206 | 187 | { | ||
207 | 188 | ALOGI("%s():%d context=%p", __PRETTY_FUNCTION__, __LINE__, context); | ||
208 | 189 | |||
209 | 190 | auto s = static_cast<Holder<IUApplicationLifecycleDelegate*>*>(delegate); | ||
210 | 191 | if (s->value->context == NULL) | ||
211 | 192 | s->value->context = context; | ||
212 | 193 | } | ||
213 | 194 | |||
214 | 195 | void* | ||
215 | 196 | u_application_lifecycle_delegate_get_context( | ||
216 | 197 | UApplicationLifecycleDelegate *delegate, | ||
217 | 198 | void *context) | ||
218 | 199 | { | ||
219 | 200 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
220 | 201 | |||
221 | 202 | auto s = static_cast<Holder<IUApplicationLifecycleDelegate*>*>(delegate); | ||
222 | 203 | return s->value->context; | ||
223 | 204 | } | ||
224 | 205 | |||
225 | 206 | /* | ||
226 | 207 | * Application Options | ||
227 | 208 | */ | ||
228 | 209 | |||
229 | 210 | UApplicationOptions* | ||
230 | 211 | u_application_options_new_from_cmd_line( | ||
231 | 212 | int argc, | ||
232 | 213 | char** argv) | ||
233 | 214 | { | ||
234 | 215 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
235 | 216 | |||
236 | 217 | ubuntu::application::ui::init(argc, argv); | ||
237 | 218 | |||
238 | 219 | return ubuntu::application::ui::Setup::instance().get(); | ||
239 | 220 | } | ||
240 | 221 | |||
241 | 222 | UAUiFormFactor | ||
242 | 223 | u_application_options_get_form_factor( | ||
243 | 224 | UApplicationOptions *options) | ||
244 | 225 | { | ||
245 | 226 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
246 | 227 | |||
247 | 228 | auto setup = static_cast<ubuntu::application::ui::Setup*>(options); | ||
248 | 229 | return static_cast<UAUiFormFactor>(setup->form_factor_hint()); | ||
249 | 230 | } | ||
250 | 231 | |||
251 | 232 | UAUiStage | ||
252 | 233 | u_application_options_get_stage( | ||
253 | 234 | UApplicationOptions *options) | ||
254 | 235 | { | ||
255 | 236 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
256 | 237 | |||
257 | 238 | auto setup = static_cast<ubuntu::application::ui::Setup*>(options); | ||
258 | 239 | return static_cast<UAUiStage>(setup->stage_hint()); | ||
259 | 240 | } | ||
260 | 241 | |||
261 | 242 | /* | ||
262 | 243 | * Application Id | ||
263 | 244 | */ | ||
264 | 245 | |||
265 | 246 | UApplicationId* | ||
266 | 247 | u_application_id_new_from_stringn( | ||
267 | 248 | const char *string, | ||
268 | 249 | size_t size) | ||
269 | 250 | { | ||
270 | 251 | ubuntu::application::Id::Ptr id( | ||
271 | 252 | new ubuntu::application::Id(string, size) | ||
272 | 253 | ); | ||
273 | 254 | |||
274 | 255 | return make_holder(id); | ||
275 | 256 | } | ||
276 | 257 | |||
277 | 258 | void | ||
278 | 259 | u_application_id_destroy(UApplicationId *id) | ||
279 | 260 | { | ||
280 | 261 | |||
281 | 262 | auto p = static_cast<Holder<ubuntu::application::Id::Ptr>*>(id); | ||
282 | 263 | |||
283 | 264 | if (p) | ||
284 | 265 | delete p; | ||
285 | 266 | } | ||
286 | 267 | |||
287 | 268 | int | ||
288 | 269 | u_application_id_compare( | ||
289 | 270 | UApplicationId *lhs, | ||
290 | 271 | UApplicationId *rhs) | ||
291 | 272 | { | ||
292 | 273 | auto ilhs = static_cast<Holder<ubuntu::application::Id::Ptr>*>(lhs); | ||
293 | 274 | auto irhs = static_cast<Holder<ubuntu::application::Id::Ptr>*>(rhs); | ||
294 | 275 | |||
295 | 276 | if (ilhs->value->size != irhs->value->size) | ||
296 | 277 | return 1; | ||
297 | 278 | |||
298 | 279 | for (size_t i = 0; i < ilhs->value->size; i++) | ||
299 | 280 | { | ||
300 | 281 | if ((char) ilhs->value->string[i] == (char) irhs->value->string[i]) | ||
301 | 282 | continue; | ||
302 | 283 | |||
303 | 284 | return 1; | ||
304 | 285 | } | ||
305 | 286 | |||
306 | 287 | return 0; | ||
307 | 288 | } | ||
308 | 289 | |||
309 | 290 | /* | ||
310 | 291 | * Description | ||
311 | 292 | */ | ||
312 | 293 | |||
313 | 294 | UApplicationDescription* | ||
314 | 295 | u_application_description_new() | ||
315 | 296 | { | ||
316 | 297 | ubuntu::application::Description::Ptr desc( | ||
317 | 298 | new ubuntu::application::Description() | ||
318 | 299 | ); | ||
319 | 300 | |||
320 | 301 | return make_holder(desc); | ||
321 | 302 | } | ||
322 | 303 | |||
323 | 304 | void | ||
324 | 305 | u_application_description_destroy( | ||
325 | 306 | UApplicationDescription *desc) | ||
326 | 307 | { | ||
327 | 308 | auto p = static_cast<Holder<ubuntu::application::Description::Ptr>*>(desc); | ||
328 | 309 | |||
329 | 310 | if (p) | ||
330 | 311 | delete p; | ||
331 | 312 | } | ||
332 | 313 | |||
333 | 314 | void | ||
334 | 315 | u_application_description_set_application_id( | ||
335 | 316 | UApplicationDescription *desc, | ||
336 | 317 | UApplicationId *id) | ||
337 | 318 | { | ||
338 | 319 | if (id == NULL) | ||
339 | 320 | return; | ||
340 | 321 | |||
341 | 322 | auto p = static_cast<Holder<ubuntu::application::Description::Ptr>*>(desc); | ||
342 | 323 | p->value->set_application_id(id); | ||
343 | 324 | } | ||
344 | 325 | |||
345 | 326 | UApplicationId* | ||
346 | 327 | u_application_description_get_application_id( | ||
347 | 328 | UApplicationDescription *desc) | ||
348 | 329 | { | ||
349 | 330 | auto p = static_cast<Holder<ubuntu::application::Description::Ptr>*>(desc); | ||
350 | 331 | return p->value->get_application_id(); | ||
351 | 332 | } | ||
352 | 333 | |||
353 | 334 | void | ||
354 | 335 | u_application_description_set_application_lifecycle_delegate( | ||
355 | 336 | UApplicationDescription *desc, | ||
356 | 337 | UApplicationLifecycleDelegate *delegate) | ||
357 | 338 | { | ||
358 | 339 | if (delegate == NULL) | ||
359 | 340 | return; | ||
360 | 341 | |||
361 | 342 | ALOGI("%s():%d -- delegate=%p", __PRETTY_FUNCTION__, __LINE__, delegate); | ||
362 | 343 | |||
363 | 344 | auto p = static_cast<Holder<ubuntu::application::Description::Ptr>*>(desc); | ||
364 | 345 | p->value->set_lifecycle_delegate(delegate); | ||
365 | 346 | } | ||
366 | 347 | |||
367 | 348 | UApplicationLifecycleDelegate* | ||
368 | 349 | u_application_description_get_application_lifecycle_delegate( | ||
369 | 350 | UApplicationDescription *desc) | ||
370 | 351 | { | ||
371 | 352 | auto p = static_cast<Holder<ubuntu::application::Description::Ptr>*>(desc); | ||
372 | 353 | return p->value->get_lifecycle_delegate(); | ||
373 | 354 | } | ||
374 | 355 | |||
375 | 356 | /* | ||
376 | 357 | * Instance | ||
377 | 358 | */ | ||
378 | 359 | |||
379 | 360 | UApplicationInstance* | ||
380 | 361 | u_application_instance_new_from_description_with_options( | ||
381 | 362 | UApplicationDescription *desc, | ||
382 | 363 | UApplicationOptions *options) | ||
383 | 364 | { | ||
384 | 365 | if (desc == NULL || options == NULL) | ||
385 | 366 | return NULL; | ||
386 | 367 | |||
387 | 368 | ubuntu::application::Instance::Ptr instance( | ||
388 | 369 | new ubuntu::application::Instance(desc, options) | ||
389 | 370 | ); | ||
390 | 371 | |||
391 | 372 | return make_holder(instance); | ||
392 | 373 | } | ||
393 | 374 | |||
394 | 375 | void | ||
395 | 376 | u_application_instance_ref( | ||
396 | 377 | UApplicationInstance *instance) | ||
397 | 378 | { | ||
398 | 379 | auto p = static_cast<Holder<ubuntu::application::Instance::Ptr>*>(instance); | ||
399 | 380 | p->value->ref(); | ||
400 | 381 | } | ||
401 | 382 | |||
402 | 383 | void | ||
403 | 384 | u_application_instance_unref( | ||
404 | 385 | UApplicationInstance *instance) | ||
405 | 386 | { | ||
406 | 387 | auto p = static_cast<Holder<ubuntu::application::Instance::Ptr>*>(instance); | ||
407 | 388 | p->value->unref(); | ||
408 | 389 | } | ||
409 | 390 | |||
410 | 391 | void | ||
411 | 392 | u_application_instance_destroy( | ||
412 | 393 | UApplicationInstance *instance) | ||
413 | 394 | { | ||
414 | 395 | auto p = static_cast<Holder<ubuntu::application::Instance::Ptr>*>(instance); | ||
415 | 396 | |||
416 | 397 | if (p->value->get_refcount() == 0) | ||
417 | 398 | delete p; | ||
418 | 399 | } | ||
419 | 400 | |||
420 | 401 | void | ||
421 | 402 | u_application_instance_run( | ||
422 | 403 | UApplicationInstance *instance) | ||
423 | 404 | { | ||
424 | 405 | auto p = static_cast<Holder<ubuntu::application::Instance::Ptr>*>(instance); | ||
425 | 406 | |||
426 | 407 | if (p) | ||
427 | 408 | p->value->run(); | ||
428 | 409 | } | ||
429 | 410 | 0 | ||
430 | === removed file 'android/default/default_ubuntu_application_ui.cpp' | |||
431 | --- android/default/default_ubuntu_application_ui.cpp 2014-09-29 19:56:49 +0000 | |||
432 | +++ android/default/default_ubuntu_application_ui.cpp 1970-01-01 00:00:00 +0000 | |||
433 | @@ -1,465 +0,0 @@ | |||
434 | 1 | /* | ||
435 | 2 | * Copyright © 2013 Canonical Ltd. | ||
436 | 3 | * | ||
437 | 4 | * This program is free software: you can redistribute it and/or modify | ||
438 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
439 | 6 | * published by the Free Software Foundation. | ||
440 | 7 | * | ||
441 | 8 | * This program is distributed in the hope that it will be useful, | ||
442 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
443 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
444 | 11 | * GNU Lesser General Public License for more details. | ||
445 | 12 | * | ||
446 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
447 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
448 | 15 | * | ||
449 | 16 | * Authored by: Thomas Voß <thomas.voss@canonical.com> | ||
450 | 17 | * Ricardo Mendoza <ricardo.mendoza@canonical.com> | ||
451 | 18 | */ | ||
452 | 19 | |||
453 | 20 | // Private | ||
454 | 21 | #include <private/application/ui/init.h> | ||
455 | 22 | #include <private/application/ui/session.h> | ||
456 | 23 | #include <private/application/ui/session_credentials.h> | ||
457 | 24 | #include <private/application/ui/setup.h> | ||
458 | 25 | #include <private/application/ui/surface.h> | ||
459 | 26 | #include <private/application/ui/surface_factory.h> | ||
460 | 27 | #include <private/application/ui/surface_properties.h> | ||
461 | 28 | |||
462 | 29 | // Public C apis | ||
463 | 30 | #include <private/application/ui/ubuntu_application_ui.h> | ||
464 | 31 | #include <ubuntu/application/instance.h> | ||
465 | 32 | #include <ubuntu/application/lifecycle_delegate.h> | ||
466 | 33 | #include <ubuntu/application/ui/options.h> | ||
467 | 34 | #include <ubuntu/application/ui/session.h> | ||
468 | 35 | #include <ubuntu/application/ui/window.h> | ||
469 | 36 | #include <ubuntu/application/ui/clipboard.h> | ||
470 | 37 | #include <ubuntu/application/ui/display.h> | ||
471 | 38 | |||
472 | 39 | // ver2.0 Private | ||
473 | 40 | #include <private/application/ui/window_internal.h> | ||
474 | 41 | |||
475 | 42 | #include <private/ui/session_service.h> | ||
476 | 43 | #include <private/application/ui/ubuntu_application_ui.h> | ||
477 | 44 | #include <private/application/application.h> | ||
478 | 45 | |||
479 | 46 | #include <utils/Log.h> | ||
480 | 47 | |||
481 | 48 | namespace | ||
482 | 49 | { | ||
483 | 50 | ubuntu::application::ui::Session::Ptr session; | ||
484 | 51 | |||
485 | 52 | struct CallbackEventListener : public ubuntu::application::ui::input::Listener | ||
486 | 53 | { | ||
487 | 54 | CallbackEventListener(input_event_cb cb, void* context) : cb(cb), | ||
488 | 55 | context(context) | ||
489 | 56 | { | ||
490 | 57 | } | ||
491 | 58 | |||
492 | 59 | void on_new_event(const ::Event& e) | ||
493 | 60 | { | ||
494 | 61 | if (cb) | ||
495 | 62 | cb(context, &e); | ||
496 | 63 | } | ||
497 | 64 | |||
498 | 65 | input_event_cb cb; | ||
499 | 66 | void* context; | ||
500 | 67 | }; | ||
501 | 68 | |||
502 | 69 | template<typename T> | ||
503 | 70 | struct Holder | ||
504 | 71 | { | ||
505 | 72 | Holder(const T&value = T()) : value(value) | ||
506 | 73 | { | ||
507 | 74 | } | ||
508 | 75 | |||
509 | 76 | T value; | ||
510 | 77 | }; | ||
511 | 78 | |||
512 | 79 | template<typename T> | ||
513 | 80 | Holder<T>* make_holder(const T& value) | ||
514 | 81 | { | ||
515 | 82 | return new Holder<T>(value); | ||
516 | 83 | } | ||
517 | 84 | } | ||
518 | 85 | |||
519 | 86 | /* | ||
520 | 87 | * Clipboard | ||
521 | 88 | */ | ||
522 | 89 | |||
523 | 90 | void | ||
524 | 91 | ua_ui_set_clipboard_content(void* data, | ||
525 | 92 | size_t size) | ||
526 | 93 | { | ||
527 | 94 | static const char mime_type[ubuntu::application::ui::Clipboard::Content::MAX_MIME_TYPE_SIZE] = "none/none"; | ||
528 | 95 | |||
529 | 96 | ubuntu::application::ui::Clipboard::Content content(mime_type, data, size); | ||
530 | 97 | |||
531 | 98 | ubuntu::application::ui::Session::clipboard()->set_content(content); | ||
532 | 99 | } | ||
533 | 100 | |||
534 | 101 | void | ||
535 | 102 | ua_ui_get_clipboard_content(void** data, | ||
536 | 103 | size_t* size) | ||
537 | 104 | { | ||
538 | 105 | ubuntu::application::ui::Clipboard::Content content(ubuntu::application::ui::Session::clipboard()->get_content()); | ||
539 | 106 | |||
540 | 107 | *data = content.data; | ||
541 | 108 | *size = content.data_size; | ||
542 | 109 | } | ||
543 | 110 | |||
544 | 111 | /* | ||
545 | 112 | * Display | ||
546 | 113 | */ | ||
547 | 114 | |||
548 | 115 | UAUiDisplay* | ||
549 | 116 | ua_ui_display_new_with_index( | ||
550 | 117 | size_t index) | ||
551 | 118 | { | ||
552 | 119 | return make_holder( | ||
553 | 120 | ubuntu::application::ui::Session::physical_display_info( | ||
554 | 121 | static_cast<ubuntu::application::ui::PhysicalDisplayIdentifier>(index))); | ||
555 | 122 | } | ||
556 | 123 | |||
557 | 124 | void | ||
558 | 125 | ua_ui_display_destroy( | ||
559 | 126 | UAUiDisplay* display) | ||
560 | 127 | { | ||
561 | 128 | auto s = static_cast<Holder<ubuntu::application::ui::PhysicalDisplayInfo::Ptr>*>(display); | ||
562 | 129 | delete s; | ||
563 | 130 | } | ||
564 | 131 | |||
565 | 132 | uint32_t | ||
566 | 133 | ua_ui_display_query_horizontal_res( | ||
567 | 134 | UAUiDisplay* display) | ||
568 | 135 | { | ||
569 | 136 | auto s = static_cast<Holder<ubuntu::application::ui::PhysicalDisplayInfo::Ptr>*>(display); | ||
570 | 137 | return s->value->horizontal_resolution(); | ||
571 | 138 | } | ||
572 | 139 | |||
573 | 140 | uint32_t | ||
574 | 141 | ua_ui_display_query_vertical_res( | ||
575 | 142 | UAUiDisplay* display) | ||
576 | 143 | { | ||
577 | 144 | auto s = static_cast<Holder<ubuntu::application::ui::PhysicalDisplayInfo::Ptr>*>(display); | ||
578 | 145 | return s->value->vertical_resolution(); | ||
579 | 146 | } | ||
580 | 147 | |||
581 | 148 | EGLNativeDisplayType | ||
582 | 149 | ua_ui_display_get_native_type( | ||
583 | 150 | UAUiDisplay* display) | ||
584 | 151 | { | ||
585 | 152 | // Always EGL_DEFAULT_DISPLAY with android EGL. | ||
586 | 153 | return EGL_DEFAULT_DISPLAY; | ||
587 | 154 | } | ||
588 | 155 | |||
589 | 156 | /* | ||
590 | 157 | * Window Properties | ||
591 | 158 | */ | ||
592 | 159 | |||
593 | 160 | UAUiWindowProperties* | ||
594 | 161 | ua_ui_window_properties_new_for_normal_window() | ||
595 | 162 | { | ||
596 | 163 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
597 | 164 | |||
598 | 165 | ubuntu::application::ui::WindowProperties::Ptr p( | ||
599 | 166 | new ubuntu::application::ui::WindowProperties() | ||
600 | 167 | ); | ||
601 | 168 | |||
602 | 169 | return make_holder(p); | ||
603 | 170 | } | ||
604 | 171 | |||
605 | 172 | void | ||
606 | 173 | ua_ui_window_properties_destroy( | ||
607 | 174 | UAUiWindowProperties *properties) | ||
608 | 175 | { | ||
609 | 176 | auto p = static_cast<Holder<ubuntu::application::ui::WindowProperties::Ptr>*>(properties); | ||
610 | 177 | |||
611 | 178 | if (p) | ||
612 | 179 | delete p; | ||
613 | 180 | } | ||
614 | 181 | |||
615 | 182 | void | ||
616 | 183 | ua_ui_window_properties_set_titlen( | ||
617 | 184 | UAUiWindowProperties *properties, | ||
618 | 185 | const char *title, | ||
619 | 186 | size_t size) | ||
620 | 187 | { | ||
621 | 188 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
622 | 189 | auto p = static_cast<Holder<ubuntu::application::ui::WindowProperties::Ptr>*>(properties); | ||
623 | 190 | p->value->set_titlen(title, size); | ||
624 | 191 | } | ||
625 | 192 | |||
626 | 193 | const char* | ||
627 | 194 | ua_ui_window_properties_get_title( | ||
628 | 195 | UAUiWindowProperties *properties) | ||
629 | 196 | { | ||
630 | 197 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
631 | 198 | auto p = static_cast<Holder<ubuntu::application::ui::WindowProperties::Ptr>*>(properties); | ||
632 | 199 | return p->value->get_title(); | ||
633 | 200 | } | ||
634 | 201 | |||
635 | 202 | void | ||
636 | 203 | ua_ui_window_properties_set_role( | ||
637 | 204 | UAUiWindowProperties *properties, | ||
638 | 205 | UAUiWindowRole role) | ||
639 | 206 | { | ||
640 | 207 | ALOGI("%s():%d %p %d", __PRETTY_FUNCTION__, __LINE__, properties, role); | ||
641 | 208 | auto p = static_cast<Holder<ubuntu::application::ui::WindowProperties::Ptr>*>(properties); | ||
642 | 209 | p->value->set_role(role); | ||
643 | 210 | } | ||
644 | 211 | |||
645 | 212 | UAUiWindowRole | ||
646 | 213 | ua_ui_window_properties_get_role( | ||
647 | 214 | UAUiWindowProperties *properties) | ||
648 | 215 | { | ||
649 | 216 | auto p = static_cast<Holder<ubuntu::application::ui::WindowProperties::Ptr>*>(properties); | ||
650 | 217 | return p->value->get_role(); | ||
651 | 218 | } | ||
652 | 219 | |||
653 | 220 | void | ||
654 | 221 | ua_ui_window_properties_set_input_cb_and_ctx( | ||
655 | 222 | UAUiWindowProperties *properties, | ||
656 | 223 | UAUiWindowInputEventCb cb, | ||
657 | 224 | void *ctx) | ||
658 | 225 | { | ||
659 | 226 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
660 | 227 | auto p = static_cast<Holder<ubuntu::application::ui::WindowProperties::Ptr>*>(properties); | ||
661 | 228 | p->value->set_input_event_cb_and_ctx(cb, ctx); | ||
662 | 229 | } | ||
663 | 230 | |||
664 | 231 | void | ||
665 | 232 | ua_ui_window_properties_set_event_cb_and_ctx(UAUiWindowProperties*, UAUiWindowEventCb, void *) | ||
666 | 233 | { | ||
667 | 234 | } | ||
668 | 235 | |||
669 | 236 | void | ||
670 | 237 | ua_ui_window_properties_set_dimensions( | ||
671 | 238 | UAUiWindowProperties *properties, | ||
672 | 239 | uint32_t width, | ||
673 | 240 | uint32_t height) | ||
674 | 241 | { | ||
675 | 242 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
676 | 243 | (void) width; | ||
677 | 244 | (void) height; | ||
678 | 245 | } | ||
679 | 246 | |||
680 | 247 | /* | ||
681 | 248 | * Session | ||
682 | 249 | */ | ||
683 | 250 | |||
684 | 251 | UAUiSessionProperties* | ||
685 | 252 | ua_ui_session_properties_new() | ||
686 | 253 | { | ||
687 | 254 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
688 | 255 | |||
689 | 256 | ubuntu::application::ui::SessionProperties::Ptr props( | ||
690 | 257 | new ubuntu::application::ui::SessionProperties() | ||
691 | 258 | ); | ||
692 | 259 | |||
693 | 260 | return make_holder(props); | ||
694 | 261 | } | ||
695 | 262 | |||
696 | 263 | void | ||
697 | 264 | ua_ui_session_properties_set_type( | ||
698 | 265 | UAUiSessionProperties* properties, | ||
699 | 266 | UAUiSessionType type) | ||
700 | 267 | { | ||
701 | 268 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
702 | 269 | |||
703 | 270 | auto p = static_cast<Holder<ubuntu::application::ui::SessionProperties::Ptr>*>(properties); | ||
704 | 271 | |||
705 | 272 | if (p) | ||
706 | 273 | p->value->set_type(static_cast<ubuntu::application::ui::SessionType>(type)); | ||
707 | 274 | } | ||
708 | 275 | |||
709 | 276 | void | ||
710 | 277 | ua_ui_session_properties_set_remote_pid( | ||
711 | 278 | UAUiSessionProperties *properties, | ||
712 | 279 | uint32_t pid) | ||
713 | 280 | { | ||
714 | 281 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
715 | 282 | |||
716 | 283 | auto p = static_cast<Holder<ubuntu::application::ui::SessionProperties::Ptr>*>(properties); | ||
717 | 284 | p->value->set_remote_pid(pid); | ||
718 | 285 | } | ||
719 | 286 | |||
720 | 287 | UAUiSession* | ||
721 | 288 | ua_ui_session_new_with_properties( | ||
722 | 289 | UAUiSessionProperties *properties) | ||
723 | 290 | { | ||
724 | 291 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
725 | 292 | |||
726 | 293 | if (session != NULL) | ||
727 | 294 | return session.get(); | ||
728 | 295 | |||
729 | 296 | auto p = static_cast<Holder<ubuntu::application::ui::SessionProperties::Ptr>*>(properties); | ||
730 | 297 | |||
731 | 298 | SessionCredentials creds = { | ||
732 | 299 | static_cast<SessionType>(p->value->get_type()), | ||
733 | 300 | APPLICATION_SUPPORTS_OVERLAYED_MENUBAR, | ||
734 | 301 | "QtUbuntu", | ||
735 | 302 | p->value->get_remote_pid(), | ||
736 | 303 | NULL | ||
737 | 304 | }; | ||
738 | 305 | |||
739 | 306 | ubuntu::application::ui::SessionCredentials sc(&creds); | ||
740 | 307 | session = ubuntu::ui::SessionService::instance()->start_a_new_session(sc); | ||
741 | 308 | |||
742 | 309 | return session.get(); | ||
743 | 310 | } | ||
744 | 311 | |||
745 | 312 | /* | ||
746 | 313 | * Window (Surface) | ||
747 | 314 | */ | ||
748 | 315 | |||
749 | 316 | UAUiWindow* | ||
750 | 317 | ua_ui_window_new_for_application_with_properties( | ||
751 | 318 | UApplicationInstance *instance, | ||
752 | 319 | UAUiWindowProperties *properties) | ||
753 | 320 | { | ||
754 | 321 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
755 | 322 | |||
756 | 323 | if (session == NULL) | ||
757 | 324 | return NULL; | ||
758 | 325 | |||
759 | 326 | auto p = static_cast<Holder<ubuntu::application::ui::WindowProperties::Ptr>*>(properties); | ||
760 | 327 | |||
761 | 328 | ubuntu::application::ui::SurfaceProperties props = | ||
762 | 329 | { | ||
763 | 330 | "test", | ||
764 | 331 | 0, | ||
765 | 332 | 0, | ||
766 | 333 | static_cast<ubuntu::application::ui::SurfaceRole>(p->value->get_role()), | ||
767 | 334 | 0, //FIXME: Set flags | ||
768 | 335 | true | ||
769 | 336 | }; | ||
770 | 337 | |||
771 | 338 | ubuntu::application::ui::Surface::Ptr surface = | ||
772 | 339 | session->create_surface( | ||
773 | 340 | props, | ||
774 | 341 | ubuntu::application::ui::input::Listener::Ptr( | ||
775 | 342 | new CallbackEventListener(p->value->get_input_cb(), | ||
776 | 343 | p->value->get_ctx()))); | ||
777 | 344 | |||
778 | 345 | auto inst = static_cast<Holder<ubuntu::application::Instance::Ptr>*>(instance); | ||
779 | 346 | auto desc = static_cast<Holder<ubuntu::application::Description::Ptr>*>(inst->value->get_description()); | ||
780 | 347 | auto dele = static_cast<Holder<ubuntu::application::LifecycleDelegate::Ptr>*>(desc->value->get_lifecycle_delegate()); | ||
781 | 348 | |||
782 | 349 | session->install_lifecycle_delegate(dele->value); | ||
783 | 350 | |||
784 | 351 | return make_holder(surface); | ||
785 | 352 | } | ||
786 | 353 | |||
787 | 354 | void | ||
788 | 355 | ua_ui_window_destroy( | ||
789 | 356 | UAUiWindow *window) | ||
790 | 357 | { | ||
791 | 358 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
792 | 359 | //auto p = static_cast<Holder<ubuntu::application::ui::Window::Ptr*>*>(window); | ||
793 | 360 | auto p = static_cast<Holder<ubuntu::application::ui::Surface::Ptr>*>(window); | ||
794 | 361 | |||
795 | 362 | if (p) | ||
796 | 363 | delete p; | ||
797 | 364 | } | ||
798 | 365 | |||
799 | 366 | UAUiWindowId | ||
800 | 367 | ua_ui_window_get_id( | ||
801 | 368 | UAUiWindow *window) | ||
802 | 369 | { | ||
803 | 370 | //auto p = static_cast<Holder<ubuntu::application::ui::Window::Ptr*>*>(window); | ||
804 | 371 | auto p = static_cast<Holder<ubuntu::application::ui::Surface::Ptr>*>(window); | ||
805 | 372 | |||
806 | 373 | return p->value->get_id(); | ||
807 | 374 | } | ||
808 | 375 | |||
809 | 376 | UStatus | ||
810 | 377 | ua_ui_window_move( | ||
811 | 378 | UAUiWindow *window, | ||
812 | 379 | uint32_t new_x, | ||
813 | 380 | uint32_t new_y) | ||
814 | 381 | { | ||
815 | 382 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
816 | 383 | auto p = static_cast<Holder<ubuntu::application::ui::Surface::Ptr>*>(window); | ||
817 | 384 | p->value->move_to(new_x, new_y); | ||
818 | 385 | |||
819 | 386 | return U_STATUS_SUCCESS; | ||
820 | 387 | } | ||
821 | 388 | |||
822 | 389 | UStatus | ||
823 | 390 | ua_ui_window_resize( | ||
824 | 391 | UAUiWindow *window, | ||
825 | 392 | uint32_t new_width, | ||
826 | 393 | uint32_t new_height) | ||
827 | 394 | { | ||
828 | 395 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
829 | 396 | //auto p = static_cast<Holder<ubuntu::application::ui::Window::Ptr*>*>(window); | ||
830 | 397 | auto p = static_cast<Holder<ubuntu::application::ui::Surface::Ptr>*>(window); | ||
831 | 398 | p->value->resize(new_width, new_height); | ||
832 | 399 | |||
833 | 400 | return U_STATUS_SUCCESS; | ||
834 | 401 | } | ||
835 | 402 | |||
836 | 403 | UStatus | ||
837 | 404 | ua_ui_window_hide( | ||
838 | 405 | UAUiWindow *window) | ||
839 | 406 | { | ||
840 | 407 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
841 | 408 | //auto p = static_cast<Holder<ubuntu::application::ui::Window::Ptr*>*>(window); | ||
842 | 409 | auto p = static_cast<Holder<ubuntu::application::ui::Surface::Ptr>*>(window); | ||
843 | 410 | p->value->set_visible(session->get_session_pid(), false); | ||
844 | 411 | |||
845 | 412 | return U_STATUS_SUCCESS; | ||
846 | 413 | } | ||
847 | 414 | |||
848 | 415 | UStatus | ||
849 | 416 | ua_ui_window_show( | ||
850 | 417 | UAUiWindow *window) | ||
851 | 418 | { | ||
852 | 419 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
853 | 420 | auto p = static_cast<Holder<ubuntu::application::ui::Surface::Ptr>*>(window); | ||
854 | 421 | p->value->set_visible(session->get_session_pid(), true); | ||
855 | 422 | |||
856 | 423 | return U_STATUS_SUCCESS; | ||
857 | 424 | } | ||
858 | 425 | |||
859 | 426 | void | ||
860 | 427 | ua_ui_window_request_fullscreen( | ||
861 | 428 | UAUiWindow *window) | ||
862 | 429 | { | ||
863 | 430 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
864 | 431 | if (session == NULL) | ||
865 | 432 | return; | ||
866 | 433 | |||
867 | 434 | auto p = static_cast<Holder<ubuntu::application::ui::Surface::Ptr>*>(window); | ||
868 | 435 | session->toggle_fullscreen_for_surface(p->value); | ||
869 | 436 | } | ||
870 | 437 | |||
871 | 438 | void | ||
872 | 439 | ua_ui_window_request_state( | ||
873 | 440 | UAUiWindow *window, UApplicationUiWindowState state) | ||
874 | 441 | { | ||
875 | 442 | ALOGI("ua_ui_window_request_state unimplemented %s:%d", __PRETTY_FUNCTION__, __LINE__); | ||
876 | 443 | (void) window; | ||
877 | 444 | (void) state; | ||
878 | 445 | } | ||
879 | 446 | |||
880 | 447 | EGLNativeWindowType | ||
881 | 448 | ua_ui_window_get_native_type( | ||
882 | 449 | UAUiWindow *window) | ||
883 | 450 | { | ||
884 | 451 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
885 | 452 | auto p = static_cast<Holder<ubuntu::application::ui::Surface::Ptr>*>(window); | ||
886 | 453 | return p->value->to_native_window_type(); | ||
887 | 454 | } | ||
888 | 455 | |||
889 | 456 | UApplicationUiWindowOrientation | ||
890 | 457 | ua_ui_window_get_orientation( | ||
891 | 458 | UAUiWindow *window) | ||
892 | 459 | { | ||
893 | 460 | ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__); | ||
894 | 461 | (void*) window; | ||
895 | 462 | // Orientation flag not available with android, return default | ||
896 | 463 | return U_ORIENTATION_NORMAL; | ||
897 | 464 | } | ||
898 | 465 | |||
899 | 466 | 0 | ||
900 | === removed file 'android/default/default_ubuntu_ui.cpp' | |||
901 | --- android/default/default_ubuntu_ui.cpp 2013-06-07 01:08:41 +0000 | |||
902 | +++ android/default/default_ubuntu_ui.cpp 1970-01-01 00:00:00 +0000 | |||
903 | @@ -1,273 +0,0 @@ | |||
904 | 1 | /* | ||
905 | 2 | * Copyright © 2012 Canonical Ltd. | ||
906 | 3 | * | ||
907 | 4 | * This program is free software: you can redistribute it and/or modify | ||
908 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
909 | 6 | * published by the Free Software Foundation. | ||
910 | 7 | * | ||
911 | 8 | * This program is distributed in the hope that it will be useful, | ||
912 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
913 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
914 | 11 | * GNU Lesser General Public License for more details. | ||
915 | 12 | * | ||
916 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
917 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
918 | 15 | * | ||
919 | 16 | * Authored by: Thomas Voß <thomas.voss@canonical.com> | ||
920 | 17 | */ | ||
921 | 18 | |||
922 | 19 | #include <ubuntu/ui/ubuntu_ui_session_service.h> | ||
923 | 20 | |||
924 | 21 | #include <private/ui/session_service.h> | ||
925 | 22 | #include <private/ui/session_enumerator.h> | ||
926 | 23 | |||
927 | 24 | #include <stdio.h> | ||
928 | 25 | |||
929 | 26 | #include <utils/Log.h> | ||
930 | 27 | |||
931 | 28 | namespace | ||
932 | 29 | { | ||
933 | 30 | struct TaskController : public ubuntu::ui::TaskController | ||
934 | 31 | { | ||
935 | 32 | TaskController(ubuntu_ui_task_controller* controller) : controller(controller) | ||
936 | 33 | { | ||
937 | 34 | } | ||
938 | 35 | |||
939 | 36 | void continue_task(int pid) | ||
940 | 37 | { | ||
941 | 38 | if (!controller) | ||
942 | 39 | return; | ||
943 | 40 | |||
944 | 41 | if (!controller->continue_task) | ||
945 | 42 | return; | ||
946 | 43 | |||
947 | 44 | controller->continue_task(pid, controller->context); | ||
948 | 45 | } | ||
949 | 46 | |||
950 | 47 | void suspend_task(int pid) | ||
951 | 48 | { | ||
952 | 49 | if (!controller) | ||
953 | 50 | return; | ||
954 | 51 | |||
955 | 52 | if (!controller->suspend_task) | ||
956 | 53 | return; | ||
957 | 54 | |||
958 | 55 | controller->suspend_task(pid, controller->context); | ||
959 | 56 | } | ||
960 | 57 | |||
961 | 58 | ubuntu_ui_task_controller* controller; | ||
962 | 59 | }; | ||
963 | 60 | |||
964 | 61 | struct SessionLifeCycleObserver : public ubuntu::ui::SessionLifeCycleObserver | ||
965 | 62 | { | ||
966 | 63 | SessionLifeCycleObserver(ubuntu_ui_session_lifecycle_observer* observer) : observer(observer) | ||
967 | 64 | { | ||
968 | 65 | } | ||
969 | 66 | |||
970 | 67 | void on_session_requested(ubuntu::ui::WellKnownApplication app) | ||
971 | 68 | { | ||
972 | 69 | if (!observer) | ||
973 | 70 | return; | ||
974 | 71 | |||
975 | 72 | if (!observer->on_session_requested) | ||
976 | 73 | return; | ||
977 | 74 | |||
978 | 75 | observer->on_session_requested(static_cast<ubuntu_ui_well_known_application>(app), observer->context); | ||
979 | 76 | } | ||
980 | 77 | |||
981 | 78 | void on_session_born(const ubuntu::ui::SessionProperties::Ptr& props) | ||
982 | 79 | { | ||
983 | 80 | if (!observer) | ||
984 | 81 | return; | ||
985 | 82 | |||
986 | 83 | if (!observer->on_session_born) | ||
987 | 84 | return; | ||
988 | 85 | |||
989 | 86 | observer->on_session_born(&props, observer->context); | ||
990 | 87 | } | ||
991 | 88 | |||
992 | 89 | void on_session_unfocused(const ubuntu::ui::SessionProperties::Ptr& props) | ||
993 | 90 | { | ||
994 | 91 | if (!observer) | ||
995 | 92 | return; | ||
996 | 93 | |||
997 | 94 | if (!observer->on_session_unfocused) | ||
998 | 95 | return; | ||
999 | 96 | |||
1000 | 97 | observer->on_session_unfocused(&props, observer->context); | ||
1001 | 98 | } | ||
1002 | 99 | |||
1003 | 100 | void on_session_focused(const ubuntu::ui::SessionProperties::Ptr& props) | ||
1004 | 101 | { | ||
1005 | 102 | if (!observer) | ||
1006 | 103 | return; | ||
1007 | 104 | |||
1008 | 105 | if (!observer->on_session_focused) | ||
1009 | 106 | return; | ||
1010 | 107 | |||
1011 | 108 | observer->on_session_focused(&props, observer->context); | ||
1012 | 109 | } | ||
1013 | 110 | |||
1014 | 111 | void on_keyboard_geometry_changed(int x, int y, int width, int height) | ||
1015 | 112 | { | ||
1016 | 113 | if (!observer) | ||
1017 | 114 | return; | ||
1018 | 115 | |||
1019 | 116 | if (!observer->on_keyboard_geometry_changed) | ||
1020 | 117 | return; | ||
1021 | 118 | |||
1022 | 119 | observer->on_keyboard_geometry_changed(x, y, width, height, observer->context); | ||
1023 | 120 | } | ||
1024 | 121 | |||
1025 | 122 | void on_session_requested_fullscreen(const ubuntu::ui::SessionProperties::Ptr& props) | ||
1026 | 123 | { | ||
1027 | 124 | if (!observer) | ||
1028 | 125 | return; | ||
1029 | 126 | |||
1030 | 127 | if(!observer->on_session_requested_fullscreen) | ||
1031 | 128 | return; | ||
1032 | 129 | |||
1033 | 130 | observer->on_session_requested_fullscreen(&props, observer->context); | ||
1034 | 131 | } | ||
1035 | 132 | |||
1036 | 133 | void on_session_died(const ubuntu::ui::SessionProperties::Ptr& props) | ||
1037 | 134 | { | ||
1038 | 135 | if (!observer) | ||
1039 | 136 | return; | ||
1040 | 137 | |||
1041 | 138 | if (!observer->on_session_died) | ||
1042 | 139 | return; | ||
1043 | 140 | |||
1044 | 141 | observer->on_session_died(&props, observer->context); | ||
1045 | 142 | } | ||
1046 | 143 | |||
1047 | 144 | ubuntu_ui_session_lifecycle_observer* observer; | ||
1048 | 145 | }; | ||
1049 | 146 | |||
1050 | 147 | } | ||
1051 | 148 | |||
1052 | 149 | const char* ubuntu_ui_session_properties_get_value_for_key(ubuntu_ui_session_properties props, const char* key) | ||
1053 | 150 | { | ||
1054 | 151 | if (!props) | ||
1055 | 152 | return NULL; | ||
1056 | 153 | |||
1057 | 154 | if (!key) | ||
1058 | 155 | return NULL; | ||
1059 | 156 | |||
1060 | 157 | const ubuntu::ui::SessionProperties::Ptr* p = static_cast<const ubuntu::ui::SessionProperties::Ptr*>(props); | ||
1061 | 158 | |||
1062 | 159 | return (*p)->value_for_key(key); | ||
1063 | 160 | } | ||
1064 | 161 | |||
1065 | 162 | int ubuntu_ui_session_properties_get_application_stage_hint(ubuntu_ui_session_properties props) | ||
1066 | 163 | { | ||
1067 | 164 | if (!props) | ||
1068 | 165 | return -1; | ||
1069 | 166 | |||
1070 | 167 | const ubuntu::ui::SessionProperties::Ptr* p = static_cast<const ubuntu::ui::SessionProperties::Ptr*>(props); | ||
1071 | 168 | |||
1072 | 169 | return (*p)->application_stage_hint(); | ||
1073 | 170 | } | ||
1074 | 171 | |||
1075 | 172 | int ubuntu_ui_session_properties_get_application_instance_id(ubuntu_ui_session_properties props) | ||
1076 | 173 | { | ||
1077 | 174 | if (!props) | ||
1078 | 175 | return -1; | ||
1079 | 176 | |||
1080 | 177 | const ubuntu::ui::SessionProperties::Ptr* p = static_cast<const ubuntu::ui::SessionProperties::Ptr*>(props); | ||
1081 | 178 | |||
1082 | 179 | return (*p)->application_instance_id(); | ||
1083 | 180 | } | ||
1084 | 181 | |||
1085 | 182 | const char* ubuntu_ui_session_properties_get_desktop_file_hint(ubuntu_ui_session_properties props) | ||
1086 | 183 | { | ||
1087 | 184 | if (!props) | ||
1088 | 185 | return NULL; | ||
1089 | 186 | |||
1090 | 187 | const ubuntu::ui::SessionProperties::Ptr* p = static_cast<const ubuntu::ui::SessionProperties::Ptr*>(props); | ||
1091 | 188 | |||
1092 | 189 | return (*p)->desktop_file_hint(); | ||
1093 | 190 | } | ||
1094 | 191 | |||
1095 | 192 | bool ubuntu_ui_session_preview_provider_update_session_preview_texture(ubuntu_ui_session_preview_provider pp, int id, GLuint texture, unsigned int* width, unsigned int* height) | ||
1096 | 193 | { | ||
1097 | 194 | if (!pp) | ||
1098 | 195 | return false; | ||
1099 | 196 | |||
1100 | 197 | const ubuntu::ui::SessionPreviewProvider::Ptr* spp = | ||
1101 | 198 | static_cast<const ubuntu::ui::SessionPreviewProvider::Ptr*>(pp); | ||
1102 | 199 | |||
1103 | 200 | return (*spp)->get_or_update_session_preview(texture, *width, *height); | ||
1104 | 201 | } | ||
1105 | 202 | |||
1106 | 203 | void ubuntu_ui_session_install_session_lifecycle_observer(ubuntu_ui_session_lifecycle_observer* observer) | ||
1107 | 204 | { | ||
1108 | 205 | ubuntu::ui::SessionLifeCycleObserver::Ptr p(new SessionLifeCycleObserver(observer)); | ||
1109 | 206 | ubuntu::ui::SessionService::instance()->install_session_lifecycle_observer(p); | ||
1110 | 207 | } | ||
1111 | 208 | |||
1112 | 209 | void ubuntu_ui_session_unfocus_running_sessions() | ||
1113 | 210 | { | ||
1114 | 211 | ubuntu::ui::SessionService::instance()->unfocus_running_sessions(); | ||
1115 | 212 | } | ||
1116 | 213 | |||
1117 | 214 | void ubuntu_ui_session_focus_running_session_with_id(int id) | ||
1118 | 215 | { | ||
1119 | 216 | ubuntu::ui::SessionService::instance()->focus_running_session_with_id(id); | ||
1120 | 217 | } | ||
1121 | 218 | |||
1122 | 219 | void ubuntu_ui_session_snapshot_running_session_with_id(int id, ubuntu_ui_session_service_snapshot_cb cb, void* context) | ||
1123 | 220 | { | ||
1124 | 221 | ubuntu::ui::SessionSnapshot::Ptr ss = ubuntu::ui::SessionService::instance()->snapshot_running_session_with_id(id); | ||
1125 | 222 | |||
1126 | 223 | if (cb) | ||
1127 | 224 | { | ||
1128 | 225 | ALOGI("screenshot buffer (%d, %d) geometry (%d, %d, %d, %d)\n", ss->width(), ss->height(), ss->x(), ss->y(), ss->source_width(), ss->source_height()); | ||
1129 | 226 | cb(ss->pixel_data(), ss->width(), ss->height(), ss->x(), ss->y(), | ||
1130 | 227 | ss->source_width(), ss->source_height(), ss->stride(), context); | ||
1131 | 228 | } | ||
1132 | 229 | } | ||
1133 | 230 | |||
1134 | 231 | void ubuntu_ui_session_trigger_switch_to_well_known_application(ubuntu_ui_well_known_application app) | ||
1135 | 232 | { | ||
1136 | 233 | ubuntu::ui::SessionService::instance()->trigger_switch_to_well_known_application( | ||
1137 | 234 | static_cast<ubuntu::ui::WellKnownApplication>(app)); | ||
1138 | 235 | } | ||
1139 | 236 | |||
1140 | 237 | int32_t ubuntu_ui_set_surface_trap(int32_t x, int32_t y, int32_t width, int32_t height) | ||
1141 | 238 | { | ||
1142 | 239 | return ubuntu::ui::SessionService::instance()->set_surface_trap(x, y, width, height); | ||
1143 | 240 | } | ||
1144 | 241 | |||
1145 | 242 | void ubuntu_ui_unset_surface_trap(int32_t handle) | ||
1146 | 243 | { | ||
1147 | 244 | ubuntu::ui::SessionService::instance()->unset_surface_trap(handle); | ||
1148 | 245 | } | ||
1149 | 246 | |||
1150 | 247 | void ubuntu_ui_report_osk_visible(int x, int y, int width, int height) | ||
1151 | 248 | { | ||
1152 | 249 | ubuntu::ui::SessionService::instance()->report_osk_visible(x, y, width, height); | ||
1153 | 250 | } | ||
1154 | 251 | |||
1155 | 252 | void ubuntu_ui_report_osk_invisible() | ||
1156 | 253 | { | ||
1157 | 254 | ubuntu::ui::SessionService::instance()->report_osk_invisible(); | ||
1158 | 255 | } | ||
1159 | 256 | |||
1160 | 257 | void ubuntu_ui_report_notification_visible() | ||
1161 | 258 | { | ||
1162 | 259 | ubuntu::ui::SessionService::instance()->report_notification_visible(); | ||
1163 | 260 | } | ||
1164 | 261 | |||
1165 | 262 | void ubuntu_ui_report_notification_invisible() | ||
1166 | 263 | { | ||
1167 | 264 | ubuntu::ui::SessionService::instance()->report_notification_invisible(); | ||
1168 | 265 | } | ||
1169 | 266 | |||
1170 | 267 | void ubuntu_ui_install_task_controller(ubuntu_ui_task_controller *controller) | ||
1171 | 268 | { | ||
1172 | 269 | printf("installing task controller"); | ||
1173 | 270 | ubuntu::ui::TaskController::Ptr p(new TaskController(controller)); | ||
1174 | 271 | ubuntu::ui::SessionService::instance()->install_task_controller(p); | ||
1175 | 272 | } | ||
1176 | 273 | |||
1177 | 274 | 0 | ||
1178 | === modified file 'android/hybris/Android.mk' | |||
1179 | --- android/hybris/Android.mk 2015-03-19 19:56:37 +0000 | |||
1180 | +++ android/hybris/Android.mk 2015-07-06 16:10:44 +0000 | |||
1181 | @@ -22,12 +22,10 @@ | |||
1182 | 22 | $(UPAPI_PATH)/android/include | 22 | $(UPAPI_PATH)/android/include |
1183 | 23 | 23 | ||
1184 | 24 | LOCAL_SRC_FILES := \ | 24 | LOCAL_SRC_FILES := \ |
1185 | 25 | ubuntu_application_api_for_hybris.cpp \ | ||
1186 | 26 | ubuntu_application_gps_for_hybris.cpp \ | 25 | ubuntu_application_gps_for_hybris.cpp \ |
1187 | 27 | ubuntu_application_sensors_for_hybris.cpp \ | 26 | ubuntu_application_sensors_for_hybris.cpp \ |
1191 | 28 | ../default/default_ubuntu_application_sensor.cpp \ | 27 | ../default/default_ubuntu_application_sensor.cpp |
1192 | 29 | ../default/default_ubuntu_ui.cpp \ | 28 | |
1190 | 30 | application_manager.cpp | ||
1193 | 31 | 29 | ||
1194 | 32 | LOCAL_MODULE := libubuntu_application_api | 30 | LOCAL_MODULE := libubuntu_application_api |
1195 | 33 | LOCAL_MODULE_TAGS := optional | 31 | LOCAL_MODULE_TAGS := optional |
1196 | @@ -55,121 +53,6 @@ | |||
1197 | 55 | $(UPAPI_PATH)/android/include | 53 | $(UPAPI_PATH)/android/include |
1198 | 56 | 54 | ||
1199 | 57 | LOCAL_SRC_FILES:= \ | 55 | LOCAL_SRC_FILES:= \ |
1200 | 58 | test.cpp \ | ||
1201 | 59 | |||
1202 | 60 | LOCAL_MODULE:= direct_ubuntu_application_api_for_hybris_test | ||
1203 | 61 | LOCAL_MODULE_TAGS := optional | ||
1204 | 62 | |||
1205 | 63 | LOCAL_SHARED_LIBRARIES := \ | ||
1206 | 64 | libandroidfw \ | ||
1207 | 65 | libutils \ | ||
1208 | 66 | libEGL \ | ||
1209 | 67 | libGLESv2 \ | ||
1210 | 68 | libubuntu_application_api | ||
1211 | 69 | |||
1212 | 70 | include $(BUILD_EXECUTABLE) | ||
1213 | 71 | |||
1214 | 72 | include $(CLEAR_VARS) | ||
1215 | 73 | |||
1216 | 74 | LOCAL_CFLAGS += -std=gnu++0x | ||
1217 | 75 | |||
1218 | 76 | LOCAL_C_INCLUDES := \ | ||
1219 | 77 | $(UPAPI_PATH)/include \ | ||
1220 | 78 | $(UPAPI_PATH)/android/include | ||
1221 | 79 | |||
1222 | 80 | LOCAL_SRC_FILES:= \ | ||
1223 | 81 | test_c_api.cpp \ | ||
1224 | 82 | |||
1225 | 83 | LOCAL_MODULE:= direct_ubuntu_application_c_api_for_hybris_test | ||
1226 | 84 | LOCAL_MODULE_TAGS := optional | ||
1227 | 85 | |||
1228 | 86 | LOCAL_SHARED_LIBRARIES := \ | ||
1229 | 87 | libandroidfw \ | ||
1230 | 88 | libutils \ | ||
1231 | 89 | libEGL \ | ||
1232 | 90 | libGLESv2 \ | ||
1233 | 91 | libubuntu_application_api | ||
1234 | 92 | |||
1235 | 93 | include $(BUILD_EXECUTABLE) | ||
1236 | 94 | |||
1237 | 95 | include $(CLEAR_VARS) | ||
1238 | 96 | |||
1239 | 97 | LOCAL_CFLAGS += -std=gnu++0x | ||
1240 | 98 | |||
1241 | 99 | LOCAL_C_INCLUDES := \ | ||
1242 | 100 | $(UPAPI_PATH)/include \ | ||
1243 | 101 | $(UPAPI_PATH)/android/include | ||
1244 | 102 | |||
1245 | 103 | LOCAL_SRC_FILES:= \ | ||
1246 | 104 | test_session_c_api.cpp \ | ||
1247 | 105 | |||
1248 | 106 | LOCAL_MODULE:= direct_ubuntu_application_session_c_api_for_hybris_test | ||
1249 | 107 | LOCAL_MODULE_TAGS := optional | ||
1250 | 108 | |||
1251 | 109 | LOCAL_SHARED_LIBRARIES := \ | ||
1252 | 110 | libandroidfw \ | ||
1253 | 111 | libutils \ | ||
1254 | 112 | libEGL \ | ||
1255 | 113 | libGLESv2 \ | ||
1256 | 114 | libubuntu_application_api | ||
1257 | 115 | |||
1258 | 116 | include $(BUILD_EXECUTABLE) | ||
1259 | 117 | |||
1260 | 118 | include $(CLEAR_VARS) | ||
1261 | 119 | |||
1262 | 120 | LOCAL_CFLAGS += -std=gnu++0x | ||
1263 | 121 | |||
1264 | 122 | LOCAL_C_INCLUDES := \ | ||
1265 | 123 | $(UPAPI_PATH)/include \ | ||
1266 | 124 | $(UPAPI_PATH)/android/include | ||
1267 | 125 | |||
1268 | 126 | LOCAL_SRC_FILES:= \ | ||
1269 | 127 | test_trap.cpp \ | ||
1270 | 128 | |||
1271 | 129 | LOCAL_MODULE:= direct_set_trap | ||
1272 | 130 | LOCAL_MODULE_TAGS := optional | ||
1273 | 131 | |||
1274 | 132 | LOCAL_SHARED_LIBRARIES := \ | ||
1275 | 133 | libandroidfw \ | ||
1276 | 134 | libutils \ | ||
1277 | 135 | libEGL \ | ||
1278 | 136 | libGLESv2 \ | ||
1279 | 137 | libubuntu_application_api | ||
1280 | 138 | |||
1281 | 139 | include $(BUILD_EXECUTABLE) | ||
1282 | 140 | |||
1283 | 141 | include $(CLEAR_VARS) | ||
1284 | 142 | |||
1285 | 143 | LOCAL_CFLAGS += -std=gnu++0x | ||
1286 | 144 | |||
1287 | 145 | LOCAL_C_INCLUDES := \ | ||
1288 | 146 | $(UPAPI_PATH)/include \ | ||
1289 | 147 | $(UPAPI_PATH)/android/include | ||
1290 | 148 | |||
1291 | 149 | LOCAL_SRC_FILES:= \ | ||
1292 | 150 | test_osk_visibility.cpp \ | ||
1293 | 151 | |||
1294 | 152 | LOCAL_MODULE:= direct_osk_visibility | ||
1295 | 153 | LOCAL_MODULE_TAGS := optional | ||
1296 | 154 | |||
1297 | 155 | LOCAL_SHARED_LIBRARIES := \ | ||
1298 | 156 | libandroidfw \ | ||
1299 | 157 | libutils \ | ||
1300 | 158 | libEGL \ | ||
1301 | 159 | libGLESv2 \ | ||
1302 | 160 | libubuntu_application_api | ||
1303 | 161 | |||
1304 | 162 | include $(BUILD_EXECUTABLE) | ||
1305 | 163 | |||
1306 | 164 | include $(CLEAR_VARS) | ||
1307 | 165 | |||
1308 | 166 | LOCAL_CFLAGS += -std=gnu++0x | ||
1309 | 167 | |||
1310 | 168 | LOCAL_C_INCLUDES := \ | ||
1311 | 169 | $(UPAPI_PATH)/include \ | ||
1312 | 170 | $(UPAPI_PATH)/android/include | ||
1313 | 171 | |||
1314 | 172 | LOCAL_SRC_FILES:= \ | ||
1315 | 173 | test_sensors_c_api.cpp \ | 56 | test_sensors_c_api.cpp \ |
1316 | 174 | 57 | ||
1317 | 175 | LOCAL_MODULE:= direct_ubuntu_application_sensors_c_api_for_hybris_test | 58 | LOCAL_MODULE:= direct_ubuntu_application_sensors_c_api_for_hybris_test |
1318 | @@ -209,71 +92,6 @@ | |||
1319 | 209 | 92 | ||
1320 | 210 | include $(CLEAR_VARS) | 93 | include $(CLEAR_VARS) |
1321 | 211 | 94 | ||
1322 | 212 | LOCAL_CFLAGS += \ | ||
1323 | 213 | -DANDROID_VERSION_MAJOR=$(ANDROID_VERSION_MAJOR) \ | ||
1324 | 214 | -DANDROID_VERSION_MINOR=$(ANDROID_VERSION_MINOR) \ | ||
1325 | 215 | -DANDROID_VERSION_PATCH=$(ANDROID_VERSION_PATCH) | ||
1326 | 216 | |||
1327 | 217 | LOCAL_CFLAGS += -std=gnu++0x | ||
1328 | 218 | |||
1329 | 219 | LOCAL_C_INCLUDES := \ | ||
1330 | 220 | external/skia/include/core \ | ||
1331 | 221 | frameworks/base/services \ | ||
1332 | 222 | $(UPAPI_PATH)/include \ | ||
1333 | 223 | $(UPAPI_PATH)/android/include | ||
1334 | 224 | |||
1335 | 225 | LOCAL_SRC_FILES:= \ | ||
1336 | 226 | application_manager.cpp \ | ||
1337 | 227 | default_application_manager.cpp \ | ||
1338 | 228 | |||
1339 | 229 | LOCAL_MODULE:= ubuntuappmanager | ||
1340 | 230 | LOCAL_MODULE_TAGS := optional | ||
1341 | 231 | |||
1342 | 232 | LOCAL_SHARED_LIBRARIES := \ | ||
1343 | 233 | libbinder \ | ||
1344 | 234 | libinput \ | ||
1345 | 235 | liblog \ | ||
1346 | 236 | libgui \ | ||
1347 | 237 | libskia \ | ||
1348 | 238 | libandroidfw \ | ||
1349 | 239 | libutils \ | ||
1350 | 240 | libEGL \ | ||
1351 | 241 | libGLESv2 \ | ||
1352 | 242 | libubuntu_application_api | ||
1353 | 243 | |||
1354 | 244 | ifeq ($(HAS_LIBINPUTSERVICE),true) | ||
1355 | 245 | LOCAL_SHARED_LIBRARIES += libinputservice | ||
1356 | 246 | endif | ||
1357 | 247 | |||
1358 | 248 | include $(BUILD_EXECUTABLE) | ||
1359 | 249 | |||
1360 | 250 | include $(CLEAR_VARS) | ||
1361 | 251 | |||
1362 | 252 | LOCAL_CFLAGS += -std=gnu++0x | ||
1363 | 253 | |||
1364 | 254 | LOCAL_C_INCLUDES := \ | ||
1365 | 255 | $(UPAPI_PATH)/include \ | ||
1366 | 256 | $(UPAPI_PATH)/android/include | ||
1367 | 257 | |||
1368 | 258 | LOCAL_SRC_FILES:= \ | ||
1369 | 259 | application_manager.cpp \ | ||
1370 | 260 | default_application_manager_test.cpp \ | ||
1371 | 261 | |||
1372 | 262 | LOCAL_MODULE:= ubuntuappmanager_test | ||
1373 | 263 | LOCAL_MODULE_TAGS := optional | ||
1374 | 264 | |||
1375 | 265 | LOCAL_SHARED_LIBRARIES := \ | ||
1376 | 266 | libbinder \ | ||
1377 | 267 | libandroidfw \ | ||
1378 | 268 | libutils \ | ||
1379 | 269 | libEGL \ | ||
1380 | 270 | libGLESv2 \ | ||
1381 | 271 | libubuntu_application_api | ||
1382 | 272 | |||
1383 | 273 | include $(BUILD_EXECUTABLE) | ||
1384 | 274 | |||
1385 | 275 | include $(CLEAR_VARS) | ||
1386 | 276 | |||
1387 | 277 | LOCAL_CFLAGS += -std=gnu++0x | 95 | LOCAL_CFLAGS += -std=gnu++0x |
1388 | 278 | 96 | ||
1389 | 279 | LOCAL_C_INCLUDES := \ | 97 | LOCAL_C_INCLUDES := \ |
1390 | 280 | 98 | ||
1391 | === removed file 'android/hybris/application_manager.cpp' | |||
1392 | --- android/hybris/application_manager.cpp 2013-06-07 01:08:41 +0000 | |||
1393 | +++ android/hybris/application_manager.cpp 1970-01-01 00:00:00 +0000 | |||
1394 | @@ -1,900 +0,0 @@ | |||
1395 | 1 | /* | ||
1396 | 2 | * Copyright © 2012 Canonical Ltd. | ||
1397 | 3 | * | ||
1398 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1399 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
1400 | 6 | * published by the Free Software Foundation. | ||
1401 | 7 | * | ||
1402 | 8 | * This program is distributed in the hope that it will be useful, | ||
1403 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1404 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1405 | 11 | * GNU General Public License for more details. | ||
1406 | 12 | * | ||
1407 | 13 | * You should have received a copy of the GNU General Public License | ||
1408 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1409 | 15 | * | ||
1410 | 16 | * Authored by: Thomas Voß <thomas.voss@canonical.com> | ||
1411 | 17 | */ | ||
1412 | 18 | #include "application_manager.h" | ||
1413 | 19 | |||
1414 | 20 | #include <binder/Parcel.h> | ||
1415 | 21 | #include <utils/String8.h> | ||
1416 | 22 | |||
1417 | 23 | namespace android | ||
1418 | 24 | { | ||
1419 | 25 | IMPLEMENT_META_INTERFACE(ClipboardService, "UbuntuClipboardService"); | ||
1420 | 26 | IMPLEMENT_META_INTERFACE(AMTaskController, "UbuntuApplicationManagerTaskController"); | ||
1421 | 27 | IMPLEMENT_META_INTERFACE(ApplicationManagerObserver, "UbuntuApplicationManagerObserver"); | ||
1422 | 28 | IMPLEMENT_META_INTERFACE(ApplicationManagerSession, "UbuntuApplicationManagerSession"); | ||
1423 | 29 | IMPLEMENT_META_INTERFACE(ApplicationManager, "UbuntuApplicationManager"); | ||
1424 | 30 | |||
1425 | 31 | IClipboardService::Content::Content() : data(NULL), | ||
1426 | 32 | data_size(0) | ||
1427 | 33 | { | ||
1428 | 34 | } | ||
1429 | 35 | |||
1430 | 36 | IClipboardService::Content::Content( | ||
1431 | 37 | const String8& mime_type, | ||
1432 | 38 | void* _data, | ||
1433 | 39 | size_t size) : mime_type(mime_type), | ||
1434 | 40 | data(malloc(size)), | ||
1435 | 41 | data_size(size) | ||
1436 | 42 | { | ||
1437 | 43 | memcpy(this->data, _data, size); | ||
1438 | 44 | } | ||
1439 | 45 | |||
1440 | 46 | IClipboardService::Content::~Content() | ||
1441 | 47 | { | ||
1442 | 48 | if (data != NULL && data_size != 0) | ||
1443 | 49 | free(data); | ||
1444 | 50 | } | ||
1445 | 51 | |||
1446 | 52 | IClipboardService::Content::Content(const IClipboardService::Content& content) | ||
1447 | 53 | : mime_type(content.mime_type), | ||
1448 | 54 | data(malloc(content.data_size)), | ||
1449 | 55 | data_size(content.data_size) | ||
1450 | 56 | { | ||
1451 | 57 | memcpy(data, content.data, data_size); | ||
1452 | 58 | } | ||
1453 | 59 | |||
1454 | 60 | IClipboardService::Content& IClipboardService::Content::operator=(const IClipboardService::Content& content) | ||
1455 | 61 | { | ||
1456 | 62 | mime_type = content.mime_type; | ||
1457 | 63 | data_size = content.data_size; | ||
1458 | 64 | data = realloc(data, data_size); | ||
1459 | 65 | memcpy(data, content.data, data_size); | ||
1460 | 66 | |||
1461 | 67 | return *this; | ||
1462 | 68 | } | ||
1463 | 69 | |||
1464 | 70 | status_t BnClipboardService::onTransact(uint32_t code, | ||
1465 | 71 | const Parcel& data, | ||
1466 | 72 | Parcel* reply, | ||
1467 | 73 | uint32_t flags) | ||
1468 | 74 | { | ||
1469 | 75 | switch(code) | ||
1470 | 76 | { | ||
1471 | 77 | case SET_CLIPBOARD_CONTENT_COMMAND: | ||
1472 | 78 | { | ||
1473 | 79 | IClipboardService::Content content; | ||
1474 | 80 | String8 mime_type = data.readString8(); | ||
1475 | 81 | size_t data_size = data.readInt32(); | ||
1476 | 82 | void* p = malloc(data_size); | ||
1477 | 83 | data.read(p, data_size); | ||
1478 | 84 | set_content(Content(mime_type, p, data_size)); | ||
1479 | 85 | free(p); | ||
1480 | 86 | break; | ||
1481 | 87 | } | ||
1482 | 88 | case GET_CLIPBOARD_CONTENT_COMMAND: | ||
1483 | 89 | { | ||
1484 | 90 | IClipboardService::Content content; | ||
1485 | 91 | get_content(content); | ||
1486 | 92 | |||
1487 | 93 | reply->writeString8(String8(content.mime_type)); | ||
1488 | 94 | reply->writeInt32(content.data_size); | ||
1489 | 95 | reply->write(content.data, content.data_size); | ||
1490 | 96 | } | ||
1491 | 97 | break; | ||
1492 | 98 | } | ||
1493 | 99 | |||
1494 | 100 | return NO_ERROR; | ||
1495 | 101 | } | ||
1496 | 102 | |||
1497 | 103 | BpClipboardService::BpClipboardService(const sp<IBinder>& impl) : BpInterface<IClipboardService>(impl) | ||
1498 | 104 | { | ||
1499 | 105 | } | ||
1500 | 106 | |||
1501 | 107 | void BpClipboardService::set_content(const IClipboardService::Content& content) | ||
1502 | 108 | { | ||
1503 | 109 | Parcel in, out; | ||
1504 | 110 | |||
1505 | 111 | in.writeString8(String8(content.mime_type)); | ||
1506 | 112 | in.writeInt32(content.data_size); | ||
1507 | 113 | in.write(content.data, content.data_size); | ||
1508 | 114 | |||
1509 | 115 | remote()->transact( | ||
1510 | 116 | SET_CLIPBOARD_CONTENT_COMMAND, | ||
1511 | 117 | in, | ||
1512 | 118 | &out); | ||
1513 | 119 | } | ||
1514 | 120 | |||
1515 | 121 | void BpClipboardService::get_content(IClipboardService::Content& content) | ||
1516 | 122 | { | ||
1517 | 123 | Parcel in, out; | ||
1518 | 124 | |||
1519 | 125 | remote()->transact( | ||
1520 | 126 | GET_CLIPBOARD_CONTENT_COMMAND, | ||
1521 | 127 | in, | ||
1522 | 128 | &out); | ||
1523 | 129 | |||
1524 | 130 | content.mime_type = out.readString8(); | ||
1525 | 131 | content.data_size = out.readInt32(); | ||
1526 | 132 | content.data = malloc(content.data_size); | ||
1527 | 133 | out.read(content.data, content.data_size); | ||
1528 | 134 | } | ||
1529 | 135 | |||
1530 | 136 | BnApplicationManagerSession::BnApplicationManagerSession() | ||
1531 | 137 | { | ||
1532 | 138 | } | ||
1533 | 139 | |||
1534 | 140 | BnApplicationManagerSession::~BnApplicationManagerSession() {} | ||
1535 | 141 | |||
1536 | 142 | status_t BnApplicationManagerSession::onTransact(uint32_t code, | ||
1537 | 143 | const Parcel& data, | ||
1538 | 144 | Parcel* reply, | ||
1539 | 145 | uint32_t flags) | ||
1540 | 146 | { | ||
1541 | 147 | switch(code) | ||
1542 | 148 | { | ||
1543 | 149 | case RAISE_APPLICATION_SURFACES_TO_LAYER_COMMAND: | ||
1544 | 150 | { | ||
1545 | 151 | int32_t layer; | ||
1546 | 152 | data.readInt32(&layer); | ||
1547 | 153 | |||
1548 | 154 | raise_application_surfaces_to_layer(layer); | ||
1549 | 155 | } | ||
1550 | 156 | break; | ||
1551 | 157 | case RAISE_SURFACE_TO_LAYER_COMMAND: | ||
1552 | 158 | { | ||
1553 | 159 | int32_t token, layer; | ||
1554 | 160 | token = data.readInt32(); | ||
1555 | 161 | layer = data.readInt32(); | ||
1556 | 162 | |||
1557 | 163 | raise_surface_to_layer(token, layer); | ||
1558 | 164 | } | ||
1559 | 165 | break; | ||
1560 | 166 | case QUERY_SURFACE_PROPERTIES_FOR_TOKEN_COMMAND: | ||
1561 | 167 | { | ||
1562 | 168 | int32_t token = data.readInt32(); | ||
1563 | 169 | IApplicationManagerSession::SurfaceProperties props = | ||
1564 | 170 | query_surface_properties_for_token(token); | ||
1565 | 171 | reply->writeInt32(props.layer); | ||
1566 | 172 | reply->writeInt32(props.left); | ||
1567 | 173 | reply->writeInt32(props.top); | ||
1568 | 174 | reply->writeInt32(props.right); | ||
1569 | 175 | reply->writeInt32(props.bottom); | ||
1570 | 176 | } | ||
1571 | 177 | break; | ||
1572 | 178 | case ON_APPLICATION_STARTED_NOTIFICATION: | ||
1573 | 179 | { | ||
1574 | 180 | on_application_resumed(); | ||
1575 | 181 | } | ||
1576 | 182 | break; | ||
1577 | 183 | case ON_APPLICATION_ABOUT_TO_STOP_NOTIFICATION: | ||
1578 | 184 | { | ||
1579 | 185 | on_application_about_to_stop(); | ||
1580 | 186 | } | ||
1581 | 187 | break; | ||
1582 | 188 | } | ||
1583 | 189 | return NO_ERROR; | ||
1584 | 190 | } | ||
1585 | 191 | |||
1586 | 192 | BpApplicationManagerSession::BpApplicationManagerSession(const sp<IBinder>& impl) | ||
1587 | 193 | : BpInterface<IApplicationManagerSession>(impl) | ||
1588 | 194 | { | ||
1589 | 195 | } | ||
1590 | 196 | |||
1591 | 197 | BpApplicationManagerSession::~BpApplicationManagerSession() | ||
1592 | 198 | { | ||
1593 | 199 | } | ||
1594 | 200 | |||
1595 | 201 | void BpApplicationManagerSession::raise_surface_to_layer(int32_t token, int layer) | ||
1596 | 202 | { | ||
1597 | 203 | Parcel in, out; | ||
1598 | 204 | |||
1599 | 205 | in.writeInt32(token); | ||
1600 | 206 | in.writeInt32(layer); | ||
1601 | 207 | |||
1602 | 208 | remote()->transact( | ||
1603 | 209 | RAISE_SURFACE_TO_LAYER_COMMAND, | ||
1604 | 210 | in, | ||
1605 | 211 | &out); | ||
1606 | 212 | } | ||
1607 | 213 | |||
1608 | 214 | void BpApplicationManagerSession::raise_application_surfaces_to_layer(int layer) | ||
1609 | 215 | { | ||
1610 | 216 | Parcel in, out; | ||
1611 | 217 | in.writeInt32(layer); | ||
1612 | 218 | |||
1613 | 219 | remote()->transact( | ||
1614 | 220 | RAISE_APPLICATION_SURFACES_TO_LAYER_COMMAND, | ||
1615 | 221 | in, | ||
1616 | 222 | &out); | ||
1617 | 223 | } | ||
1618 | 224 | |||
1619 | 225 | IApplicationManagerSession::SurfaceProperties BpApplicationManagerSession::query_surface_properties_for_token(int32_t token) | ||
1620 | 226 | { | ||
1621 | 227 | Parcel in, out; | ||
1622 | 228 | in.writeInt32(token); | ||
1623 | 229 | |||
1624 | 230 | remote()->transact( | ||
1625 | 231 | QUERY_SURFACE_PROPERTIES_FOR_TOKEN_COMMAND, | ||
1626 | 232 | in, | ||
1627 | 233 | &out); | ||
1628 | 234 | |||
1629 | 235 | IApplicationManagerSession::SurfaceProperties props; | ||
1630 | 236 | props.layer = out.readInt32(); | ||
1631 | 237 | props.left = out.readInt32(); | ||
1632 | 238 | props.top = out.readInt32(); | ||
1633 | 239 | props.right = out.readInt32(); | ||
1634 | 240 | props.bottom = out.readInt32(); | ||
1635 | 241 | |||
1636 | 242 | return props; | ||
1637 | 243 | } | ||
1638 | 244 | |||
1639 | 245 | void BpApplicationManagerSession::on_application_resumed() | ||
1640 | 246 | { | ||
1641 | 247 | Parcel in, out; | ||
1642 | 248 | |||
1643 | 249 | remote()->transact( | ||
1644 | 250 | ON_APPLICATION_STARTED_NOTIFICATION, | ||
1645 | 251 | in, | ||
1646 | 252 | &out, | ||
1647 | 253 | android::IBinder::FLAG_ONEWAY); | ||
1648 | 254 | } | ||
1649 | 255 | |||
1650 | 256 | void BpApplicationManagerSession::on_application_about_to_stop() | ||
1651 | 257 | { | ||
1652 | 258 | Parcel in, out; | ||
1653 | 259 | |||
1654 | 260 | remote()->transact( | ||
1655 | 261 | ON_APPLICATION_ABOUT_TO_STOP_NOTIFICATION, | ||
1656 | 262 | in, | ||
1657 | 263 | &out, | ||
1658 | 264 | android::IBinder::FLAG_ONEWAY); | ||
1659 | 265 | } | ||
1660 | 266 | |||
1661 | 267 | status_t BnAMTaskController::onTransact(uint32_t code, | ||
1662 | 268 | const Parcel& data, | ||
1663 | 269 | Parcel* reply, | ||
1664 | 270 | uint32_t flags) | ||
1665 | 271 | { | ||
1666 | 272 | switch(code) | ||
1667 | 273 | { | ||
1668 | 274 | case CONTINUE_TASK_COMMAND: | ||
1669 | 275 | { | ||
1670 | 276 | uint32_t pid = data.readInt32(); | ||
1671 | 277 | continue_task(pid); | ||
1672 | 278 | break; | ||
1673 | 279 | } | ||
1674 | 280 | case SUSPEND_TASK_COMMAND: | ||
1675 | 281 | { | ||
1676 | 282 | int pid = data.readInt32(); | ||
1677 | 283 | suspend_task(pid); | ||
1678 | 284 | break; | ||
1679 | 285 | } | ||
1680 | 286 | } | ||
1681 | 287 | |||
1682 | 288 | return NO_ERROR; | ||
1683 | 289 | } | ||
1684 | 290 | |||
1685 | 291 | BpAMTaskController::BpAMTaskController(const sp<IBinder>& impl) | ||
1686 | 292 | : BpInterface<IAMTaskController>(impl) | ||
1687 | 293 | { | ||
1688 | 294 | } | ||
1689 | 295 | |||
1690 | 296 | void BpAMTaskController::continue_task(uint32_t pid) | ||
1691 | 297 | { | ||
1692 | 298 | Parcel in, out; | ||
1693 | 299 | in.writeInt32(pid); | ||
1694 | 300 | |||
1695 | 301 | remote()->transact( | ||
1696 | 302 | CONTINUE_TASK_COMMAND, | ||
1697 | 303 | in, | ||
1698 | 304 | &out, | ||
1699 | 305 | android::IBinder::FLAG_ONEWAY); | ||
1700 | 306 | } | ||
1701 | 307 | |||
1702 | 308 | void BpAMTaskController::suspend_task(uint32_t pid) | ||
1703 | 309 | { | ||
1704 | 310 | Parcel in, out; | ||
1705 | 311 | in.writeInt32(pid); | ||
1706 | 312 | |||
1707 | 313 | remote()->transact( | ||
1708 | 314 | SUSPEND_TASK_COMMAND, | ||
1709 | 315 | in, | ||
1710 | 316 | &out, | ||
1711 | 317 | android::IBinder::FLAG_ONEWAY); | ||
1712 | 318 | } | ||
1713 | 319 | |||
1714 | 320 | status_t BnApplicationManagerObserver::onTransact(uint32_t code, | ||
1715 | 321 | const Parcel& data, | ||
1716 | 322 | Parcel* reply, | ||
1717 | 323 | uint32_t flags) | ||
1718 | 324 | { | ||
1719 | 325 | |||
1720 | 326 | |||
1721 | 327 | switch(code) | ||
1722 | 328 | { | ||
1723 | 329 | case ON_SESSION_REQUESTED_NOTIFICATION: | ||
1724 | 330 | { | ||
1725 | 331 | uint32_t app = data.readInt32(); | ||
1726 | 332 | on_session_requested(app); | ||
1727 | 333 | break; | ||
1728 | 334 | } | ||
1729 | 335 | case ON_SESSION_BORN_NOTIFICATION: | ||
1730 | 336 | { | ||
1731 | 337 | int id = data.readInt32(); | ||
1732 | 338 | int stage_hint = data.readInt32(); | ||
1733 | 339 | String8 desktop_file = data.readString8(); | ||
1734 | 340 | on_session_born(id, stage_hint, desktop_file); | ||
1735 | 341 | break; | ||
1736 | 342 | } | ||
1737 | 343 | case ON_SESSION_UNFOCUSED_NOTIFICATION: | ||
1738 | 344 | { | ||
1739 | 345 | int id = data.readInt32(); | ||
1740 | 346 | int stage_hint = data.readInt32(); | ||
1741 | 347 | String8 desktop_file = data.readString8(); | ||
1742 | 348 | on_session_unfocused(id, stage_hint, desktop_file); | ||
1743 | 349 | break; | ||
1744 | 350 | } | ||
1745 | 351 | case ON_SESSION_FOCUSED_NOTIFICATION: | ||
1746 | 352 | { | ||
1747 | 353 | int id = data.readInt32(); | ||
1748 | 354 | int stage_hint = data.readInt32(); | ||
1749 | 355 | String8 desktop_file = data.readString8(); | ||
1750 | 356 | on_session_focused(id, stage_hint, desktop_file); | ||
1751 | 357 | break; | ||
1752 | 358 | } | ||
1753 | 359 | case ON_KEYBOARD_GEOMETRY_CHANGED_NOTIFICATION: | ||
1754 | 360 | { | ||
1755 | 361 | int x = data.readInt32(); | ||
1756 | 362 | int y = data.readInt32(); | ||
1757 | 363 | int width = data.readInt32(); | ||
1758 | 364 | int height = data.readInt32(); | ||
1759 | 365 | on_keyboard_geometry_changed(x, y, width, height); | ||
1760 | 366 | break; | ||
1761 | 367 | } | ||
1762 | 368 | case ON_SESSION_REQUESTED_FULLSCREEN_NOTIFICATION: | ||
1763 | 369 | { | ||
1764 | 370 | int id = data.readInt32(); | ||
1765 | 371 | int stage_hint = data.readInt32(); | ||
1766 | 372 | String8 desktop_file = data.readString8(); | ||
1767 | 373 | on_session_requested_fullscreen(id, stage_hint, desktop_file); | ||
1768 | 374 | break; | ||
1769 | 375 | } | ||
1770 | 376 | case ON_SESSION_DIED_NOTIFICATION: | ||
1771 | 377 | { | ||
1772 | 378 | int id = data.readInt32(); | ||
1773 | 379 | int stage_hint = data.readInt32(); | ||
1774 | 380 | String8 desktop_file = data.readString8(); | ||
1775 | 381 | on_session_died(id, stage_hint, desktop_file); | ||
1776 | 382 | break; | ||
1777 | 383 | } | ||
1778 | 384 | } | ||
1779 | 385 | |||
1780 | 386 | return NO_ERROR; | ||
1781 | 387 | } | ||
1782 | 388 | |||
1783 | 389 | BpApplicationManagerObserver::BpApplicationManagerObserver(const sp<IBinder>& impl) | ||
1784 | 390 | : BpInterface<IApplicationManagerObserver>(impl) | ||
1785 | 391 | { | ||
1786 | 392 | } | ||
1787 | 393 | |||
1788 | 394 | void BpApplicationManagerObserver::on_session_requested( | ||
1789 | 395 | uint32_t app) | ||
1790 | 396 | { | ||
1791 | 397 | Parcel in, out; | ||
1792 | 398 | in.writeInt32(app); | ||
1793 | 399 | |||
1794 | 400 | remote()->transact( | ||
1795 | 401 | ON_SESSION_REQUESTED_NOTIFICATION, | ||
1796 | 402 | in, | ||
1797 | 403 | &out, | ||
1798 | 404 | android::IBinder::FLAG_ONEWAY); | ||
1799 | 405 | } | ||
1800 | 406 | |||
1801 | 407 | void BpApplicationManagerObserver::on_session_born(int id, | ||
1802 | 408 | int stage_hint, | ||
1803 | 409 | const String8& desktop_file_hint) | ||
1804 | 410 | { | ||
1805 | 411 | Parcel in, out; | ||
1806 | 412 | in.writeInt32(id); | ||
1807 | 413 | in.writeInt32(stage_hint); | ||
1808 | 414 | in.writeString8(desktop_file_hint); | ||
1809 | 415 | |||
1810 | 416 | remote()->transact( | ||
1811 | 417 | ON_SESSION_BORN_NOTIFICATION, | ||
1812 | 418 | in, | ||
1813 | 419 | &out, | ||
1814 | 420 | android::IBinder::FLAG_ONEWAY); | ||
1815 | 421 | } | ||
1816 | 422 | |||
1817 | 423 | void BpApplicationManagerObserver::on_session_unfocused(int id, | ||
1818 | 424 | int stage_hint, | ||
1819 | 425 | const String8& desktop_file_hint) | ||
1820 | 426 | { | ||
1821 | 427 | Parcel in, out; | ||
1822 | 428 | in.writeInt32(id); | ||
1823 | 429 | in.writeInt32(stage_hint); | ||
1824 | 430 | in.writeString8(desktop_file_hint); | ||
1825 | 431 | |||
1826 | 432 | remote()->transact( | ||
1827 | 433 | ON_SESSION_UNFOCUSED_NOTIFICATION, | ||
1828 | 434 | in, | ||
1829 | 435 | &out, | ||
1830 | 436 | android::IBinder::FLAG_ONEWAY); | ||
1831 | 437 | } | ||
1832 | 438 | |||
1833 | 439 | void BpApplicationManagerObserver::on_session_focused(int id, | ||
1834 | 440 | int stage_hint, | ||
1835 | 441 | const String8& desktop_file_hint) | ||
1836 | 442 | { | ||
1837 | 443 | Parcel in, out; | ||
1838 | 444 | in.writeInt32(id); | ||
1839 | 445 | in.writeInt32(stage_hint); | ||
1840 | 446 | in.writeString8(desktop_file_hint); | ||
1841 | 447 | |||
1842 | 448 | remote()->transact( | ||
1843 | 449 | ON_SESSION_FOCUSED_NOTIFICATION, | ||
1844 | 450 | in, | ||
1845 | 451 | &out, | ||
1846 | 452 | android::IBinder::FLAG_ONEWAY); | ||
1847 | 453 | } | ||
1848 | 454 | |||
1849 | 455 | void BpApplicationManagerObserver::on_keyboard_geometry_changed(int x, | ||
1850 | 456 | int y, | ||
1851 | 457 | int width, | ||
1852 | 458 | int height) | ||
1853 | 459 | { | ||
1854 | 460 | Parcel in, out; | ||
1855 | 461 | in.writeInt32(x); | ||
1856 | 462 | in.writeInt32(y); | ||
1857 | 463 | in.writeInt32(width); | ||
1858 | 464 | in.writeInt32(height); | ||
1859 | 465 | |||
1860 | 466 | remote()->transact( | ||
1861 | 467 | ON_KEYBOARD_GEOMETRY_CHANGED_NOTIFICATION, | ||
1862 | 468 | in, | ||
1863 | 469 | &out, | ||
1864 | 470 | android::IBinder::FLAG_ONEWAY); | ||
1865 | 471 | } | ||
1866 | 472 | |||
1867 | 473 | void BpApplicationManagerObserver::on_session_requested_fullscreen(int id, | ||
1868 | 474 | int stage_hint, | ||
1869 | 475 | const String8& desktop_file_hint) | ||
1870 | 476 | { | ||
1871 | 477 | Parcel in, out; | ||
1872 | 478 | in.writeInt32(id); | ||
1873 | 479 | in.writeInt32(stage_hint); | ||
1874 | 480 | in.writeString8(desktop_file_hint); | ||
1875 | 481 | |||
1876 | 482 | remote()->transact( | ||
1877 | 483 | ON_SESSION_REQUESTED_FULLSCREEN_NOTIFICATION, | ||
1878 | 484 | in, | ||
1879 | 485 | &out, | ||
1880 | 486 | android::IBinder::FLAG_ONEWAY); | ||
1881 | 487 | } | ||
1882 | 488 | |||
1883 | 489 | void BpApplicationManagerObserver::on_session_died(int id, | ||
1884 | 490 | int stage_hint, | ||
1885 | 491 | const String8& desktop_file_hint) | ||
1886 | 492 | { | ||
1887 | 493 | Parcel in, out; | ||
1888 | 494 | in.writeInt32(id); | ||
1889 | 495 | in.writeInt32(stage_hint); | ||
1890 | 496 | in.writeString8(desktop_file_hint); | ||
1891 | 497 | |||
1892 | 498 | remote()->transact( | ||
1893 | 499 | ON_SESSION_DIED_NOTIFICATION, | ||
1894 | 500 | in, | ||
1895 | 501 | &out, | ||
1896 | 502 | android::IBinder::FLAG_ONEWAY); | ||
1897 | 503 | } | ||
1898 | 504 | |||
1899 | 505 | BnApplicationManager::BnApplicationManager() | ||
1900 | 506 | { | ||
1901 | 507 | } | ||
1902 | 508 | |||
1903 | 509 | BnApplicationManager::~BnApplicationManager() | ||
1904 | 510 | { | ||
1905 | 511 | } | ||
1906 | 512 | |||
1907 | 513 | status_t BnApplicationManager::onTransact(uint32_t code, | ||
1908 | 514 | const Parcel& data, | ||
1909 | 515 | Parcel* reply, | ||
1910 | 516 | uint32_t flags) | ||
1911 | 517 | { | ||
1912 | 518 | switch(code) | ||
1913 | 519 | { | ||
1914 | 520 | case START_A_NEW_SESSION_COMMAND: | ||
1915 | 521 | { | ||
1916 | 522 | int32_t session_type = data.readInt32(); | ||
1917 | 523 | int32_t stage_hint = data.readInt32(); | ||
1918 | 524 | String8 app_name = data.readString8(); | ||
1919 | 525 | String8 desktop_file = data.readString8(); | ||
1920 | 526 | sp<IBinder> binder = data.readStrongBinder(); | ||
1921 | 527 | sp<BpApplicationManagerSession> session(new BpApplicationManagerSession(binder)); | ||
1922 | 528 | int fd = data.readFileDescriptor(); | ||
1923 | 529 | uint32_t remote_pid = data.readInt32(); | ||
1924 | 530 | |||
1925 | 531 | start_a_new_session(session_type, stage_hint, app_name, desktop_file, session, fd, remote_pid); | ||
1926 | 532 | } | ||
1927 | 533 | break; | ||
1928 | 534 | case REGISTER_A_SURFACE_COMMAND: | ||
1929 | 535 | { | ||
1930 | 536 | String8 title = data.readString8(); | ||
1931 | 537 | sp<IBinder> binder = data.readStrongBinder(); | ||
1932 | 538 | sp<BpApplicationManagerSession> session(new BpApplicationManagerSession(binder)); | ||
1933 | 539 | int32_t surface_role = data.readInt32(); | ||
1934 | 540 | int32_t surface_token = data.readInt32(); | ||
1935 | 541 | int fd = data.readFileDescriptor(); | ||
1936 | 542 | |||
1937 | 543 | register_a_surface(title, session, surface_role, surface_token, fd); | ||
1938 | 544 | } | ||
1939 | 545 | break; | ||
1940 | 546 | case GET_SESSION_PID_COMMAND: | ||
1941 | 547 | { | ||
1942 | 548 | sp<IBinder> binder = data.readStrongBinder(); | ||
1943 | 549 | sp<BpApplicationManagerSession> session(new BpApplicationManagerSession(binder)); | ||
1944 | 550 | int pid = get_session_pid(session); | ||
1945 | 551 | reply->writeInt32(pid); | ||
1946 | 552 | } | ||
1947 | 553 | break; | ||
1948 | 554 | case REQUEST_FULLSCREEN_COMMAND: | ||
1949 | 555 | { | ||
1950 | 556 | sp<IBinder> binder = data.readStrongBinder(); | ||
1951 | 557 | sp<BpApplicationManagerSession> session(new BpApplicationManagerSession(binder)); | ||
1952 | 558 | request_fullscreen(session); | ||
1953 | 559 | } | ||
1954 | 560 | break; | ||
1955 | 561 | case REGISTER_AN_OBSERVER_COMMAND: | ||
1956 | 562 | { | ||
1957 | 563 | sp<IBinder> binder = data.readStrongBinder(); | ||
1958 | 564 | sp<BpApplicationManagerObserver> observer(new BpApplicationManagerObserver(binder)); | ||
1959 | 565 | register_an_observer(observer); | ||
1960 | 566 | break; | ||
1961 | 567 | } | ||
1962 | 568 | case REGISTER_TASK_CONTROLLER_COMMAND: | ||
1963 | 569 | { | ||
1964 | 570 | sp<IBinder> binder = data.readStrongBinder(); | ||
1965 | 571 | sp<BpAMTaskController> controller(new BpAMTaskController(binder)); | ||
1966 | 572 | register_task_controller(controller); | ||
1967 | 573 | break; | ||
1968 | 574 | } | ||
1969 | 575 | case REQUEST_UPDATE_FOR_SESSION_COMMAND: | ||
1970 | 576 | { | ||
1971 | 577 | sp<IBinder> binder = data.readStrongBinder(); | ||
1972 | 578 | sp<BpApplicationManagerSession> session(new BpApplicationManagerSession(binder)); | ||
1973 | 579 | request_update_for_session(session); | ||
1974 | 580 | break; | ||
1975 | 581 | } | ||
1976 | 582 | case UNFOCUS_RUNNING_SESSIONS_COMMAND: | ||
1977 | 583 | { | ||
1978 | 584 | unfocus_running_sessions(); | ||
1979 | 585 | break; | ||
1980 | 586 | } | ||
1981 | 587 | case FOCUS_RUNNING_SESSION_WITH_ID_COMMAND: | ||
1982 | 588 | { | ||
1983 | 589 | int32_t id = data.readInt32(); | ||
1984 | 590 | focus_running_session_with_id(id); | ||
1985 | 591 | break; | ||
1986 | 592 | } | ||
1987 | 593 | case QUERY_SNAPSHOT_LAYER_FOR_SESSION_WITH_ID_COMMAND: | ||
1988 | 594 | { | ||
1989 | 595 | int32_t id = data.readInt32(); | ||
1990 | 596 | int32_t layer = query_snapshot_layer_for_session_with_id(id); | ||
1991 | 597 | reply->writeInt32(layer); | ||
1992 | 598 | break; | ||
1993 | 599 | } | ||
1994 | 600 | case QUERY_SURFACE_PROPERTIES_FOR_SESSION_ID_COMMAND: | ||
1995 | 601 | { | ||
1996 | 602 | int32_t id = data.readInt32(); | ||
1997 | 603 | IApplicationManagerSession::SurfaceProperties props = | ||
1998 | 604 | query_surface_properties_for_session_id(id); | ||
1999 | 605 | reply->writeInt32(props.layer); | ||
2000 | 606 | reply->writeInt32(props.left); | ||
2001 | 607 | reply->writeInt32(props.top); | ||
2002 | 608 | reply->writeInt32(props.right); | ||
2003 | 609 | reply->writeInt32(props.bottom); | ||
2004 | 610 | break; | ||
2005 | 611 | } | ||
2006 | 612 | case SWITCH_TO_WELL_KNOWN_APPLICATION_COMMAND: | ||
2007 | 613 | { | ||
2008 | 614 | int32_t app = data.readInt32(); | ||
2009 | 615 | switch_to_well_known_application(app); | ||
2010 | 616 | break; | ||
2011 | 617 | } | ||
2012 | 618 | case SET_SURFACE_TRAP_COMMAND: | ||
2013 | 619 | { | ||
2014 | 620 | int32_t x = data.readInt32(); | ||
2015 | 621 | int32_t y = data.readInt32(); | ||
2016 | 622 | int32_t width = data.readInt32(); | ||
2017 | 623 | int32_t height = data.readInt32(); | ||
2018 | 624 | int32_t handle = set_surface_trap(x, y, width, height); | ||
2019 | 625 | reply->writeInt32(handle); | ||
2020 | 626 | break; | ||
2021 | 627 | } | ||
2022 | 628 | case UNSET_SURFACE_TRAP_COMMAND: | ||
2023 | 629 | { | ||
2024 | 630 | int32_t handle = data.readInt32(); | ||
2025 | 631 | unset_surface_trap(handle); | ||
2026 | 632 | break; | ||
2027 | 633 | } | ||
2028 | 634 | case REPORT_OSK_VISIBLE_COMMAND: | ||
2029 | 635 | { | ||
2030 | 636 | int32_t x = data.readInt32(); | ||
2031 | 637 | int32_t y = data.readInt32(); | ||
2032 | 638 | int32_t width = data.readInt32(); | ||
2033 | 639 | int32_t height = data.readInt32(); | ||
2034 | 640 | report_osk_visible(x, y, width, height); | ||
2035 | 641 | break; | ||
2036 | 642 | } | ||
2037 | 643 | case REPORT_OSK_INVISIBLE_COMMAND: | ||
2038 | 644 | { | ||
2039 | 645 | report_osk_invisible(); | ||
2040 | 646 | break; | ||
2041 | 647 | } | ||
2042 | 648 | case REPORT_NOTIFICATION_VISIBLE_COMMAND: | ||
2043 | 649 | { | ||
2044 | 650 | report_notification_visible(); | ||
2045 | 651 | break; | ||
2046 | 652 | } | ||
2047 | 653 | case REPORT_NOTIFICATION_INVISIBLE_COMMAND: | ||
2048 | 654 | { | ||
2049 | 655 | report_notification_invisible(); | ||
2050 | 656 | break; | ||
2051 | 657 | } | ||
2052 | 658 | } | ||
2053 | 659 | return NO_ERROR; | ||
2054 | 660 | } | ||
2055 | 661 | |||
2056 | 662 | BpApplicationManager::BpApplicationManager(const sp<IBinder>& impl) | ||
2057 | 663 | : BpInterface<IApplicationManager>(impl) | ||
2058 | 664 | { | ||
2059 | 665 | } | ||
2060 | 666 | |||
2061 | 667 | BpApplicationManager::~BpApplicationManager() | ||
2062 | 668 | { | ||
2063 | 669 | } | ||
2064 | 670 | |||
2065 | 671 | void BpApplicationManager::start_a_new_session( | ||
2066 | 672 | int32_t session_type, | ||
2067 | 673 | int32_t stage_hint, | ||
2068 | 674 | const String8& app_name, | ||
2069 | 675 | const String8& desktop_file, | ||
2070 | 676 | const sp<IApplicationManagerSession>& session, | ||
2071 | 677 | int fd, | ||
2072 | 678 | uint32_t remote_pid) | ||
2073 | 679 | { | ||
2074 | 680 | //printf("%s \n", __PRETTY_FUNCTION__); | ||
2075 | 681 | Parcel in, out; | ||
2076 | 682 | in.pushAllowFds(true); | ||
2077 | 683 | in.writeInt32(session_type); | ||
2078 | 684 | in.writeInt32(stage_hint); | ||
2079 | 685 | in.writeString8(app_name); | ||
2080 | 686 | in.writeString8(desktop_file); | ||
2081 | 687 | in.writeStrongBinder(session->asBinder()); | ||
2082 | 688 | in.writeFileDescriptor(fd); | ||
2083 | 689 | in.writeInt32(remote_pid); | ||
2084 | 690 | |||
2085 | 691 | remote()->transact(START_A_NEW_SESSION_COMMAND, | ||
2086 | 692 | in, | ||
2087 | 693 | &out); | ||
2088 | 694 | } | ||
2089 | 695 | |||
2090 | 696 | void BpApplicationManager::register_a_surface( | ||
2091 | 697 | const String8& title, | ||
2092 | 698 | const sp<IApplicationManagerSession>& session, | ||
2093 | 699 | int32_t surface_role, | ||
2094 | 700 | int32_t token, | ||
2095 | 701 | int fd) | ||
2096 | 702 | { | ||
2097 | 703 | //printf("%s \n", __PRETTY_FUNCTION__); | ||
2098 | 704 | Parcel in, out; | ||
2099 | 705 | in.pushAllowFds(true); | ||
2100 | 706 | in.writeString8(title); | ||
2101 | 707 | in.writeStrongBinder(session->asBinder()); | ||
2102 | 708 | in.writeInt32(surface_role); | ||
2103 | 709 | in.writeInt32(token); | ||
2104 | 710 | in.writeFileDescriptor(fd); | ||
2105 | 711 | |||
2106 | 712 | remote()->transact(REGISTER_A_SURFACE_COMMAND, | ||
2107 | 713 | in, | ||
2108 | 714 | &out); | ||
2109 | 715 | } | ||
2110 | 716 | |||
2111 | 717 | int BpApplicationManager::get_session_pid( | ||
2112 | 718 | const sp<IApplicationManagerSession>& session) | ||
2113 | 719 | { | ||
2114 | 720 | Parcel in, out; | ||
2115 | 721 | in.writeStrongBinder(session->asBinder()); | ||
2116 | 722 | |||
2117 | 723 | remote()->transact(GET_SESSION_PID_COMMAND, | ||
2118 | 724 | in, | ||
2119 | 725 | &out); | ||
2120 | 726 | |||
2121 | 727 | int32_t pid = out.readInt32(); | ||
2122 | 728 | |||
2123 | 729 | return pid; | ||
2124 | 730 | } | ||
2125 | 731 | |||
2126 | 732 | |||
2127 | 733 | void BpApplicationManager::request_fullscreen( | ||
2128 | 734 | const sp<IApplicationManagerSession>& session) | ||
2129 | 735 | { | ||
2130 | 736 | //printf("%s \n", __PRETTY_FUNCTION__); | ||
2131 | 737 | Parcel in, out; | ||
2132 | 738 | in.writeStrongBinder(session->asBinder()); | ||
2133 | 739 | |||
2134 | 740 | remote()->transact(REQUEST_FULLSCREEN_COMMAND, | ||
2135 | 741 | in, | ||
2136 | 742 | &out); | ||
2137 | 743 | } | ||
2138 | 744 | |||
2139 | 745 | void BpApplicationManager::register_task_controller(const sp<IAMTaskController>& controller) | ||
2140 | 746 | { | ||
2141 | 747 | Parcel in, out; | ||
2142 | 748 | in.writeStrongBinder(controller->asBinder()); | ||
2143 | 749 | |||
2144 | 750 | remote()->transact(REGISTER_TASK_CONTROLLER_COMMAND, | ||
2145 | 751 | in, | ||
2146 | 752 | &out); | ||
2147 | 753 | } | ||
2148 | 754 | |||
2149 | 755 | void BpApplicationManager::register_an_observer(const sp<IApplicationManagerObserver>& observer) | ||
2150 | 756 | { | ||
2151 | 757 | Parcel in, out; | ||
2152 | 758 | in.writeStrongBinder(observer->asBinder()); | ||
2153 | 759 | |||
2154 | 760 | remote()->transact(REGISTER_AN_OBSERVER_COMMAND, | ||
2155 | 761 | in, | ||
2156 | 762 | &out); | ||
2157 | 763 | } | ||
2158 | 764 | |||
2159 | 765 | void BpApplicationManager::request_update_for_session(const sp<IApplicationManagerSession>& session) | ||
2160 | 766 | { | ||
2161 | 767 | Parcel in, out; | ||
2162 | 768 | in.writeStrongBinder(session->asBinder()); | ||
2163 | 769 | remote()->transact(REQUEST_UPDATE_FOR_SESSION_COMMAND, | ||
2164 | 770 | in, | ||
2165 | 771 | &out); | ||
2166 | 772 | } | ||
2167 | 773 | |||
2168 | 774 | void BpApplicationManager::unfocus_running_sessions() | ||
2169 | 775 | { | ||
2170 | 776 | Parcel in, out; | ||
2171 | 777 | |||
2172 | 778 | remote()->transact(UNFOCUS_RUNNING_SESSIONS_COMMAND, | ||
2173 | 779 | in, | ||
2174 | 780 | &out); | ||
2175 | 781 | } | ||
2176 | 782 | |||
2177 | 783 | void BpApplicationManager::focus_running_session_with_id(int id) | ||
2178 | 784 | { | ||
2179 | 785 | Parcel in, out; | ||
2180 | 786 | in.writeInt32(id); | ||
2181 | 787 | |||
2182 | 788 | remote()->transact(FOCUS_RUNNING_SESSION_WITH_ID_COMMAND, | ||
2183 | 789 | in, | ||
2184 | 790 | &out); | ||
2185 | 791 | } | ||
2186 | 792 | |||
2187 | 793 | int32_t BpApplicationManager::query_snapshot_layer_for_session_with_id(int id) | ||
2188 | 794 | { | ||
2189 | 795 | Parcel in, out; | ||
2190 | 796 | in.writeInt32(id); | ||
2191 | 797 | remote()->transact(QUERY_SNAPSHOT_LAYER_FOR_SESSION_WITH_ID_COMMAND, | ||
2192 | 798 | in, | ||
2193 | 799 | &out); | ||
2194 | 800 | |||
2195 | 801 | int32_t layer = out.readInt32(); | ||
2196 | 802 | return layer; | ||
2197 | 803 | } | ||
2198 | 804 | |||
2199 | 805 | IApplicationManagerSession::SurfaceProperties BpApplicationManager::query_surface_properties_for_session_id(int id) | ||
2200 | 806 | { | ||
2201 | 807 | Parcel in, out; | ||
2202 | 808 | in.writeInt32(id); | ||
2203 | 809 | |||
2204 | 810 | remote()->transact(QUERY_SURFACE_PROPERTIES_FOR_SESSION_ID_COMMAND, | ||
2205 | 811 | in, | ||
2206 | 812 | &out); | ||
2207 | 813 | |||
2208 | 814 | IApplicationManagerSession::SurfaceProperties props; | ||
2209 | 815 | props.layer = out.readInt32(); | ||
2210 | 816 | props.left = out.readInt32(); | ||
2211 | 817 | props.top = out.readInt32(); | ||
2212 | 818 | props.right = out.readInt32(); | ||
2213 | 819 | props.bottom = out.readInt32(); | ||
2214 | 820 | |||
2215 | 821 | return props; | ||
2216 | 822 | } | ||
2217 | 823 | void BpApplicationManager::switch_to_well_known_application(int32_t app) | ||
2218 | 824 | { | ||
2219 | 825 | Parcel in, out; | ||
2220 | 826 | in.writeInt32(app); | ||
2221 | 827 | |||
2222 | 828 | remote()->transact(SWITCH_TO_WELL_KNOWN_APPLICATION_COMMAND, | ||
2223 | 829 | in, | ||
2224 | 830 | &out); | ||
2225 | 831 | } | ||
2226 | 832 | |||
2227 | 833 | int32_t BpApplicationManager::set_surface_trap(int32_t x, int32_t y, int32_t width, int32_t height) | ||
2228 | 834 | { | ||
2229 | 835 | Parcel in, out; | ||
2230 | 836 | in.writeInt32(x); | ||
2231 | 837 | in.writeInt32(y); | ||
2232 | 838 | in.writeInt32(width); | ||
2233 | 839 | in.writeInt32(height); | ||
2234 | 840 | |||
2235 | 841 | remote()->transact(SET_SURFACE_TRAP_COMMAND, | ||
2236 | 842 | in, | ||
2237 | 843 | &out); | ||
2238 | 844 | |||
2239 | 845 | int32_t handle = out.readInt32(); | ||
2240 | 846 | |||
2241 | 847 | return handle; | ||
2242 | 848 | } | ||
2243 | 849 | |||
2244 | 850 | void BpApplicationManager::unset_surface_trap(int32_t handle) | ||
2245 | 851 | { | ||
2246 | 852 | Parcel in, out; | ||
2247 | 853 | in.writeInt32(handle); | ||
2248 | 854 | |||
2249 | 855 | remote()->transact(UNSET_SURFACE_TRAP_COMMAND, | ||
2250 | 856 | in, | ||
2251 | 857 | &out); | ||
2252 | 858 | } | ||
2253 | 859 | |||
2254 | 860 | void BpApplicationManager::report_osk_visible(int32_t x, int32_t y, int32_t width, int32_t height) | ||
2255 | 861 | { | ||
2256 | 862 | Parcel in, out; | ||
2257 | 863 | in.writeInt32(x); | ||
2258 | 864 | in.writeInt32(y); | ||
2259 | 865 | in.writeInt32(width); | ||
2260 | 866 | in.writeInt32(height); | ||
2261 | 867 | |||
2262 | 868 | remote()->transact(REPORT_OSK_VISIBLE_COMMAND, | ||
2263 | 869 | in, | ||
2264 | 870 | &out); | ||
2265 | 871 | } | ||
2266 | 872 | |||
2267 | 873 | void BpApplicationManager::report_osk_invisible() | ||
2268 | 874 | { | ||
2269 | 875 | Parcel in, out; | ||
2270 | 876 | |||
2271 | 877 | remote()->transact(REPORT_OSK_INVISIBLE_COMMAND, | ||
2272 | 878 | in, | ||
2273 | 879 | &out); | ||
2274 | 880 | } | ||
2275 | 881 | |||
2276 | 882 | void BpApplicationManager::report_notification_visible() | ||
2277 | 883 | { | ||
2278 | 884 | Parcel in, out; | ||
2279 | 885 | |||
2280 | 886 | remote()->transact(REPORT_NOTIFICATION_VISIBLE_COMMAND, | ||
2281 | 887 | in, | ||
2282 | 888 | &out); | ||
2283 | 889 | } | ||
2284 | 890 | |||
2285 | 891 | void BpApplicationManager::report_notification_invisible() | ||
2286 | 892 | { | ||
2287 | 893 | Parcel in, out; | ||
2288 | 894 | |||
2289 | 895 | remote()->transact(REPORT_NOTIFICATION_INVISIBLE_COMMAND, | ||
2290 | 896 | in, | ||
2291 | 897 | &out); | ||
2292 | 898 | } | ||
2293 | 899 | |||
2294 | 900 | } | ||
2295 | 901 | 0 | ||
2296 | === removed file 'android/hybris/application_manager.h' | |||
2297 | --- android/hybris/application_manager.h 2013-06-07 01:08:41 +0000 | |||
2298 | +++ android/hybris/application_manager.h 1970-01-01 00:00:00 +0000 | |||
2299 | @@ -1,412 +0,0 @@ | |||
2300 | 1 | /* | ||
2301 | 2 | * Copyright © 2012 Canonical Ltd. | ||
2302 | 3 | * | ||
2303 | 4 | * This program is free software: you can redistribute it and/or modify | ||
2304 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
2305 | 6 | * published by the Free Software Foundation. | ||
2306 | 7 | * | ||
2307 | 8 | * This program is distributed in the hope that it will be useful, | ||
2308 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2309 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2310 | 11 | * GNU Lesser General Public License for more details. | ||
2311 | 12 | * | ||
2312 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2313 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2314 | 15 | * | ||
2315 | 16 | * Authored by: Thomas Voß <thomas.voss@canonical.com> | ||
2316 | 17 | */ | ||
2317 | 18 | #ifndef HYBRIS_APPLICATION_MANAGER_H_ | ||
2318 | 19 | #define HYBRIS_APPLICATION_MANAGER_H_ | ||
2319 | 20 | |||
2320 | 21 | #include <binder/IInterface.h> | ||
2321 | 22 | #include <utils/String8.h> | ||
2322 | 23 | |||
2323 | 24 | namespace android | ||
2324 | 25 | { | ||
2325 | 26 | |||
2326 | 27 | class IClipboardService : public IInterface | ||
2327 | 28 | { | ||
2328 | 29 | public: | ||
2329 | 30 | DECLARE_META_INTERFACE(ClipboardService); | ||
2330 | 31 | |||
2331 | 32 | static const char* exported_service_name() | ||
2332 | 33 | { | ||
2333 | 34 | return "UbuntuClipboardService"; | ||
2334 | 35 | } | ||
2335 | 36 | |||
2336 | 37 | struct Content | ||
2337 | 38 | { | ||
2338 | 39 | Content(); | ||
2339 | 40 | Content(const String8& mime_type, void* data, size_t data_size); | ||
2340 | 41 | ~Content(); | ||
2341 | 42 | Content(const Content& rhs); | ||
2342 | 43 | Content& operator=(const Content& rhs); | ||
2343 | 44 | |||
2344 | 45 | String8 mime_type; | ||
2345 | 46 | void* data; | ||
2346 | 47 | size_t data_size; | ||
2347 | 48 | }; | ||
2348 | 49 | |||
2349 | 50 | virtual void set_content(const Content& content) = 0; | ||
2350 | 51 | virtual void get_content(Content& content) = 0; | ||
2351 | 52 | |||
2352 | 53 | protected: | ||
2353 | 54 | enum | ||
2354 | 55 | { | ||
2355 | 56 | SET_CLIPBOARD_CONTENT_COMMAND = IBinder::FIRST_CALL_TRANSACTION, | ||
2356 | 57 | GET_CLIPBOARD_CONTENT_COMMAND | ||
2357 | 58 | }; | ||
2358 | 59 | }; | ||
2359 | 60 | |||
2360 | 61 | class BnClipboardService : public BnInterface<IClipboardService> | ||
2361 | 62 | { | ||
2362 | 63 | public: | ||
2363 | 64 | status_t onTransact(uint32_t code, | ||
2364 | 65 | const Parcel& data, | ||
2365 | 66 | Parcel* reply, | ||
2366 | 67 | uint32_t flags = 0); | ||
2367 | 68 | }; | ||
2368 | 69 | |||
2369 | 70 | class BpClipboardService : public BpInterface<IClipboardService> | ||
2370 | 71 | { | ||
2371 | 72 | public: | ||
2372 | 73 | BpClipboardService(const sp<IBinder>& impl); | ||
2373 | 74 | |||
2374 | 75 | void set_content(const IClipboardService::Content& content); | ||
2375 | 76 | void get_content(IClipboardService::Content& content); | ||
2376 | 77 | |||
2377 | 78 | }; | ||
2378 | 79 | |||
2379 | 80 | class IApplicationManagerSession : public IInterface | ||
2380 | 81 | { | ||
2381 | 82 | public: | ||
2382 | 83 | DECLARE_META_INTERFACE(ApplicationManagerSession); | ||
2383 | 84 | |||
2384 | 85 | struct SurfaceProperties | ||
2385 | 86 | { | ||
2386 | 87 | int32_t layer; | ||
2387 | 88 | int32_t left; | ||
2388 | 89 | int32_t top; | ||
2389 | 90 | int32_t right; | ||
2390 | 91 | int32_t bottom; | ||
2391 | 92 | }; | ||
2392 | 93 | |||
2393 | 94 | virtual void raise_application_surfaces_to_layer(int layer) = 0; | ||
2394 | 95 | virtual void raise_surface_to_layer(int32_t token, int layer) = 0; | ||
2395 | 96 | virtual SurfaceProperties query_surface_properties_for_token(int32_t token) = 0; | ||
2396 | 97 | virtual void on_application_resumed() = 0; | ||
2397 | 98 | virtual void on_application_about_to_stop() = 0; | ||
2398 | 99 | |||
2399 | 100 | protected: | ||
2400 | 101 | enum | ||
2401 | 102 | { | ||
2402 | 103 | RAISE_APPLICATION_SURFACES_TO_LAYER_COMMAND = IBinder::FIRST_CALL_TRANSACTION, | ||
2403 | 104 | RAISE_SURFACE_TO_LAYER_COMMAND, | ||
2404 | 105 | QUERY_SURFACE_PROPERTIES_FOR_TOKEN_COMMAND, | ||
2405 | 106 | ON_APPLICATION_STARTED_NOTIFICATION, | ||
2406 | 107 | ON_APPLICATION_ABOUT_TO_STOP_NOTIFICATION, | ||
2407 | 108 | }; | ||
2408 | 109 | }; | ||
2409 | 110 | |||
2410 | 111 | class BnApplicationManagerSession : public BnInterface<IApplicationManagerSession> | ||
2411 | 112 | { | ||
2412 | 113 | public: | ||
2413 | 114 | BnApplicationManagerSession(); | ||
2414 | 115 | virtual ~BnApplicationManagerSession(); | ||
2415 | 116 | |||
2416 | 117 | virtual status_t onTransact(uint32_t code, | ||
2417 | 118 | const Parcel& data, | ||
2418 | 119 | Parcel* reply, | ||
2419 | 120 | uint32_t flags = 0); | ||
2420 | 121 | }; | ||
2421 | 122 | |||
2422 | 123 | class BpApplicationManagerSession : public BpInterface<IApplicationManagerSession> | ||
2423 | 124 | { | ||
2424 | 125 | public: | ||
2425 | 126 | BpApplicationManagerSession(const sp<IBinder>& impl); | ||
2426 | 127 | ~BpApplicationManagerSession(); | ||
2427 | 128 | |||
2428 | 129 | void raise_application_surfaces_to_layer(int layer); | ||
2429 | 130 | void raise_surface_to_layer(int32_t token, int layer); | ||
2430 | 131 | IApplicationManagerSession::SurfaceProperties query_surface_properties_for_token(int32_t token); | ||
2431 | 132 | void on_application_resumed(); | ||
2432 | 133 | void on_application_about_to_stop(); | ||
2433 | 134 | }; | ||
2434 | 135 | |||
2435 | 136 | class IAMTaskController : public IInterface | ||
2436 | 137 | { | ||
2437 | 138 | public: | ||
2438 | 139 | DECLARE_META_INTERFACE(AMTaskController); | ||
2439 | 140 | |||
2440 | 141 | virtual void continue_task(uint32_t pid) = 0; | ||
2441 | 142 | |||
2442 | 143 | virtual void suspend_task(uint32_t pid) = 0; | ||
2443 | 144 | |||
2444 | 145 | protected: | ||
2445 | 146 | enum | ||
2446 | 147 | { | ||
2447 | 148 | CONTINUE_TASK_COMMAND = IBinder::FIRST_CALL_TRANSACTION, | ||
2448 | 149 | SUSPEND_TASK_COMMAND | ||
2449 | 150 | }; | ||
2450 | 151 | |||
2451 | 152 | IAMTaskController(const IAMTaskController&) = delete; | ||
2452 | 153 | IAMTaskController& operator=(const IAMTaskController&) = delete; | ||
2453 | 154 | }; | ||
2454 | 155 | |||
2455 | 156 | class BnAMTaskController : public BnInterface<IAMTaskController> | ||
2456 | 157 | { | ||
2457 | 158 | public: | ||
2458 | 159 | status_t onTransact(uint32_t code, | ||
2459 | 160 | const Parcel& data, | ||
2460 | 161 | Parcel* reply, | ||
2461 | 162 | uint32_t flags = 0); | ||
2462 | 163 | }; | ||
2463 | 164 | |||
2464 | 165 | class BpAMTaskController : public BpInterface<IAMTaskController> | ||
2465 | 166 | { | ||
2466 | 167 | public: | ||
2467 | 168 | BpAMTaskController(const sp<IBinder>& impl); | ||
2468 | 169 | |||
2469 | 170 | void continue_task(uint32_t pid); | ||
2470 | 171 | |||
2471 | 172 | void suspend_task(uint32_t pid); | ||
2472 | 173 | }; | ||
2473 | 174 | |||
2474 | 175 | class IApplicationManagerObserver : public IInterface | ||
2475 | 176 | { | ||
2476 | 177 | public: | ||
2477 | 178 | DECLARE_META_INTERFACE(ApplicationManagerObserver); | ||
2478 | 179 | |||
2479 | 180 | virtual void on_session_requested(uint32_t app) = 0; | ||
2480 | 181 | |||
2481 | 182 | virtual void on_session_born(int id, | ||
2482 | 183 | int stage_hint, | ||
2483 | 184 | const String8& desktop_file) = 0; | ||
2484 | 185 | |||
2485 | 186 | virtual void on_session_unfocused(int id, | ||
2486 | 187 | int stage_hint, | ||
2487 | 188 | const String8& desktop_file) = 0; | ||
2488 | 189 | |||
2489 | 190 | virtual void on_session_focused(int id, | ||
2490 | 191 | int stage_hint, | ||
2491 | 192 | const String8& desktop_file) = 0; | ||
2492 | 193 | |||
2493 | 194 | virtual void on_session_requested_fullscreen(int id, | ||
2494 | 195 | int stage_hint, | ||
2495 | 196 | const String8& desktop_file) = 0; | ||
2496 | 197 | |||
2497 | 198 | virtual void on_keyboard_geometry_changed(int x, | ||
2498 | 199 | int y, | ||
2499 | 200 | int width, | ||
2500 | 201 | int height) = 0; | ||
2501 | 202 | |||
2502 | 203 | virtual void on_session_died(int id, | ||
2503 | 204 | int stage_hint, | ||
2504 | 205 | const String8& desktop_file) = 0; | ||
2505 | 206 | |||
2506 | 207 | protected: | ||
2507 | 208 | enum | ||
2508 | 209 | { | ||
2509 | 210 | ON_SESSION_REQUESTED_NOTIFICATION = IBinder::FIRST_CALL_TRANSACTION, | ||
2510 | 211 | ON_SESSION_BORN_NOTIFICATION, | ||
2511 | 212 | ON_SESSION_UNFOCUSED_NOTIFICATION, | ||
2512 | 213 | ON_SESSION_FOCUSED_NOTIFICATION, | ||
2513 | 214 | ON_KEYBOARD_GEOMETRY_CHANGED_NOTIFICATION, | ||
2514 | 215 | ON_SESSION_REQUESTED_FULLSCREEN_NOTIFICATION, | ||
2515 | 216 | ON_SESSION_DIED_NOTIFICATION | ||
2516 | 217 | }; | ||
2517 | 218 | |||
2518 | 219 | IApplicationManagerObserver(const IApplicationManagerObserver&) = delete; | ||
2519 | 220 | IApplicationManagerObserver& operator=(const IApplicationManagerObserver&) = delete; | ||
2520 | 221 | }; | ||
2521 | 222 | |||
2522 | 223 | class BnApplicationManagerObserver : public BnInterface<IApplicationManagerObserver> | ||
2523 | 224 | { | ||
2524 | 225 | public: | ||
2525 | 226 | status_t onTransact(uint32_t code, | ||
2526 | 227 | const Parcel& data, | ||
2527 | 228 | Parcel* reply, | ||
2528 | 229 | uint32_t flags = 0); | ||
2529 | 230 | }; | ||
2530 | 231 | |||
2531 | 232 | class BpApplicationManagerObserver : public BpInterface<IApplicationManagerObserver> | ||
2532 | 233 | { | ||
2533 | 234 | public: | ||
2534 | 235 | BpApplicationManagerObserver(const sp<IBinder>& impl); | ||
2535 | 236 | |||
2536 | 237 | void on_session_requested(uint32_t app); | ||
2537 | 238 | |||
2538 | 239 | void on_session_born(int id, | ||
2539 | 240 | int stage_hint, | ||
2540 | 241 | const String8& desktop_file); | ||
2541 | 242 | |||
2542 | 243 | void on_session_unfocused(int id, | ||
2543 | 244 | int stage_hint, | ||
2544 | 245 | const String8& desktop_file); | ||
2545 | 246 | |||
2546 | 247 | void on_session_focused(int id, | ||
2547 | 248 | int stage_hint, | ||
2548 | 249 | const String8& desktop_file); | ||
2549 | 250 | |||
2550 | 251 | void on_session_requested_fullscreen(int id, | ||
2551 | 252 | int stage_hint, | ||
2552 | 253 | const String8& desktop_file); | ||
2553 | 254 | |||
2554 | 255 | void on_keyboard_geometry_changed(int x, | ||
2555 | 256 | int y, | ||
2556 | 257 | int width, | ||
2557 | 258 | int height); | ||
2558 | 259 | |||
2559 | 260 | void on_session_died(int id, | ||
2560 | 261 | int stage_hint, | ||
2561 | 262 | const String8& desktop_file); | ||
2562 | 263 | }; | ||
2563 | 264 | |||
2564 | 265 | class IApplicationManager : public IInterface | ||
2565 | 266 | { | ||
2566 | 267 | public: | ||
2567 | 268 | DECLARE_META_INTERFACE(ApplicationManager); | ||
2568 | 269 | |||
2569 | 270 | static const char* exported_service_name() | ||
2570 | 271 | { | ||
2571 | 272 | return "UbuntuApplicationManager"; | ||
2572 | 273 | } | ||
2573 | 274 | |||
2574 | 275 | virtual void start_a_new_session(int32_t session_type, | ||
2575 | 276 | int32_t stage_hint, | ||
2576 | 277 | const String8& app_name, | ||
2577 | 278 | const String8& desktop_file, | ||
2578 | 279 | const sp<IApplicationManagerSession>& session, | ||
2579 | 280 | int fd, | ||
2580 | 281 | uint32_t remote_pid) = 0; | ||
2581 | 282 | |||
2582 | 283 | virtual void register_a_surface(const String8& title, | ||
2583 | 284 | const sp<IApplicationManagerSession>& session, | ||
2584 | 285 | int32_t surface_role, | ||
2585 | 286 | int32_t token, | ||
2586 | 287 | int fd) = 0; | ||
2587 | 288 | |||
2588 | 289 | virtual int get_session_pid(const sp<IApplicationManagerSession>& session) = 0; | ||
2589 | 290 | |||
2590 | 291 | virtual void request_fullscreen(const sp<IApplicationManagerSession>& session) = 0; | ||
2591 | 292 | |||
2592 | 293 | virtual void request_update_for_session(const sp<IApplicationManagerSession>& session) = 0; | ||
2593 | 294 | |||
2594 | 295 | virtual void register_an_observer(const sp<IApplicationManagerObserver>& observer) = 0; | ||
2595 | 296 | |||
2596 | 297 | virtual void register_task_controller(const sp<IAMTaskController>& controller) = 0; | ||
2597 | 298 | |||
2598 | 299 | virtual void unfocus_running_sessions() = 0; | ||
2599 | 300 | |||
2600 | 301 | virtual void focus_running_session_with_id(int id) = 0; | ||
2601 | 302 | |||
2602 | 303 | virtual int32_t query_snapshot_layer_for_session_with_id(int id) = 0; | ||
2603 | 304 | |||
2604 | 305 | virtual IApplicationManagerSession::SurfaceProperties query_surface_properties_for_session_id(int id) = 0; | ||
2605 | 306 | |||
2606 | 307 | virtual void switch_to_well_known_application(int32_t app) = 0; | ||
2607 | 308 | |||
2608 | 309 | virtual int32_t set_surface_trap(int32_t x, int32_t y, int32_t width, int32_t height) = 0; | ||
2609 | 310 | |||
2610 | 311 | virtual void unset_surface_trap(int32_t handle) = 0; | ||
2611 | 312 | |||
2612 | 313 | virtual void report_osk_visible(int32_t x, int32_t y, int32_t width, int32_t height) = 0; | ||
2613 | 314 | |||
2614 | 315 | virtual void report_osk_invisible() = 0; | ||
2615 | 316 | |||
2616 | 317 | virtual void report_notification_visible() = 0; | ||
2617 | 318 | |||
2618 | 319 | virtual void report_notification_invisible() = 0; | ||
2619 | 320 | |||
2620 | 321 | protected: | ||
2621 | 322 | enum | ||
2622 | 323 | { | ||
2623 | 324 | START_A_NEW_SESSION_COMMAND = IBinder::FIRST_CALL_TRANSACTION, | ||
2624 | 325 | REGISTER_A_SURFACE_COMMAND, | ||
2625 | 326 | GET_SESSION_PID_COMMAND, | ||
2626 | 327 | REQUEST_FULLSCREEN_COMMAND, | ||
2627 | 328 | REGISTER_AN_OBSERVER_COMMAND, | ||
2628 | 329 | REGISTER_TASK_CONTROLLER_COMMAND, | ||
2629 | 330 | REQUEST_UPDATE_FOR_SESSION_COMMAND, | ||
2630 | 331 | UNFOCUS_RUNNING_SESSIONS_COMMAND, | ||
2631 | 332 | FOCUS_RUNNING_SESSION_WITH_ID_COMMAND, | ||
2632 | 333 | QUERY_SNAPSHOT_LAYER_FOR_SESSION_WITH_ID_COMMAND, | ||
2633 | 334 | QUERY_SURFACE_PROPERTIES_FOR_SESSION_ID_COMMAND, | ||
2634 | 335 | SWITCH_TO_WELL_KNOWN_APPLICATION_COMMAND, | ||
2635 | 336 | SET_SURFACE_TRAP_COMMAND, | ||
2636 | 337 | UNSET_SURFACE_TRAP_COMMAND, | ||
2637 | 338 | REPORT_OSK_VISIBLE_COMMAND, | ||
2638 | 339 | REPORT_OSK_INVISIBLE_COMMAND, | ||
2639 | 340 | REPORT_NOTIFICATION_VISIBLE_COMMAND, | ||
2640 | 341 | REPORT_NOTIFICATION_INVISIBLE_COMMAND | ||
2641 | 342 | }; | ||
2642 | 343 | }; | ||
2643 | 344 | |||
2644 | 345 | class BnApplicationManager : public BnInterface<IApplicationManager> | ||
2645 | 346 | { | ||
2646 | 347 | public: | ||
2647 | 348 | BnApplicationManager(); | ||
2648 | 349 | virtual ~BnApplicationManager(); | ||
2649 | 350 | |||
2650 | 351 | virtual status_t onTransact(uint32_t code, | ||
2651 | 352 | const Parcel& data, | ||
2652 | 353 | Parcel* reply, | ||
2653 | 354 | uint32_t flags = 0); | ||
2654 | 355 | }; | ||
2655 | 356 | |||
2656 | 357 | class BpApplicationManager : public BpInterface<IApplicationManager> | ||
2657 | 358 | { | ||
2658 | 359 | public: | ||
2659 | 360 | BpApplicationManager(const sp<IBinder>& impl); | ||
2660 | 361 | ~BpApplicationManager(); | ||
2661 | 362 | |||
2662 | 363 | void start_a_new_session(int32_t session_type, | ||
2663 | 364 | int32_t stage_hint, | ||
2664 | 365 | const String8& app_name, | ||
2665 | 366 | const String8& desktop_file, | ||
2666 | 367 | const sp<IApplicationManagerSession>& session, | ||
2667 | 368 | int fd, | ||
2668 | 369 | uint32_t remote_pid); | ||
2669 | 370 | |||
2670 | 371 | void register_a_surface(const String8& title, | ||
2671 | 372 | const android::sp<android::IApplicationManagerSession>& session, | ||
2672 | 373 | int32_t surface_role, | ||
2673 | 374 | int32_t token, | ||
2674 | 375 | int fd); | ||
2675 | 376 | |||
2676 | 377 | int get_session_pid(const android::sp<android::IApplicationManagerSession>& session); | ||
2677 | 378 | |||
2678 | 379 | void request_fullscreen(const android::sp<android::IApplicationManagerSession>& session); | ||
2679 | 380 | |||
2680 | 381 | void request_update_for_session(const sp<IApplicationManagerSession>& session); | ||
2681 | 382 | |||
2682 | 383 | void register_an_observer(const sp<IApplicationManagerObserver>& observer); | ||
2683 | 384 | |||
2684 | 385 | void register_task_controller(const sp<IAMTaskController>& controller); | ||
2685 | 386 | |||
2686 | 387 | void unfocus_running_sessions(); | ||
2687 | 388 | |||
2688 | 389 | void focus_running_session_with_id(int id); | ||
2689 | 390 | |||
2690 | 391 | int32_t query_snapshot_layer_for_session_with_id(int id); | ||
2691 | 392 | |||
2692 | 393 | IApplicationManagerSession::SurfaceProperties query_surface_properties_for_session_id(int id); | ||
2693 | 394 | |||
2694 | 395 | void switch_to_well_known_application(int32_t app); | ||
2695 | 396 | |||
2696 | 397 | int32_t set_surface_trap(int32_t x, int32_t y, int32_t width, int32_t height); | ||
2697 | 398 | |||
2698 | 399 | void unset_surface_trap(int handle); | ||
2699 | 400 | |||
2700 | 401 | void report_osk_visible(int32_t x, int32_t y, int32_t width, int32_t height); | ||
2701 | 402 | |||
2702 | 403 | void report_osk_invisible(); | ||
2703 | 404 | |||
2704 | 405 | void report_notification_visible(); | ||
2705 | 406 | |||
2706 | 407 | void report_notification_invisible(); | ||
2707 | 408 | }; | ||
2708 | 409 | |||
2709 | 410 | } | ||
2710 | 411 | |||
2711 | 412 | #endif // HYBRIS_APPLICATION_MANAGER_H_ | ||
2712 | 413 | 0 | ||
2713 | === removed file 'android/hybris/default_application_manager.cpp' | |||
2714 | --- android/hybris/default_application_manager.cpp 2014-01-22 05:28:18 +0000 | |||
2715 | +++ android/hybris/default_application_manager.cpp 1970-01-01 00:00:00 +0000 | |||
2716 | @@ -1,1257 +0,0 @@ | |||
2717 | 1 | /* | ||
2718 | 2 | * Copyright © 2012 Canonical Ltd. | ||
2719 | 3 | * | ||
2720 | 4 | * This program is free software: you can redistribute it and/or modify | ||
2721 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
2722 | 6 | * published by the Free Software Foundation. | ||
2723 | 7 | * | ||
2724 | 8 | * This program is distributed in the hope that it will be useful, | ||
2725 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2726 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2727 | 11 | * GNU Lesser General Public License for more details. | ||
2728 | 12 | * | ||
2729 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2730 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2731 | 15 | * | ||
2732 | 16 | * Authored by: Thomas Voß <thomas.voss@canonical.com> | ||
2733 | 17 | */ | ||
2734 | 18 | #undef LOG_TAG | ||
2735 | 19 | #define LOG_TAG "ubuntu::detail::ApplicationManager" | ||
2736 | 20 | |||
2737 | 21 | #include "default_application_manager.h" | ||
2738 | 22 | |||
2739 | 23 | #include "default_application_manager_input_setup.h" | ||
2740 | 24 | #include "default_application_session.h" | ||
2741 | 25 | #include "default_shell.h" | ||
2742 | 26 | |||
2743 | 27 | #include <binder/IPCThreadState.h> | ||
2744 | 28 | #include <binder/IServiceManager.h> | ||
2745 | 29 | #include <binder/ProcessState.h> | ||
2746 | 30 | |||
2747 | 31 | #include <input/InputListener.h> | ||
2748 | 32 | #include <input/InputReader.h> | ||
2749 | 33 | #if ANDROID_VERSION_MAJOR==4 && ANDROID_VERSION_MINOR<=2 | ||
2750 | 34 | #include <androidfw/InputTransport.h> | ||
2751 | 35 | #else | ||
2752 | 36 | #include <input/InputTransport.h> | ||
2753 | 37 | #endif | ||
2754 | 38 | #include <utils/threads.h> | ||
2755 | 39 | #include <utils/Errors.h> | ||
2756 | 40 | #include <utils/Timers.h> | ||
2757 | 41 | |||
2758 | 42 | #include <cstdio> | ||
2759 | 43 | #include <cstdlib> | ||
2760 | 44 | |||
2761 | 45 | #include <sys/types.h> | ||
2762 | 46 | #include <sys/wait.h> | ||
2763 | 47 | #include <signal.h> | ||
2764 | 48 | #include <fcntl.h> | ||
2765 | 49 | |||
2766 | 50 | namespace ubuntu { namespace detail | ||
2767 | 51 | { | ||
2768 | 52 | |||
2769 | 53 | template<typename T, typename U> | ||
2770 | 54 | const T& min(const T& lhs, const U& rhs) | ||
2771 | 55 | { | ||
2772 | 56 | return lhs < rhs ? lhs : rhs; | ||
2773 | 57 | } | ||
2774 | 58 | |||
2775 | 59 | /* TODO: Currently we need to map local pids to the ones of the | ||
2776 | 60 | * container where Ubuntu is running as sessions need to be | ||
2777 | 61 | * referenced to observers in terms of the said namespace. | ||
2778 | 62 | */ | ||
2779 | 63 | pid_t pid_to_vpid(int pid) | ||
2780 | 64 | { | ||
2781 | 65 | ALOGI("%s(%d)", __PRETTY_FUNCTION__, pid); | ||
2782 | 66 | |||
2783 | 67 | if (pid <= 0) | ||
2784 | 68 | return -1; | ||
2785 | 69 | |||
2786 | 70 | char proc_name[128], buf[1024]; | ||
2787 | 71 | char *rpid; | ||
2788 | 72 | char key[] = "Vpid:"; | ||
2789 | 73 | |||
2790 | 74 | sprintf(proc_name, "/proc/%d/status", pid); | ||
2791 | 75 | |||
2792 | 76 | int fd; | ||
2793 | 77 | |||
2794 | 78 | fd = open(proc_name, O_RDONLY); | ||
2795 | 79 | if (fd < 0) | ||
2796 | 80 | { | ||
2797 | 81 | ALOGI("%s(): Cannot find %s\n", __PRETTY_FUNCTION__, proc_name); | ||
2798 | 82 | return -1; | ||
2799 | 83 | } | ||
2800 | 84 | |||
2801 | 85 | memset(buf, '\0', sizeof(buf)); | ||
2802 | 86 | read(fd, buf, sizeof(buf)); | ||
2803 | 87 | rpid = strstr(buf, key); | ||
2804 | 88 | |||
2805 | 89 | close(fd); | ||
2806 | 90 | |||
2807 | 91 | if (rpid == NULL) | ||
2808 | 92 | { | ||
2809 | 93 | ALOGI("%s(): Vpid not supported\n", __PRETTY_FUNCTION__); | ||
2810 | 94 | return pid; | ||
2811 | 95 | } | ||
2812 | 96 | |||
2813 | 97 | return atoi(rpid+sizeof(key)); | ||
2814 | 98 | } | ||
2815 | 99 | |||
2816 | 100 | bool is_session_allowed_to_run_in_background( | ||
2817 | 101 | const android::sp<ubuntu::detail::ApplicationSession>& session) | ||
2818 | 102 | { | ||
2819 | 103 | ALOGI("%s: %s", __PRETTY_FUNCTION__, session->desktop_file.string()); | ||
2820 | 104 | static const android::String8 phone_app_desktop_file("/usr/share/applications/phone-app.desktop"); | ||
2821 | 105 | static const android::String8 music_app_desktop_file("/usr/share/applications/music-app.desktop"); | ||
2822 | 106 | |||
2823 | 107 | if (session->desktop_file == phone_app_desktop_file || | ||
2824 | 108 | session->desktop_file == music_app_desktop_file) | ||
2825 | 109 | { | ||
2826 | 110 | return true; | ||
2827 | 111 | } | ||
2828 | 112 | |||
2829 | 113 | return false; | ||
2830 | 114 | } | ||
2831 | 115 | |||
2832 | 116 | bool write_proc_file(pid_t pid, const char* filename, const char* value) | ||
2833 | 117 | { | ||
2834 | 118 | char proc_name[128]; | ||
2835 | 119 | sprintf(proc_name, "/proc/%d/%s", pid, filename); | ||
2836 | 120 | |||
2837 | 121 | int file; | ||
2838 | 122 | |||
2839 | 123 | if (access(proc_name, F_OK) == 0) | ||
2840 | 124 | { | ||
2841 | 125 | file = open(proc_name, O_WRONLY); | ||
2842 | 126 | write(file, value, sizeof(value)); | ||
2843 | 127 | close(file); | ||
2844 | 128 | return true; | ||
2845 | 129 | } else | ||
2846 | 130 | return false; | ||
2847 | 131 | } | ||
2848 | 132 | |||
2849 | 133 | void update_oom_values(const android::sp<ubuntu::detail::ApplicationSession>& session) | ||
2850 | 134 | { | ||
2851 | 135 | if (session->session_type == ubuntu::application::ui::system_session_type) | ||
2852 | 136 | { | ||
2853 | 137 | if (!write_proc_file(session->pid, "oom_score_adj", "-940")) | ||
2854 | 138 | write_proc_file(session->pid, "oom_adj", "-16"); | ||
2855 | 139 | return; | ||
2856 | 140 | } | ||
2857 | 141 | |||
2858 | 142 | if (session->running_state == ubuntu::application::ui::process_suspended) | ||
2859 | 143 | { | ||
2860 | 144 | if (!write_proc_file(session->pid, "oom_score_adj", "1000")) | ||
2861 | 145 | write_proc_file(session->pid, "oom_adj", "15"); | ||
2862 | 146 | } else | ||
2863 | 147 | { | ||
2864 | 148 | if (!write_proc_file(session->pid, "oom_score_adj", "0")) | ||
2865 | 149 | write_proc_file(session->pid, "oom_adj", "0"); | ||
2866 | 150 | } | ||
2867 | 151 | } | ||
2868 | 152 | |||
2869 | 153 | template<int x, int y, int w, int h> | ||
2870 | 154 | int ApplicationManager::ShellInputSetup::Window<x, y, w, h>::looper_callback(int receiveFd, int events, void* ctxt) | ||
2871 | 155 | { | ||
2872 | 156 | // ALOGI("%s", __PRETTY_FUNCTION__); | ||
2873 | 157 | |||
2874 | 158 | bool result = true; | ||
2875 | 159 | ApplicationManager::ShellInputSetup::Window<x, y, w, h>* window = static_cast<ApplicationManager::ShellInputSetup::Window<x, y, w, h>*>(ctxt); | ||
2876 | 160 | |||
2877 | 161 | //window->input_consumer.receiveDispatchSignal(); | ||
2878 | 162 | uint32_t seq; | ||
2879 | 163 | android::InputEvent* ev; | ||
2880 | 164 | static const bool consume_batches = true; | ||
2881 | 165 | static const nsecs_t frame_time = -1; | ||
2882 | 166 | switch(window->input_consumer.consume(&window->event_factory, consume_batches, frame_time, &seq, &ev)) | ||
2883 | 167 | { | ||
2884 | 168 | case android::OK: | ||
2885 | 169 | result = true; | ||
2886 | 170 | //printf("We have a client side event for process %d. \n", getpid()); | ||
2887 | 171 | window->input_consumer.sendFinishedSignal(seq, result); | ||
2888 | 172 | break; | ||
2889 | 173 | case android::INVALID_OPERATION: | ||
2890 | 174 | result = true; | ||
2891 | 175 | break; | ||
2892 | 176 | case android::NO_MEMORY: | ||
2893 | 177 | result = true; | ||
2894 | 178 | break; | ||
2895 | 179 | } | ||
2896 | 180 | |||
2897 | 181 | return result ? 1 : 0; | ||
2898 | 182 | } | ||
2899 | 183 | |||
2900 | 184 | template<int x, int y, int w, int h> | ||
2901 | 185 | ApplicationManager::ShellInputSetup::Window<x, y, w, h>::Window( | ||
2902 | 186 | ApplicationManager::ShellInputSetup* parent, | ||
2903 | 187 | int _x, | ||
2904 | 188 | int _y, | ||
2905 | 189 | int _w, | ||
2906 | 190 | int _h) : parent(parent), | ||
2907 | 191 | input_consumer(client_channel) | ||
2908 | 192 | { | ||
2909 | 193 | auto window = new android::InputSetup::DummyApplicationWindow( | ||
2910 | 194 | parent->shell_application, | ||
2911 | 195 | _x, | ||
2912 | 196 | _y, | ||
2913 | 197 | _w, | ||
2914 | 198 | _h); | ||
2915 | 199 | |||
2916 | 200 | android::InputChannel::openInputChannelPair( | ||
2917 | 201 | android::String8("DummyShellInputChannel"), | ||
2918 | 202 | server_channel, | ||
2919 | 203 | client_channel); | ||
2920 | 204 | |||
2921 | 205 | window->input_channel = server_channel; | ||
2922 | 206 | input_window = window; | ||
2923 | 207 | |||
2924 | 208 | parent->input_manager->getDispatcher()->registerInputChannel( | ||
2925 | 209 | window->input_channel, | ||
2926 | 210 | input_window, | ||
2927 | 211 | false); | ||
2928 | 212 | |||
2929 | 213 | input_consumer = android::InputConsumer(client_channel); | ||
2930 | 214 | |||
2931 | 215 | // input_consumer.initialize(); | ||
2932 | 216 | parent->looper->addFd(client_channel->getFd(), //client_channel->getReceivePipeFd(), | ||
2933 | 217 | 0, | ||
2934 | 218 | ALOOPER_EVENT_INPUT, | ||
2935 | 219 | looper_callback, | ||
2936 | 220 | this); | ||
2937 | 221 | } | ||
2938 | 222 | |||
2939 | 223 | ApplicationManager::ShellInputSetup::DisplayInfo::DisplayInfo() | ||
2940 | 224 | { | ||
2941 | 225 | auto display = android::SurfaceComposerClient::getBuiltInDisplay( | ||
2942 | 226 | android::ISurfaceComposer::eDisplayIdMain); | ||
2943 | 227 | |||
2944 | 228 | android::SurfaceComposerClient::getDisplayInfo( | ||
2945 | 229 | display, | ||
2946 | 230 | &info); | ||
2947 | 231 | } | ||
2948 | 232 | |||
2949 | 233 | ApplicationManager::ShellInputSetup::ShellInputSetup(const android::sp<android::InputManager>& input_manager) | ||
2950 | 234 | : shell_has_focus(true), | ||
2951 | 235 | input_manager(input_manager), | ||
2952 | 236 | shell_application(new android::InputSetup::DummyApplication()), | ||
2953 | 237 | looper(new android::Looper(true)), | ||
2954 | 238 | event_loop(looper), | ||
2955 | 239 | event_trap_window(this, 0, 0, display_info.info.w, display_info.info.h), | ||
2956 | 240 | osk_window(this), | ||
2957 | 241 | notifications_window(this) | ||
2958 | 242 | { | ||
2959 | 243 | event_loop.run(); | ||
2960 | 244 | } | ||
2961 | 245 | |||
2962 | 246 | ApplicationManager::InputFilter::InputFilter(ApplicationManager* manager) : manager(manager) | ||
2963 | 247 | { | ||
2964 | 248 | } | ||
2965 | 249 | |||
2966 | 250 | bool ApplicationManager::InputFilter::filter_event(const android::InputEvent* event) | ||
2967 | 251 | { | ||
2968 | 252 | bool result = true; | ||
2969 | 253 | |||
2970 | 254 | switch (event->getType()) | ||
2971 | 255 | { | ||
2972 | 256 | case AINPUT_EVENT_TYPE_KEY: | ||
2973 | 257 | result = handle_key_event(static_cast<const android::KeyEvent*>(event)); | ||
2974 | 258 | break; | ||
2975 | 259 | } | ||
2976 | 260 | |||
2977 | 261 | return result; | ||
2978 | 262 | } | ||
2979 | 263 | |||
2980 | 264 | bool ApplicationManager::InputFilter::handle_key_event(const android::KeyEvent* event) | ||
2981 | 265 | { | ||
2982 | 266 | bool result = true; | ||
2983 | 267 | |||
2984 | 268 | return result; | ||
2985 | 269 | } | ||
2986 | 270 | |||
2987 | 271 | ApplicationManager::LockingIterator::LockingIterator( | ||
2988 | 272 | ApplicationManager* manager, | ||
2989 | 273 | size_t index) : manager(manager), | ||
2990 | 274 | it(index) | ||
2991 | 275 | { | ||
2992 | 276 | } | ||
2993 | 277 | |||
2994 | 278 | void ApplicationManager::LockingIterator::advance() | ||
2995 | 279 | { | ||
2996 | 280 | it += 1; | ||
2997 | 281 | } | ||
2998 | 282 | |||
2999 | 283 | bool ApplicationManager::LockingIterator::is_valid() const | ||
3000 | 284 | { | ||
3001 | 285 | return it < manager->apps.size(); | ||
3002 | 286 | } | ||
3003 | 287 | |||
3004 | 288 | void ApplicationManager::LockingIterator::make_current() | ||
3005 | 289 | { | ||
3006 | 290 | //printf("%s \n", __PRETTY_FUNCTION__); | ||
3007 | 291 | } | ||
3008 | 292 | |||
3009 | 293 | const android::sp<ubuntu::detail::ApplicationSession>& ApplicationManager::LockingIterator::operator*() | ||
3010 | 294 | { | ||
3011 | 295 | return manager->apps.valueFor(manager->apps_as_added[it]); | ||
3012 | 296 | } | ||
3013 | 297 | |||
3014 | 298 | ApplicationManager::LockingIterator::~LockingIterator() | ||
3015 | 299 | { | ||
3016 | 300 | manager->unlock(); | ||
3017 | 301 | } | ||
3018 | 302 | |||
3019 | 303 | ApplicationManager::ApplicationManager() : input_filter(new InputFilter(this)), | ||
3020 | 304 | input_setup(new android::InputSetup(input_filter)), | ||
3021 | 305 | is_osk_visible(false), | ||
3022 | 306 | are_notifications_visible(false), | ||
3023 | 307 | app_manager_task_controller(NULL), | ||
3024 | 308 | focused_application(0), | ||
3025 | 309 | side_stage_application(0), | ||
3026 | 310 | main_stage_application(0) | ||
3027 | 311 | { | ||
3028 | 312 | shell_input_setup = new ShellInputSetup(input_setup->input_manager); | ||
3029 | 313 | |||
3030 | 314 | input_setup->input_manager->getDispatcher()->setFocusedApplication( | ||
3031 | 315 | shell_input_setup->shell_application); | ||
3032 | 316 | |||
3033 | 317 | android::Vector< android::sp<android::InputWindowHandle> > input_windows; | ||
3034 | 318 | input_windows.push(shell_input_setup->event_trap_window.input_window); | ||
3035 | 319 | input_setup->input_manager->getDispatcher()->setInputWindows( | ||
3036 | 320 | input_windows); | ||
3037 | 321 | |||
3038 | 322 | input_setup->start(); | ||
3039 | 323 | } | ||
3040 | 324 | |||
3041 | 325 | void ApplicationManager::update_app_lists() | ||
3042 | 326 | { | ||
3043 | 327 | int idx; | ||
3044 | 328 | |||
3045 | 329 | for (idx = apps_as_added.size()-1; idx >= 0; idx--) | ||
3046 | 330 | { | ||
3047 | 331 | const android::sp<ubuntu::detail::ApplicationSession>& session = | ||
3048 | 332 | apps.valueFor(apps_as_added[idx]); | ||
3049 | 333 | |||
3050 | 334 | if (session->session_type == ubuntu::application::ui::system_session_type) | ||
3051 | 335 | continue; | ||
3052 | 336 | |||
3053 | 337 | if (session->stage_hint == ubuntu::application::ui::side_stage) | ||
3054 | 338 | { | ||
3055 | 339 | side_stage_application = idx; | ||
3056 | 340 | break; | ||
3057 | 341 | } | ||
3058 | 342 | } | ||
3059 | 343 | |||
3060 | 344 | if (idx < 0) | ||
3061 | 345 | side_stage_application = 0; | ||
3062 | 346 | |||
3063 | 347 | for (idx = apps_as_added.size()-1; idx >= 0; idx--) | ||
3064 | 348 | { | ||
3065 | 349 | const android::sp<ubuntu::detail::ApplicationSession>& session = | ||
3066 | 350 | apps.valueFor(apps_as_added[idx]); | ||
3067 | 351 | |||
3068 | 352 | if (session->session_type == ubuntu::application::ui::system_session_type) | ||
3069 | 353 | continue; | ||
3070 | 354 | |||
3071 | 355 | if (session->stage_hint == ubuntu::application::ui::main_stage) | ||
3072 | 356 | { | ||
3073 | 357 | main_stage_application = idx; | ||
3074 | 358 | break; | ||
3075 | 359 | } | ||
3076 | 360 | } | ||
3077 | 361 | |||
3078 | 362 | if (idx < 0) | ||
3079 | 363 | main_stage_application = 0; | ||
3080 | 364 | } | ||
3081 | 365 | |||
3082 | 366 | // From DeathRecipient | ||
3083 | 367 | void ApplicationManager::binderDied(const android::wp<android::IBinder>& who) | ||
3084 | 368 | { | ||
3085 | 369 | android::Mutex::Autolock al(guard); | ||
3086 | 370 | android::sp<android::IBinder> sp = who.promote(); | ||
3087 | 371 | |||
3088 | 372 | ALOGI("%s():%d\n", __PRETTY_FUNCTION__, __LINE__); | ||
3089 | 373 | |||
3090 | 374 | const android::sp<ubuntu::detail::ApplicationSession>& dead_session = apps.valueFor(sp); | ||
3091 | 375 | |||
3092 | 376 | ALOGI("%s():%d -- remote_pid=%d desktop_file=%s\n", __PRETTY_FUNCTION__, __LINE__, | ||
3093 | 377 | dead_session->remote_pid, | ||
3094 | 378 | dead_session->desktop_file.string()); | ||
3095 | 379 | |||
3096 | 380 | notify_observers_about_session_died(dead_session->remote_pid, | ||
3097 | 381 | dead_session->stage_hint, | ||
3098 | 382 | dead_session->desktop_file); | ||
3099 | 383 | |||
3100 | 384 | ALOGI("%s():%d\n", __PRETTY_FUNCTION__, __LINE__); | ||
3101 | 385 | size_t i = 0; | ||
3102 | 386 | for(i = 0; i < apps_as_added.size(); i++) | ||
3103 | 387 | if (apps_as_added[i] == sp) | ||
3104 | 388 | break; | ||
3105 | 389 | |||
3106 | 390 | ALOGI("%s():%d\n", __PRETTY_FUNCTION__, __LINE__); | ||
3107 | 391 | size_t next_focused_app = 0; | ||
3108 | 392 | next_focused_app = apps_as_added.removeAt(i); | ||
3109 | 393 | |||
3110 | 394 | ALOGI("%s():%d\n", __PRETTY_FUNCTION__, __LINE__); | ||
3111 | 395 | next_focused_app = main_stage_application; | ||
3112 | 396 | update_app_lists(); | ||
3113 | 397 | |||
3114 | 398 | ALOGI("%s():%d\n", __PRETTY_FUNCTION__, __LINE__); | ||
3115 | 399 | if (dead_session->stage_hint == ubuntu::application::ui::side_stage) | ||
3116 | 400 | next_focused_app = side_stage_application ? side_stage_application : next_focused_app; | ||
3117 | 401 | |||
3118 | 402 | ALOGI("%s():%d\n", __PRETTY_FUNCTION__, __LINE__); | ||
3119 | 403 | if (dead_session->stage_hint == ubuntu::application::ui::main_stage) | ||
3120 | 404 | next_focused_app = main_stage_application; | ||
3121 | 405 | |||
3122 | 406 | ALOGI("%s():%d\n", __PRETTY_FUNCTION__, __LINE__); | ||
3123 | 407 | if (i && i == focused_application && | ||
3124 | 408 | shell_input_setup->shell_has_focus == false) | ||
3125 | 409 | { | ||
3126 | 410 | switch_focused_application_locked(next_focused_app); | ||
3127 | 411 | } | ||
3128 | 412 | else if(focused_application > i) | ||
3129 | 413 | focused_application--; | ||
3130 | 414 | |||
3131 | 415 | if (i == 0) | ||
3132 | 416 | { | ||
3133 | 417 | shell_input_setup->trap_windows.clear(); | ||
3134 | 418 | shell_input_setup->shell_has_focus = true; | ||
3135 | 419 | } | ||
3136 | 420 | |||
3137 | 421 | ALOGI("%s():%d\n", __PRETTY_FUNCTION__, __LINE__); | ||
3138 | 422 | apps.removeItem(sp); | ||
3139 | 423 | ALOGI("%s():%d\n", __PRETTY_FUNCTION__, __LINE__); | ||
3140 | 424 | } | ||
3141 | 425 | |||
3142 | 426 | void ApplicationManager::lock() | ||
3143 | 427 | { | ||
3144 | 428 | guard.lock(); | ||
3145 | 429 | } | ||
3146 | 430 | |||
3147 | 431 | void ApplicationManager::unlock() | ||
3148 | 432 | { | ||
3149 | 433 | guard.unlock(); | ||
3150 | 434 | } | ||
3151 | 435 | |||
3152 | 436 | android::sp<ApplicationManager::LockingIterator> ApplicationManager::iterator() | ||
3153 | 437 | { | ||
3154 | 438 | lock(); | ||
3155 | 439 | android::sp<ApplicationManager::LockingIterator> it( | ||
3156 | 440 | new ApplicationManager::LockingIterator(this, 0)); | ||
3157 | 441 | |||
3158 | 442 | return it; | ||
3159 | 443 | } | ||
3160 | 444 | |||
3161 | 445 | void ApplicationManager::session_set_state(const android::sp<ubuntu::detail::ApplicationSession>& as, | ||
3162 | 446 | int32_t new_state) | ||
3163 | 447 | { | ||
3164 | 448 | ALOGI("%s():%d running->running", __PRETTY_FUNCTION__, __LINE__); | ||
3165 | 449 | |||
3166 | 450 | switch (new_state) | ||
3167 | 451 | { | ||
3168 | 452 | case ubuntu::application::ui::process_running: | ||
3169 | 453 | { | ||
3170 | 454 | if (as->running_state == ubuntu::application::ui::process_running) | ||
3171 | 455 | { | ||
3172 | 456 | ALOGI("%s():%d running->running", __PRETTY_FUNCTION__, __LINE__); | ||
3173 | 457 | /* FIXME: | ||
3174 | 458 | * Technically invalid, this transition currently is hit because | ||
3175 | 459 | * of focus being requested on the session before its delagate call | ||
3176 | 460 | */ | ||
3177 | 461 | } else if (as->running_state == ubuntu::application::ui::process_destroyed) | ||
3178 | 462 | { | ||
3179 | 463 | ALOGI("%s():%d destroyed->running", __PRETTY_FUNCTION__, __LINE__); | ||
3180 | 464 | /* TODO: | ||
3181 | 465 | * Resume application with a null archive handler | ||
3182 | 466 | */ | ||
3183 | 467 | } else if (as->running_state == ubuntu::application::ui::process_stopped) | ||
3184 | 468 | { | ||
3185 | 469 | ALOGI("%s():%d stopped->running", __PRETTY_FUNCTION__, __LINE__); | ||
3186 | 470 | /* TODO: | ||
3187 | 471 | * Support starting the new process and wait for the | ||
3188 | 472 | * session to be available to call its delegate | ||
3189 | 473 | */ | ||
3190 | 474 | return; | ||
3191 | 475 | } else | ||
3192 | 476 | { | ||
3193 | 477 | /* suspended->running | ||
3194 | 478 | * nothing to do, process image still in memory | ||
3195 | 479 | */ | ||
3196 | 480 | if (app_manager_task_controller != NULL) | ||
3197 | 481 | app_manager_task_controller->continue_task(as->remote_pid); | ||
3198 | 482 | else | ||
3199 | 483 | kill(as->pid, SIGCONT); | ||
3200 | 484 | } | ||
3201 | 485 | as->running_state = ubuntu::application::ui::process_running; | ||
3202 | 486 | as->on_application_resumed(); | ||
3203 | 487 | update_oom_values(as); | ||
3204 | 488 | } | ||
3205 | 489 | break; | ||
3206 | 490 | case ubuntu::application::ui::process_suspended: | ||
3207 | 491 | { | ||
3208 | 492 | ALOGI("%s() state->suspended", __PRETTY_FUNCTION__); | ||
3209 | 493 | /* TODO: create archive */ | ||
3210 | 494 | as->on_application_about_to_stop(); | ||
3211 | 495 | as->running_state = ubuntu::application::ui::process_suspended; | ||
3212 | 496 | android::sp<android::Thread> deferred_kill(new ubuntu::application::ProcessKiller(as, app_manager_task_controller)); | ||
3213 | 497 | deferred_kill->run(); | ||
3214 | 498 | update_oom_values(as); | ||
3215 | 499 | } | ||
3216 | 500 | break; | ||
3217 | 501 | case ubuntu::application::ui::process_stopped: | ||
3218 | 502 | { | ||
3219 | 503 | ALOGI("%s() state->stopped", __PRETTY_FUNCTION__); | ||
3220 | 504 | /* TODO: | ||
3221 | 505 | * This transition occurs while SIGSTOP'd. Check we hold a valid archive | ||
3222 | 506 | * and then destroy the process image. No need to signal via delegates. | ||
3223 | 507 | */ | ||
3224 | 508 | as->running_state = ubuntu::application::ui::process_stopped; | ||
3225 | 509 | } | ||
3226 | 510 | break; | ||
3227 | 511 | case ubuntu::application::ui::process_destroyed: | ||
3228 | 512 | { | ||
3229 | 513 | ALOGI("%s() state->destroyed", __PRETTY_FUNCTION__); | ||
3230 | 514 | /* TODO: | ||
3231 | 515 | * Internal transition: Invalidate archive if any, destroy | ||
3232 | 516 | * process image. | ||
3233 | 517 | */ | ||
3234 | 518 | as->running_state = ubuntu::application::ui::process_destroyed; | ||
3235 | 519 | } | ||
3236 | 520 | break; | ||
3237 | 521 | } | ||
3238 | 522 | } | ||
3239 | 523 | |||
3240 | 524 | void ApplicationManager::start_a_new_session( | ||
3241 | 525 | int32_t session_type, | ||
3242 | 526 | int32_t stage_hint, | ||
3243 | 527 | const android::String8& app_name, | ||
3244 | 528 | const android::String8& desktop_file, | ||
3245 | 529 | const android::sp<android::IApplicationManagerSession>& session, | ||
3246 | 530 | int fd, | ||
3247 | 531 | uint32_t remote_pid) | ||
3248 | 532 | { | ||
3249 | 533 | android::Mutex::Autolock al(guard); | ||
3250 | 534 | (void) session_type; | ||
3251 | 535 | pid_t pid = android::IPCThreadState::self()->getCallingPid(); | ||
3252 | 536 | |||
3253 | 537 | pid_t rpid; | ||
3254 | 538 | if (!remote_pid) | ||
3255 | 539 | { | ||
3256 | 540 | ALOGI("%s() no remote_pid set from client, lookup in proc", __PRETTY_FUNCTION__); | ||
3257 | 541 | rpid = pid_to_vpid(pid); | ||
3258 | 542 | } | ||
3259 | 543 | else | ||
3260 | 544 | { | ||
3261 | 545 | ALOGI("%s() remote_pid=%d", __PRETTY_FUNCTION__, remote_pid); | ||
3262 | 546 | rpid = static_cast<pid_t>(remote_pid); | ||
3263 | 547 | } | ||
3264 | 548 | |||
3265 | 549 | ALOGI("%s() starting new session pid=%d rpid=%d", __PRETTY_FUNCTION__, pid, rpid); | ||
3266 | 550 | |||
3267 | 551 | android::sp<ubuntu::detail::ApplicationSession> app_session( | ||
3268 | 552 | new ubuntu::detail::ApplicationSession( | ||
3269 | 553 | pid, | ||
3270 | 554 | rpid, | ||
3271 | 555 | session, | ||
3272 | 556 | session_type, | ||
3273 | 557 | stage_hint, | ||
3274 | 558 | app_name, | ||
3275 | 559 | desktop_file)); | ||
3276 | 560 | |||
3277 | 561 | apps.add(session->asBinder(), app_session); | ||
3278 | 562 | apps_as_added.push_back(session->asBinder()); | ||
3279 | 563 | |||
3280 | 564 | session->asBinder()->linkToDeath( | ||
3281 | 565 | android::sp<android::IBinder::DeathRecipient>(this)); | ||
3282 | 566 | |||
3283 | 567 | switch(session_type) | ||
3284 | 568 | { | ||
3285 | 569 | case ubuntu::application::ui::user_session_type: | ||
3286 | 570 | ALOGI("%s: Invoked for user_session_type \n", __PRETTY_FUNCTION__); | ||
3287 | 571 | break; | ||
3288 | 572 | case ubuntu::application::ui::system_session_type: | ||
3289 | 573 | ALOGI("%s: Invoked for system_session_type \n", __PRETTY_FUNCTION__); | ||
3290 | 574 | break; | ||
3291 | 575 | } | ||
3292 | 576 | |||
3293 | 577 | notify_observers_about_session_born(app_session->remote_pid, | ||
3294 | 578 | app_session->stage_hint, | ||
3295 | 579 | app_session->desktop_file); | ||
3296 | 580 | |||
3297 | 581 | ALOGI("%s():%d session", __PRETTY_FUNCTION__, __LINE__); | ||
3298 | 582 | } | ||
3299 | 583 | |||
3300 | 584 | void ApplicationManager::register_a_surface( | ||
3301 | 585 | const android::String8& title, | ||
3302 | 586 | const android::sp<android::IApplicationManagerSession>& session, | ||
3303 | 587 | int32_t surface_role, | ||
3304 | 588 | int32_t token, | ||
3305 | 589 | int fd) | ||
3306 | 590 | { | ||
3307 | 591 | android::Mutex::Autolock al(guard); | ||
3308 | 592 | android::sp<android::InputChannel> input_channel( | ||
3309 | 593 | new android::InputChannel( | ||
3310 | 594 | title, | ||
3311 | 595 | dup(fd))); | ||
3312 | 596 | |||
3313 | 597 | android::sp<ubuntu::detail::ApplicationSession::Surface> surface( | ||
3314 | 598 | new ubuntu::detail::ApplicationSession::Surface( | ||
3315 | 599 | apps.valueFor(session->asBinder()).get(), | ||
3316 | 600 | input_channel, | ||
3317 | 601 | surface_role, | ||
3318 | 602 | token)); | ||
3319 | 603 | |||
3320 | 604 | auto registered_session = apps.valueFor(session->asBinder()); | ||
3321 | 605 | |||
3322 | 606 | ALOGI("Registering input channel as observer: %s", | ||
3323 | 607 | registered_session->session_type == ubuntu::application::ui::system_session_type ? "true" : "false"); | ||
3324 | 608 | |||
3325 | 609 | input_setup->input_manager->getDispatcher()->registerInputChannel( | ||
3326 | 610 | surface->input_channel, | ||
3327 | 611 | surface->make_input_window_handle(), | ||
3328 | 612 | registered_session->session_type == ubuntu::application::ui::system_session_type); | ||
3329 | 613 | |||
3330 | 614 | registered_session->register_surface(surface); | ||
3331 | 615 | |||
3332 | 616 | if (registered_session->session_type == ubuntu::application::ui::system_session_type) | ||
3333 | 617 | { | ||
3334 | 618 | ALOGI("New surface for system session, adjusting layer now."); | ||
3335 | 619 | switch(surface_role) | ||
3336 | 620 | { | ||
3337 | 621 | case ubuntu::application::ui::dash_actor_role: | ||
3338 | 622 | registered_session->raise_surface_to_layer(token, default_dash_layer); | ||
3339 | 623 | break; | ||
3340 | 624 | case ubuntu::application::ui::indicator_actor_role: | ||
3341 | 625 | registered_session->raise_surface_to_layer(token, default_indicator_layer); | ||
3342 | 626 | break; | ||
3343 | 627 | case ubuntu::application::ui::notifications_actor_role: | ||
3344 | 628 | registered_session->raise_surface_to_layer(token, default_notifications_layer); | ||
3345 | 629 | break; | ||
3346 | 630 | case ubuntu::application::ui::greeter_actor_role: | ||
3347 | 631 | registered_session->raise_surface_to_layer(token, default_greeter_layer); | ||
3348 | 632 | break; | ||
3349 | 633 | case ubuntu::application::ui::launcher_actor_role: | ||
3350 | 634 | registered_session->raise_surface_to_layer(token, default_launcher_layer); | ||
3351 | 635 | break; | ||
3352 | 636 | case ubuntu::application::ui::on_screen_keyboard_actor_role: | ||
3353 | 637 | registered_session->raise_surface_to_layer(token, default_osk_layer); | ||
3354 | 638 | break; | ||
3355 | 639 | case ubuntu::application::ui::shutdown_dialog_actor_role: | ||
3356 | 640 | registered_session->raise_surface_to_layer(token, default_shutdown_dialog_layer); | ||
3357 | 641 | break; | ||
3358 | 642 | } | ||
3359 | 643 | } | ||
3360 | 644 | } | ||
3361 | 645 | |||
3362 | 646 | void ApplicationManager::request_fullscreen(const android::sp<android::IApplicationManagerSession>& session) | ||
3363 | 647 | { | ||
3364 | 648 | ALOGI("%s", __PRETTY_FUNCTION__); | ||
3365 | 649 | android::Mutex::Autolock al(guard); | ||
3366 | 650 | |||
3367 | 651 | const android::sp<ubuntu::detail::ApplicationSession>& as = | ||
3368 | 652 | apps.valueFor(session->asBinder()); | ||
3369 | 653 | |||
3370 | 654 | notify_observers_about_session_requested_fullscreen( | ||
3371 | 655 | as->remote_pid, | ||
3372 | 656 | as->stage_hint, | ||
3373 | 657 | as->desktop_file); | ||
3374 | 658 | } | ||
3375 | 659 | |||
3376 | 660 | int ApplicationManager::get_session_pid(const android::sp<android::IApplicationManagerSession>& session) | ||
3377 | 661 | { | ||
3378 | 662 | ALOGI("%s", __PRETTY_FUNCTION__); | ||
3379 | 663 | android::Mutex::Autolock al(guard); | ||
3380 | 664 | |||
3381 | 665 | if (apps.indexOfKey(session->asBinder()) == android::NAME_NOT_FOUND) | ||
3382 | 666 | return 0; | ||
3383 | 667 | |||
3384 | 668 | const android::sp<ubuntu::detail::ApplicationSession>& as = | ||
3385 | 669 | apps.valueFor(session->asBinder()); | ||
3386 | 670 | |||
3387 | 671 | return as->remote_pid; | ||
3388 | 672 | } | ||
3389 | 673 | |||
3390 | 674 | void ApplicationManager::request_update_for_session(const android::sp<android::IApplicationManagerSession>& session) | ||
3391 | 675 | { | ||
3392 | 676 | ALOGI("%s", __PRETTY_FUNCTION__); | ||
3393 | 677 | android::Mutex::Autolock al(guard); | ||
3394 | 678 | |||
3395 | 679 | if (apps_as_added[focused_application] != session->asBinder()) | ||
3396 | 680 | return; | ||
3397 | 681 | |||
3398 | 682 | const android::sp<ubuntu::detail::ApplicationSession>& as = | ||
3399 | 683 | apps.valueFor(apps_as_added[focused_application]); | ||
3400 | 684 | |||
3401 | 685 | if (as->session_type == ubuntu::application::ui::system_session_type) | ||
3402 | 686 | { | ||
3403 | 687 | input_setup->input_manager->getDispatcher()->setFocusedApplication( | ||
3404 | 688 | shell_input_setup->shell_application); | ||
3405 | 689 | android::Vector< android::sp<android::InputWindowHandle> > input_windows; | ||
3406 | 690 | input_windows.push(shell_input_setup->event_trap_window.input_window); | ||
3407 | 691 | input_setup->input_manager->getDispatcher()->setInputWindows( | ||
3408 | 692 | input_windows); | ||
3409 | 693 | } else | ||
3410 | 694 | { | ||
3411 | 695 | input_setup->input_manager->getDispatcher()->setFocusedApplication( | ||
3412 | 696 | as->input_application_handle()); | ||
3413 | 697 | |||
3414 | 698 | android::Vector< android::sp<android::InputWindowHandle> > input_windows; | ||
3415 | 699 | |||
3416 | 700 | if (is_osk_visible) | ||
3417 | 701 | input_windows.push(shell_input_setup->osk_window.input_window); | ||
3418 | 702 | if (are_notifications_visible) | ||
3419 | 703 | input_windows.push(shell_input_setup->notifications_window.input_window); | ||
3420 | 704 | |||
3421 | 705 | if (!shell_input_setup->trap_windows.isEmpty()) | ||
3422 | 706 | { | ||
3423 | 707 | int key = 0; | ||
3424 | 708 | for (size_t i = 0; i < shell_input_setup->trap_windows.size(); i++) | ||
3425 | 709 | { | ||
3426 | 710 | key = shell_input_setup->trap_windows.keyAt(i); | ||
3427 | 711 | input_windows.push(shell_input_setup->trap_windows.valueFor(key)); | ||
3428 | 712 | } | ||
3429 | 713 | } | ||
3430 | 714 | |||
3431 | 715 | input_windows.appendVector(as->input_window_handles()); | ||
3432 | 716 | |||
3433 | 717 | if (as->stage_hint == ubuntu::application::ui::side_stage) | ||
3434 | 718 | { | ||
3435 | 719 | const android::sp<ubuntu::detail::ApplicationSession>& main_session = | ||
3436 | 720 | apps.valueFor(apps_as_added[main_stage_application]); | ||
3437 | 721 | input_windows.appendVector(main_session->input_window_handles()); | ||
3438 | 722 | } | ||
3439 | 723 | |||
3440 | 724 | input_setup->input_manager->getDispatcher()->setInputWindows( | ||
3441 | 725 | input_windows); | ||
3442 | 726 | } | ||
3443 | 727 | } | ||
3444 | 728 | |||
3445 | 729 | void ApplicationManager::register_task_controller( | ||
3446 | 730 | const android::sp<android::IAMTaskController>& controller) | ||
3447 | 731 | { | ||
3448 | 732 | ALOGI("%s() registering task controller", __PRETTY_FUNCTION__); | ||
3449 | 733 | |||
3450 | 734 | //TODO: Register the task controller to use it instead of sigkilling | ||
3451 | 735 | android::Mutex::Autolock al(guard); | ||
3452 | 736 | |||
3453 | 737 | if (app_manager_task_controller != NULL) | ||
3454 | 738 | return; | ||
3455 | 739 | |||
3456 | 740 | ALOGI("%s() done registering task controller", __PRETTY_FUNCTION__); | ||
3457 | 741 | |||
3458 | 742 | app_manager_task_controller = controller; | ||
3459 | 743 | } | ||
3460 | 744 | |||
3461 | 745 | void ApplicationManager::register_an_observer( | ||
3462 | 746 | const android::sp<android::IApplicationManagerObserver>& observer) | ||
3463 | 747 | { | ||
3464 | 748 | android::Mutex::Autolock al(observer_guard); | ||
3465 | 749 | app_manager_observers.push_back(observer); | ||
3466 | 750 | { | ||
3467 | 751 | android::Mutex::Autolock al(guard); | ||
3468 | 752 | |||
3469 | 753 | for(unsigned int i = 0; i < apps_as_added.size(); i++) | ||
3470 | 754 | { | ||
3471 | 755 | const android::sp<ubuntu::detail::ApplicationSession>& session = | ||
3472 | 756 | apps.valueFor(apps_as_added[i]); | ||
3473 | 757 | |||
3474 | 758 | observer->on_session_born(session->remote_pid, | ||
3475 | 759 | session->stage_hint, | ||
3476 | 760 | session->desktop_file); | ||
3477 | 761 | } | ||
3478 | 762 | |||
3479 | 763 | if (focused_application < apps_as_added.size()) | ||
3480 | 764 | { | ||
3481 | 765 | const android::sp<ubuntu::detail::ApplicationSession>& session = | ||
3482 | 766 | apps.valueFor(apps_as_added[focused_application]); | ||
3483 | 767 | |||
3484 | 768 | observer->on_session_focused(session->remote_pid, | ||
3485 | 769 | session->stage_hint, | ||
3486 | 770 | session->desktop_file); | ||
3487 | 771 | } | ||
3488 | 772 | } | ||
3489 | 773 | } | ||
3490 | 774 | |||
3491 | 775 | void ApplicationManager::focus_running_session_with_id(int id) | ||
3492 | 776 | { | ||
3493 | 777 | android::Mutex::Autolock al(guard); | ||
3494 | 778 | |||
3495 | 779 | size_t idx = session_id_to_index(id); | ||
3496 | 780 | |||
3497 | 781 | if (idx < apps_as_added.size()) | ||
3498 | 782 | { | ||
3499 | 783 | switch_focused_application_locked(idx); | ||
3500 | 784 | } | ||
3501 | 785 | } | ||
3502 | 786 | |||
3503 | 787 | void ApplicationManager::unfocus_running_sessions() | ||
3504 | 788 | { | ||
3505 | 789 | ALOGI("%s", __PRETTY_FUNCTION__); | ||
3506 | 790 | |||
3507 | 791 | android::Mutex::Autolock al(guard); | ||
3508 | 792 | |||
3509 | 793 | if (shell_input_setup->shell_has_focus) | ||
3510 | 794 | return; | ||
3511 | 795 | |||
3512 | 796 | input_setup->input_manager->getDispatcher()->setFocusedApplication( | ||
3513 | 797 | shell_input_setup->shell_application); | ||
3514 | 798 | android::Vector< android::sp<android::InputWindowHandle> > input_windows; | ||
3515 | 799 | input_windows.push(shell_input_setup->event_trap_window.input_window); | ||
3516 | 800 | input_setup->input_manager->getDispatcher()->setInputWindows( | ||
3517 | 801 | input_windows); | ||
3518 | 802 | |||
3519 | 803 | if (focused_application < apps.size()) | ||
3520 | 804 | { | ||
3521 | 805 | const android::sp<ubuntu::detail::ApplicationSession>& session = | ||
3522 | 806 | apps.valueFor(apps_as_added[focused_application]); | ||
3523 | 807 | |||
3524 | 808 | if (session->session_type != ubuntu::application::ui::system_session_type) | ||
3525 | 809 | { | ||
3526 | 810 | notify_observers_about_session_unfocused(session->remote_pid, | ||
3527 | 811 | session->stage_hint, | ||
3528 | 812 | session->desktop_file); | ||
3529 | 813 | |||
3530 | 814 | if (!is_session_allowed_to_run_in_background(session)) | ||
3531 | 815 | session_set_state(session, ubuntu::application::ui::process_suspended); | ||
3532 | 816 | } | ||
3533 | 817 | } | ||
3534 | 818 | shell_input_setup->shell_has_focus = true; | ||
3535 | 819 | } | ||
3536 | 820 | |||
3537 | 821 | int32_t ApplicationManager::query_snapshot_layer_for_session_with_id(int id) | ||
3538 | 822 | { | ||
3539 | 823 | size_t idx = session_id_to_index(id); | ||
3540 | 824 | |||
3541 | 825 | if (idx < apps_as_added.size()) | ||
3542 | 826 | { | ||
3543 | 827 | return apps.valueFor(apps_as_added[idx])->layer(); | ||
3544 | 828 | } | ||
3545 | 829 | |||
3546 | 830 | return INT_MAX; | ||
3547 | 831 | } | ||
3548 | 832 | |||
3549 | 833 | android::IApplicationManagerSession::SurfaceProperties ApplicationManager::query_surface_properties_for_session_id(int id) | ||
3550 | 834 | { | ||
3551 | 835 | android::Mutex::Autolock al(guard); | ||
3552 | 836 | |||
3553 | 837 | size_t idx = session_id_to_index(id); | ||
3554 | 838 | android::IApplicationManagerSession::SurfaceProperties props; | ||
3555 | 839 | int status; | ||
3556 | 840 | |||
3557 | 841 | if (idx < apps_as_added.size()) | ||
3558 | 842 | { | ||
3559 | 843 | const android::sp<ubuntu::detail::ApplicationSession>& session = | ||
3560 | 844 | apps.valueFor(apps_as_added[idx]); | ||
3561 | 845 | |||
3562 | 846 | if (session->running_state == ubuntu::application::ui::process_suspended) | ||
3563 | 847 | { | ||
3564 | 848 | kill(session->pid, SIGCONT); | ||
3565 | 849 | props = session->query_properties(); | ||
3566 | 850 | kill(session->pid, SIGSTOP); | ||
3567 | 851 | } else { | ||
3568 | 852 | props = session->query_properties(); | ||
3569 | 853 | } | ||
3570 | 854 | |||
3571 | 855 | return props; | ||
3572 | 856 | } | ||
3573 | 857 | |||
3574 | 858 | return android::IApplicationManagerSession::SurfaceProperties(); | ||
3575 | 859 | } | ||
3576 | 860 | |||
3577 | 861 | void ApplicationManager::switch_to_well_known_application(int32_t app) | ||
3578 | 862 | { | ||
3579 | 863 | notify_observers_about_session_requested(app); | ||
3580 | 864 | } | ||
3581 | 865 | |||
3582 | 866 | int32_t ApplicationManager::set_surface_trap(int x, int y, int width, int height) | ||
3583 | 867 | { | ||
3584 | 868 | static int32_t key = 0; | ||
3585 | 869 | |||
3586 | 870 | ApplicationManager::ShellInputSetup::Window<0, 0, 2048, 2048>* w = | ||
3587 | 871 | new ApplicationManager::ShellInputSetup::Window<0, 0, 2048, 2048>(shell_input_setup.get(), x, y, width, height); | ||
3588 | 872 | |||
3589 | 873 | key++; | ||
3590 | 874 | shell_input_setup->trap_windows.add(key, w->input_window); | ||
3591 | 875 | |||
3592 | 876 | update_input_setup_locked(); | ||
3593 | 877 | |||
3594 | 878 | return key; | ||
3595 | 879 | } | ||
3596 | 880 | |||
3597 | 881 | void ApplicationManager::unset_surface_trap(int32_t handle) | ||
3598 | 882 | { | ||
3599 | 883 | shell_input_setup->trap_windows.removeItem(handle); | ||
3600 | 884 | |||
3601 | 885 | update_input_setup_locked(); | ||
3602 | 886 | } | ||
3603 | 887 | |||
3604 | 888 | void ApplicationManager::report_osk_visible(int32_t x, int32_t y, int32_t width, int32_t height) | ||
3605 | 889 | { | ||
3606 | 890 | ALOGI("%s(x=%d, y=%d, width=%d, height=%d)", __PRETTY_FUNCTION__, x, y, width, height); | ||
3607 | 891 | |||
3608 | 892 | shell_input_setup->osk_window.input_window->x = x; | ||
3609 | 893 | shell_input_setup->osk_window.input_window->y = y; | ||
3610 | 894 | shell_input_setup->osk_window.input_window->w = width; | ||
3611 | 895 | shell_input_setup->osk_window.input_window->h = height; | ||
3612 | 896 | |||
3613 | 897 | android::Mutex::Autolock al(guard); | ||
3614 | 898 | is_osk_visible = true; | ||
3615 | 899 | |||
3616 | 900 | update_input_setup_locked(); | ||
3617 | 901 | |||
3618 | 902 | notify_observers_about_keyboard_geometry_changed(x, y, width, height); | ||
3619 | 903 | } | ||
3620 | 904 | |||
3621 | 905 | void ApplicationManager::report_osk_invisible() | ||
3622 | 906 | { | ||
3623 | 907 | ALOGI("%s", __PRETTY_FUNCTION__); | ||
3624 | 908 | android::Mutex::Autolock al(guard); | ||
3625 | 909 | is_osk_visible = false; | ||
3626 | 910 | |||
3627 | 911 | update_input_setup_locked(); | ||
3628 | 912 | |||
3629 | 913 | notify_observers_about_keyboard_geometry_changed(0, 0, 0, 0); | ||
3630 | 914 | } | ||
3631 | 915 | |||
3632 | 916 | void ApplicationManager::report_notification_visible() | ||
3633 | 917 | { | ||
3634 | 918 | ALOGI("%s", __PRETTY_FUNCTION__); | ||
3635 | 919 | android::Mutex::Autolock al(guard); | ||
3636 | 920 | are_notifications_visible = true; | ||
3637 | 921 | |||
3638 | 922 | update_input_setup_locked(); | ||
3639 | 923 | } | ||
3640 | 924 | |||
3641 | 925 | void ApplicationManager::report_notification_invisible() | ||
3642 | 926 | { | ||
3643 | 927 | ALOGI("%s", __PRETTY_FUNCTION__); | ||
3644 | 928 | android::Mutex::Autolock al(guard); | ||
3645 | 929 | are_notifications_visible = false; | ||
3646 | 930 | |||
3647 | 931 | update_input_setup_locked(); | ||
3648 | 932 | } | ||
3649 | 933 | |||
3650 | 934 | void ApplicationManager::update_input_setup_locked() | ||
3651 | 935 | { | ||
3652 | 936 | if (focused_application >= apps.size()) | ||
3653 | 937 | return; | ||
3654 | 938 | |||
3655 | 939 | const android::sp<ubuntu::detail::ApplicationSession>& session = | ||
3656 | 940 | apps.valueFor(apps_as_added[focused_application]); | ||
3657 | 941 | |||
3658 | 942 | if (shell_input_setup->shell_has_focus) | ||
3659 | 943 | { | ||
3660 | 944 | input_setup->input_manager->getDispatcher()->setFocusedApplication( | ||
3661 | 945 | shell_input_setup->shell_application); | ||
3662 | 946 | |||
3663 | 947 | android::Vector< android::sp<android::InputWindowHandle> > input_windows; | ||
3664 | 948 | input_windows.push(shell_input_setup->event_trap_window.input_window); | ||
3665 | 949 | |||
3666 | 950 | input_setup->input_manager->getDispatcher()->setInputWindows( | ||
3667 | 951 | input_windows); | ||
3668 | 952 | } else | ||
3669 | 953 | { | ||
3670 | 954 | ALOGI("Adjusting input setup to account for change in visibility of osk/notifications"); | ||
3671 | 955 | |||
3672 | 956 | input_setup->input_manager->getDispatcher()->setFocusedApplication( | ||
3673 | 957 | session->input_application_handle()); | ||
3674 | 958 | |||
3675 | 959 | android::Vector< android::sp<android::InputWindowHandle> > input_windows; | ||
3676 | 960 | if (is_osk_visible) | ||
3677 | 961 | input_windows.push(shell_input_setup->osk_window.input_window); | ||
3678 | 962 | if (are_notifications_visible) | ||
3679 | 963 | input_windows.push(shell_input_setup->notifications_window.input_window); | ||
3680 | 964 | if (!shell_input_setup->trap_windows.isEmpty()) | ||
3681 | 965 | { | ||
3682 | 966 | int key = 0; | ||
3683 | 967 | for (size_t i = 0; i < shell_input_setup->trap_windows.size(); i++) | ||
3684 | 968 | { | ||
3685 | 969 | key = shell_input_setup->trap_windows.keyAt(i); | ||
3686 | 970 | input_windows.push(shell_input_setup->trap_windows.valueFor(key)); | ||
3687 | 971 | } | ||
3688 | 972 | } | ||
3689 | 973 | |||
3690 | 974 | android::sp<android::IBinder> sb = apps_as_added[focused_application]; | ||
3691 | 975 | |||
3692 | 976 | if (sb->isBinderAlive()) | ||
3693 | 977 | input_windows.appendVector(session->input_window_handles()); | ||
3694 | 978 | |||
3695 | 979 | if (session->stage_hint == ubuntu::application::ui::side_stage) | ||
3696 | 980 | { | ||
3697 | 981 | const android::sp<ubuntu::detail::ApplicationSession>& main_session = | ||
3698 | 982 | apps.valueFor(apps_as_added[main_stage_application]); | ||
3699 | 983 | |||
3700 | 984 | android::sp<android::IBinder> msb = apps_as_added[focused_application]; | ||
3701 | 985 | if (msb->isBinderAlive()) | ||
3702 | 986 | { | ||
3703 | 987 | input_windows.appendVector(main_session->input_window_handles()); | ||
3704 | 988 | } | ||
3705 | 989 | } | ||
3706 | 990 | |||
3707 | 991 | input_setup->input_manager->getDispatcher()->setInputWindows( | ||
3708 | 992 | input_windows); | ||
3709 | 993 | } | ||
3710 | 994 | } | ||
3711 | 995 | |||
3712 | 996 | void ApplicationManager::switch_focused_application_locked(size_t index_of_next_focused_app) | ||
3713 | 997 | { | ||
3714 | 998 | static int focused_layer = 0; | ||
3715 | 999 | static const int focused_layer_increment = 10; | ||
3716 | 1000 | |||
3717 | 1001 | if (apps.size() > 1 && | ||
3718 | 1002 | focused_application < apps.size() && | ||
3719 | 1003 | focused_application < apps_as_added.size() && | ||
3720 | 1004 | focused_application != index_of_next_focused_app) | ||
3721 | 1005 | { | ||
3722 | 1006 | ALOGI("Lowering current application now for idx: %d \n", focused_application); | ||
3723 | 1007 | const android::sp<ubuntu::detail::ApplicationSession>& session = | ||
3724 | 1008 | apps.valueFor(apps_as_added[focused_application]); | ||
3725 | 1009 | |||
3726 | 1010 | const android::sp<ubuntu::detail::ApplicationSession>& next_session = | ||
3727 | 1011 | apps.valueFor(apps_as_added[index_of_next_focused_app]); | ||
3728 | 1012 | |||
3729 | 1013 | if (next_session->session_type == ubuntu::application::ui::system_session_type) | ||
3730 | 1014 | return; | ||
3731 | 1015 | |||
3732 | 1016 | if (session->session_type != ubuntu::application::ui::system_session_type) | ||
3733 | 1017 | { | ||
3734 | 1018 | // Stop the session | ||
3735 | 1019 | if (!is_session_allowed_to_run_in_background(session)) | ||
3736 | 1020 | { | ||
3737 | 1021 | if ((session->stage_hint == ubuntu::application::ui::main_stage && | ||
3738 | 1022 | next_session->stage_hint != ubuntu::application::ui::side_stage) || | ||
3739 | 1023 | (session->stage_hint == ubuntu::application::ui::side_stage && | ||
3740 | 1024 | next_session->stage_hint != ubuntu::application::ui::main_stage)) | ||
3741 | 1025 | { | ||
3742 | 1026 | notify_observers_about_session_unfocused(session->remote_pid, | ||
3743 | 1027 | session->stage_hint, | ||
3744 | 1028 | session->desktop_file); | ||
3745 | 1029 | |||
3746 | 1030 | session_set_state(session, ubuntu::application::ui::process_suspended); | ||
3747 | 1031 | } else | ||
3748 | 1032 | { | ||
3749 | 1033 | if (session->stage_hint == ubuntu::application::ui::side_stage && | ||
3750 | 1034 | next_session->stage_hint == ubuntu::application::ui::main_stage && | ||
3751 | 1035 | main_stage_application < apps.size()) | ||
3752 | 1036 | { | ||
3753 | 1037 | const android::sp<ubuntu::detail::ApplicationSession>& main_session = | ||
3754 | 1038 | apps.valueFor(apps_as_added[main_stage_application]); | ||
3755 | 1039 | |||
3756 | 1040 | if (main_session->session_type != ubuntu::application::ui::system_session_type) | ||
3757 | 1041 | session_set_state(main_session, ubuntu::application::ui::process_suspended); | ||
3758 | 1042 | } | ||
3759 | 1043 | } | ||
3760 | 1044 | } | ||
3761 | 1045 | } | ||
3762 | 1046 | } | ||
3763 | 1047 | |||
3764 | 1048 | focused_application = index_of_next_focused_app; | ||
3765 | 1049 | is_osk_visible = false; | ||
3766 | 1050 | notify_observers_about_keyboard_geometry_changed(0, 0, 0, 0); | ||
3767 | 1051 | |||
3768 | 1052 | if (focused_application < apps.size()) | ||
3769 | 1053 | { | ||
3770 | 1054 | |||
3771 | 1055 | focused_layer += focused_layer_increment; | ||
3772 | 1056 | |||
3773 | 1057 | const android::sp<ubuntu::detail::ApplicationSession>& session = | ||
3774 | 1058 | apps.valueFor(apps_as_added[focused_application]); | ||
3775 | 1059 | |||
3776 | 1060 | ALOGI("Raising application now for idx: %d (stage_hint: %d)\n", focused_application, session->stage_hint); | ||
3777 | 1061 | |||
3778 | 1062 | if (session->session_type == ubuntu::application::ui::system_session_type) | ||
3779 | 1063 | { | ||
3780 | 1064 | ALOGI("\t system session - not raising it."); | ||
3781 | 1065 | return; | ||
3782 | 1066 | } | ||
3783 | 1067 | |||
3784 | 1068 | // Continue the session | ||
3785 | 1069 | if (!is_session_allowed_to_run_in_background(session)) | ||
3786 | 1070 | session_set_state(session, ubuntu::application::ui::process_running); | ||
3787 | 1071 | |||
3788 | 1072 | if (session->stage_hint == ubuntu::application::ui::side_stage) | ||
3789 | 1073 | side_stage_application = focused_application; | ||
3790 | 1074 | else | ||
3791 | 1075 | main_stage_application = focused_application; | ||
3792 | 1076 | |||
3793 | 1077 | session->raise_application_surfaces_to_layer(focused_layer); | ||
3794 | 1078 | input_setup->input_manager->getDispatcher()->setFocusedApplication( | ||
3795 | 1079 | session->input_application_handle()); | ||
3796 | 1080 | |||
3797 | 1081 | android::Vector< android::sp<android::InputWindowHandle> > input_windows; | ||
3798 | 1082 | |||
3799 | 1083 | if (are_notifications_visible) | ||
3800 | 1084 | input_windows.push(shell_input_setup->notifications_window.input_window); | ||
3801 | 1085 | if (!shell_input_setup->trap_windows.isEmpty()) | ||
3802 | 1086 | { | ||
3803 | 1087 | int key = 0; | ||
3804 | 1088 | for (size_t i = 0; i < shell_input_setup->trap_windows.size(); i++) | ||
3805 | 1089 | { | ||
3806 | 1090 | key = shell_input_setup->trap_windows.keyAt(i); | ||
3807 | 1091 | input_windows.push(shell_input_setup->trap_windows.valueFor(key)); | ||
3808 | 1092 | } | ||
3809 | 1093 | } | ||
3810 | 1094 | |||
3811 | 1095 | input_windows.appendVector(session->input_window_handles()); | ||
3812 | 1096 | |||
3813 | 1097 | if (session->stage_hint == ubuntu::application::ui::side_stage) | ||
3814 | 1098 | { | ||
3815 | 1099 | if (main_stage_application) | ||
3816 | 1100 | { | ||
3817 | 1101 | const android::sp<ubuntu::detail::ApplicationSession>& main_session = | ||
3818 | 1102 | apps.valueFor(apps_as_added[main_stage_application]); | ||
3819 | 1103 | session_set_state(main_session, ubuntu::application::ui::process_running); | ||
3820 | 1104 | input_windows.appendVector(main_session->input_window_handles()); | ||
3821 | 1105 | } | ||
3822 | 1106 | } | ||
3823 | 1107 | |||
3824 | 1108 | input_setup->input_manager->getDispatcher()->setInputWindows( | ||
3825 | 1109 | input_windows); | ||
3826 | 1110 | |||
3827 | 1111 | notify_observers_about_session_focused(session->remote_pid, | ||
3828 | 1112 | session->stage_hint, | ||
3829 | 1113 | session->desktop_file); | ||
3830 | 1114 | |||
3831 | 1115 | shell_input_setup->shell_has_focus = false; | ||
3832 | 1116 | } | ||
3833 | 1117 | } | ||
3834 | 1118 | |||
3835 | 1119 | void ApplicationManager::switch_focus_to_next_application_locked() | ||
3836 | 1120 | { | ||
3837 | 1121 | size_t new_idx = (focused_application + 1) % apps.size(); | ||
3838 | 1122 | |||
3839 | 1123 | ALOGI("current: %d, next: %d \n", focused_application, new_idx); | ||
3840 | 1124 | |||
3841 | 1125 | switch_focused_application_locked(new_idx); | ||
3842 | 1126 | } | ||
3843 | 1127 | |||
3844 | 1128 | void ApplicationManager::kill_focused_application_locked() | ||
3845 | 1129 | { | ||
3846 | 1130 | if (focused_application < apps.size()) | ||
3847 | 1131 | { | ||
3848 | 1132 | const android::sp<ubuntu::detail::ApplicationSession>& session = | ||
3849 | 1133 | apps.valueFor(apps_as_added[focused_application]); | ||
3850 | 1134 | |||
3851 | 1135 | kill(session->pid, SIGKILL); | ||
3852 | 1136 | } | ||
3853 | 1137 | } | ||
3854 | 1138 | |||
3855 | 1139 | size_t ApplicationManager::session_id_to_index(int id) | ||
3856 | 1140 | { | ||
3857 | 1141 | size_t idx = 0; | ||
3858 | 1142 | |||
3859 | 1143 | for(idx = 0; idx < apps_as_added.size(); idx++) | ||
3860 | 1144 | { | ||
3861 | 1145 | const android::sp<ubuntu::detail::ApplicationSession>& session = | ||
3862 | 1146 | apps.valueFor(apps_as_added[idx]); | ||
3863 | 1147 | |||
3864 | 1148 | if (session->remote_pid == id) | ||
3865 | 1149 | break; | ||
3866 | 1150 | } | ||
3867 | 1151 | |||
3868 | 1152 | return idx; | ||
3869 | 1153 | } | ||
3870 | 1154 | |||
3871 | 1155 | void ApplicationManager::notify_observers_about_session_requested(uint32_t app) | ||
3872 | 1156 | { | ||
3873 | 1157 | android::Mutex::Autolock al(observer_guard); | ||
3874 | 1158 | for(unsigned int i = 0; i < app_manager_observers.size(); i++) | ||
3875 | 1159 | { | ||
3876 | 1160 | app_manager_observers[i]->on_session_requested(app); | ||
3877 | 1161 | } | ||
3878 | 1162 | } | ||
3879 | 1163 | |||
3880 | 1164 | void ApplicationManager::notify_observers_about_session_born(int id, int stage_hint, const android::String8& desktop_file) | ||
3881 | 1165 | { | ||
3882 | 1166 | android::Mutex::Autolock al(observer_guard); | ||
3883 | 1167 | for(unsigned int i = 0; i < app_manager_observers.size(); i++) | ||
3884 | 1168 | { | ||
3885 | 1169 | app_manager_observers[i]->on_session_born(id, stage_hint, desktop_file); | ||
3886 | 1170 | } | ||
3887 | 1171 | } | ||
3888 | 1172 | |||
3889 | 1173 | void ApplicationManager::notify_observers_about_session_unfocused(int id, int stage_hint, const android::String8& desktop_file) | ||
3890 | 1174 | { | ||
3891 | 1175 | android::Mutex::Autolock al(observer_guard); | ||
3892 | 1176 | for(unsigned int i = 0; i < app_manager_observers.size(); i++) | ||
3893 | 1177 | { | ||
3894 | 1178 | app_manager_observers[i]->on_session_unfocused(id, stage_hint, desktop_file); | ||
3895 | 1179 | } | ||
3896 | 1180 | } | ||
3897 | 1181 | |||
3898 | 1182 | void ApplicationManager::notify_observers_about_session_focused(int id, int stage_hint, const android::String8& desktop_file) | ||
3899 | 1183 | { | ||
3900 | 1184 | android::Mutex::Autolock al(observer_guard); | ||
3901 | 1185 | for(unsigned int i = 0; i < app_manager_observers.size(); i++) | ||
3902 | 1186 | { | ||
3903 | 1187 | app_manager_observers[i]->on_session_focused(id, stage_hint, desktop_file); | ||
3904 | 1188 | } | ||
3905 | 1189 | } | ||
3906 | 1190 | |||
3907 | 1191 | void ApplicationManager::notify_observers_about_keyboard_geometry_changed(int x, int y, int width, int height) | ||
3908 | 1192 | { | ||
3909 | 1193 | android::Mutex::Autolock al(observer_guard); | ||
3910 | 1194 | for(unsigned int i = 0; i < app_manager_observers.size(); i++) | ||
3911 | 1195 | { | ||
3912 | 1196 | app_manager_observers[i]->on_keyboard_geometry_changed(x, y, width, height); | ||
3913 | 1197 | } | ||
3914 | 1198 | } | ||
3915 | 1199 | |||
3916 | 1200 | void ApplicationManager::notify_observers_about_session_requested_fullscreen(int id, int stage_hint, const android::String8& desktop_file) | ||
3917 | 1201 | { | ||
3918 | 1202 | android::Mutex::Autolock al(observer_guard); | ||
3919 | 1203 | for(unsigned int i = 0; i < app_manager_observers.size(); i++) | ||
3920 | 1204 | { | ||
3921 | 1205 | app_manager_observers[i]->on_session_requested_fullscreen(id, stage_hint, desktop_file); | ||
3922 | 1206 | } | ||
3923 | 1207 | } | ||
3924 | 1208 | |||
3925 | 1209 | void ApplicationManager::notify_observers_about_session_died(int id, int stage_hint, const android::String8& desktop_file) | ||
3926 | 1210 | { | ||
3927 | 1211 | android::Mutex::Autolock al(observer_guard); | ||
3928 | 1212 | for(unsigned int i = 0; i < app_manager_observers.size(); i++) | ||
3929 | 1213 | { | ||
3930 | 1214 | app_manager_observers[i]->on_session_died(id, stage_hint, desktop_file); | ||
3931 | 1215 | } | ||
3932 | 1216 | } | ||
3933 | 1217 | |||
3934 | 1218 | struct ClipboardService : public android::BnClipboardService | ||
3935 | 1219 | { | ||
3936 | 1220 | void set_content(const android::IClipboardService::Content& content) | ||
3937 | 1221 | { | ||
3938 | 1222 | this->content = content; | ||
3939 | 1223 | } | ||
3940 | 1224 | |||
3941 | 1225 | void get_content(android::IClipboardService::Content& content) | ||
3942 | 1226 | { | ||
3943 | 1227 | content = this->content; | ||
3944 | 1228 | } | ||
3945 | 1229 | |||
3946 | 1230 | android::IClipboardService::Content content; | ||
3947 | 1231 | }; | ||
3948 | 1232 | |||
3949 | 1233 | } | ||
3950 | 1234 | } | ||
3951 | 1235 | int main(int argc, char** argv) | ||
3952 | 1236 | { | ||
3953 | 1237 | android::sp<ubuntu::detail::ApplicationManager> app_manager(new ubuntu::detail::ApplicationManager()); | ||
3954 | 1238 | android::sp<ubuntu::detail::ClipboardService> clipboard_service(new ubuntu::detail::ClipboardService()); | ||
3955 | 1239 | // Register service | ||
3956 | 1240 | android::sp<android::IServiceManager> service_manager = android::defaultServiceManager(); | ||
3957 | 1241 | if (android::NO_ERROR != service_manager->addService( | ||
3958 | 1242 | android::String16(android::IApplicationManager::exported_service_name()), | ||
3959 | 1243 | app_manager)) | ||
3960 | 1244 | { | ||
3961 | 1245 | return EXIT_FAILURE; | ||
3962 | 1246 | } | ||
3963 | 1247 | |||
3964 | 1248 | if (android::NO_ERROR != service_manager->addService( | ||
3965 | 1249 | android::String16(android::IClipboardService::exported_service_name()), | ||
3966 | 1250 | clipboard_service)) | ||
3967 | 1251 | { | ||
3968 | 1252 | return EXIT_FAILURE; | ||
3969 | 1253 | } | ||
3970 | 1254 | |||
3971 | 1255 | android::ProcessState::self()->startThreadPool(); | ||
3972 | 1256 | android::IPCThreadState::self()->joinThreadPool(); | ||
3973 | 1257 | } | ||
3974 | 1258 | 0 | ||
3975 | === removed file 'android/hybris/default_application_manager.h' | |||
3976 | --- android/hybris/default_application_manager.h 2014-01-22 05:28:18 +0000 | |||
3977 | +++ android/hybris/default_application_manager.h 1970-01-01 00:00:00 +0000 | |||
3978 | @@ -1,255 +0,0 @@ | |||
3979 | 1 | /* | ||
3980 | 2 | * Copyright © 2012 Canonical Ltd. | ||
3981 | 3 | * | ||
3982 | 4 | * This program is free software: you can redistribute it and/or modify | ||
3983 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
3984 | 6 | * published by the Free Software Foundation. | ||
3985 | 7 | * | ||
3986 | 8 | * This program is distributed in the hope that it will be useful, | ||
3987 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3988 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3989 | 11 | * GNU Lesser General Public License for more details. | ||
3990 | 12 | * | ||
3991 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
3992 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3993 | 15 | * | ||
3994 | 16 | * Authored by: Thomas Voß <thomas.voss@canonical.com> | ||
3995 | 17 | */ | ||
3996 | 18 | #ifndef DEFAULT_APPLICATION_MANAGER_H_ | ||
3997 | 19 | #define DEFAULT_APPLICATION_MANAGER_H_ | ||
3998 | 20 | |||
3999 | 21 | #include "application_manager.h" | ||
4000 | 22 | #include "default_application_manager_input_setup.h" | ||
4001 | 23 | #include "default_application_session.h" | ||
4002 | 24 | #include "event_loop.h" | ||
4003 | 25 | #include "lifecycle_helpers.h" | ||
4004 | 26 | |||
4005 | 27 | #include <binder/IPCThreadState.h> | ||
4006 | 28 | #include <binder/IServiceManager.h> | ||
4007 | 29 | #include <binder/ProcessState.h> | ||
4008 | 30 | |||
4009 | 31 | #include <input/InputListener.h> | ||
4010 | 32 | #include <input/InputReader.h> | ||
4011 | 33 | #if ANDROID_VERSION_MAJOR==4 && ANDROID_VERSION_MINOR<=2 | ||
4012 | 34 | #include <androidfw/InputTransport.h> | ||
4013 | 35 | #else | ||
4014 | 36 | #include <input/InputTransport.h> | ||
4015 | 37 | #endif | ||
4016 | 38 | #include <utils/threads.h> | ||
4017 | 39 | |||
4018 | 40 | namespace ubuntu { namespace detail | ||
4019 | 41 | { | ||
4020 | 42 | struct ApplicationManager : | ||
4021 | 43 | public android::BnApplicationManager, | ||
4022 | 44 | public android::IBinder::DeathRecipient | ||
4023 | 45 | { | ||
4024 | 46 | static const int default_shell_component_layer = 1000000; | ||
4025 | 47 | |||
4026 | 48 | static const int default_dash_layer = default_shell_component_layer + 1; | ||
4027 | 49 | static const int default_indicator_layer = default_shell_component_layer + 2; | ||
4028 | 50 | static const int default_notifications_layer = default_shell_component_layer + 3; | ||
4029 | 51 | static const int default_greeter_layer = default_shell_component_layer + 4; | ||
4030 | 52 | static const int default_launcher_layer = default_shell_component_layer + 5; | ||
4031 | 53 | static const int default_osk_layer = default_shell_component_layer + 6; | ||
4032 | 54 | static const int default_shutdown_dialog_layer = default_shell_component_layer + 7; | ||
4033 | 55 | |||
4034 | 56 | static const int focused_application_base_layer = 100; | ||
4035 | 57 | static const int wallpaper_layer = 0; | ||
4036 | 58 | static const int non_focused_application_layer = -1; | ||
4037 | 59 | |||
4038 | 60 | struct ShellInputSetup : public android::RefBase | ||
4039 | 61 | { | ||
4040 | 62 | struct DisplayInfo | ||
4041 | 63 | { | ||
4042 | 64 | DisplayInfo(); | ||
4043 | 65 | |||
4044 | 66 | android::DisplayInfo info; | ||
4045 | 67 | }; | ||
4046 | 68 | |||
4047 | 69 | template<int x, int y, int w, int h> | ||
4048 | 70 | struct Window : public android::RefBase | ||
4049 | 71 | { | ||
4050 | 72 | static int looper_callback(int receiveFd, int events, void* ctxt); | ||
4051 | 73 | |||
4052 | 74 | Window(ShellInputSetup* parent, | ||
4053 | 75 | int _x = x, | ||
4054 | 76 | int _y = y, | ||
4055 | 77 | int _w = w, | ||
4056 | 78 | int _h = h); | ||
4057 | 79 | |||
4058 | 80 | android::sp<android::InputSetup::DummyApplicationWindow> input_window; | ||
4059 | 81 | |||
4060 | 82 | ShellInputSetup* parent; | ||
4061 | 83 | android::sp<android::InputChannel> server_channel; | ||
4062 | 84 | android::sp<android::InputChannel> client_channel; | ||
4063 | 85 | android::InputConsumer input_consumer; | ||
4064 | 86 | android::PreallocatedInputEventFactory event_factory; | ||
4065 | 87 | }; | ||
4066 | 88 | |||
4067 | 89 | ShellInputSetup(const android::sp<android::InputManager>& input_manager); | ||
4068 | 90 | |||
4069 | 91 | bool shell_has_focus; | ||
4070 | 92 | |||
4071 | 93 | DisplayInfo display_info; | ||
4072 | 94 | |||
4073 | 95 | android::sp<android::InputManager> input_manager; | ||
4074 | 96 | android::sp<android::InputApplicationHandle> shell_application; | ||
4075 | 97 | |||
4076 | 98 | android::sp<android::Looper> looper; | ||
4077 | 99 | ubuntu::application::EventLoop event_loop; | ||
4078 | 100 | |||
4079 | 101 | android::KeyedVector<int32_t, android::sp<android::InputWindowHandle> > trap_windows; | ||
4080 | 102 | |||
4081 | 103 | // TODO(tvoss): Get rid of hard coded values. | ||
4082 | 104 | Window<0, 0, 720, 1280> event_trap_window; | ||
4083 | 105 | // TODO(tvoss): This is really hacky, but we need to | ||
4084 | 106 | // synchronize/reflect state changes across multiple processes | ||
4085 | 107 | // here, i.e.: | ||
4086 | 108 | // * maliit-server, which takes care of hiding and showing the osk | ||
4087 | 109 | // * notify-osd, which takes care of hiding and showing notifications | ||
4088 | 110 | Window<0, 812, 720, 468> osk_window; | ||
4089 | 111 | Window<36, 18, 684, 216> notifications_window; | ||
4090 | 112 | }; | ||
4091 | 113 | |||
4092 | 114 | class InputFilter : public android::InputFilter | ||
4093 | 115 | { | ||
4094 | 116 | public: | ||
4095 | 117 | InputFilter(ApplicationManager* manager); | ||
4096 | 118 | |||
4097 | 119 | bool filter_event(const android::InputEvent* event); | ||
4098 | 120 | |||
4099 | 121 | private: | ||
4100 | 122 | ApplicationManager* manager; | ||
4101 | 123 | |||
4102 | 124 | bool handle_key_event(const android::KeyEvent* event); | ||
4103 | 125 | }; | ||
4104 | 126 | |||
4105 | 127 | class LockingIterator : public android::RefBase | ||
4106 | 128 | { | ||
4107 | 129 | public: | ||
4108 | 130 | void advance() ; | ||
4109 | 131 | |||
4110 | 132 | bool is_valid() const; | ||
4111 | 133 | |||
4112 | 134 | void make_current(); | ||
4113 | 135 | |||
4114 | 136 | const android::sp<ubuntu::detail::ApplicationSession>& operator*(); | ||
4115 | 137 | |||
4116 | 138 | protected: | ||
4117 | 139 | friend class ApplicationManager; | ||
4118 | 140 | |||
4119 | 141 | LockingIterator( | ||
4120 | 142 | ApplicationManager* manager, | ||
4121 | 143 | size_t index); | ||
4122 | 144 | |||
4123 | 145 | virtual ~LockingIterator(); | ||
4124 | 146 | |||
4125 | 147 | private: | ||
4126 | 148 | ApplicationManager* manager; | ||
4127 | 149 | size_t it; | ||
4128 | 150 | }; | ||
4129 | 151 | |||
4130 | 152 | ApplicationManager(); | ||
4131 | 153 | |||
4132 | 154 | void update_app_lists(); | ||
4133 | 155 | |||
4134 | 156 | // From DeathRecipient | ||
4135 | 157 | void binderDied(const android::wp<android::IBinder>& who); | ||
4136 | 158 | |||
4137 | 159 | void lock(); | ||
4138 | 160 | |||
4139 | 161 | void unlock(); | ||
4140 | 162 | |||
4141 | 163 | android::sp<LockingIterator> iterator(); | ||
4142 | 164 | |||
4143 | 165 | void session_set_state(const android::sp<ubuntu::detail::ApplicationSession>& session, | ||
4144 | 166 | int32_t new_state); | ||
4145 | 167 | |||
4146 | 168 | void start_a_new_session( | ||
4147 | 169 | int32_t session_type, | ||
4148 | 170 | int32_t stage_hint, | ||
4149 | 171 | const android::String8& app_name, | ||
4150 | 172 | const android::String8& desktop_file, | ||
4151 | 173 | const android::sp<android::IApplicationManagerSession>& session, | ||
4152 | 174 | int fd, | ||
4153 | 175 | uint32_t remote_pid); | ||
4154 | 176 | |||
4155 | 177 | void register_a_surface( | ||
4156 | 178 | const android::String8& title, | ||
4157 | 179 | const android::sp<android::IApplicationManagerSession>& session, | ||
4158 | 180 | int32_t surface_role, | ||
4159 | 181 | int32_t token, | ||
4160 | 182 | int fd); | ||
4161 | 183 | |||
4162 | 184 | void request_fullscreen(const android::sp<android::IApplicationManagerSession>& session); | ||
4163 | 185 | |||
4164 | 186 | void register_an_observer(const android::sp<android::IApplicationManagerObserver>& observer); | ||
4165 | 187 | |||
4166 | 188 | void register_task_controller(const android::sp<android::IAMTaskController>& controller); | ||
4167 | 189 | |||
4168 | 190 | int get_session_pid(const android::sp<android::IApplicationManagerSession>& session); | ||
4169 | 191 | |||
4170 | 192 | void request_update_for_session(const android::sp<android::IApplicationManagerSession>& session); | ||
4171 | 193 | |||
4172 | 194 | void focus_running_session_with_id(int id); | ||
4173 | 195 | |||
4174 | 196 | void unfocus_running_sessions(); | ||
4175 | 197 | |||
4176 | 198 | int32_t query_snapshot_layer_for_session_with_id(int id); | ||
4177 | 199 | |||
4178 | 200 | android::IApplicationManagerSession::SurfaceProperties query_surface_properties_for_session_id(int id); | ||
4179 | 201 | |||
4180 | 202 | void switch_to_well_known_application(int32_t app); | ||
4181 | 203 | |||
4182 | 204 | int32_t set_surface_trap(int32_t x, int32_t y, int32_t width, int32_t height); | ||
4183 | 205 | |||
4184 | 206 | void unset_surface_trap(int32_t handle); | ||
4185 | 207 | |||
4186 | 208 | void report_osk_visible(int32_t x, int32_t y, int32_t width, int32_t height); | ||
4187 | 209 | |||
4188 | 210 | void report_osk_invisible(); | ||
4189 | 211 | |||
4190 | 212 | void report_notification_visible(); | ||
4191 | 213 | |||
4192 | 214 | void report_notification_invisible(); | ||
4193 | 215 | |||
4194 | 216 | void switch_focused_application_locked(size_t index_of_next_focused_app); | ||
4195 | 217 | void switch_focus_to_next_application_locked(); | ||
4196 | 218 | |||
4197 | 219 | void kill_focused_application_locked(); | ||
4198 | 220 | |||
4199 | 221 | private: | ||
4200 | 222 | void update_input_setup_locked(); | ||
4201 | 223 | |||
4202 | 224 | size_t session_id_to_index(int id); | ||
4203 | 225 | void notify_observers_about_session_requested(uint32_t app); | ||
4204 | 226 | void notify_observers_about_session_born(int id, int stage_hint, const android::String8& desktop_file); | ||
4205 | 227 | void notify_observers_about_session_unfocused(int id, int stage_hint, const android::String8& desktop_file); | ||
4206 | 228 | void notify_observers_about_session_focused(int id, int stage_hint, const android::String8& desktop_file); | ||
4207 | 229 | void notify_observers_about_keyboard_geometry_changed(int x, int y, int width, int height); | ||
4208 | 230 | void notify_observers_about_session_requested_fullscreen(int id, int stage_hint, const android::String8& desktop_file); | ||
4209 | 231 | void notify_observers_about_session_died(int id, int stage_hint, const android::String8& desktop_file); | ||
4210 | 232 | |||
4211 | 233 | android::sp<android::InputListenerInterface> input_listener; | ||
4212 | 234 | android::sp<InputFilter> input_filter; | ||
4213 | 235 | android::sp<android::InputSetup> input_setup; | ||
4214 | 236 | android::sp<ShellInputSetup> shell_input_setup; | ||
4215 | 237 | bool is_osk_visible; | ||
4216 | 238 | bool are_notifications_visible; | ||
4217 | 239 | android::Condition state_cond; | ||
4218 | 240 | android::Mutex state_lock; | ||
4219 | 241 | android::Mutex guard; | ||
4220 | 242 | android::KeyedVector< android::sp<android::IBinder>, android::sp<ubuntu::detail::ApplicationSession> > apps; | ||
4221 | 243 | android::Vector< android::sp<android::IBinder> > apps_as_added; | ||
4222 | 244 | android::Mutex observer_guard; | ||
4223 | 245 | android::Vector< android::sp<android::IApplicationManagerObserver> > app_manager_observers; | ||
4224 | 246 | android::sp<android::IAMTaskController> app_manager_task_controller; | ||
4225 | 247 | size_t focused_application; | ||
4226 | 248 | size_t side_stage_application; | ||
4227 | 249 | size_t main_stage_application; | ||
4228 | 250 | }; | ||
4229 | 251 | |||
4230 | 252 | } | ||
4231 | 253 | } | ||
4232 | 254 | |||
4233 | 255 | #endif // DEFAULT_APPLICATION_MANAGER_H_ | ||
4234 | 256 | 0 | ||
4235 | === removed file 'android/hybris/default_application_manager_input_setup.h' | |||
4236 | --- android/hybris/default_application_manager_input_setup.h 2014-01-22 05:28:18 +0000 | |||
4237 | +++ android/hybris/default_application_manager_input_setup.h 1970-01-01 00:00:00 +0000 | |||
4238 | @@ -1,452 +0,0 @@ | |||
4239 | 1 | /* | ||
4240 | 2 | * Copyright © 2012 Canonical Ltd. | ||
4241 | 3 | * | ||
4242 | 4 | * This program is free software: you can redistribute it and/or modify | ||
4243 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
4244 | 6 | * published by the Free Software Foundation. | ||
4245 | 7 | * | ||
4246 | 8 | * This program is distributed in the hope that it will be useful, | ||
4247 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4248 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4249 | 11 | * GNU Lesser General Public License for more details. | ||
4250 | 12 | * | ||
4251 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
4252 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4253 | 15 | * | ||
4254 | 16 | * Authored by: Thomas Voß <thomas.voss@canonical.com> | ||
4255 | 17 | */ | ||
4256 | 18 | #ifndef DEFAULT_APPLICATION_MANAGER_INPUT_SETUP_H_ | ||
4257 | 19 | #define DEFAULT_APPLICATION_MANAGER_INPUT_SETUP_H_ | ||
4258 | 20 | |||
4259 | 21 | #include <input/InputDispatcher.h> | ||
4260 | 22 | #include <input/InputListener.h> | ||
4261 | 23 | #include <input/InputManager.h> | ||
4262 | 24 | #include <input/InputReader.h> | ||
4263 | 25 | #include <input/PointerController.h> | ||
4264 | 26 | #include <input/SpriteController.h> | ||
4265 | 27 | #include <gui/ISurfaceComposer.h> | ||
4266 | 28 | #include <gui/SurfaceComposerClient.h> | ||
4267 | 29 | |||
4268 | 30 | #include <cstdio> | ||
4269 | 31 | |||
4270 | 32 | #define REPORT_FUNCTION_CALL()// printf("%s \n", __PRETTY_FUNCTION__); | ||
4271 | 33 | |||
4272 | 34 | namespace android | ||
4273 | 35 | { | ||
4274 | 36 | class DefaultPointerControllerPolicy : public android::PointerControllerPolicyInterface | ||
4275 | 37 | { | ||
4276 | 38 | public: | ||
4277 | 39 | |||
4278 | 40 | static const size_t bitmap_width = 64; | ||
4279 | 41 | static const size_t bitmap_height = 64; | ||
4280 | 42 | |||
4281 | 43 | DefaultPointerControllerPolicy() | ||
4282 | 44 | { | ||
4283 | 45 | bitmap.setConfig( | ||
4284 | 46 | SkBitmap::kARGB_8888_Config, | ||
4285 | 47 | bitmap_width, | ||
4286 | 48 | bitmap_height); | ||
4287 | 49 | bitmap.allocPixels(); | ||
4288 | 50 | |||
4289 | 51 | // Icon for spot touches | ||
4290 | 52 | bitmap.eraseARGB(125, 0, 255, 0); | ||
4291 | 53 | spotTouchIcon = android::SpriteIcon( | ||
4292 | 54 | bitmap, | ||
4293 | 55 | bitmap_width/2, | ||
4294 | 56 | bitmap_height/2); | ||
4295 | 57 | // Icon for anchor touches | ||
4296 | 58 | bitmap.eraseARGB(125, 0, 0, 255); | ||
4297 | 59 | spotAnchorIcon = android::SpriteIcon( | ||
4298 | 60 | bitmap, | ||
4299 | 61 | bitmap_width/2, | ||
4300 | 62 | bitmap_height/2); | ||
4301 | 63 | // Icon for hovering touches | ||
4302 | 64 | bitmap.eraseARGB(125, 255, 0, 0); | ||
4303 | 65 | spotHoverIcon = android::SpriteIcon( | ||
4304 | 66 | bitmap, | ||
4305 | 67 | bitmap_width/2, | ||
4306 | 68 | bitmap_height/2); | ||
4307 | 69 | } | ||
4308 | 70 | |||
4309 | 71 | void loadPointerResources(android::PointerResources* outResources) | ||
4310 | 72 | { | ||
4311 | 73 | outResources->spotHover = spotHoverIcon.copy(); | ||
4312 | 74 | outResources->spotTouch = spotTouchIcon.copy(); | ||
4313 | 75 | outResources->spotAnchor = spotAnchorIcon.copy(); | ||
4314 | 76 | } | ||
4315 | 77 | |||
4316 | 78 | android::SpriteIcon spotHoverIcon; | ||
4317 | 79 | android::SpriteIcon spotTouchIcon; | ||
4318 | 80 | android::SpriteIcon spotAnchorIcon; | ||
4319 | 81 | SkBitmap bitmap; | ||
4320 | 82 | }; | ||
4321 | 83 | |||
4322 | 84 | class DefaultInputReaderPolicyInterface : public android::InputReaderPolicyInterface | ||
4323 | 85 | { | ||
4324 | 86 | public: | ||
4325 | 87 | static const int32_t internal_display_id = android::ISurfaceComposer::eDisplayIdMain; | ||
4326 | 88 | static const int32_t external_display_id = android::ISurfaceComposer::eDisplayIdHdmi; | ||
4327 | 89 | |||
4328 | 90 | DefaultInputReaderPolicyInterface(const android::sp<android::Looper>& looper) | ||
4329 | 91 | : looper(looper), | ||
4330 | 92 | default_layer_for_touch_point_visualization(INT_MAX) | ||
4331 | 93 | { | ||
4332 | 94 | default_configuration.showTouches = false; | ||
4333 | 95 | |||
4334 | 96 | auto display = android::SurfaceComposerClient::getBuiltInDisplay( | ||
4335 | 97 | android::ISurfaceComposer::eDisplayIdMain); | ||
4336 | 98 | android::DisplayInfo info; | ||
4337 | 99 | android::SurfaceComposerClient::getDisplayInfo( | ||
4338 | 100 | display, | ||
4339 | 101 | &info); | ||
4340 | 102 | |||
4341 | 103 | android::DisplayViewport viewport; | ||
4342 | 104 | viewport.setNonDisplayViewport(info.w, info.h); | ||
4343 | 105 | viewport.displayId = android::ISurfaceComposer::eDisplayIdMain; | ||
4344 | 106 | default_configuration.setDisplayInfo( | ||
4345 | 107 | false, /* external */ | ||
4346 | 108 | viewport); | ||
4347 | 109 | |||
4348 | 110 | } | ||
4349 | 111 | |||
4350 | 112 | void getReaderConfiguration(android::InputReaderConfiguration* outConfig) | ||
4351 | 113 | { | ||
4352 | 114 | *outConfig = default_configuration; | ||
4353 | 115 | } | ||
4354 | 116 | |||
4355 | 117 | android::sp<android::PointerControllerInterface> obtainPointerController(int32_t deviceId) | ||
4356 | 118 | { | ||
4357 | 119 | (void) deviceId; | ||
4358 | 120 | |||
4359 | 121 | android::sp<android::SpriteController> sprite_controller( | ||
4360 | 122 | new android::SpriteController( | ||
4361 | 123 | looper, | ||
4362 | 124 | default_layer_for_touch_point_visualization)); | ||
4363 | 125 | android::sp<android::PointerController> pointer_controller( | ||
4364 | 126 | new android::PointerController( | ||
4365 | 127 | android::sp<DefaultPointerControllerPolicy>(new DefaultPointerControllerPolicy()), | ||
4366 | 128 | looper, | ||
4367 | 129 | sprite_controller)); | ||
4368 | 130 | pointer_controller->setPresentation( | ||
4369 | 131 | android::PointerControllerInterface::PRESENTATION_SPOT); | ||
4370 | 132 | int32_t w, h, o; | ||
4371 | 133 | auto display = android::SurfaceComposerClient::getBuiltInDisplay( | ||
4372 | 134 | android::ISurfaceComposer::eDisplayIdMain); | ||
4373 | 135 | android::DisplayInfo info; | ||
4374 | 136 | android::SurfaceComposerClient::getDisplayInfo( | ||
4375 | 137 | display, | ||
4376 | 138 | &info); | ||
4377 | 139 | |||
4378 | 140 | pointer_controller->setDisplayViewport(info.w, info.h, info.orientation); | ||
4379 | 141 | return pointer_controller; | ||
4380 | 142 | } | ||
4381 | 143 | |||
4382 | 144 | virtual void notifyInputDevicesChanged(const Vector<InputDeviceInfo>& inputDevices) { | ||
4383 | 145 | mInputDevices = inputDevices; | ||
4384 | 146 | } | ||
4385 | 147 | |||
4386 | 148 | virtual sp<KeyCharacterMap> getKeyboardLayoutOverlay(const String8& inputDeviceDescriptor) { | ||
4387 | 149 | return NULL; | ||
4388 | 150 | } | ||
4389 | 151 | |||
4390 | 152 | virtual String8 getDeviceAlias(const InputDeviceIdentifier& identifier) { | ||
4391 | 153 | return String8::empty(); | ||
4392 | 154 | } | ||
4393 | 155 | private: | ||
4394 | 156 | android::sp<android::Looper> looper; | ||
4395 | 157 | int default_layer_for_touch_point_visualization; | ||
4396 | 158 | android::InputReaderConfiguration default_configuration; | ||
4397 | 159 | Vector<InputDeviceInfo> mInputDevices; | ||
4398 | 160 | }; | ||
4399 | 161 | |||
4400 | 162 | class InputFilter : public android::RefBase | ||
4401 | 163 | { | ||
4402 | 164 | public: | ||
4403 | 165 | virtual bool filter_event(const android::InputEvent* event) = 0; | ||
4404 | 166 | |||
4405 | 167 | protected: | ||
4406 | 168 | InputFilter() {} | ||
4407 | 169 | virtual ~InputFilter() {} | ||
4408 | 170 | |||
4409 | 171 | InputFilter(const InputFilter&) = delete; | ||
4410 | 172 | InputFilter& operator=(const InputFilter&) = delete; | ||
4411 | 173 | }; | ||
4412 | 174 | |||
4413 | 175 | class DefaultInputDispatcherPolicy : public InputDispatcherPolicyInterface | ||
4414 | 176 | { | ||
4415 | 177 | public: | ||
4416 | 178 | DefaultInputDispatcherPolicy(const android::sp<InputFilter>& input_filter) | ||
4417 | 179 | : input_filter(input_filter) | ||
4418 | 180 | { | ||
4419 | 181 | } | ||
4420 | 182 | |||
4421 | 183 | ~DefaultInputDispatcherPolicy() | ||
4422 | 184 | { | ||
4423 | 185 | } | ||
4424 | 186 | |||
4425 | 187 | void notifyConfigurationChanged(nsecs_t when) | ||
4426 | 188 | { | ||
4427 | 189 | REPORT_FUNCTION_CALL(); | ||
4428 | 190 | (void) when; | ||
4429 | 191 | } | ||
4430 | 192 | |||
4431 | 193 | nsecs_t notifyANR(const sp<InputApplicationHandle>& inputApplicationHandle, | ||
4432 | 194 | #if ANDROID_VERSION_MAJOR==4 && ANDROID_VERSION_MINOR<4 | ||
4433 | 195 | const sp<InputWindowHandle>& inputWindowHandle) | ||
4434 | 196 | #else | ||
4435 | 197 | const sp<InputWindowHandle>& inputWindowHandle, | ||
4436 | 198 | const android::String8& reason) | ||
4437 | 199 | #endif | ||
4438 | 200 | { | ||
4439 | 201 | REPORT_FUNCTION_CALL(); | ||
4440 | 202 | (void) inputApplicationHandle; | ||
4441 | 203 | (void) inputWindowHandle; | ||
4442 | 204 | #if ANDROID_VERSION_MAJOR==4 && ANDROID_VERSION_MINOR>=4 | ||
4443 | 205 | (void) reason; | ||
4444 | 206 | #endif | ||
4445 | 207 | |||
4446 | 208 | return 0; | ||
4447 | 209 | } | ||
4448 | 210 | |||
4449 | 211 | void notifyInputChannelBroken(const sp<InputWindowHandle>& inputWindowHandle) | ||
4450 | 212 | { | ||
4451 | 213 | REPORT_FUNCTION_CALL(); | ||
4452 | 214 | (void) inputWindowHandle; | ||
4453 | 215 | } | ||
4454 | 216 | |||
4455 | 217 | void getDispatcherConfiguration(InputDispatcherConfiguration* outConfig) | ||
4456 | 218 | { | ||
4457 | 219 | REPORT_FUNCTION_CALL(); | ||
4458 | 220 | static InputDispatcherConfiguration config; | ||
4459 | 221 | //config.maxEventsPerSecond = INT_MAX; | ||
4460 | 222 | *outConfig = config; | ||
4461 | 223 | } | ||
4462 | 224 | |||
4463 | 225 | bool isKeyRepeatEnabled() | ||
4464 | 226 | { | ||
4465 | 227 | REPORT_FUNCTION_CALL(); | ||
4466 | 228 | return true; | ||
4467 | 229 | } | ||
4468 | 230 | |||
4469 | 231 | bool filterInputEvent(const InputEvent* event, uint32_t policyFlags) | ||
4470 | 232 | { | ||
4471 | 233 | REPORT_FUNCTION_CALL(); | ||
4472 | 234 | (void) event; | ||
4473 | 235 | (void) policyFlags; | ||
4474 | 236 | return input_filter->filter_event(event); | ||
4475 | 237 | } | ||
4476 | 238 | |||
4477 | 239 | void interceptKeyBeforeQueueing(const KeyEvent* event, uint32_t& policyFlags) | ||
4478 | 240 | { | ||
4479 | 241 | REPORT_FUNCTION_CALL(); | ||
4480 | 242 | (void) event; | ||
4481 | 243 | policyFlags |= POLICY_FLAG_PASS_TO_USER; | ||
4482 | 244 | } | ||
4483 | 245 | |||
4484 | 246 | void interceptMotionBeforeQueueing(nsecs_t when, uint32_t& policyFlags) | ||
4485 | 247 | { | ||
4486 | 248 | REPORT_FUNCTION_CALL(); | ||
4487 | 249 | (void) when; | ||
4488 | 250 | (void) policyFlags; | ||
4489 | 251 | policyFlags |= POLICY_FLAG_PASS_TO_USER; | ||
4490 | 252 | } | ||
4491 | 253 | |||
4492 | 254 | nsecs_t interceptKeyBeforeDispatching( | ||
4493 | 255 | const sp<InputWindowHandle>& inputWindowHandle, | ||
4494 | 256 | const KeyEvent* keyEvent, | ||
4495 | 257 | uint32_t policyFlags) | ||
4496 | 258 | { | ||
4497 | 259 | REPORT_FUNCTION_CALL(); | ||
4498 | 260 | (void) inputWindowHandle; | ||
4499 | 261 | (void) keyEvent; | ||
4500 | 262 | (void) policyFlags; | ||
4501 | 263 | |||
4502 | 264 | return 0; | ||
4503 | 265 | } | ||
4504 | 266 | |||
4505 | 267 | bool dispatchUnhandledKey( | ||
4506 | 268 | const sp<InputWindowHandle>& inputWindowHandle, | ||
4507 | 269 | const KeyEvent* keyEvent, | ||
4508 | 270 | uint32_t policyFlags, | ||
4509 | 271 | KeyEvent* outFallbackKeyEvent) | ||
4510 | 272 | { | ||
4511 | 273 | REPORT_FUNCTION_CALL(); | ||
4512 | 274 | (void) inputWindowHandle; | ||
4513 | 275 | (void) keyEvent; | ||
4514 | 276 | (void) policyFlags; | ||
4515 | 277 | (void) outFallbackKeyEvent; | ||
4516 | 278 | return false; | ||
4517 | 279 | } | ||
4518 | 280 | |||
4519 | 281 | virtual void notifySwitch( | ||
4520 | 282 | nsecs_t when, | ||
4521 | 283 | uint32_t switchCode, | ||
4522 | 284 | uint32_t switchValue, | ||
4523 | 285 | uint32_t policyFlags) | ||
4524 | 286 | { | ||
4525 | 287 | REPORT_FUNCTION_CALL(); | ||
4526 | 288 | (void) when; | ||
4527 | 289 | (void) switchCode; | ||
4528 | 290 | (void) switchValue; | ||
4529 | 291 | (void) policyFlags; | ||
4530 | 292 | } | ||
4531 | 293 | |||
4532 | 294 | void pokeUserActivity(nsecs_t eventTime, int32_t eventType) | ||
4533 | 295 | { | ||
4534 | 296 | REPORT_FUNCTION_CALL(); | ||
4535 | 297 | (void) eventTime; | ||
4536 | 298 | (void) eventType; | ||
4537 | 299 | } | ||
4538 | 300 | |||
4539 | 301 | bool checkInjectEventsPermissionNonReentrant( | ||
4540 | 302 | int32_t injectorPid, | ||
4541 | 303 | int32_t injectorUid) | ||
4542 | 304 | { | ||
4543 | 305 | REPORT_FUNCTION_CALL(); | ||
4544 | 306 | (void) injectorPid; | ||
4545 | 307 | (void) injectorUid; | ||
4546 | 308 | |||
4547 | 309 | return true; | ||
4548 | 310 | } | ||
4549 | 311 | |||
4550 | 312 | android::sp<InputFilter> input_filter; | ||
4551 | 313 | }; | ||
4552 | 314 | |||
4553 | 315 | class LooperThread : public android::Thread | ||
4554 | 316 | { | ||
4555 | 317 | public: | ||
4556 | 318 | static const int default_poll_timeout_ms = 500; | ||
4557 | 319 | |||
4558 | 320 | LooperThread(const android::sp<android::Looper>& looper) : looper(looper) | ||
4559 | 321 | { | ||
4560 | 322 | } | ||
4561 | 323 | |||
4562 | 324 | private: | ||
4563 | 325 | bool threadLoop() | ||
4564 | 326 | { | ||
4565 | 327 | if (ALOOPER_POLL_ERROR == looper->pollAll(default_poll_timeout_ms)) | ||
4566 | 328 | return false; | ||
4567 | 329 | return true; | ||
4568 | 330 | } | ||
4569 | 331 | |||
4570 | 332 | android::sp<android::Looper> looper; | ||
4571 | 333 | }; | ||
4572 | 334 | |||
4573 | 335 | struct InputSetup : public android::RefBase | ||
4574 | 336 | { | ||
4575 | 337 | struct DummyApplication : public android::InputApplicationHandle | ||
4576 | 338 | { | ||
4577 | 339 | bool updateInfo() | ||
4578 | 340 | { | ||
4579 | 341 | ALOGI("%s", __PRETTY_FUNCTION__); | ||
4580 | 342 | if (mInfo == NULL) | ||
4581 | 343 | { | ||
4582 | 344 | mInfo = new android::InputApplicationInfo(); | ||
4583 | 345 | mInfo->name = "Shell"; | ||
4584 | 346 | mInfo->dispatchingTimeout = INT_MAX; | ||
4585 | 347 | } | ||
4586 | 348 | |||
4587 | 349 | return true; | ||
4588 | 350 | } | ||
4589 | 351 | }; | ||
4590 | 352 | |||
4591 | 353 | struct DummyApplicationWindow : public android::InputWindowHandle | ||
4592 | 354 | { | ||
4593 | 355 | DummyApplicationWindow( | ||
4594 | 356 | const android::sp<android::InputApplicationHandle>& app_handle, | ||
4595 | 357 | int x = 0, | ||
4596 | 358 | int y = 0, | ||
4597 | 359 | int w = 720, | ||
4598 | 360 | int h = 1280) | ||
4599 | 361 | : android::InputWindowHandle(app_handle), | ||
4600 | 362 | x(x), | ||
4601 | 363 | y(y), | ||
4602 | 364 | w(w), | ||
4603 | 365 | h(h) | ||
4604 | 366 | { | ||
4605 | 367 | } | ||
4606 | 368 | |||
4607 | 369 | bool updateInfo() | ||
4608 | 370 | { | ||
4609 | 371 | ALOGI("%s", __PRETTY_FUNCTION__); | ||
4610 | 372 | if (mInfo == NULL) | ||
4611 | 373 | { | ||
4612 | 374 | mInfo = new android::InputWindowInfo(); | ||
4613 | 375 | SkRegion touchable_region; | ||
4614 | 376 | touchable_region.setRect(x, y, x+w, y+h); | ||
4615 | 377 | |||
4616 | 378 | mInfo->name = "ShellInputWindow"; | ||
4617 | 379 | mInfo->layoutParamsFlags = android::InputWindowInfo::FLAG_NOT_TOUCH_MODAL | android::InputWindowInfo::FLAG_SPLIT_TOUCH; | ||
4618 | 380 | mInfo->layoutParamsType = android::InputWindowInfo::TYPE_APPLICATION; | ||
4619 | 381 | mInfo->touchableRegion = touchable_region; | ||
4620 | 382 | mInfo->frameLeft = x; | ||
4621 | 383 | mInfo->frameTop = y; | ||
4622 | 384 | mInfo->frameRight = x + w; | ||
4623 | 385 | mInfo->frameBottom = y + h; | ||
4624 | 386 | mInfo->scaleFactor = 1.f; | ||
4625 | 387 | mInfo->visible = true; | ||
4626 | 388 | mInfo->canReceiveKeys = true; | ||
4627 | 389 | mInfo->hasFocus = true; | ||
4628 | 390 | mInfo->hasWallpaper = false; | ||
4629 | 391 | mInfo->paused = false; | ||
4630 | 392 | mInfo->layer = 0; | ||
4631 | 393 | mInfo->dispatchingTimeout = INT_MAX; | ||
4632 | 394 | mInfo->ownerPid = 0; | ||
4633 | 395 | mInfo->ownerUid = 0; | ||
4634 | 396 | mInfo->inputFeatures = 0; | ||
4635 | 397 | mInfo->inputChannel = input_channel; | ||
4636 | 398 | } | ||
4637 | 399 | |||
4638 | 400 | return true; | ||
4639 | 401 | } | ||
4640 | 402 | |||
4641 | 403 | android::sp<android::InputChannel> input_channel; | ||
4642 | 404 | int x; | ||
4643 | 405 | int y; | ||
4644 | 406 | int w; | ||
4645 | 407 | int h; | ||
4646 | 408 | }; | ||
4647 | 409 | |||
4648 | 410 | InputSetup(const android::sp<InputFilter>& input_filter) | ||
4649 | 411 | : looper(new android::Looper(false)), | ||
4650 | 412 | looper_thread(new LooperThread(looper)), | ||
4651 | 413 | event_hub(new android::EventHub()), | ||
4652 | 414 | input_reader_policy(new DefaultInputReaderPolicyInterface(looper)), | ||
4653 | 415 | input_dispatcher_policy(new DefaultInputDispatcherPolicy(input_filter)), | ||
4654 | 416 | input_manager(new InputManager(event_hub, input_reader_policy, input_dispatcher_policy)) | ||
4655 | 417 | { | ||
4656 | 418 | input_manager->getDispatcher()->setInputFilterEnabled(true); | ||
4657 | 419 | } | ||
4658 | 420 | |||
4659 | 421 | void start() | ||
4660 | 422 | { | ||
4661 | 423 | input_manager->start(); | ||
4662 | 424 | looper_thread->run(__PRETTY_FUNCTION__, | ||
4663 | 425 | android::PRIORITY_URGENT_DISPLAY); | ||
4664 | 426 | } | ||
4665 | 427 | |||
4666 | 428 | void stop() | ||
4667 | 429 | { | ||
4668 | 430 | input_manager->stop(); | ||
4669 | 431 | looper_thread->requestExitAndWait(); | ||
4670 | 432 | } | ||
4671 | 433 | |||
4672 | 434 | ~InputSetup() | ||
4673 | 435 | { | ||
4674 | 436 | stop(); | ||
4675 | 437 | } | ||
4676 | 438 | android::sp<android::Looper> looper; | ||
4677 | 439 | android::sp<LooperThread> looper_thread; | ||
4678 | 440 | |||
4679 | 441 | android::sp<android::EventHubInterface> event_hub; | ||
4680 | 442 | android::sp<android::InputReaderPolicyInterface> input_reader_policy; | ||
4681 | 443 | android::sp<android::InputDispatcherPolicyInterface> input_dispatcher_policy; | ||
4682 | 444 | android::sp<android::InputManager> input_manager; | ||
4683 | 445 | |||
4684 | 446 | android::Condition wait_condition; | ||
4685 | 447 | android::Mutex wait_guard; | ||
4686 | 448 | }; | ||
4687 | 449 | |||
4688 | 450 | } | ||
4689 | 451 | |||
4690 | 452 | #endif // DEFAULT_APPLICATION_MANAGER_INPUT_SETUP_H_ | ||
4691 | 453 | 0 | ||
4692 | === removed file 'android/hybris/default_application_manager_test.cpp' | |||
4693 | --- android/hybris/default_application_manager_test.cpp 2013-07-25 19:50:52 +0000 | |||
4694 | +++ android/hybris/default_application_manager_test.cpp 1970-01-01 00:00:00 +0000 | |||
4695 | @@ -1,146 +0,0 @@ | |||
4696 | 1 | /* | ||
4697 | 2 | * Copyright © 2012 Canonical Ltd. | ||
4698 | 3 | * | ||
4699 | 4 | * This program is free software: you can redistribute it and/or modify | ||
4700 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
4701 | 6 | * published by the Free Software Foundation. | ||
4702 | 7 | * | ||
4703 | 8 | * This program is distributed in the hope that it will be useful, | ||
4704 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4705 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4706 | 11 | * GNU Lesser General Public License for more details. | ||
4707 | 12 | * | ||
4708 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
4709 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4710 | 15 | * | ||
4711 | 16 | * Authored by: Thomas Voß <thomas.voss@canonical.com> | ||
4712 | 17 | */ | ||
4713 | 18 | #include "application_manager.h" | ||
4714 | 19 | |||
4715 | 20 | #include <binder/IPCThreadState.h> | ||
4716 | 21 | #include <binder/IServiceManager.h> | ||
4717 | 22 | #include <binder/ProcessState.h> | ||
4718 | 23 | |||
4719 | 24 | #include <sys/types.h> | ||
4720 | 25 | #include <sys/stat.h> | ||
4721 | 26 | #include <fcntl.h> | ||
4722 | 27 | |||
4723 | 28 | namespace | ||
4724 | 29 | { | ||
4725 | 30 | struct ApplicationManagerSession : public android::BnApplicationManagerSession | ||
4726 | 31 | { | ||
4727 | 32 | ApplicationManagerSession() | ||
4728 | 33 | { | ||
4729 | 34 | } | ||
4730 | 35 | |||
4731 | 36 | void on_application_resumed() | ||
4732 | 37 | { | ||
4733 | 38 | printf("%s \n", __PRETTY_FUNCTION__); | ||
4734 | 39 | } | ||
4735 | 40 | |||
4736 | 41 | void on_application_about_to_stop() | ||
4737 | 42 | { | ||
4738 | 43 | printf("%s \n", __PRETTY_FUNCTION__); | ||
4739 | 44 | } | ||
4740 | 45 | |||
4741 | 46 | void raise_application_surfaces_to_layer(int layer) | ||
4742 | 47 | { | ||
4743 | 48 | printf("%s \n", __PRETTY_FUNCTION__); | ||
4744 | 49 | printf("%d \n", layer); | ||
4745 | 50 | } | ||
4746 | 51 | |||
4747 | 52 | void raise_surface_to_layer(int32_t token, int layer) | ||
4748 | 53 | { | ||
4749 | 54 | printf("%s: %d, %d \n", __PRETTY_FUNCTION__, token, layer); | ||
4750 | 55 | } | ||
4751 | 56 | |||
4752 | 57 | SurfaceProperties query_surface_properties_for_token(int32_t token) | ||
4753 | 58 | { | ||
4754 | 59 | static const int layer = 100; | ||
4755 | 60 | SurfaceProperties props = { layer, 0, 0, 960, 1280 }; | ||
4756 | 61 | return props; | ||
4757 | 62 | } | ||
4758 | 63 | }; | ||
4759 | 64 | |||
4760 | 65 | struct ApplicationManagerObserver : public android::BnApplicationManagerObserver | ||
4761 | 66 | { | ||
4762 | 67 | void on_session_requested(uint32_t app) | ||
4763 | 68 | { | ||
4764 | 69 | printf("%s: %d \n", __PRETTY_FUNCTION__, app); | ||
4765 | 70 | } | ||
4766 | 71 | |||
4767 | 72 | void on_session_born(int id, | ||
4768 | 73 | int stage_hint, | ||
4769 | 74 | const android::String8& desktop_file) | ||
4770 | 75 | { | ||
4771 | 76 | printf("%s: %d, %d, %s \n", __PRETTY_FUNCTION__, id, stage_hint, desktop_file.string()); | ||
4772 | 77 | } | ||
4773 | 78 | |||
4774 | 79 | void on_session_unfocused(int id, | ||
4775 | 80 | int stage_hint, | ||
4776 | 81 | const android::String8& desktop_file) | ||
4777 | 82 | { | ||
4778 | 83 | printf("%s: %d, %d, %s \n", __PRETTY_FUNCTION__, id, stage_hint, desktop_file.string()); | ||
4779 | 84 | } | ||
4780 | 85 | |||
4781 | 86 | void on_session_focused(int id, | ||
4782 | 87 | int stage_hint, | ||
4783 | 88 | const android::String8& desktop_file) | ||
4784 | 89 | { | ||
4785 | 90 | printf("%s: %d, %d, %s \n", __PRETTY_FUNCTION__, id, stage_hint, desktop_file.string()); | ||
4786 | 91 | } | ||
4787 | 92 | |||
4788 | 93 | void on_keyboard_geometry_changed(int x, | ||
4789 | 94 | int y, | ||
4790 | 95 | int width, | ||
4791 | 96 | int height) | ||
4792 | 97 | { | ||
4793 | 98 | printf("%s: %d, %d, %d, %d \n", __PRETTY_FUNCTION__, x, y, width, height); | ||
4794 | 99 | } | ||
4795 | 100 | |||
4796 | 101 | void on_session_requested_fullscreen(int id, | ||
4797 | 102 | int stage_hint, | ||
4798 | 103 | const android::String8& desktop_file) | ||
4799 | 104 | { | ||
4800 | 105 | printf("%s: %d, %s \n", __PRETTY_FUNCTION__, id, desktop_file.string()); | ||
4801 | 106 | } | ||
4802 | 107 | |||
4803 | 108 | void on_session_died(int id, | ||
4804 | 109 | int stage_hint, | ||
4805 | 110 | const android::String8& desktop_file) | ||
4806 | 111 | { | ||
4807 | 112 | printf("%s: %d, %d, %s \n", __PRETTY_FUNCTION__, id, stage_hint, desktop_file.string()); | ||
4808 | 113 | } | ||
4809 | 114 | }; | ||
4810 | 115 | |||
4811 | 116 | } | ||
4812 | 117 | |||
4813 | 118 | int main(int argc, char** argv) | ||
4814 | 119 | { | ||
4815 | 120 | android::ProcessState::self()->startThreadPool(); | ||
4816 | 121 | |||
4817 | 122 | int test_fd = open("test.file", O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO); | ||
4818 | 123 | |||
4819 | 124 | android::sp<ApplicationManagerObserver> observer(new ApplicationManagerObserver()); | ||
4820 | 125 | android::sp<ApplicationManagerSession> session(new ApplicationManagerSession()); | ||
4821 | 126 | android::sp<android::IServiceManager> service_manager = android::defaultServiceManager(); | ||
4822 | 127 | android::sp<android::IBinder> service = service_manager->getService( | ||
4823 | 128 | android::String16(android::IApplicationManager::exported_service_name())); | ||
4824 | 129 | android::BpApplicationManager app_manager(service); | ||
4825 | 130 | |||
4826 | 131 | app_manager.register_an_observer(observer); | ||
4827 | 132 | |||
4828 | 133 | static const int32_t session_type = 0; | ||
4829 | 134 | static const int32_t stage_hint = 0; | ||
4830 | 135 | |||
4831 | 136 | app_manager.start_a_new_session( | ||
4832 | 137 | session_type, | ||
4833 | 138 | stage_hint, | ||
4834 | 139 | android::String8("default_application_manager_test"), | ||
4835 | 140 | android::String8("default_application_manager_test"), | ||
4836 | 141 | session, | ||
4837 | 142 | test_fd, | ||
4838 | 143 | 0); | ||
4839 | 144 | |||
4840 | 145 | for(;;) {} | ||
4841 | 146 | } | ||
4842 | 147 | 0 | ||
4843 | === removed file 'android/hybris/default_application_session.h' | |||
4844 | --- android/hybris/default_application_session.h 2013-05-22 00:38:39 +0000 | |||
4845 | +++ android/hybris/default_application_session.h 1970-01-01 00:00:00 +0000 | |||
4846 | @@ -1,250 +0,0 @@ | |||
4847 | 1 | /* | ||
4848 | 2 | * Copyright © 2012 Canonical Ltd. | ||
4849 | 3 | * | ||
4850 | 4 | * This program is free software: you can redistribute it and/or modify | ||
4851 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
4852 | 6 | * published by the Free Software Foundation. | ||
4853 | 7 | * | ||
4854 | 8 | * This program is distributed in the hope that it will be useful, | ||
4855 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4856 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4857 | 11 | * GNU Lesser General Public License for more details. | ||
4858 | 12 | * | ||
4859 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
4860 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4861 | 15 | * | ||
4862 | 16 | * Authored by: Thomas Voß <thomas.voss@canonical.com> | ||
4863 | 17 | */ | ||
4864 | 18 | #ifndef DEFAULT_APPLICATION_SESSION_H_ | ||
4865 | 19 | #define DEFAULT_APPLICATION_SESSION_H_ | ||
4866 | 20 | |||
4867 | 21 | #include "application_manager.h" | ||
4868 | 22 | |||
4869 | 23 | #include "private/application/ui/session_credentials.h" | ||
4870 | 24 | #include "private/application/ui/surface_role.h" | ||
4871 | 25 | #include "private/application/ui/stage_hint.h" | ||
4872 | 26 | |||
4873 | 27 | #include <binder/IPCThreadState.h> | ||
4874 | 28 | #include <binder/IServiceManager.h> | ||
4875 | 29 | #include <binder/ProcessState.h> | ||
4876 | 30 | |||
4877 | 31 | namespace ubuntu { namespace detail | ||
4878 | 32 | { | ||
4879 | 33 | |||
4880 | 34 | struct ApplicationSession : public android::RefBase | ||
4881 | 35 | { | ||
4882 | 36 | struct Surface : public android::RefBase | ||
4883 | 37 | { | ||
4884 | 38 | Surface(ApplicationSession* parent, | ||
4885 | 39 | const android::sp<android::InputChannel>& input_channel, | ||
4886 | 40 | int32_t surface_role, | ||
4887 | 41 | int32_t token) | ||
4888 | 42 | : parent(parent), | ||
4889 | 43 | input_channel(input_channel), | ||
4890 | 44 | role(static_cast<ubuntu::application::ui::SurfaceRole>(surface_role)), | ||
4891 | 45 | token(token) | ||
4892 | 46 | { | ||
4893 | 47 | } | ||
4894 | 48 | |||
4895 | 49 | android::IApplicationManagerSession::SurfaceProperties query_properties() | ||
4896 | 50 | { | ||
4897 | 51 | android::IApplicationManagerSession::SurfaceProperties props = | ||
4898 | 52 | parent->remote_session->query_surface_properties_for_token(token); | ||
4899 | 53 | |||
4900 | 54 | return props; | ||
4901 | 55 | } | ||
4902 | 56 | |||
4903 | 57 | android::sp<android::InputWindowHandle> make_input_window_handle() | ||
4904 | 58 | { | ||
4905 | 59 | return android::sp<android::InputWindowHandle>(new InputWindowHandle(parent, android::sp<Surface>(this))); | ||
4906 | 60 | } | ||
4907 | 61 | |||
4908 | 62 | ApplicationSession* parent; | ||
4909 | 63 | android::sp<android::InputChannel> input_channel; | ||
4910 | 64 | ubuntu::application::ui::SurfaceRole role; | ||
4911 | 65 | int32_t token; | ||
4912 | 66 | }; | ||
4913 | 67 | |||
4914 | 68 | ApplicationSession( | ||
4915 | 69 | pid_t pid, | ||
4916 | 70 | pid_t remote_pid, | ||
4917 | 71 | android::sp<android::IApplicationManagerSession> remote_session, | ||
4918 | 72 | int32_t session_type, | ||
4919 | 73 | int32_t stage_hint, | ||
4920 | 74 | const android::String8& app_name, | ||
4921 | 75 | const android::String8& desktop_file) | ||
4922 | 76 | : running_state(ubuntu::application::ui::process_destroyed), | ||
4923 | 77 | pid(pid), | ||
4924 | 78 | remote_pid(remote_pid), | ||
4925 | 79 | app_layer(0), | ||
4926 | 80 | remote_session(remote_session), | ||
4927 | 81 | session_type(static_cast<ubuntu::application::ui::SessionType>(session_type)), | ||
4928 | 82 | stage_hint(stage_hint), | ||
4929 | 83 | app_name(app_name), | ||
4930 | 84 | desktop_file(desktop_file) | ||
4931 | 85 | { | ||
4932 | 86 | } | ||
4933 | 87 | |||
4934 | 88 | struct InputApplicationHandle : public android::InputApplicationHandle | ||
4935 | 89 | { | ||
4936 | 90 | InputApplicationHandle(ApplicationSession* parent) : parent(parent) | ||
4937 | 91 | { | ||
4938 | 92 | updateInfo(); | ||
4939 | 93 | } | ||
4940 | 94 | |||
4941 | 95 | bool updateInfo() | ||
4942 | 96 | { | ||
4943 | 97 | if (mInfo == NULL) | ||
4944 | 98 | { | ||
4945 | 99 | mInfo = new android::InputApplicationInfo(); | ||
4946 | 100 | mInfo->name = parent->app_name; | ||
4947 | 101 | mInfo->dispatchingTimeout = INT_MAX; | ||
4948 | 102 | } | ||
4949 | 103 | |||
4950 | 104 | return true; | ||
4951 | 105 | } | ||
4952 | 106 | |||
4953 | 107 | ApplicationSession* parent; | ||
4954 | 108 | }; | ||
4955 | 109 | |||
4956 | 110 | struct InputWindowHandle : public android::InputWindowHandle | ||
4957 | 111 | { | ||
4958 | 112 | InputWindowHandle(ApplicationSession* parent, const android::sp<Surface>& surface) | ||
4959 | 113 | : android::InputWindowHandle( | ||
4960 | 114 | android::sp<InputApplicationHandle>( | ||
4961 | 115 | new InputApplicationHandle(parent))), | ||
4962 | 116 | parent(parent), | ||
4963 | 117 | surface(surface) | ||
4964 | 118 | { | ||
4965 | 119 | updateInfo(); | ||
4966 | 120 | } | ||
4967 | 121 | |||
4968 | 122 | bool updateInfo() | ||
4969 | 123 | { | ||
4970 | 124 | if (mInfo == NULL) | ||
4971 | 125 | { | ||
4972 | 126 | mInfo = new android::InputWindowInfo(); | ||
4973 | 127 | } | ||
4974 | 128 | |||
4975 | 129 | android::IApplicationManagerSession::SurfaceProperties props; | ||
4976 | 130 | if (parent->running_state == ubuntu::application::ui::process_suspended) | ||
4977 | 131 | { | ||
4978 | 132 | kill(parent->pid, SIGCONT); | ||
4979 | 133 | props = surface->query_properties(); | ||
4980 | 134 | kill(parent->pid, SIGSTOP); | ||
4981 | 135 | } else | ||
4982 | 136 | props = surface->query_properties(); | ||
4983 | 137 | |||
4984 | 138 | ALOGI("%s: touchable_region = (%d, %d, %d, %d)", | ||
4985 | 139 | __PRETTY_FUNCTION__, | ||
4986 | 140 | props.left, | ||
4987 | 141 | props.top, | ||
4988 | 142 | props.right, | ||
4989 | 143 | props.bottom); | ||
4990 | 144 | |||
4991 | 145 | SkRegion touchable_region; | ||
4992 | 146 | touchable_region.setRect(props.left, props.top, props.right+1, props.bottom+1); | ||
4993 | 147 | |||
4994 | 148 | mInfo->name = parent->app_name; | ||
4995 | 149 | mInfo->layoutParamsFlags = android::InputWindowInfo::FLAG_NOT_TOUCH_MODAL; | ||
4996 | 150 | mInfo->layoutParamsType = android::InputWindowInfo::TYPE_APPLICATION; | ||
4997 | 151 | mInfo->touchableRegion = touchable_region; | ||
4998 | 152 | mInfo->frameLeft = props.left; | ||
4999 | 153 | mInfo->frameTop = props.top; | ||
5000 | 154 | mInfo->frameRight = props.right+1; |
FAILED: Continuous integration, rev:304 jenkins. qa.ubuntu. com/job/ platform- api-ci/ 417/ jenkins. qa.ubuntu. com/job/ platform- api-vivid- amd64-ci/ 30/console jenkins. qa.ubuntu. com/job/ platform- api-vivid- armhf-ci/ 30/console jenkins. qa.ubuntu. com/job/ platform- api-vivid- i386-ci/ 30/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/platform- api-ci/ 417/rebuild
http://