Merge lp:~mir-team/platform-api/delete-deprecations into lp:platform-api

Proposed by Robert Carr
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
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://code.launchpad.net/~mir-team/mir/privatize-event/+merge/254149

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://code.launchpad.net/~mir-team/mir/privatize-event/+merge/254149

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.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
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+15.04.20150320-0ubuntu1) UNRELEASED; urgency=medium
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_ubuntu_app_api
- test_android_ubuntu_app_api_multiple_surfaces
These look useful for device bring-up, can they not be ported to use mirclient?

review: Needs Fixing
Revision history for this message
Robert Carr (robertcarr) wrote :

>>=== modified file 'debian/changelog'
>> +platform-api (3.0.0+15.04.20150320-0ubuntu1) UNRELEASED; urgency=medium
>> 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_ubuntu_app_api
>> - test_android_ubuntu_app_api_multiple_surfaces
>> These look useful for device bring-up, can they not be ported to use mirclient?

mir already has so many examples though...

Revision history for this message
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.

Revision history for this message
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?

Revision history for this message
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://wiki.ubuntu.com/Touch/Emulator#Building_from_scratch

Nothing wrong about building this as part of the Mir release silo, my
question is what happened that it wasn't.

Revision history for this message
Robert Carr (robertcarr) wrote :

Talked a bit on IRC :) I'll test building an image soon.

Revision history for this message
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.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

FTBFS in my wily chroot:

[ 5%] Building CXX object src/ubuntu/application/CMakeFiles/ubuntu_application_api.dir/ubuntu_application_api.cpp.o
cd /«PKGBUILDDIR»/obj-x86_64-linux-gnu/src/ubuntu/application && /usr/lib/ccache/x86_64-linux-gnu-g++-4.9 -Dubuntu_application_api_EXPORTS -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fvisibility=hidden --std=c++11 -fPIC -fPIC -I/«PKGBUILDDIR»/include -I/«PKGBUILDDIR»/android/include -I/usr/include/mirclient -I/usr/include/mircommon -I/«PKGBUILDDIR»/src -I/«PKGBUILDDIR»/obj-x86_64-linux-gnu/include -I/«PKGBUILDDIR»/src/ubuntu/application/../../bridge -o CMakeFiles/ubuntu_application_api.dir/ubuntu_application_api.cpp.o -c /«PKGBUILDDIR»/src/ubuntu/application
/ubuntu_application_api.cpp
/«PKGBUILDDIR»/src/ubuntu/application/ubuntu_application_api.cpp:22:42: fatal error: ubuntu/application/ui/window.h: No such file or directory
 #include <ubuntu/application/ui/window.h>
                                          ^
compilation terminated.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
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.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

I can confirm it builds in vivid+overlay & wily. So yay for that. Who will land it?

review: Approve (build)
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

Version should be updated in src/ubuntu/application/desktop/module_version.h as well right?

review: Needs Information
Revision history for this message
Robert Carr (robertcarr) wrote :

Good catch! fixed all three module_version.h are correct now.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

Looks ok, haven't tested.

I should probably rebase this: https://code.launchpad.net/~mir-team/platform-api/remove-mirserver on top of this one given the major revision bump and land them together.

review: Approve
Revision history for this message
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-location-service2
qtubuntu-sensors
cameraplugin-aal

Any other packages missing from that list?

Revision history for this message
Gerry Boland (gerboland) wrote :

based on https://code.launchpad.net/~vorlon/platform-api/lp.1465958/+merge/262254 , you might need to add gst-plugins-bad1.0 to that list

Revision history for this message
Iain Lane (laney) wrote :

Any chance we can try to get this uploaded?

Revision history for this message
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-across-the-board review right now.

review: Approve
Revision history for this message
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+14.10.20140819-0ubuntu1

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2015-03-18 10:03:52 +0000
+++ CMakeLists.txt 2015-07-06 16:10:44 +0000
@@ -2,8 +2,8 @@
22
3project(ubuntu-platform-api)3project(ubuntu-platform-api)
44
5set(UBUNTU_PLATFORM_API_VERSION_MAJOR 2)5set(UBUNTU_PLATFORM_API_VERSION_MAJOR 3)
6set(UBUNTU_PLATFORM_API_VERSION_MINOR 9)6set(UBUNTU_PLATFORM_API_VERSION_MINOR 0)
7set(UBUNTU_PLATFORM_API_VERSION_PATCH 0)7set(UBUNTU_PLATFORM_API_VERSION_PATCH 0)
88
9set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")9set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
1010
=== removed file 'android/default/default_ubuntu_application.cpp'
--- android/default/default_ubuntu_application.cpp 2013-05-30 01:08:53 +0000
+++ android/default/default_ubuntu_application.cpp 1970-01-01 00:00:00 +0000
@@ -1,409 +0,0 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 * Ricardo Mendoza <ricardo.mendoza@canonical.com>
18 */
19
20// Private
21#include <private/application/ui/init.h>
22#include <private/application/ui/setup.h>
23#include <private/application/ui/ubuntu_application_ui.h>
24
25// Public C apis
26#include <ubuntu/application/id.h>
27#include <ubuntu/application/instance.h>
28#include <ubuntu/application/lifecycle_delegate.h>
29#include <ubuntu/application/ui/options.h>
30
31// ver2.0 Private
32
33#include <private/ui/session_service.h>
34#include <private/application/application.h>
35
36#include <utils/Log.h>
37
38// C APIs
39namespace
40{
41struct IUApplicationLifecycleDelegate : public ubuntu::application::LifecycleDelegate
42{
43 IUApplicationLifecycleDelegate(void *context) :
44 application_resumed_cb(NULL),
45 application_about_to_stop_cb(NULL),
46 context(context),
47 refcount(1)
48 {
49 }
50
51 void on_application_resumed()
52 {
53 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
54
55 if (!application_resumed_cb)
56 return;
57
58 application_resumed_cb(NULL, this->context);
59 }
60
61 void on_application_about_to_stop()
62 {
63 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
64
65 if (!application_about_to_stop_cb)
66 return;
67
68 application_about_to_stop_cb(NULL, this->context);
69 }
70
71 u_on_application_resumed application_resumed_cb;
72 u_on_application_about_to_stop application_about_to_stop_cb;
73 void *context;
74
75 unsigned refcount;
76};
77
78template<typename T>
79struct Holder
80{
81 Holder(const T&value = T()) : value(value)
82 {
83 }
84
85 T value;
86};
87
88template<typename T>
89Holder<T>* make_holder(const T& value)
90{
91 return new Holder<T>(value);
92}
93}
94
95/*
96 * Application Lifecycle
97 */
98
99UApplicationLifecycleDelegate*
100u_application_lifecycle_delegate_new()
101{
102 ALOGI("%s()", __PRETTY_FUNCTION__);
103
104 ubuntu::application::LifecycleDelegate::Ptr p(new IUApplicationLifecycleDelegate(NULL));
105
106 return make_holder(p);
107}
108
109void
110u_application_lifecycle_delegate_destroy(UApplicationLifecycleDelegate *delegate)
111{
112 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
113
114 auto s = static_cast<Holder<IUApplicationLifecycleDelegate*>*>(delegate);
115
116 if (s->value->refcount)
117 return;
118
119 delete s;
120}
121
122void
123u_application_lifecycle_delegate_ref(UApplicationLifecycleDelegate *delegate)
124{
125 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
126
127 auto s = static_cast<Holder<IUApplicationLifecycleDelegate*>*>(delegate);
128 s->value->refcount++;
129}
130
131void
132u_application_lifecycle_delegate_unref(UApplicationLifecycleDelegate *delegate)
133{
134 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
135
136 auto s = static_cast<Holder<IUApplicationLifecycleDelegate*>*>(delegate);
137 if (s->value->refcount)
138 s->value->refcount--;
139}
140
141void
142u_application_lifecycle_delegate_set_application_resumed_cb(
143 UApplicationLifecycleDelegate *delegate,
144 u_on_application_resumed cb)
145{
146 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
147
148 auto s = static_cast<Holder<IUApplicationLifecycleDelegate*>*>(delegate);
149 s->value->application_resumed_cb = cb;
150}
151
152u_on_application_resumed
153u_application_lifecycle_delegate_get_application_resumed_cb(
154 UApplicationLifecycleDelegate *delegate)
155{
156 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
157
158 auto s = static_cast<Holder<IUApplicationLifecycleDelegate*>*>(delegate);
159 return s->value->application_resumed_cb;
160}
161
162void
163u_application_lifecycle_delegate_set_application_about_to_stop_cb(
164 UApplicationLifecycleDelegate *delegate,
165 u_on_application_about_to_stop cb)
166{
167 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
168
169 auto s = static_cast<Holder<IUApplicationLifecycleDelegate*>*>(delegate);
170 s->value->application_about_to_stop_cb = cb;
171}
172
173u_on_application_about_to_stop
174u_application_lifecycle_delegate_get_application_about_to_stop_cb(
175 UApplicationLifecycleDelegate *delegate)
176{
177 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
178
179 auto s = static_cast<Holder<IUApplicationLifecycleDelegate*>*>(delegate);
180 return s->value->application_about_to_stop_cb;
181}
182
183void
184u_application_lifecycle_delegate_set_context(
185 UApplicationLifecycleDelegate *delegate,
186 void *context)
187{
188 ALOGI("%s():%d context=%p", __PRETTY_FUNCTION__, __LINE__, context);
189
190 auto s = static_cast<Holder<IUApplicationLifecycleDelegate*>*>(delegate);
191 if (s->value->context == NULL)
192 s->value->context = context;
193}
194
195void*
196u_application_lifecycle_delegate_get_context(
197 UApplicationLifecycleDelegate *delegate,
198 void *context)
199{
200 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
201
202 auto s = static_cast<Holder<IUApplicationLifecycleDelegate*>*>(delegate);
203 return s->value->context;
204}
205
206/*
207 * Application Options
208 */
209
210UApplicationOptions*
211u_application_options_new_from_cmd_line(
212 int argc,
213 char** argv)
214{
215 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
216
217 ubuntu::application::ui::init(argc, argv);
218
219 return ubuntu::application::ui::Setup::instance().get();
220}
221
222UAUiFormFactor
223u_application_options_get_form_factor(
224 UApplicationOptions *options)
225{
226 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
227
228 auto setup = static_cast<ubuntu::application::ui::Setup*>(options);
229 return static_cast<UAUiFormFactor>(setup->form_factor_hint());
230}
231
232UAUiStage
233u_application_options_get_stage(
234 UApplicationOptions *options)
235{
236 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
237
238 auto setup = static_cast<ubuntu::application::ui::Setup*>(options);
239 return static_cast<UAUiStage>(setup->stage_hint());
240}
241
242/*
243 * Application Id
244 */
245
246UApplicationId*
247u_application_id_new_from_stringn(
248 const char *string,
249 size_t size)
250{
251 ubuntu::application::Id::Ptr id(
252 new ubuntu::application::Id(string, size)
253 );
254
255 return make_holder(id);
256}
257
258void
259u_application_id_destroy(UApplicationId *id)
260{
261
262 auto p = static_cast<Holder<ubuntu::application::Id::Ptr>*>(id);
263
264 if (p)
265 delete p;
266}
267
268int
269u_application_id_compare(
270 UApplicationId *lhs,
271 UApplicationId *rhs)
272{
273 auto ilhs = static_cast<Holder<ubuntu::application::Id::Ptr>*>(lhs);
274 auto irhs = static_cast<Holder<ubuntu::application::Id::Ptr>*>(rhs);
275
276 if (ilhs->value->size != irhs->value->size)
277 return 1;
278
279 for (size_t i = 0; i < ilhs->value->size; i++)
280 {
281 if ((char) ilhs->value->string[i] == (char) irhs->value->string[i])
282 continue;
283
284 return 1;
285 }
286
287 return 0;
288}
289
290/*
291 * Description
292 */
293
294UApplicationDescription*
295u_application_description_new()
296{
297 ubuntu::application::Description::Ptr desc(
298 new ubuntu::application::Description()
299 );
300
301 return make_holder(desc);
302}
303
304void
305u_application_description_destroy(
306 UApplicationDescription *desc)
307{
308 auto p = static_cast<Holder<ubuntu::application::Description::Ptr>*>(desc);
309
310 if (p)
311 delete p;
312}
313
314void
315u_application_description_set_application_id(
316 UApplicationDescription *desc,
317 UApplicationId *id)
318{
319 if (id == NULL)
320 return;
321
322 auto p = static_cast<Holder<ubuntu::application::Description::Ptr>*>(desc);
323 p->value->set_application_id(id);
324}
325
326UApplicationId*
327u_application_description_get_application_id(
328 UApplicationDescription *desc)
329{
330 auto p = static_cast<Holder<ubuntu::application::Description::Ptr>*>(desc);
331 return p->value->get_application_id();
332}
333
334void
335u_application_description_set_application_lifecycle_delegate(
336 UApplicationDescription *desc,
337 UApplicationLifecycleDelegate *delegate)
338{
339 if (delegate == NULL)
340 return;
341
342 ALOGI("%s():%d -- delegate=%p", __PRETTY_FUNCTION__, __LINE__, delegate);
343
344 auto p = static_cast<Holder<ubuntu::application::Description::Ptr>*>(desc);
345 p->value->set_lifecycle_delegate(delegate);
346}
347
348UApplicationLifecycleDelegate*
349u_application_description_get_application_lifecycle_delegate(
350 UApplicationDescription *desc)
351{
352 auto p = static_cast<Holder<ubuntu::application::Description::Ptr>*>(desc);
353 return p->value->get_lifecycle_delegate();
354}
355
356/*
357 * Instance
358 */
359
360UApplicationInstance*
361u_application_instance_new_from_description_with_options(
362 UApplicationDescription *desc,
363 UApplicationOptions *options)
364{
365 if (desc == NULL || options == NULL)
366 return NULL;
367
368 ubuntu::application::Instance::Ptr instance(
369 new ubuntu::application::Instance(desc, options)
370 );
371
372 return make_holder(instance);
373}
374
375void
376u_application_instance_ref(
377 UApplicationInstance *instance)
378{
379 auto p = static_cast<Holder<ubuntu::application::Instance::Ptr>*>(instance);
380 p->value->ref();
381}
382
383void
384u_application_instance_unref(
385 UApplicationInstance *instance)
386{
387 auto p = static_cast<Holder<ubuntu::application::Instance::Ptr>*>(instance);
388 p->value->unref();
389}
390
391void
392u_application_instance_destroy(
393 UApplicationInstance *instance)
394{
395 auto p = static_cast<Holder<ubuntu::application::Instance::Ptr>*>(instance);
396
397 if (p->value->get_refcount() == 0)
398 delete p;
399}
400
401void
402u_application_instance_run(
403 UApplicationInstance *instance)
404{
405 auto p = static_cast<Holder<ubuntu::application::Instance::Ptr>*>(instance);
406
407 if (p)
408 p->value->run();
409}
4100
=== removed file 'android/default/default_ubuntu_application_ui.cpp'
--- android/default/default_ubuntu_application_ui.cpp 2014-09-29 19:56:49 +0000
+++ android/default/default_ubuntu_application_ui.cpp 1970-01-01 00:00:00 +0000
@@ -1,465 +0,0 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 * Ricardo Mendoza <ricardo.mendoza@canonical.com>
18 */
19
20// Private
21#include <private/application/ui/init.h>
22#include <private/application/ui/session.h>
23#include <private/application/ui/session_credentials.h>
24#include <private/application/ui/setup.h>
25#include <private/application/ui/surface.h>
26#include <private/application/ui/surface_factory.h>
27#include <private/application/ui/surface_properties.h>
28
29// Public C apis
30#include <private/application/ui/ubuntu_application_ui.h>
31#include <ubuntu/application/instance.h>
32#include <ubuntu/application/lifecycle_delegate.h>
33#include <ubuntu/application/ui/options.h>
34#include <ubuntu/application/ui/session.h>
35#include <ubuntu/application/ui/window.h>
36#include <ubuntu/application/ui/clipboard.h>
37#include <ubuntu/application/ui/display.h>
38
39// ver2.0 Private
40#include <private/application/ui/window_internal.h>
41
42#include <private/ui/session_service.h>
43#include <private/application/ui/ubuntu_application_ui.h>
44#include <private/application/application.h>
45
46#include <utils/Log.h>
47
48namespace
49{
50ubuntu::application::ui::Session::Ptr session;
51
52struct CallbackEventListener : public ubuntu::application::ui::input::Listener
53{
54 CallbackEventListener(input_event_cb cb, void* context) : cb(cb),
55 context(context)
56 {
57 }
58
59 void on_new_event(const ::Event& e)
60 {
61 if (cb)
62 cb(context, &e);
63 }
64
65 input_event_cb cb;
66 void* context;
67};
68
69template<typename T>
70struct Holder
71{
72 Holder(const T&value = T()) : value(value)
73 {
74 }
75
76 T value;
77};
78
79template<typename T>
80Holder<T>* make_holder(const T& value)
81{
82 return new Holder<T>(value);
83}
84}
85
86/*
87 * Clipboard
88 */
89
90void
91ua_ui_set_clipboard_content(void* data,
92 size_t size)
93{
94 static const char mime_type[ubuntu::application::ui::Clipboard::Content::MAX_MIME_TYPE_SIZE] = "none/none";
95
96 ubuntu::application::ui::Clipboard::Content content(mime_type, data, size);
97
98 ubuntu::application::ui::Session::clipboard()->set_content(content);
99}
100
101void
102ua_ui_get_clipboard_content(void** data,
103 size_t* size)
104{
105 ubuntu::application::ui::Clipboard::Content content(ubuntu::application::ui::Session::clipboard()->get_content());
106
107 *data = content.data;
108 *size = content.data_size;
109}
110
111/*
112 * Display
113 */
114
115UAUiDisplay*
116ua_ui_display_new_with_index(
117 size_t index)
118{
119 return make_holder(
120 ubuntu::application::ui::Session::physical_display_info(
121 static_cast<ubuntu::application::ui::PhysicalDisplayIdentifier>(index)));
122}
123
124void
125ua_ui_display_destroy(
126 UAUiDisplay* display)
127{
128 auto s = static_cast<Holder<ubuntu::application::ui::PhysicalDisplayInfo::Ptr>*>(display);
129 delete s;
130}
131
132uint32_t
133ua_ui_display_query_horizontal_res(
134 UAUiDisplay* display)
135{
136 auto s = static_cast<Holder<ubuntu::application::ui::PhysicalDisplayInfo::Ptr>*>(display);
137 return s->value->horizontal_resolution();
138}
139
140uint32_t
141ua_ui_display_query_vertical_res(
142 UAUiDisplay* display)
143{
144 auto s = static_cast<Holder<ubuntu::application::ui::PhysicalDisplayInfo::Ptr>*>(display);
145 return s->value->vertical_resolution();
146}
147
148EGLNativeDisplayType
149ua_ui_display_get_native_type(
150 UAUiDisplay* display)
151{
152 // Always EGL_DEFAULT_DISPLAY with android EGL.
153 return EGL_DEFAULT_DISPLAY;
154}
155
156/*
157 * Window Properties
158 */
159
160UAUiWindowProperties*
161ua_ui_window_properties_new_for_normal_window()
162{
163 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
164
165 ubuntu::application::ui::WindowProperties::Ptr p(
166 new ubuntu::application::ui::WindowProperties()
167 );
168
169 return make_holder(p);
170}
171
172void
173ua_ui_window_properties_destroy(
174 UAUiWindowProperties *properties)
175{
176 auto p = static_cast<Holder<ubuntu::application::ui::WindowProperties::Ptr>*>(properties);
177
178 if (p)
179 delete p;
180}
181
182void
183ua_ui_window_properties_set_titlen(
184 UAUiWindowProperties *properties,
185 const char *title,
186 size_t size)
187{
188 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
189 auto p = static_cast<Holder<ubuntu::application::ui::WindowProperties::Ptr>*>(properties);
190 p->value->set_titlen(title, size);
191}
192
193const char*
194ua_ui_window_properties_get_title(
195 UAUiWindowProperties *properties)
196{
197 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
198 auto p = static_cast<Holder<ubuntu::application::ui::WindowProperties::Ptr>*>(properties);
199 return p->value->get_title();
200}
201
202void
203ua_ui_window_properties_set_role(
204 UAUiWindowProperties *properties,
205 UAUiWindowRole role)
206{
207 ALOGI("%s():%d %p %d", __PRETTY_FUNCTION__, __LINE__, properties, role);
208 auto p = static_cast<Holder<ubuntu::application::ui::WindowProperties::Ptr>*>(properties);
209 p->value->set_role(role);
210}
211
212UAUiWindowRole
213ua_ui_window_properties_get_role(
214 UAUiWindowProperties *properties)
215{
216 auto p = static_cast<Holder<ubuntu::application::ui::WindowProperties::Ptr>*>(properties);
217 return p->value->get_role();
218}
219
220void
221ua_ui_window_properties_set_input_cb_and_ctx(
222 UAUiWindowProperties *properties,
223 UAUiWindowInputEventCb cb,
224 void *ctx)
225{
226 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
227 auto p = static_cast<Holder<ubuntu::application::ui::WindowProperties::Ptr>*>(properties);
228 p->value->set_input_event_cb_and_ctx(cb, ctx);
229}
230
231void
232ua_ui_window_properties_set_event_cb_and_ctx(UAUiWindowProperties*, UAUiWindowEventCb, void *)
233{
234}
235
236void
237ua_ui_window_properties_set_dimensions(
238 UAUiWindowProperties *properties,
239 uint32_t width,
240 uint32_t height)
241{
242 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
243 (void) width;
244 (void) height;
245}
246
247/*
248 * Session
249 */
250
251UAUiSessionProperties*
252ua_ui_session_properties_new()
253{
254 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
255
256 ubuntu::application::ui::SessionProperties::Ptr props(
257 new ubuntu::application::ui::SessionProperties()
258 );
259
260 return make_holder(props);
261}
262
263void
264ua_ui_session_properties_set_type(
265 UAUiSessionProperties* properties,
266 UAUiSessionType type)
267{
268 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
269
270 auto p = static_cast<Holder<ubuntu::application::ui::SessionProperties::Ptr>*>(properties);
271
272 if (p)
273 p->value->set_type(static_cast<ubuntu::application::ui::SessionType>(type));
274}
275
276void
277ua_ui_session_properties_set_remote_pid(
278 UAUiSessionProperties *properties,
279 uint32_t pid)
280{
281 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
282
283 auto p = static_cast<Holder<ubuntu::application::ui::SessionProperties::Ptr>*>(properties);
284 p->value->set_remote_pid(pid);
285}
286
287UAUiSession*
288ua_ui_session_new_with_properties(
289 UAUiSessionProperties *properties)
290{
291 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
292
293 if (session != NULL)
294 return session.get();
295
296 auto p = static_cast<Holder<ubuntu::application::ui::SessionProperties::Ptr>*>(properties);
297
298 SessionCredentials creds = {
299 static_cast<SessionType>(p->value->get_type()),
300 APPLICATION_SUPPORTS_OVERLAYED_MENUBAR,
301 "QtUbuntu",
302 p->value->get_remote_pid(),
303 NULL
304 };
305
306 ubuntu::application::ui::SessionCredentials sc(&creds);
307 session = ubuntu::ui::SessionService::instance()->start_a_new_session(sc);
308
309 return session.get();
310}
311
312/*
313 * Window (Surface)
314 */
315
316UAUiWindow*
317ua_ui_window_new_for_application_with_properties(
318 UApplicationInstance *instance,
319 UAUiWindowProperties *properties)
320{
321 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
322
323 if (session == NULL)
324 return NULL;
325
326 auto p = static_cast<Holder<ubuntu::application::ui::WindowProperties::Ptr>*>(properties);
327
328 ubuntu::application::ui::SurfaceProperties props =
329 {
330 "test",
331 0,
332 0,
333 static_cast<ubuntu::application::ui::SurfaceRole>(p->value->get_role()),
334 0, //FIXME: Set flags
335 true
336 };
337
338 ubuntu::application::ui::Surface::Ptr surface =
339 session->create_surface(
340 props,
341 ubuntu::application::ui::input::Listener::Ptr(
342 new CallbackEventListener(p->value->get_input_cb(),
343 p->value->get_ctx())));
344
345 auto inst = static_cast<Holder<ubuntu::application::Instance::Ptr>*>(instance);
346 auto desc = static_cast<Holder<ubuntu::application::Description::Ptr>*>(inst->value->get_description());
347 auto dele = static_cast<Holder<ubuntu::application::LifecycleDelegate::Ptr>*>(desc->value->get_lifecycle_delegate());
348
349 session->install_lifecycle_delegate(dele->value);
350
351 return make_holder(surface);
352}
353
354void
355ua_ui_window_destroy(
356 UAUiWindow *window)
357{
358 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
359 //auto p = static_cast<Holder<ubuntu::application::ui::Window::Ptr*>*>(window);
360 auto p = static_cast<Holder<ubuntu::application::ui::Surface::Ptr>*>(window);
361
362 if (p)
363 delete p;
364}
365
366UAUiWindowId
367ua_ui_window_get_id(
368 UAUiWindow *window)
369{
370 //auto p = static_cast<Holder<ubuntu::application::ui::Window::Ptr*>*>(window);
371 auto p = static_cast<Holder<ubuntu::application::ui::Surface::Ptr>*>(window);
372
373 return p->value->get_id();
374}
375
376UStatus
377ua_ui_window_move(
378 UAUiWindow *window,
379 uint32_t new_x,
380 uint32_t new_y)
381{
382 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
383 auto p = static_cast<Holder<ubuntu::application::ui::Surface::Ptr>*>(window);
384 p->value->move_to(new_x, new_y);
385
386 return U_STATUS_SUCCESS;
387}
388
389UStatus
390ua_ui_window_resize(
391 UAUiWindow *window,
392 uint32_t new_width,
393 uint32_t new_height)
394{
395 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
396 //auto p = static_cast<Holder<ubuntu::application::ui::Window::Ptr*>*>(window);
397 auto p = static_cast<Holder<ubuntu::application::ui::Surface::Ptr>*>(window);
398 p->value->resize(new_width, new_height);
399
400 return U_STATUS_SUCCESS;
401}
402
403UStatus
404ua_ui_window_hide(
405 UAUiWindow *window)
406{
407 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
408 //auto p = static_cast<Holder<ubuntu::application::ui::Window::Ptr*>*>(window);
409 auto p = static_cast<Holder<ubuntu::application::ui::Surface::Ptr>*>(window);
410 p->value->set_visible(session->get_session_pid(), false);
411
412 return U_STATUS_SUCCESS;
413}
414
415UStatus
416ua_ui_window_show(
417 UAUiWindow *window)
418{
419 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
420 auto p = static_cast<Holder<ubuntu::application::ui::Surface::Ptr>*>(window);
421 p->value->set_visible(session->get_session_pid(), true);
422
423 return U_STATUS_SUCCESS;
424}
425
426void
427ua_ui_window_request_fullscreen(
428 UAUiWindow *window)
429{
430 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
431 if (session == NULL)
432 return;
433
434 auto p = static_cast<Holder<ubuntu::application::ui::Surface::Ptr>*>(window);
435 session->toggle_fullscreen_for_surface(p->value);
436}
437
438void
439ua_ui_window_request_state(
440 UAUiWindow *window, UApplicationUiWindowState state)
441{
442 ALOGI("ua_ui_window_request_state unimplemented %s:%d", __PRETTY_FUNCTION__, __LINE__);
443 (void) window;
444 (void) state;
445}
446
447EGLNativeWindowType
448ua_ui_window_get_native_type(
449 UAUiWindow *window)
450{
451 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
452 auto p = static_cast<Holder<ubuntu::application::ui::Surface::Ptr>*>(window);
453 return p->value->to_native_window_type();
454}
455
456UApplicationUiWindowOrientation
457ua_ui_window_get_orientation(
458 UAUiWindow *window)
459{
460 ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
461 (void*) window;
462 // Orientation flag not available with android, return default
463 return U_ORIENTATION_NORMAL;
464}
465
4660
=== removed file 'android/default/default_ubuntu_ui.cpp'
--- android/default/default_ubuntu_ui.cpp 2013-06-07 01:08:41 +0000
+++ android/default/default_ubuntu_ui.cpp 1970-01-01 00:00:00 +0000
@@ -1,273 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18
19#include <ubuntu/ui/ubuntu_ui_session_service.h>
20
21#include <private/ui/session_service.h>
22#include <private/ui/session_enumerator.h>
23
24#include <stdio.h>
25
26#include <utils/Log.h>
27
28namespace
29{
30struct TaskController : public ubuntu::ui::TaskController
31{
32 TaskController(ubuntu_ui_task_controller* controller) : controller(controller)
33 {
34 }
35
36 void continue_task(int pid)
37 {
38 if (!controller)
39 return;
40
41 if (!controller->continue_task)
42 return;
43
44 controller->continue_task(pid, controller->context);
45 }
46
47 void suspend_task(int pid)
48 {
49 if (!controller)
50 return;
51
52 if (!controller->suspend_task)
53 return;
54
55 controller->suspend_task(pid, controller->context);
56 }
57
58 ubuntu_ui_task_controller* controller;
59};
60
61struct SessionLifeCycleObserver : public ubuntu::ui::SessionLifeCycleObserver
62{
63 SessionLifeCycleObserver(ubuntu_ui_session_lifecycle_observer* observer) : observer(observer)
64 {
65 }
66
67 void on_session_requested(ubuntu::ui::WellKnownApplication app)
68 {
69 if (!observer)
70 return;
71
72 if (!observer->on_session_requested)
73 return;
74
75 observer->on_session_requested(static_cast<ubuntu_ui_well_known_application>(app), observer->context);
76 }
77
78 void on_session_born(const ubuntu::ui::SessionProperties::Ptr& props)
79 {
80 if (!observer)
81 return;
82
83 if (!observer->on_session_born)
84 return;
85
86 observer->on_session_born(&props, observer->context);
87 }
88
89 void on_session_unfocused(const ubuntu::ui::SessionProperties::Ptr& props)
90 {
91 if (!observer)
92 return;
93
94 if (!observer->on_session_unfocused)
95 return;
96
97 observer->on_session_unfocused(&props, observer->context);
98 }
99
100 void on_session_focused(const ubuntu::ui::SessionProperties::Ptr& props)
101 {
102 if (!observer)
103 return;
104
105 if (!observer->on_session_focused)
106 return;
107
108 observer->on_session_focused(&props, observer->context);
109 }
110
111 void on_keyboard_geometry_changed(int x, int y, int width, int height)
112 {
113 if (!observer)
114 return;
115
116 if (!observer->on_keyboard_geometry_changed)
117 return;
118
119 observer->on_keyboard_geometry_changed(x, y, width, height, observer->context);
120 }
121
122 void on_session_requested_fullscreen(const ubuntu::ui::SessionProperties::Ptr& props)
123 {
124 if (!observer)
125 return;
126
127 if(!observer->on_session_requested_fullscreen)
128 return;
129
130 observer->on_session_requested_fullscreen(&props, observer->context);
131 }
132
133 void on_session_died(const ubuntu::ui::SessionProperties::Ptr& props)
134 {
135 if (!observer)
136 return;
137
138 if (!observer->on_session_died)
139 return;
140
141 observer->on_session_died(&props, observer->context);
142 }
143
144 ubuntu_ui_session_lifecycle_observer* observer;
145};
146
147}
148
149const char* ubuntu_ui_session_properties_get_value_for_key(ubuntu_ui_session_properties props, const char* key)
150{
151 if (!props)
152 return NULL;
153
154 if (!key)
155 return NULL;
156
157 const ubuntu::ui::SessionProperties::Ptr* p = static_cast<const ubuntu::ui::SessionProperties::Ptr*>(props);
158
159 return (*p)->value_for_key(key);
160}
161
162int ubuntu_ui_session_properties_get_application_stage_hint(ubuntu_ui_session_properties props)
163{
164 if (!props)
165 return -1;
166
167 const ubuntu::ui::SessionProperties::Ptr* p = static_cast<const ubuntu::ui::SessionProperties::Ptr*>(props);
168
169 return (*p)->application_stage_hint();
170}
171
172int ubuntu_ui_session_properties_get_application_instance_id(ubuntu_ui_session_properties props)
173{
174 if (!props)
175 return -1;
176
177 const ubuntu::ui::SessionProperties::Ptr* p = static_cast<const ubuntu::ui::SessionProperties::Ptr*>(props);
178
179 return (*p)->application_instance_id();
180}
181
182const char* ubuntu_ui_session_properties_get_desktop_file_hint(ubuntu_ui_session_properties props)
183{
184 if (!props)
185 return NULL;
186
187 const ubuntu::ui::SessionProperties::Ptr* p = static_cast<const ubuntu::ui::SessionProperties::Ptr*>(props);
188
189 return (*p)->desktop_file_hint();
190}
191
192bool 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)
193{
194 if (!pp)
195 return false;
196
197 const ubuntu::ui::SessionPreviewProvider::Ptr* spp =
198 static_cast<const ubuntu::ui::SessionPreviewProvider::Ptr*>(pp);
199
200 return (*spp)->get_or_update_session_preview(texture, *width, *height);
201}
202
203void ubuntu_ui_session_install_session_lifecycle_observer(ubuntu_ui_session_lifecycle_observer* observer)
204{
205 ubuntu::ui::SessionLifeCycleObserver::Ptr p(new SessionLifeCycleObserver(observer));
206 ubuntu::ui::SessionService::instance()->install_session_lifecycle_observer(p);
207}
208
209void ubuntu_ui_session_unfocus_running_sessions()
210{
211 ubuntu::ui::SessionService::instance()->unfocus_running_sessions();
212}
213
214void ubuntu_ui_session_focus_running_session_with_id(int id)
215{
216 ubuntu::ui::SessionService::instance()->focus_running_session_with_id(id);
217}
218
219void ubuntu_ui_session_snapshot_running_session_with_id(int id, ubuntu_ui_session_service_snapshot_cb cb, void* context)
220{
221 ubuntu::ui::SessionSnapshot::Ptr ss = ubuntu::ui::SessionService::instance()->snapshot_running_session_with_id(id);
222
223 if (cb)
224 {
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());
226 cb(ss->pixel_data(), ss->width(), ss->height(), ss->x(), ss->y(),
227 ss->source_width(), ss->source_height(), ss->stride(), context);
228 }
229}
230
231void ubuntu_ui_session_trigger_switch_to_well_known_application(ubuntu_ui_well_known_application app)
232{
233 ubuntu::ui::SessionService::instance()->trigger_switch_to_well_known_application(
234 static_cast<ubuntu::ui::WellKnownApplication>(app));
235}
236
237int32_t ubuntu_ui_set_surface_trap(int32_t x, int32_t y, int32_t width, int32_t height)
238{
239 return ubuntu::ui::SessionService::instance()->set_surface_trap(x, y, width, height);
240}
241
242void ubuntu_ui_unset_surface_trap(int32_t handle)
243{
244 ubuntu::ui::SessionService::instance()->unset_surface_trap(handle);
245}
246
247void ubuntu_ui_report_osk_visible(int x, int y, int width, int height)
248{
249 ubuntu::ui::SessionService::instance()->report_osk_visible(x, y, width, height);
250}
251
252void ubuntu_ui_report_osk_invisible()
253{
254 ubuntu::ui::SessionService::instance()->report_osk_invisible();
255}
256
257void ubuntu_ui_report_notification_visible()
258{
259 ubuntu::ui::SessionService::instance()->report_notification_visible();
260}
261
262void ubuntu_ui_report_notification_invisible()
263{
264 ubuntu::ui::SessionService::instance()->report_notification_invisible();
265}
266
267void ubuntu_ui_install_task_controller(ubuntu_ui_task_controller *controller)
268{
269 printf("installing task controller");
270 ubuntu::ui::TaskController::Ptr p(new TaskController(controller));
271 ubuntu::ui::SessionService::instance()->install_task_controller(p);
272}
273
2740
=== modified file 'android/hybris/Android.mk'
--- android/hybris/Android.mk 2015-03-19 19:56:37 +0000
+++ android/hybris/Android.mk 2015-07-06 16:10:44 +0000
@@ -22,12 +22,10 @@
22 $(UPAPI_PATH)/android/include22 $(UPAPI_PATH)/android/include
2323
24LOCAL_SRC_FILES := \24LOCAL_SRC_FILES := \
25 ubuntu_application_api_for_hybris.cpp \
26 ubuntu_application_gps_for_hybris.cpp \25 ubuntu_application_gps_for_hybris.cpp \
27 ubuntu_application_sensors_for_hybris.cpp \26 ubuntu_application_sensors_for_hybris.cpp \
28 ../default/default_ubuntu_application_sensor.cpp \27 ../default/default_ubuntu_application_sensor.cpp
29 ../default/default_ubuntu_ui.cpp \28
30 application_manager.cpp
3129
32LOCAL_MODULE := libubuntu_application_api30LOCAL_MODULE := libubuntu_application_api
33LOCAL_MODULE_TAGS := optional31LOCAL_MODULE_TAGS := optional
@@ -55,121 +53,6 @@
55 $(UPAPI_PATH)/android/include53 $(UPAPI_PATH)/android/include
5654
57LOCAL_SRC_FILES:= \55LOCAL_SRC_FILES:= \
58 test.cpp \
59
60LOCAL_MODULE:= direct_ubuntu_application_api_for_hybris_test
61LOCAL_MODULE_TAGS := optional
62
63LOCAL_SHARED_LIBRARIES := \
64 libandroidfw \
65 libutils \
66 libEGL \
67 libGLESv2 \
68 libubuntu_application_api
69
70include $(BUILD_EXECUTABLE)
71
72include $(CLEAR_VARS)
73
74LOCAL_CFLAGS += -std=gnu++0x
75
76LOCAL_C_INCLUDES := \
77 $(UPAPI_PATH)/include \
78 $(UPAPI_PATH)/android/include
79
80LOCAL_SRC_FILES:= \
81 test_c_api.cpp \
82
83LOCAL_MODULE:= direct_ubuntu_application_c_api_for_hybris_test
84LOCAL_MODULE_TAGS := optional
85
86LOCAL_SHARED_LIBRARIES := \
87 libandroidfw \
88 libutils \
89 libEGL \
90 libGLESv2 \
91 libubuntu_application_api
92
93include $(BUILD_EXECUTABLE)
94
95include $(CLEAR_VARS)
96
97LOCAL_CFLAGS += -std=gnu++0x
98
99LOCAL_C_INCLUDES := \
100 $(UPAPI_PATH)/include \
101 $(UPAPI_PATH)/android/include
102
103LOCAL_SRC_FILES:= \
104 test_session_c_api.cpp \
105
106LOCAL_MODULE:= direct_ubuntu_application_session_c_api_for_hybris_test
107LOCAL_MODULE_TAGS := optional
108
109LOCAL_SHARED_LIBRARIES := \
110 libandroidfw \
111 libutils \
112 libEGL \
113 libGLESv2 \
114 libubuntu_application_api
115
116include $(BUILD_EXECUTABLE)
117
118include $(CLEAR_VARS)
119
120LOCAL_CFLAGS += -std=gnu++0x
121
122LOCAL_C_INCLUDES := \
123 $(UPAPI_PATH)/include \
124 $(UPAPI_PATH)/android/include
125
126LOCAL_SRC_FILES:= \
127 test_trap.cpp \
128
129LOCAL_MODULE:= direct_set_trap
130LOCAL_MODULE_TAGS := optional
131
132LOCAL_SHARED_LIBRARIES := \
133 libandroidfw \
134 libutils \
135 libEGL \
136 libGLESv2 \
137 libubuntu_application_api
138
139include $(BUILD_EXECUTABLE)
140
141include $(CLEAR_VARS)
142
143LOCAL_CFLAGS += -std=gnu++0x
144
145LOCAL_C_INCLUDES := \
146 $(UPAPI_PATH)/include \
147 $(UPAPI_PATH)/android/include
148
149LOCAL_SRC_FILES:= \
150 test_osk_visibility.cpp \
151
152LOCAL_MODULE:= direct_osk_visibility
153LOCAL_MODULE_TAGS := optional
154
155LOCAL_SHARED_LIBRARIES := \
156 libandroidfw \
157 libutils \
158 libEGL \
159 libGLESv2 \
160 libubuntu_application_api
161
162include $(BUILD_EXECUTABLE)
163
164include $(CLEAR_VARS)
165
166LOCAL_CFLAGS += -std=gnu++0x
167
168LOCAL_C_INCLUDES := \
169 $(UPAPI_PATH)/include \
170 $(UPAPI_PATH)/android/include
171
172LOCAL_SRC_FILES:= \
173 test_sensors_c_api.cpp \56 test_sensors_c_api.cpp \
17457
175LOCAL_MODULE:= direct_ubuntu_application_sensors_c_api_for_hybris_test58LOCAL_MODULE:= direct_ubuntu_application_sensors_c_api_for_hybris_test
@@ -209,71 +92,6 @@
20992
210include $(CLEAR_VARS)93include $(CLEAR_VARS)
21194
212LOCAL_CFLAGS += \
213 -DANDROID_VERSION_MAJOR=$(ANDROID_VERSION_MAJOR) \
214 -DANDROID_VERSION_MINOR=$(ANDROID_VERSION_MINOR) \
215 -DANDROID_VERSION_PATCH=$(ANDROID_VERSION_PATCH)
216
217LOCAL_CFLAGS += -std=gnu++0x
218
219LOCAL_C_INCLUDES := \
220 external/skia/include/core \
221 frameworks/base/services \
222 $(UPAPI_PATH)/include \
223 $(UPAPI_PATH)/android/include
224
225LOCAL_SRC_FILES:= \
226 application_manager.cpp \
227 default_application_manager.cpp \
228
229LOCAL_MODULE:= ubuntuappmanager
230LOCAL_MODULE_TAGS := optional
231
232LOCAL_SHARED_LIBRARIES := \
233 libbinder \
234 libinput \
235 liblog \
236 libgui \
237 libskia \
238 libandroidfw \
239 libutils \
240 libEGL \
241 libGLESv2 \
242 libubuntu_application_api
243
244ifeq ($(HAS_LIBINPUTSERVICE),true)
245LOCAL_SHARED_LIBRARIES += libinputservice
246endif
247
248include $(BUILD_EXECUTABLE)
249
250include $(CLEAR_VARS)
251
252LOCAL_CFLAGS += -std=gnu++0x
253
254LOCAL_C_INCLUDES := \
255 $(UPAPI_PATH)/include \
256 $(UPAPI_PATH)/android/include
257
258LOCAL_SRC_FILES:= \
259 application_manager.cpp \
260 default_application_manager_test.cpp \
261
262LOCAL_MODULE:= ubuntuappmanager_test
263LOCAL_MODULE_TAGS := optional
264
265LOCAL_SHARED_LIBRARIES := \
266 libbinder \
267 libandroidfw \
268 libutils \
269 libEGL \
270 libGLESv2 \
271 libubuntu_application_api
272
273include $(BUILD_EXECUTABLE)
274
275include $(CLEAR_VARS)
276
277LOCAL_CFLAGS += -std=gnu++0x95LOCAL_CFLAGS += -std=gnu++0x
27896
279LOCAL_C_INCLUDES := \97LOCAL_C_INCLUDES := \
28098
=== removed file 'android/hybris/application_manager.cpp'
--- android/hybris/application_manager.cpp 2013-06-07 01:08:41 +0000
+++ android/hybris/application_manager.cpp 1970-01-01 00:00:00 +0000
@@ -1,900 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18#include "application_manager.h"
19
20#include <binder/Parcel.h>
21#include <utils/String8.h>
22
23namespace android
24{
25IMPLEMENT_META_INTERFACE(ClipboardService, "UbuntuClipboardService");
26IMPLEMENT_META_INTERFACE(AMTaskController, "UbuntuApplicationManagerTaskController");
27IMPLEMENT_META_INTERFACE(ApplicationManagerObserver, "UbuntuApplicationManagerObserver");
28IMPLEMENT_META_INTERFACE(ApplicationManagerSession, "UbuntuApplicationManagerSession");
29IMPLEMENT_META_INTERFACE(ApplicationManager, "UbuntuApplicationManager");
30
31IClipboardService::Content::Content() : data(NULL),
32 data_size(0)
33{
34}
35
36IClipboardService::Content::Content(
37 const String8& mime_type,
38 void* _data,
39 size_t size) : mime_type(mime_type),
40 data(malloc(size)),
41 data_size(size)
42{
43 memcpy(this->data, _data, size);
44}
45
46IClipboardService::Content::~Content()
47{
48 if (data != NULL && data_size != 0)
49 free(data);
50}
51
52IClipboardService::Content::Content(const IClipboardService::Content& content)
53 : mime_type(content.mime_type),
54 data(malloc(content.data_size)),
55 data_size(content.data_size)
56{
57 memcpy(data, content.data, data_size);
58}
59
60IClipboardService::Content& IClipboardService::Content::operator=(const IClipboardService::Content& content)
61{
62 mime_type = content.mime_type;
63 data_size = content.data_size;
64 data = realloc(data, data_size);
65 memcpy(data, content.data, data_size);
66
67 return *this;
68}
69
70status_t BnClipboardService::onTransact(uint32_t code,
71 const Parcel& data,
72 Parcel* reply,
73 uint32_t flags)
74{
75 switch(code)
76 {
77 case SET_CLIPBOARD_CONTENT_COMMAND:
78 {
79 IClipboardService::Content content;
80 String8 mime_type = data.readString8();
81 size_t data_size = data.readInt32();
82 void* p = malloc(data_size);
83 data.read(p, data_size);
84 set_content(Content(mime_type, p, data_size));
85 free(p);
86 break;
87 }
88 case GET_CLIPBOARD_CONTENT_COMMAND:
89 {
90 IClipboardService::Content content;
91 get_content(content);
92
93 reply->writeString8(String8(content.mime_type));
94 reply->writeInt32(content.data_size);
95 reply->write(content.data, content.data_size);
96 }
97 break;
98 }
99
100 return NO_ERROR;
101}
102
103BpClipboardService::BpClipboardService(const sp<IBinder>& impl) : BpInterface<IClipboardService>(impl)
104{
105}
106
107void BpClipboardService::set_content(const IClipboardService::Content& content)
108{
109 Parcel in, out;
110
111 in.writeString8(String8(content.mime_type));
112 in.writeInt32(content.data_size);
113 in.write(content.data, content.data_size);
114
115 remote()->transact(
116 SET_CLIPBOARD_CONTENT_COMMAND,
117 in,
118 &out);
119}
120
121void BpClipboardService::get_content(IClipboardService::Content& content)
122{
123 Parcel in, out;
124
125 remote()->transact(
126 GET_CLIPBOARD_CONTENT_COMMAND,
127 in,
128 &out);
129
130 content.mime_type = out.readString8();
131 content.data_size = out.readInt32();
132 content.data = malloc(content.data_size);
133 out.read(content.data, content.data_size);
134}
135
136BnApplicationManagerSession::BnApplicationManagerSession()
137{
138}
139
140BnApplicationManagerSession::~BnApplicationManagerSession() {}
141
142status_t BnApplicationManagerSession::onTransact(uint32_t code,
143 const Parcel& data,
144 Parcel* reply,
145 uint32_t flags)
146{
147 switch(code)
148 {
149 case RAISE_APPLICATION_SURFACES_TO_LAYER_COMMAND:
150 {
151 int32_t layer;
152 data.readInt32(&layer);
153
154 raise_application_surfaces_to_layer(layer);
155 }
156 break;
157 case RAISE_SURFACE_TO_LAYER_COMMAND:
158 {
159 int32_t token, layer;
160 token = data.readInt32();
161 layer = data.readInt32();
162
163 raise_surface_to_layer(token, layer);
164 }
165 break;
166 case QUERY_SURFACE_PROPERTIES_FOR_TOKEN_COMMAND:
167 {
168 int32_t token = data.readInt32();
169 IApplicationManagerSession::SurfaceProperties props =
170 query_surface_properties_for_token(token);
171 reply->writeInt32(props.layer);
172 reply->writeInt32(props.left);
173 reply->writeInt32(props.top);
174 reply->writeInt32(props.right);
175 reply->writeInt32(props.bottom);
176 }
177 break;
178 case ON_APPLICATION_STARTED_NOTIFICATION:
179 {
180 on_application_resumed();
181 }
182 break;
183 case ON_APPLICATION_ABOUT_TO_STOP_NOTIFICATION:
184 {
185 on_application_about_to_stop();
186 }
187 break;
188 }
189 return NO_ERROR;
190}
191
192BpApplicationManagerSession::BpApplicationManagerSession(const sp<IBinder>& impl)
193 : BpInterface<IApplicationManagerSession>(impl)
194{
195}
196
197BpApplicationManagerSession::~BpApplicationManagerSession()
198{
199}
200
201void BpApplicationManagerSession::raise_surface_to_layer(int32_t token, int layer)
202{
203 Parcel in, out;
204
205 in.writeInt32(token);
206 in.writeInt32(layer);
207
208 remote()->transact(
209 RAISE_SURFACE_TO_LAYER_COMMAND,
210 in,
211 &out);
212}
213
214void BpApplicationManagerSession::raise_application_surfaces_to_layer(int layer)
215{
216 Parcel in, out;
217 in.writeInt32(layer);
218
219 remote()->transact(
220 RAISE_APPLICATION_SURFACES_TO_LAYER_COMMAND,
221 in,
222 &out);
223}
224
225IApplicationManagerSession::SurfaceProperties BpApplicationManagerSession::query_surface_properties_for_token(int32_t token)
226{
227 Parcel in, out;
228 in.writeInt32(token);
229
230 remote()->transact(
231 QUERY_SURFACE_PROPERTIES_FOR_TOKEN_COMMAND,
232 in,
233 &out);
234
235 IApplicationManagerSession::SurfaceProperties props;
236 props.layer = out.readInt32();
237 props.left = out.readInt32();
238 props.top = out.readInt32();
239 props.right = out.readInt32();
240 props.bottom = out.readInt32();
241
242 return props;
243}
244
245void BpApplicationManagerSession::on_application_resumed()
246{
247 Parcel in, out;
248
249 remote()->transact(
250 ON_APPLICATION_STARTED_NOTIFICATION,
251 in,
252 &out,
253 android::IBinder::FLAG_ONEWAY);
254}
255
256void BpApplicationManagerSession::on_application_about_to_stop()
257{
258 Parcel in, out;
259
260 remote()->transact(
261 ON_APPLICATION_ABOUT_TO_STOP_NOTIFICATION,
262 in,
263 &out,
264 android::IBinder::FLAG_ONEWAY);
265}
266
267status_t BnAMTaskController::onTransact(uint32_t code,
268 const Parcel& data,
269 Parcel* reply,
270 uint32_t flags)
271{
272 switch(code)
273 {
274 case CONTINUE_TASK_COMMAND:
275 {
276 uint32_t pid = data.readInt32();
277 continue_task(pid);
278 break;
279 }
280 case SUSPEND_TASK_COMMAND:
281 {
282 int pid = data.readInt32();
283 suspend_task(pid);
284 break;
285 }
286 }
287
288 return NO_ERROR;
289}
290
291BpAMTaskController::BpAMTaskController(const sp<IBinder>& impl)
292 : BpInterface<IAMTaskController>(impl)
293{
294}
295
296void BpAMTaskController::continue_task(uint32_t pid)
297{
298 Parcel in, out;
299 in.writeInt32(pid);
300
301 remote()->transact(
302 CONTINUE_TASK_COMMAND,
303 in,
304 &out,
305 android::IBinder::FLAG_ONEWAY);
306}
307
308void BpAMTaskController::suspend_task(uint32_t pid)
309{
310 Parcel in, out;
311 in.writeInt32(pid);
312
313 remote()->transact(
314 SUSPEND_TASK_COMMAND,
315 in,
316 &out,
317 android::IBinder::FLAG_ONEWAY);
318}
319
320status_t BnApplicationManagerObserver::onTransact(uint32_t code,
321 const Parcel& data,
322 Parcel* reply,
323 uint32_t flags)
324{
325
326
327 switch(code)
328 {
329 case ON_SESSION_REQUESTED_NOTIFICATION:
330 {
331 uint32_t app = data.readInt32();
332 on_session_requested(app);
333 break;
334 }
335 case ON_SESSION_BORN_NOTIFICATION:
336 {
337 int id = data.readInt32();
338 int stage_hint = data.readInt32();
339 String8 desktop_file = data.readString8();
340 on_session_born(id, stage_hint, desktop_file);
341 break;
342 }
343 case ON_SESSION_UNFOCUSED_NOTIFICATION:
344 {
345 int id = data.readInt32();
346 int stage_hint = data.readInt32();
347 String8 desktop_file = data.readString8();
348 on_session_unfocused(id, stage_hint, desktop_file);
349 break;
350 }
351 case ON_SESSION_FOCUSED_NOTIFICATION:
352 {
353 int id = data.readInt32();
354 int stage_hint = data.readInt32();
355 String8 desktop_file = data.readString8();
356 on_session_focused(id, stage_hint, desktop_file);
357 break;
358 }
359 case ON_KEYBOARD_GEOMETRY_CHANGED_NOTIFICATION:
360 {
361 int x = data.readInt32();
362 int y = data.readInt32();
363 int width = data.readInt32();
364 int height = data.readInt32();
365 on_keyboard_geometry_changed(x, y, width, height);
366 break;
367 }
368 case ON_SESSION_REQUESTED_FULLSCREEN_NOTIFICATION:
369 {
370 int id = data.readInt32();
371 int stage_hint = data.readInt32();
372 String8 desktop_file = data.readString8();
373 on_session_requested_fullscreen(id, stage_hint, desktop_file);
374 break;
375 }
376 case ON_SESSION_DIED_NOTIFICATION:
377 {
378 int id = data.readInt32();
379 int stage_hint = data.readInt32();
380 String8 desktop_file = data.readString8();
381 on_session_died(id, stage_hint, desktop_file);
382 break;
383 }
384 }
385
386 return NO_ERROR;
387}
388
389BpApplicationManagerObserver::BpApplicationManagerObserver(const sp<IBinder>& impl)
390 : BpInterface<IApplicationManagerObserver>(impl)
391{
392}
393
394void BpApplicationManagerObserver::on_session_requested(
395 uint32_t app)
396{
397 Parcel in, out;
398 in.writeInt32(app);
399
400 remote()->transact(
401 ON_SESSION_REQUESTED_NOTIFICATION,
402 in,
403 &out,
404 android::IBinder::FLAG_ONEWAY);
405}
406
407void BpApplicationManagerObserver::on_session_born(int id,
408 int stage_hint,
409 const String8& desktop_file_hint)
410{
411 Parcel in, out;
412 in.writeInt32(id);
413 in.writeInt32(stage_hint);
414 in.writeString8(desktop_file_hint);
415
416 remote()->transact(
417 ON_SESSION_BORN_NOTIFICATION,
418 in,
419 &out,
420 android::IBinder::FLAG_ONEWAY);
421}
422
423void BpApplicationManagerObserver::on_session_unfocused(int id,
424 int stage_hint,
425 const String8& desktop_file_hint)
426{
427 Parcel in, out;
428 in.writeInt32(id);
429 in.writeInt32(stage_hint);
430 in.writeString8(desktop_file_hint);
431
432 remote()->transact(
433 ON_SESSION_UNFOCUSED_NOTIFICATION,
434 in,
435 &out,
436 android::IBinder::FLAG_ONEWAY);
437}
438
439void BpApplicationManagerObserver::on_session_focused(int id,
440 int stage_hint,
441 const String8& desktop_file_hint)
442{
443 Parcel in, out;
444 in.writeInt32(id);
445 in.writeInt32(stage_hint);
446 in.writeString8(desktop_file_hint);
447
448 remote()->transact(
449 ON_SESSION_FOCUSED_NOTIFICATION,
450 in,
451 &out,
452 android::IBinder::FLAG_ONEWAY);
453}
454
455void BpApplicationManagerObserver::on_keyboard_geometry_changed(int x,
456 int y,
457 int width,
458 int height)
459{
460 Parcel in, out;
461 in.writeInt32(x);
462 in.writeInt32(y);
463 in.writeInt32(width);
464 in.writeInt32(height);
465
466 remote()->transact(
467 ON_KEYBOARD_GEOMETRY_CHANGED_NOTIFICATION,
468 in,
469 &out,
470 android::IBinder::FLAG_ONEWAY);
471}
472
473void BpApplicationManagerObserver::on_session_requested_fullscreen(int id,
474 int stage_hint,
475 const String8& desktop_file_hint)
476{
477 Parcel in, out;
478 in.writeInt32(id);
479 in.writeInt32(stage_hint);
480 in.writeString8(desktop_file_hint);
481
482 remote()->transact(
483 ON_SESSION_REQUESTED_FULLSCREEN_NOTIFICATION,
484 in,
485 &out,
486 android::IBinder::FLAG_ONEWAY);
487}
488
489void BpApplicationManagerObserver::on_session_died(int id,
490 int stage_hint,
491 const String8& desktop_file_hint)
492{
493 Parcel in, out;
494 in.writeInt32(id);
495 in.writeInt32(stage_hint);
496 in.writeString8(desktop_file_hint);
497
498 remote()->transact(
499 ON_SESSION_DIED_NOTIFICATION,
500 in,
501 &out,
502 android::IBinder::FLAG_ONEWAY);
503}
504
505BnApplicationManager::BnApplicationManager()
506{
507}
508
509BnApplicationManager::~BnApplicationManager()
510{
511}
512
513status_t BnApplicationManager::onTransact(uint32_t code,
514 const Parcel& data,
515 Parcel* reply,
516 uint32_t flags)
517{
518 switch(code)
519 {
520 case START_A_NEW_SESSION_COMMAND:
521 {
522 int32_t session_type = data.readInt32();
523 int32_t stage_hint = data.readInt32();
524 String8 app_name = data.readString8();
525 String8 desktop_file = data.readString8();
526 sp<IBinder> binder = data.readStrongBinder();
527 sp<BpApplicationManagerSession> session(new BpApplicationManagerSession(binder));
528 int fd = data.readFileDescriptor();
529 uint32_t remote_pid = data.readInt32();
530
531 start_a_new_session(session_type, stage_hint, app_name, desktop_file, session, fd, remote_pid);
532 }
533 break;
534 case REGISTER_A_SURFACE_COMMAND:
535 {
536 String8 title = data.readString8();
537 sp<IBinder> binder = data.readStrongBinder();
538 sp<BpApplicationManagerSession> session(new BpApplicationManagerSession(binder));
539 int32_t surface_role = data.readInt32();
540 int32_t surface_token = data.readInt32();
541 int fd = data.readFileDescriptor();
542
543 register_a_surface(title, session, surface_role, surface_token, fd);
544 }
545 break;
546 case GET_SESSION_PID_COMMAND:
547 {
548 sp<IBinder> binder = data.readStrongBinder();
549 sp<BpApplicationManagerSession> session(new BpApplicationManagerSession(binder));
550 int pid = get_session_pid(session);
551 reply->writeInt32(pid);
552 }
553 break;
554 case REQUEST_FULLSCREEN_COMMAND:
555 {
556 sp<IBinder> binder = data.readStrongBinder();
557 sp<BpApplicationManagerSession> session(new BpApplicationManagerSession(binder));
558 request_fullscreen(session);
559 }
560 break;
561 case REGISTER_AN_OBSERVER_COMMAND:
562 {
563 sp<IBinder> binder = data.readStrongBinder();
564 sp<BpApplicationManagerObserver> observer(new BpApplicationManagerObserver(binder));
565 register_an_observer(observer);
566 break;
567 }
568 case REGISTER_TASK_CONTROLLER_COMMAND:
569 {
570 sp<IBinder> binder = data.readStrongBinder();
571 sp<BpAMTaskController> controller(new BpAMTaskController(binder));
572 register_task_controller(controller);
573 break;
574 }
575 case REQUEST_UPDATE_FOR_SESSION_COMMAND:
576 {
577 sp<IBinder> binder = data.readStrongBinder();
578 sp<BpApplicationManagerSession> session(new BpApplicationManagerSession(binder));
579 request_update_for_session(session);
580 break;
581 }
582 case UNFOCUS_RUNNING_SESSIONS_COMMAND:
583 {
584 unfocus_running_sessions();
585 break;
586 }
587 case FOCUS_RUNNING_SESSION_WITH_ID_COMMAND:
588 {
589 int32_t id = data.readInt32();
590 focus_running_session_with_id(id);
591 break;
592 }
593 case QUERY_SNAPSHOT_LAYER_FOR_SESSION_WITH_ID_COMMAND:
594 {
595 int32_t id = data.readInt32();
596 int32_t layer = query_snapshot_layer_for_session_with_id(id);
597 reply->writeInt32(layer);
598 break;
599 }
600 case QUERY_SURFACE_PROPERTIES_FOR_SESSION_ID_COMMAND:
601 {
602 int32_t id = data.readInt32();
603 IApplicationManagerSession::SurfaceProperties props =
604 query_surface_properties_for_session_id(id);
605 reply->writeInt32(props.layer);
606 reply->writeInt32(props.left);
607 reply->writeInt32(props.top);
608 reply->writeInt32(props.right);
609 reply->writeInt32(props.bottom);
610 break;
611 }
612 case SWITCH_TO_WELL_KNOWN_APPLICATION_COMMAND:
613 {
614 int32_t app = data.readInt32();
615 switch_to_well_known_application(app);
616 break;
617 }
618 case SET_SURFACE_TRAP_COMMAND:
619 {
620 int32_t x = data.readInt32();
621 int32_t y = data.readInt32();
622 int32_t width = data.readInt32();
623 int32_t height = data.readInt32();
624 int32_t handle = set_surface_trap(x, y, width, height);
625 reply->writeInt32(handle);
626 break;
627 }
628 case UNSET_SURFACE_TRAP_COMMAND:
629 {
630 int32_t handle = data.readInt32();
631 unset_surface_trap(handle);
632 break;
633 }
634 case REPORT_OSK_VISIBLE_COMMAND:
635 {
636 int32_t x = data.readInt32();
637 int32_t y = data.readInt32();
638 int32_t width = data.readInt32();
639 int32_t height = data.readInt32();
640 report_osk_visible(x, y, width, height);
641 break;
642 }
643 case REPORT_OSK_INVISIBLE_COMMAND:
644 {
645 report_osk_invisible();
646 break;
647 }
648 case REPORT_NOTIFICATION_VISIBLE_COMMAND:
649 {
650 report_notification_visible();
651 break;
652 }
653 case REPORT_NOTIFICATION_INVISIBLE_COMMAND:
654 {
655 report_notification_invisible();
656 break;
657 }
658 }
659 return NO_ERROR;
660}
661
662BpApplicationManager::BpApplicationManager(const sp<IBinder>& impl)
663 : BpInterface<IApplicationManager>(impl)
664{
665}
666
667BpApplicationManager::~BpApplicationManager()
668{
669}
670
671void BpApplicationManager::start_a_new_session(
672 int32_t session_type,
673 int32_t stage_hint,
674 const String8& app_name,
675 const String8& desktop_file,
676 const sp<IApplicationManagerSession>& session,
677 int fd,
678 uint32_t remote_pid)
679{
680 //printf("%s \n", __PRETTY_FUNCTION__);
681 Parcel in, out;
682 in.pushAllowFds(true);
683 in.writeInt32(session_type);
684 in.writeInt32(stage_hint);
685 in.writeString8(app_name);
686 in.writeString8(desktop_file);
687 in.writeStrongBinder(session->asBinder());
688 in.writeFileDescriptor(fd);
689 in.writeInt32(remote_pid);
690
691 remote()->transact(START_A_NEW_SESSION_COMMAND,
692 in,
693 &out);
694}
695
696void BpApplicationManager::register_a_surface(
697 const String8& title,
698 const sp<IApplicationManagerSession>& session,
699 int32_t surface_role,
700 int32_t token,
701 int fd)
702{
703 //printf("%s \n", __PRETTY_FUNCTION__);
704 Parcel in, out;
705 in.pushAllowFds(true);
706 in.writeString8(title);
707 in.writeStrongBinder(session->asBinder());
708 in.writeInt32(surface_role);
709 in.writeInt32(token);
710 in.writeFileDescriptor(fd);
711
712 remote()->transact(REGISTER_A_SURFACE_COMMAND,
713 in,
714 &out);
715}
716
717int BpApplicationManager::get_session_pid(
718 const sp<IApplicationManagerSession>& session)
719{
720 Parcel in, out;
721 in.writeStrongBinder(session->asBinder());
722
723 remote()->transact(GET_SESSION_PID_COMMAND,
724 in,
725 &out);
726
727 int32_t pid = out.readInt32();
728
729 return pid;
730}
731
732
733void BpApplicationManager::request_fullscreen(
734 const sp<IApplicationManagerSession>& session)
735{
736 //printf("%s \n", __PRETTY_FUNCTION__);
737 Parcel in, out;
738 in.writeStrongBinder(session->asBinder());
739
740 remote()->transact(REQUEST_FULLSCREEN_COMMAND,
741 in,
742 &out);
743}
744
745void BpApplicationManager::register_task_controller(const sp<IAMTaskController>& controller)
746{
747 Parcel in, out;
748 in.writeStrongBinder(controller->asBinder());
749
750 remote()->transact(REGISTER_TASK_CONTROLLER_COMMAND,
751 in,
752 &out);
753}
754
755void BpApplicationManager::register_an_observer(const sp<IApplicationManagerObserver>& observer)
756{
757 Parcel in, out;
758 in.writeStrongBinder(observer->asBinder());
759
760 remote()->transact(REGISTER_AN_OBSERVER_COMMAND,
761 in,
762 &out);
763}
764
765void BpApplicationManager::request_update_for_session(const sp<IApplicationManagerSession>& session)
766{
767 Parcel in, out;
768 in.writeStrongBinder(session->asBinder());
769 remote()->transact(REQUEST_UPDATE_FOR_SESSION_COMMAND,
770 in,
771 &out);
772}
773
774void BpApplicationManager::unfocus_running_sessions()
775{
776 Parcel in, out;
777
778 remote()->transact(UNFOCUS_RUNNING_SESSIONS_COMMAND,
779 in,
780 &out);
781}
782
783void BpApplicationManager::focus_running_session_with_id(int id)
784{
785 Parcel in, out;
786 in.writeInt32(id);
787
788 remote()->transact(FOCUS_RUNNING_SESSION_WITH_ID_COMMAND,
789 in,
790 &out);
791}
792
793int32_t BpApplicationManager::query_snapshot_layer_for_session_with_id(int id)
794{
795 Parcel in, out;
796 in.writeInt32(id);
797 remote()->transact(QUERY_SNAPSHOT_LAYER_FOR_SESSION_WITH_ID_COMMAND,
798 in,
799 &out);
800
801 int32_t layer = out.readInt32();
802 return layer;
803}
804
805IApplicationManagerSession::SurfaceProperties BpApplicationManager::query_surface_properties_for_session_id(int id)
806{
807 Parcel in, out;
808 in.writeInt32(id);
809
810 remote()->transact(QUERY_SURFACE_PROPERTIES_FOR_SESSION_ID_COMMAND,
811 in,
812 &out);
813
814 IApplicationManagerSession::SurfaceProperties props;
815 props.layer = out.readInt32();
816 props.left = out.readInt32();
817 props.top = out.readInt32();
818 props.right = out.readInt32();
819 props.bottom = out.readInt32();
820
821 return props;
822}
823void BpApplicationManager::switch_to_well_known_application(int32_t app)
824{
825 Parcel in, out;
826 in.writeInt32(app);
827
828 remote()->transact(SWITCH_TO_WELL_KNOWN_APPLICATION_COMMAND,
829 in,
830 &out);
831}
832
833int32_t BpApplicationManager::set_surface_trap(int32_t x, int32_t y, int32_t width, int32_t height)
834{
835 Parcel in, out;
836 in.writeInt32(x);
837 in.writeInt32(y);
838 in.writeInt32(width);
839 in.writeInt32(height);
840
841 remote()->transact(SET_SURFACE_TRAP_COMMAND,
842 in,
843 &out);
844
845 int32_t handle = out.readInt32();
846
847 return handle;
848}
849
850void BpApplicationManager::unset_surface_trap(int32_t handle)
851{
852 Parcel in, out;
853 in.writeInt32(handle);
854
855 remote()->transact(UNSET_SURFACE_TRAP_COMMAND,
856 in,
857 &out);
858}
859
860void BpApplicationManager::report_osk_visible(int32_t x, int32_t y, int32_t width, int32_t height)
861{
862 Parcel in, out;
863 in.writeInt32(x);
864 in.writeInt32(y);
865 in.writeInt32(width);
866 in.writeInt32(height);
867
868 remote()->transact(REPORT_OSK_VISIBLE_COMMAND,
869 in,
870 &out);
871}
872
873void BpApplicationManager::report_osk_invisible()
874{
875 Parcel in, out;
876
877 remote()->transact(REPORT_OSK_INVISIBLE_COMMAND,
878 in,
879 &out);
880}
881
882void BpApplicationManager::report_notification_visible()
883{
884 Parcel in, out;
885
886 remote()->transact(REPORT_NOTIFICATION_VISIBLE_COMMAND,
887 in,
888 &out);
889}
890
891void BpApplicationManager::report_notification_invisible()
892{
893 Parcel in, out;
894
895 remote()->transact(REPORT_NOTIFICATION_INVISIBLE_COMMAND,
896 in,
897 &out);
898}
899
900}
9010
=== removed file 'android/hybris/application_manager.h'
--- android/hybris/application_manager.h 2013-06-07 01:08:41 +0000
+++ android/hybris/application_manager.h 1970-01-01 00:00:00 +0000
@@ -1,412 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18#ifndef HYBRIS_APPLICATION_MANAGER_H_
19#define HYBRIS_APPLICATION_MANAGER_H_
20
21#include <binder/IInterface.h>
22#include <utils/String8.h>
23
24namespace android
25{
26
27class IClipboardService : public IInterface
28{
29public:
30 DECLARE_META_INTERFACE(ClipboardService);
31
32 static const char* exported_service_name()
33 {
34 return "UbuntuClipboardService";
35 }
36
37 struct Content
38 {
39 Content();
40 Content(const String8& mime_type, void* data, size_t data_size);
41 ~Content();
42 Content(const Content& rhs);
43 Content& operator=(const Content& rhs);
44
45 String8 mime_type;
46 void* data;
47 size_t data_size;
48 };
49
50 virtual void set_content(const Content& content) = 0;
51 virtual void get_content(Content& content) = 0;
52
53protected:
54 enum
55 {
56 SET_CLIPBOARD_CONTENT_COMMAND = IBinder::FIRST_CALL_TRANSACTION,
57 GET_CLIPBOARD_CONTENT_COMMAND
58 };
59};
60
61class BnClipboardService : public BnInterface<IClipboardService>
62{
63 public:
64 status_t onTransact(uint32_t code,
65 const Parcel& data,
66 Parcel* reply,
67 uint32_t flags = 0);
68};
69
70class BpClipboardService : public BpInterface<IClipboardService>
71{
72public:
73 BpClipboardService(const sp<IBinder>& impl);
74
75 void set_content(const IClipboardService::Content& content);
76 void get_content(IClipboardService::Content& content);
77
78};
79
80class IApplicationManagerSession : public IInterface
81{
82public:
83 DECLARE_META_INTERFACE(ApplicationManagerSession);
84
85 struct SurfaceProperties
86 {
87 int32_t layer;
88 int32_t left;
89 int32_t top;
90 int32_t right;
91 int32_t bottom;
92 };
93
94 virtual void raise_application_surfaces_to_layer(int layer) = 0;
95 virtual void raise_surface_to_layer(int32_t token, int layer) = 0;
96 virtual SurfaceProperties query_surface_properties_for_token(int32_t token) = 0;
97 virtual void on_application_resumed() = 0;
98 virtual void on_application_about_to_stop() = 0;
99
100protected:
101 enum
102 {
103 RAISE_APPLICATION_SURFACES_TO_LAYER_COMMAND = IBinder::FIRST_CALL_TRANSACTION,
104 RAISE_SURFACE_TO_LAYER_COMMAND,
105 QUERY_SURFACE_PROPERTIES_FOR_TOKEN_COMMAND,
106 ON_APPLICATION_STARTED_NOTIFICATION,
107 ON_APPLICATION_ABOUT_TO_STOP_NOTIFICATION,
108 };
109};
110
111class BnApplicationManagerSession : public BnInterface<IApplicationManagerSession>
112{
113public:
114 BnApplicationManagerSession();
115 virtual ~BnApplicationManagerSession();
116
117 virtual status_t onTransact(uint32_t code,
118 const Parcel& data,
119 Parcel* reply,
120 uint32_t flags = 0);
121};
122
123class BpApplicationManagerSession : public BpInterface<IApplicationManagerSession>
124{
125public:
126 BpApplicationManagerSession(const sp<IBinder>& impl);
127 ~BpApplicationManagerSession();
128
129 void raise_application_surfaces_to_layer(int layer);
130 void raise_surface_to_layer(int32_t token, int layer);
131 IApplicationManagerSession::SurfaceProperties query_surface_properties_for_token(int32_t token);
132 void on_application_resumed();
133 void on_application_about_to_stop();
134};
135
136class IAMTaskController : public IInterface
137{
138public:
139 DECLARE_META_INTERFACE(AMTaskController);
140
141 virtual void continue_task(uint32_t pid) = 0;
142
143 virtual void suspend_task(uint32_t pid) = 0;
144
145protected:
146 enum
147 {
148 CONTINUE_TASK_COMMAND = IBinder::FIRST_CALL_TRANSACTION,
149 SUSPEND_TASK_COMMAND
150 };
151
152 IAMTaskController(const IAMTaskController&) = delete;
153 IAMTaskController& operator=(const IAMTaskController&) = delete;
154};
155
156class BnAMTaskController : public BnInterface<IAMTaskController>
157{
158public:
159 status_t onTransact(uint32_t code,
160 const Parcel& data,
161 Parcel* reply,
162 uint32_t flags = 0);
163};
164
165class BpAMTaskController : public BpInterface<IAMTaskController>
166{
167public:
168 BpAMTaskController(const sp<IBinder>& impl);
169
170 void continue_task(uint32_t pid);
171
172 void suspend_task(uint32_t pid);
173};
174
175class IApplicationManagerObserver : public IInterface
176{
177public:
178 DECLARE_META_INTERFACE(ApplicationManagerObserver);
179
180 virtual void on_session_requested(uint32_t app) = 0;
181
182 virtual void on_session_born(int id,
183 int stage_hint,
184 const String8& desktop_file) = 0;
185
186 virtual void on_session_unfocused(int id,
187 int stage_hint,
188 const String8& desktop_file) = 0;
189
190 virtual void on_session_focused(int id,
191 int stage_hint,
192 const String8& desktop_file) = 0;
193
194 virtual void on_session_requested_fullscreen(int id,
195 int stage_hint,
196 const String8& desktop_file) = 0;
197
198 virtual void on_keyboard_geometry_changed(int x,
199 int y,
200 int width,
201 int height) = 0;
202
203 virtual void on_session_died(int id,
204 int stage_hint,
205 const String8& desktop_file) = 0;
206
207protected:
208 enum
209 {
210 ON_SESSION_REQUESTED_NOTIFICATION = IBinder::FIRST_CALL_TRANSACTION,
211 ON_SESSION_BORN_NOTIFICATION,
212 ON_SESSION_UNFOCUSED_NOTIFICATION,
213 ON_SESSION_FOCUSED_NOTIFICATION,
214 ON_KEYBOARD_GEOMETRY_CHANGED_NOTIFICATION,
215 ON_SESSION_REQUESTED_FULLSCREEN_NOTIFICATION,
216 ON_SESSION_DIED_NOTIFICATION
217 };
218
219 IApplicationManagerObserver(const IApplicationManagerObserver&) = delete;
220 IApplicationManagerObserver& operator=(const IApplicationManagerObserver&) = delete;
221};
222
223class BnApplicationManagerObserver : public BnInterface<IApplicationManagerObserver>
224{
225public:
226 status_t onTransact(uint32_t code,
227 const Parcel& data,
228 Parcel* reply,
229 uint32_t flags = 0);
230};
231
232class BpApplicationManagerObserver : public BpInterface<IApplicationManagerObserver>
233{
234public:
235 BpApplicationManagerObserver(const sp<IBinder>& impl);
236
237 void on_session_requested(uint32_t app);
238
239 void on_session_born(int id,
240 int stage_hint,
241 const String8& desktop_file);
242
243 void on_session_unfocused(int id,
244 int stage_hint,
245 const String8& desktop_file);
246
247 void on_session_focused(int id,
248 int stage_hint,
249 const String8& desktop_file);
250
251 void on_session_requested_fullscreen(int id,
252 int stage_hint,
253 const String8& desktop_file);
254
255 void on_keyboard_geometry_changed(int x,
256 int y,
257 int width,
258 int height);
259
260 void on_session_died(int id,
261 int stage_hint,
262 const String8& desktop_file);
263};
264
265class IApplicationManager : public IInterface
266{
267public:
268 DECLARE_META_INTERFACE(ApplicationManager);
269
270 static const char* exported_service_name()
271 {
272 return "UbuntuApplicationManager";
273 }
274
275 virtual void start_a_new_session(int32_t session_type,
276 int32_t stage_hint,
277 const String8& app_name,
278 const String8& desktop_file,
279 const sp<IApplicationManagerSession>& session,
280 int fd,
281 uint32_t remote_pid) = 0;
282
283 virtual void register_a_surface(const String8& title,
284 const sp<IApplicationManagerSession>& session,
285 int32_t surface_role,
286 int32_t token,
287 int fd) = 0;
288
289 virtual int get_session_pid(const sp<IApplicationManagerSession>& session) = 0;
290
291 virtual void request_fullscreen(const sp<IApplicationManagerSession>& session) = 0;
292
293 virtual void request_update_for_session(const sp<IApplicationManagerSession>& session) = 0;
294
295 virtual void register_an_observer(const sp<IApplicationManagerObserver>& observer) = 0;
296
297 virtual void register_task_controller(const sp<IAMTaskController>& controller) = 0;
298
299 virtual void unfocus_running_sessions() = 0;
300
301 virtual void focus_running_session_with_id(int id) = 0;
302
303 virtual int32_t query_snapshot_layer_for_session_with_id(int id) = 0;
304
305 virtual IApplicationManagerSession::SurfaceProperties query_surface_properties_for_session_id(int id) = 0;
306
307 virtual void switch_to_well_known_application(int32_t app) = 0;
308
309 virtual int32_t set_surface_trap(int32_t x, int32_t y, int32_t width, int32_t height) = 0;
310
311 virtual void unset_surface_trap(int32_t handle) = 0;
312
313 virtual void report_osk_visible(int32_t x, int32_t y, int32_t width, int32_t height) = 0;
314
315 virtual void report_osk_invisible() = 0;
316
317 virtual void report_notification_visible() = 0;
318
319 virtual void report_notification_invisible() = 0;
320
321protected:
322 enum
323 {
324 START_A_NEW_SESSION_COMMAND = IBinder::FIRST_CALL_TRANSACTION,
325 REGISTER_A_SURFACE_COMMAND,
326 GET_SESSION_PID_COMMAND,
327 REQUEST_FULLSCREEN_COMMAND,
328 REGISTER_AN_OBSERVER_COMMAND,
329 REGISTER_TASK_CONTROLLER_COMMAND,
330 REQUEST_UPDATE_FOR_SESSION_COMMAND,
331 UNFOCUS_RUNNING_SESSIONS_COMMAND,
332 FOCUS_RUNNING_SESSION_WITH_ID_COMMAND,
333 QUERY_SNAPSHOT_LAYER_FOR_SESSION_WITH_ID_COMMAND,
334 QUERY_SURFACE_PROPERTIES_FOR_SESSION_ID_COMMAND,
335 SWITCH_TO_WELL_KNOWN_APPLICATION_COMMAND,
336 SET_SURFACE_TRAP_COMMAND,
337 UNSET_SURFACE_TRAP_COMMAND,
338 REPORT_OSK_VISIBLE_COMMAND,
339 REPORT_OSK_INVISIBLE_COMMAND,
340 REPORT_NOTIFICATION_VISIBLE_COMMAND,
341 REPORT_NOTIFICATION_INVISIBLE_COMMAND
342 };
343};
344
345class BnApplicationManager : public BnInterface<IApplicationManager>
346{
347public:
348 BnApplicationManager();
349 virtual ~BnApplicationManager();
350
351 virtual status_t onTransact(uint32_t code,
352 const Parcel& data,
353 Parcel* reply,
354 uint32_t flags = 0);
355};
356
357class BpApplicationManager : public BpInterface<IApplicationManager>
358{
359public:
360 BpApplicationManager(const sp<IBinder>& impl);
361 ~BpApplicationManager();
362
363 void start_a_new_session(int32_t session_type,
364 int32_t stage_hint,
365 const String8& app_name,
366 const String8& desktop_file,
367 const sp<IApplicationManagerSession>& session,
368 int fd,
369 uint32_t remote_pid);
370
371 void register_a_surface(const String8& title,
372 const android::sp<android::IApplicationManagerSession>& session,
373 int32_t surface_role,
374 int32_t token,
375 int fd);
376
377 int get_session_pid(const android::sp<android::IApplicationManagerSession>& session);
378
379 void request_fullscreen(const android::sp<android::IApplicationManagerSession>& session);
380
381 void request_update_for_session(const sp<IApplicationManagerSession>& session);
382
383 void register_an_observer(const sp<IApplicationManagerObserver>& observer);
384
385 void register_task_controller(const sp<IAMTaskController>& controller);
386
387 void unfocus_running_sessions();
388
389 void focus_running_session_with_id(int id);
390
391 int32_t query_snapshot_layer_for_session_with_id(int id);
392
393 IApplicationManagerSession::SurfaceProperties query_surface_properties_for_session_id(int id);
394
395 void switch_to_well_known_application(int32_t app);
396
397 int32_t set_surface_trap(int32_t x, int32_t y, int32_t width, int32_t height);
398
399 void unset_surface_trap(int handle);
400
401 void report_osk_visible(int32_t x, int32_t y, int32_t width, int32_t height);
402
403 void report_osk_invisible();
404
405 void report_notification_visible();
406
407 void report_notification_invisible();
408};
409
410}
411
412#endif // HYBRIS_APPLICATION_MANAGER_H_
4130
=== removed file 'android/hybris/default_application_manager.cpp'
--- android/hybris/default_application_manager.cpp 2014-01-22 05:28:18 +0000
+++ android/hybris/default_application_manager.cpp 1970-01-01 00:00:00 +0000
@@ -1,1257 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18#undef LOG_TAG
19#define LOG_TAG "ubuntu::detail::ApplicationManager"
20
21#include "default_application_manager.h"
22
23#include "default_application_manager_input_setup.h"
24#include "default_application_session.h"
25#include "default_shell.h"
26
27#include <binder/IPCThreadState.h>
28#include <binder/IServiceManager.h>
29#include <binder/ProcessState.h>
30
31#include <input/InputListener.h>
32#include <input/InputReader.h>
33#if ANDROID_VERSION_MAJOR==4 && ANDROID_VERSION_MINOR<=2
34#include <androidfw/InputTransport.h>
35#else
36#include <input/InputTransport.h>
37#endif
38#include <utils/threads.h>
39#include <utils/Errors.h>
40#include <utils/Timers.h>
41
42#include <cstdio>
43#include <cstdlib>
44
45#include <sys/types.h>
46#include <sys/wait.h>
47#include <signal.h>
48#include <fcntl.h>
49
50namespace ubuntu { namespace detail
51{
52
53template<typename T, typename U>
54const T& min(const T& lhs, const U& rhs)
55{
56 return lhs < rhs ? lhs : rhs;
57}
58
59/* TODO: Currently we need to map local pids to the ones of the
60 * container where Ubuntu is running as sessions need to be
61 * referenced to observers in terms of the said namespace.
62 */
63pid_t pid_to_vpid(int pid)
64{
65 ALOGI("%s(%d)", __PRETTY_FUNCTION__, pid);
66
67 if (pid <= 0)
68 return -1;
69
70 char proc_name[128], buf[1024];
71 char *rpid;
72 char key[] = "Vpid:";
73
74 sprintf(proc_name, "/proc/%d/status", pid);
75
76 int fd;
77
78 fd = open(proc_name, O_RDONLY);
79 if (fd < 0)
80 {
81 ALOGI("%s(): Cannot find %s\n", __PRETTY_FUNCTION__, proc_name);
82 return -1;
83 }
84
85 memset(buf, '\0', sizeof(buf));
86 read(fd, buf, sizeof(buf));
87 rpid = strstr(buf, key);
88
89 close(fd);
90
91 if (rpid == NULL)
92 {
93 ALOGI("%s(): Vpid not supported\n", __PRETTY_FUNCTION__);
94 return pid;
95 }
96
97 return atoi(rpid+sizeof(key));
98}
99
100bool is_session_allowed_to_run_in_background(
101 const android::sp<ubuntu::detail::ApplicationSession>& session)
102{
103 ALOGI("%s: %s", __PRETTY_FUNCTION__, session->desktop_file.string());
104 static const android::String8 phone_app_desktop_file("/usr/share/applications/phone-app.desktop");
105 static const android::String8 music_app_desktop_file("/usr/share/applications/music-app.desktop");
106
107 if (session->desktop_file == phone_app_desktop_file ||
108 session->desktop_file == music_app_desktop_file)
109 {
110 return true;
111 }
112
113 return false;
114}
115
116bool write_proc_file(pid_t pid, const char* filename, const char* value)
117{
118 char proc_name[128];
119 sprintf(proc_name, "/proc/%d/%s", pid, filename);
120
121 int file;
122
123 if (access(proc_name, F_OK) == 0)
124 {
125 file = open(proc_name, O_WRONLY);
126 write(file, value, sizeof(value));
127 close(file);
128 return true;
129 } else
130 return false;
131}
132
133void update_oom_values(const android::sp<ubuntu::detail::ApplicationSession>& session)
134{
135 if (session->session_type == ubuntu::application::ui::system_session_type)
136 {
137 if (!write_proc_file(session->pid, "oom_score_adj", "-940"))
138 write_proc_file(session->pid, "oom_adj", "-16");
139 return;
140 }
141
142 if (session->running_state == ubuntu::application::ui::process_suspended)
143 {
144 if (!write_proc_file(session->pid, "oom_score_adj", "1000"))
145 write_proc_file(session->pid, "oom_adj", "15");
146 } else
147 {
148 if (!write_proc_file(session->pid, "oom_score_adj", "0"))
149 write_proc_file(session->pid, "oom_adj", "0");
150 }
151}
152
153template<int x, int y, int w, int h>
154int ApplicationManager::ShellInputSetup::Window<x, y, w, h>::looper_callback(int receiveFd, int events, void* ctxt)
155{
156 // ALOGI("%s", __PRETTY_FUNCTION__);
157
158 bool result = true;
159 ApplicationManager::ShellInputSetup::Window<x, y, w, h>* window = static_cast<ApplicationManager::ShellInputSetup::Window<x, y, w, h>*>(ctxt);
160
161 //window->input_consumer.receiveDispatchSignal();
162 uint32_t seq;
163 android::InputEvent* ev;
164 static const bool consume_batches = true;
165 static const nsecs_t frame_time = -1;
166 switch(window->input_consumer.consume(&window->event_factory, consume_batches, frame_time, &seq, &ev))
167 {
168 case android::OK:
169 result = true;
170 //printf("We have a client side event for process %d. \n", getpid());
171 window->input_consumer.sendFinishedSignal(seq, result);
172 break;
173 case android::INVALID_OPERATION:
174 result = true;
175 break;
176 case android::NO_MEMORY:
177 result = true;
178 break;
179 }
180
181 return result ? 1 : 0;
182}
183
184template<int x, int y, int w, int h>
185ApplicationManager::ShellInputSetup::Window<x, y, w, h>::Window(
186 ApplicationManager::ShellInputSetup* parent,
187 int _x,
188 int _y,
189 int _w,
190 int _h) : parent(parent),
191 input_consumer(client_channel)
192{
193 auto window = new android::InputSetup::DummyApplicationWindow(
194 parent->shell_application,
195 _x,
196 _y,
197 _w,
198 _h);
199
200 android::InputChannel::openInputChannelPair(
201 android::String8("DummyShellInputChannel"),
202 server_channel,
203 client_channel);
204
205 window->input_channel = server_channel;
206 input_window = window;
207
208 parent->input_manager->getDispatcher()->registerInputChannel(
209 window->input_channel,
210 input_window,
211 false);
212
213 input_consumer = android::InputConsumer(client_channel);
214
215 // input_consumer.initialize();
216 parent->looper->addFd(client_channel->getFd(), //client_channel->getReceivePipeFd(),
217 0,
218 ALOOPER_EVENT_INPUT,
219 looper_callback,
220 this);
221}
222
223ApplicationManager::ShellInputSetup::DisplayInfo::DisplayInfo()
224{
225 auto display = android::SurfaceComposerClient::getBuiltInDisplay(
226 android::ISurfaceComposer::eDisplayIdMain);
227
228 android::SurfaceComposerClient::getDisplayInfo(
229 display,
230 &info);
231}
232
233ApplicationManager::ShellInputSetup::ShellInputSetup(const android::sp<android::InputManager>& input_manager)
234 : shell_has_focus(true),
235 input_manager(input_manager),
236 shell_application(new android::InputSetup::DummyApplication()),
237 looper(new android::Looper(true)),
238 event_loop(looper),
239 event_trap_window(this, 0, 0, display_info.info.w, display_info.info.h),
240 osk_window(this),
241 notifications_window(this)
242{
243 event_loop.run();
244}
245
246ApplicationManager::InputFilter::InputFilter(ApplicationManager* manager) : manager(manager)
247{
248}
249
250bool ApplicationManager::InputFilter::filter_event(const android::InputEvent* event)
251{
252 bool result = true;
253
254 switch (event->getType())
255 {
256 case AINPUT_EVENT_TYPE_KEY:
257 result = handle_key_event(static_cast<const android::KeyEvent*>(event));
258 break;
259 }
260
261 return result;
262}
263
264bool ApplicationManager::InputFilter::handle_key_event(const android::KeyEvent* event)
265{
266 bool result = true;
267
268 return result;
269}
270
271ApplicationManager::LockingIterator::LockingIterator(
272 ApplicationManager* manager,
273 size_t index) : manager(manager),
274 it(index)
275{
276}
277
278void ApplicationManager::LockingIterator::advance()
279{
280 it += 1;
281}
282
283bool ApplicationManager::LockingIterator::is_valid() const
284{
285 return it < manager->apps.size();
286}
287
288void ApplicationManager::LockingIterator::make_current()
289{
290 //printf("%s \n", __PRETTY_FUNCTION__);
291}
292
293const android::sp<ubuntu::detail::ApplicationSession>& ApplicationManager::LockingIterator::operator*()
294{
295 return manager->apps.valueFor(manager->apps_as_added[it]);
296}
297
298ApplicationManager::LockingIterator::~LockingIterator()
299{
300 manager->unlock();
301}
302
303ApplicationManager::ApplicationManager() : input_filter(new InputFilter(this)),
304 input_setup(new android::InputSetup(input_filter)),
305 is_osk_visible(false),
306 are_notifications_visible(false),
307 app_manager_task_controller(NULL),
308 focused_application(0),
309 side_stage_application(0),
310 main_stage_application(0)
311{
312 shell_input_setup = new ShellInputSetup(input_setup->input_manager);
313
314 input_setup->input_manager->getDispatcher()->setFocusedApplication(
315 shell_input_setup->shell_application);
316
317 android::Vector< android::sp<android::InputWindowHandle> > input_windows;
318 input_windows.push(shell_input_setup->event_trap_window.input_window);
319 input_setup->input_manager->getDispatcher()->setInputWindows(
320 input_windows);
321
322 input_setup->start();
323}
324
325void ApplicationManager::update_app_lists()
326{
327 int idx;
328
329 for (idx = apps_as_added.size()-1; idx >= 0; idx--)
330 {
331 const android::sp<ubuntu::detail::ApplicationSession>& session =
332 apps.valueFor(apps_as_added[idx]);
333
334 if (session->session_type == ubuntu::application::ui::system_session_type)
335 continue;
336
337 if (session->stage_hint == ubuntu::application::ui::side_stage)
338 {
339 side_stage_application = idx;
340 break;
341 }
342 }
343
344 if (idx < 0)
345 side_stage_application = 0;
346
347 for (idx = apps_as_added.size()-1; idx >= 0; idx--)
348 {
349 const android::sp<ubuntu::detail::ApplicationSession>& session =
350 apps.valueFor(apps_as_added[idx]);
351
352 if (session->session_type == ubuntu::application::ui::system_session_type)
353 continue;
354
355 if (session->stage_hint == ubuntu::application::ui::main_stage)
356 {
357 main_stage_application = idx;
358 break;
359 }
360 }
361
362 if (idx < 0)
363 main_stage_application = 0;
364}
365
366// From DeathRecipient
367void ApplicationManager::binderDied(const android::wp<android::IBinder>& who)
368{
369 android::Mutex::Autolock al(guard);
370 android::sp<android::IBinder> sp = who.promote();
371
372 ALOGI("%s():%d\n", __PRETTY_FUNCTION__, __LINE__);
373
374 const android::sp<ubuntu::detail::ApplicationSession>& dead_session = apps.valueFor(sp);
375
376 ALOGI("%s():%d -- remote_pid=%d desktop_file=%s\n", __PRETTY_FUNCTION__, __LINE__,
377 dead_session->remote_pid,
378 dead_session->desktop_file.string());
379
380 notify_observers_about_session_died(dead_session->remote_pid,
381 dead_session->stage_hint,
382 dead_session->desktop_file);
383
384 ALOGI("%s():%d\n", __PRETTY_FUNCTION__, __LINE__);
385 size_t i = 0;
386 for(i = 0; i < apps_as_added.size(); i++)
387 if (apps_as_added[i] == sp)
388 break;
389
390 ALOGI("%s():%d\n", __PRETTY_FUNCTION__, __LINE__);
391 size_t next_focused_app = 0;
392 next_focused_app = apps_as_added.removeAt(i);
393
394 ALOGI("%s():%d\n", __PRETTY_FUNCTION__, __LINE__);
395 next_focused_app = main_stage_application;
396 update_app_lists();
397
398 ALOGI("%s():%d\n", __PRETTY_FUNCTION__, __LINE__);
399 if (dead_session->stage_hint == ubuntu::application::ui::side_stage)
400 next_focused_app = side_stage_application ? side_stage_application : next_focused_app;
401
402 ALOGI("%s():%d\n", __PRETTY_FUNCTION__, __LINE__);
403 if (dead_session->stage_hint == ubuntu::application::ui::main_stage)
404 next_focused_app = main_stage_application;
405
406 ALOGI("%s():%d\n", __PRETTY_FUNCTION__, __LINE__);
407 if (i && i == focused_application &&
408 shell_input_setup->shell_has_focus == false)
409 {
410 switch_focused_application_locked(next_focused_app);
411 }
412 else if(focused_application > i)
413 focused_application--;
414
415 if (i == 0)
416 {
417 shell_input_setup->trap_windows.clear();
418 shell_input_setup->shell_has_focus = true;
419 }
420
421 ALOGI("%s():%d\n", __PRETTY_FUNCTION__, __LINE__);
422 apps.removeItem(sp);
423 ALOGI("%s():%d\n", __PRETTY_FUNCTION__, __LINE__);
424}
425
426void ApplicationManager::lock()
427{
428 guard.lock();
429}
430
431void ApplicationManager::unlock()
432{
433 guard.unlock();
434}
435
436android::sp<ApplicationManager::LockingIterator> ApplicationManager::iterator()
437{
438 lock();
439 android::sp<ApplicationManager::LockingIterator> it(
440 new ApplicationManager::LockingIterator(this, 0));
441
442 return it;
443}
444
445void ApplicationManager::session_set_state(const android::sp<ubuntu::detail::ApplicationSession>& as,
446 int32_t new_state)
447{
448 ALOGI("%s():%d running->running", __PRETTY_FUNCTION__, __LINE__);
449
450 switch (new_state)
451 {
452 case ubuntu::application::ui::process_running:
453 {
454 if (as->running_state == ubuntu::application::ui::process_running)
455 {
456 ALOGI("%s():%d running->running", __PRETTY_FUNCTION__, __LINE__);
457 /* FIXME:
458 * Technically invalid, this transition currently is hit because
459 * of focus being requested on the session before its delagate call
460 */
461 } else if (as->running_state == ubuntu::application::ui::process_destroyed)
462 {
463 ALOGI("%s():%d destroyed->running", __PRETTY_FUNCTION__, __LINE__);
464 /* TODO:
465 * Resume application with a null archive handler
466 */
467 } else if (as->running_state == ubuntu::application::ui::process_stopped)
468 {
469 ALOGI("%s():%d stopped->running", __PRETTY_FUNCTION__, __LINE__);
470 /* TODO:
471 * Support starting the new process and wait for the
472 * session to be available to call its delegate
473 */
474 return;
475 } else
476 {
477 /* suspended->running
478 * nothing to do, process image still in memory
479 */
480 if (app_manager_task_controller != NULL)
481 app_manager_task_controller->continue_task(as->remote_pid);
482 else
483 kill(as->pid, SIGCONT);
484 }
485 as->running_state = ubuntu::application::ui::process_running;
486 as->on_application_resumed();
487 update_oom_values(as);
488 }
489 break;
490 case ubuntu::application::ui::process_suspended:
491 {
492 ALOGI("%s() state->suspended", __PRETTY_FUNCTION__);
493 /* TODO: create archive */
494 as->on_application_about_to_stop();
495 as->running_state = ubuntu::application::ui::process_suspended;
496 android::sp<android::Thread> deferred_kill(new ubuntu::application::ProcessKiller(as, app_manager_task_controller));
497 deferred_kill->run();
498 update_oom_values(as);
499 }
500 break;
501 case ubuntu::application::ui::process_stopped:
502 {
503 ALOGI("%s() state->stopped", __PRETTY_FUNCTION__);
504 /* TODO:
505 * This transition occurs while SIGSTOP'd. Check we hold a valid archive
506 * and then destroy the process image. No need to signal via delegates.
507 */
508 as->running_state = ubuntu::application::ui::process_stopped;
509 }
510 break;
511 case ubuntu::application::ui::process_destroyed:
512 {
513 ALOGI("%s() state->destroyed", __PRETTY_FUNCTION__);
514 /* TODO:
515 * Internal transition: Invalidate archive if any, destroy
516 * process image.
517 */
518 as->running_state = ubuntu::application::ui::process_destroyed;
519 }
520 break;
521 }
522}
523
524void ApplicationManager::start_a_new_session(
525 int32_t session_type,
526 int32_t stage_hint,
527 const android::String8& app_name,
528 const android::String8& desktop_file,
529 const android::sp<android::IApplicationManagerSession>& session,
530 int fd,
531 uint32_t remote_pid)
532{
533 android::Mutex::Autolock al(guard);
534 (void) session_type;
535 pid_t pid = android::IPCThreadState::self()->getCallingPid();
536
537 pid_t rpid;
538 if (!remote_pid)
539 {
540 ALOGI("%s() no remote_pid set from client, lookup in proc", __PRETTY_FUNCTION__);
541 rpid = pid_to_vpid(pid);
542 }
543 else
544 {
545 ALOGI("%s() remote_pid=%d", __PRETTY_FUNCTION__, remote_pid);
546 rpid = static_cast<pid_t>(remote_pid);
547 }
548
549 ALOGI("%s() starting new session pid=%d rpid=%d", __PRETTY_FUNCTION__, pid, rpid);
550
551 android::sp<ubuntu::detail::ApplicationSession> app_session(
552 new ubuntu::detail::ApplicationSession(
553 pid,
554 rpid,
555 session,
556 session_type,
557 stage_hint,
558 app_name,
559 desktop_file));
560
561 apps.add(session->asBinder(), app_session);
562 apps_as_added.push_back(session->asBinder());
563
564 session->asBinder()->linkToDeath(
565 android::sp<android::IBinder::DeathRecipient>(this));
566
567 switch(session_type)
568 {
569 case ubuntu::application::ui::user_session_type:
570 ALOGI("%s: Invoked for user_session_type \n", __PRETTY_FUNCTION__);
571 break;
572 case ubuntu::application::ui::system_session_type:
573 ALOGI("%s: Invoked for system_session_type \n", __PRETTY_FUNCTION__);
574 break;
575 }
576
577 notify_observers_about_session_born(app_session->remote_pid,
578 app_session->stage_hint,
579 app_session->desktop_file);
580
581 ALOGI("%s():%d session", __PRETTY_FUNCTION__, __LINE__);
582}
583
584void ApplicationManager::register_a_surface(
585 const android::String8& title,
586 const android::sp<android::IApplicationManagerSession>& session,
587 int32_t surface_role,
588 int32_t token,
589 int fd)
590{
591 android::Mutex::Autolock al(guard);
592 android::sp<android::InputChannel> input_channel(
593 new android::InputChannel(
594 title,
595 dup(fd)));
596
597 android::sp<ubuntu::detail::ApplicationSession::Surface> surface(
598 new ubuntu::detail::ApplicationSession::Surface(
599 apps.valueFor(session->asBinder()).get(),
600 input_channel,
601 surface_role,
602 token));
603
604 auto registered_session = apps.valueFor(session->asBinder());
605
606 ALOGI("Registering input channel as observer: %s",
607 registered_session->session_type == ubuntu::application::ui::system_session_type ? "true" : "false");
608
609 input_setup->input_manager->getDispatcher()->registerInputChannel(
610 surface->input_channel,
611 surface->make_input_window_handle(),
612 registered_session->session_type == ubuntu::application::ui::system_session_type);
613
614 registered_session->register_surface(surface);
615
616 if (registered_session->session_type == ubuntu::application::ui::system_session_type)
617 {
618 ALOGI("New surface for system session, adjusting layer now.");
619 switch(surface_role)
620 {
621 case ubuntu::application::ui::dash_actor_role:
622 registered_session->raise_surface_to_layer(token, default_dash_layer);
623 break;
624 case ubuntu::application::ui::indicator_actor_role:
625 registered_session->raise_surface_to_layer(token, default_indicator_layer);
626 break;
627 case ubuntu::application::ui::notifications_actor_role:
628 registered_session->raise_surface_to_layer(token, default_notifications_layer);
629 break;
630 case ubuntu::application::ui::greeter_actor_role:
631 registered_session->raise_surface_to_layer(token, default_greeter_layer);
632 break;
633 case ubuntu::application::ui::launcher_actor_role:
634 registered_session->raise_surface_to_layer(token, default_launcher_layer);
635 break;
636 case ubuntu::application::ui::on_screen_keyboard_actor_role:
637 registered_session->raise_surface_to_layer(token, default_osk_layer);
638 break;
639 case ubuntu::application::ui::shutdown_dialog_actor_role:
640 registered_session->raise_surface_to_layer(token, default_shutdown_dialog_layer);
641 break;
642 }
643 }
644}
645
646void ApplicationManager::request_fullscreen(const android::sp<android::IApplicationManagerSession>& session)
647{
648 ALOGI("%s", __PRETTY_FUNCTION__);
649 android::Mutex::Autolock al(guard);
650
651 const android::sp<ubuntu::detail::ApplicationSession>& as =
652 apps.valueFor(session->asBinder());
653
654 notify_observers_about_session_requested_fullscreen(
655 as->remote_pid,
656 as->stage_hint,
657 as->desktop_file);
658}
659
660int ApplicationManager::get_session_pid(const android::sp<android::IApplicationManagerSession>& session)
661{
662 ALOGI("%s", __PRETTY_FUNCTION__);
663 android::Mutex::Autolock al(guard);
664
665 if (apps.indexOfKey(session->asBinder()) == android::NAME_NOT_FOUND)
666 return 0;
667
668 const android::sp<ubuntu::detail::ApplicationSession>& as =
669 apps.valueFor(session->asBinder());
670
671 return as->remote_pid;
672}
673
674void ApplicationManager::request_update_for_session(const android::sp<android::IApplicationManagerSession>& session)
675{
676 ALOGI("%s", __PRETTY_FUNCTION__);
677 android::Mutex::Autolock al(guard);
678
679 if (apps_as_added[focused_application] != session->asBinder())
680 return;
681
682 const android::sp<ubuntu::detail::ApplicationSession>& as =
683 apps.valueFor(apps_as_added[focused_application]);
684
685 if (as->session_type == ubuntu::application::ui::system_session_type)
686 {
687 input_setup->input_manager->getDispatcher()->setFocusedApplication(
688 shell_input_setup->shell_application);
689 android::Vector< android::sp<android::InputWindowHandle> > input_windows;
690 input_windows.push(shell_input_setup->event_trap_window.input_window);
691 input_setup->input_manager->getDispatcher()->setInputWindows(
692 input_windows);
693 } else
694 {
695 input_setup->input_manager->getDispatcher()->setFocusedApplication(
696 as->input_application_handle());
697
698 android::Vector< android::sp<android::InputWindowHandle> > input_windows;
699
700 if (is_osk_visible)
701 input_windows.push(shell_input_setup->osk_window.input_window);
702 if (are_notifications_visible)
703 input_windows.push(shell_input_setup->notifications_window.input_window);
704
705 if (!shell_input_setup->trap_windows.isEmpty())
706 {
707 int key = 0;
708 for (size_t i = 0; i < shell_input_setup->trap_windows.size(); i++)
709 {
710 key = shell_input_setup->trap_windows.keyAt(i);
711 input_windows.push(shell_input_setup->trap_windows.valueFor(key));
712 }
713 }
714
715 input_windows.appendVector(as->input_window_handles());
716
717 if (as->stage_hint == ubuntu::application::ui::side_stage)
718 {
719 const android::sp<ubuntu::detail::ApplicationSession>& main_session =
720 apps.valueFor(apps_as_added[main_stage_application]);
721 input_windows.appendVector(main_session->input_window_handles());
722 }
723
724 input_setup->input_manager->getDispatcher()->setInputWindows(
725 input_windows);
726 }
727}
728
729void ApplicationManager::register_task_controller(
730 const android::sp<android::IAMTaskController>& controller)
731{
732 ALOGI("%s() registering task controller", __PRETTY_FUNCTION__);
733
734 //TODO: Register the task controller to use it instead of sigkilling
735 android::Mutex::Autolock al(guard);
736
737 if (app_manager_task_controller != NULL)
738 return;
739
740 ALOGI("%s() done registering task controller", __PRETTY_FUNCTION__);
741
742 app_manager_task_controller = controller;
743}
744
745void ApplicationManager::register_an_observer(
746 const android::sp<android::IApplicationManagerObserver>& observer)
747{
748 android::Mutex::Autolock al(observer_guard);
749 app_manager_observers.push_back(observer);
750 {
751 android::Mutex::Autolock al(guard);
752
753 for(unsigned int i = 0; i < apps_as_added.size(); i++)
754 {
755 const android::sp<ubuntu::detail::ApplicationSession>& session =
756 apps.valueFor(apps_as_added[i]);
757
758 observer->on_session_born(session->remote_pid,
759 session->stage_hint,
760 session->desktop_file);
761 }
762
763 if (focused_application < apps_as_added.size())
764 {
765 const android::sp<ubuntu::detail::ApplicationSession>& session =
766 apps.valueFor(apps_as_added[focused_application]);
767
768 observer->on_session_focused(session->remote_pid,
769 session->stage_hint,
770 session->desktop_file);
771 }
772 }
773}
774
775void ApplicationManager::focus_running_session_with_id(int id)
776{
777 android::Mutex::Autolock al(guard);
778
779 size_t idx = session_id_to_index(id);
780
781 if (idx < apps_as_added.size())
782 {
783 switch_focused_application_locked(idx);
784 }
785}
786
787void ApplicationManager::unfocus_running_sessions()
788{
789 ALOGI("%s", __PRETTY_FUNCTION__);
790
791 android::Mutex::Autolock al(guard);
792
793 if (shell_input_setup->shell_has_focus)
794 return;
795
796 input_setup->input_manager->getDispatcher()->setFocusedApplication(
797 shell_input_setup->shell_application);
798 android::Vector< android::sp<android::InputWindowHandle> > input_windows;
799 input_windows.push(shell_input_setup->event_trap_window.input_window);
800 input_setup->input_manager->getDispatcher()->setInputWindows(
801 input_windows);
802
803 if (focused_application < apps.size())
804 {
805 const android::sp<ubuntu::detail::ApplicationSession>& session =
806 apps.valueFor(apps_as_added[focused_application]);
807
808 if (session->session_type != ubuntu::application::ui::system_session_type)
809 {
810 notify_observers_about_session_unfocused(session->remote_pid,
811 session->stage_hint,
812 session->desktop_file);
813
814 if (!is_session_allowed_to_run_in_background(session))
815 session_set_state(session, ubuntu::application::ui::process_suspended);
816 }
817 }
818 shell_input_setup->shell_has_focus = true;
819}
820
821int32_t ApplicationManager::query_snapshot_layer_for_session_with_id(int id)
822{
823 size_t idx = session_id_to_index(id);
824
825 if (idx < apps_as_added.size())
826 {
827 return apps.valueFor(apps_as_added[idx])->layer();
828 }
829
830 return INT_MAX;
831}
832
833android::IApplicationManagerSession::SurfaceProperties ApplicationManager::query_surface_properties_for_session_id(int id)
834{
835 android::Mutex::Autolock al(guard);
836
837 size_t idx = session_id_to_index(id);
838 android::IApplicationManagerSession::SurfaceProperties props;
839 int status;
840
841 if (idx < apps_as_added.size())
842 {
843 const android::sp<ubuntu::detail::ApplicationSession>& session =
844 apps.valueFor(apps_as_added[idx]);
845
846 if (session->running_state == ubuntu::application::ui::process_suspended)
847 {
848 kill(session->pid, SIGCONT);
849 props = session->query_properties();
850 kill(session->pid, SIGSTOP);
851 } else {
852 props = session->query_properties();
853 }
854
855 return props;
856 }
857
858 return android::IApplicationManagerSession::SurfaceProperties();
859}
860
861void ApplicationManager::switch_to_well_known_application(int32_t app)
862{
863 notify_observers_about_session_requested(app);
864}
865
866int32_t ApplicationManager::set_surface_trap(int x, int y, int width, int height)
867{
868 static int32_t key = 0;
869
870 ApplicationManager::ShellInputSetup::Window<0, 0, 2048, 2048>* w =
871 new ApplicationManager::ShellInputSetup::Window<0, 0, 2048, 2048>(shell_input_setup.get(), x, y, width, height);
872
873 key++;
874 shell_input_setup->trap_windows.add(key, w->input_window);
875
876 update_input_setup_locked();
877
878 return key;
879}
880
881void ApplicationManager::unset_surface_trap(int32_t handle)
882{
883 shell_input_setup->trap_windows.removeItem(handle);
884
885 update_input_setup_locked();
886}
887
888void ApplicationManager::report_osk_visible(int32_t x, int32_t y, int32_t width, int32_t height)
889{
890 ALOGI("%s(x=%d, y=%d, width=%d, height=%d)", __PRETTY_FUNCTION__, x, y, width, height);
891
892 shell_input_setup->osk_window.input_window->x = x;
893 shell_input_setup->osk_window.input_window->y = y;
894 shell_input_setup->osk_window.input_window->w = width;
895 shell_input_setup->osk_window.input_window->h = height;
896
897 android::Mutex::Autolock al(guard);
898 is_osk_visible = true;
899
900 update_input_setup_locked();
901
902 notify_observers_about_keyboard_geometry_changed(x, y, width, height);
903}
904
905void ApplicationManager::report_osk_invisible()
906{
907 ALOGI("%s", __PRETTY_FUNCTION__);
908 android::Mutex::Autolock al(guard);
909 is_osk_visible = false;
910
911 update_input_setup_locked();
912
913 notify_observers_about_keyboard_geometry_changed(0, 0, 0, 0);
914}
915
916void ApplicationManager::report_notification_visible()
917{
918 ALOGI("%s", __PRETTY_FUNCTION__);
919 android::Mutex::Autolock al(guard);
920 are_notifications_visible = true;
921
922 update_input_setup_locked();
923}
924
925void ApplicationManager::report_notification_invisible()
926{
927 ALOGI("%s", __PRETTY_FUNCTION__);
928 android::Mutex::Autolock al(guard);
929 are_notifications_visible = false;
930
931 update_input_setup_locked();
932}
933
934void ApplicationManager::update_input_setup_locked()
935{
936 if (focused_application >= apps.size())
937 return;
938
939 const android::sp<ubuntu::detail::ApplicationSession>& session =
940 apps.valueFor(apps_as_added[focused_application]);
941
942 if (shell_input_setup->shell_has_focus)
943 {
944 input_setup->input_manager->getDispatcher()->setFocusedApplication(
945 shell_input_setup->shell_application);
946
947 android::Vector< android::sp<android::InputWindowHandle> > input_windows;
948 input_windows.push(shell_input_setup->event_trap_window.input_window);
949
950 input_setup->input_manager->getDispatcher()->setInputWindows(
951 input_windows);
952 } else
953 {
954 ALOGI("Adjusting input setup to account for change in visibility of osk/notifications");
955
956 input_setup->input_manager->getDispatcher()->setFocusedApplication(
957 session->input_application_handle());
958
959 android::Vector< android::sp<android::InputWindowHandle> > input_windows;
960 if (is_osk_visible)
961 input_windows.push(shell_input_setup->osk_window.input_window);
962 if (are_notifications_visible)
963 input_windows.push(shell_input_setup->notifications_window.input_window);
964 if (!shell_input_setup->trap_windows.isEmpty())
965 {
966 int key = 0;
967 for (size_t i = 0; i < shell_input_setup->trap_windows.size(); i++)
968 {
969 key = shell_input_setup->trap_windows.keyAt(i);
970 input_windows.push(shell_input_setup->trap_windows.valueFor(key));
971 }
972 }
973
974 android::sp<android::IBinder> sb = apps_as_added[focused_application];
975
976 if (sb->isBinderAlive())
977 input_windows.appendVector(session->input_window_handles());
978
979 if (session->stage_hint == ubuntu::application::ui::side_stage)
980 {
981 const android::sp<ubuntu::detail::ApplicationSession>& main_session =
982 apps.valueFor(apps_as_added[main_stage_application]);
983
984 android::sp<android::IBinder> msb = apps_as_added[focused_application];
985 if (msb->isBinderAlive())
986 {
987 input_windows.appendVector(main_session->input_window_handles());
988 }
989 }
990
991 input_setup->input_manager->getDispatcher()->setInputWindows(
992 input_windows);
993 }
994}
995
996void ApplicationManager::switch_focused_application_locked(size_t index_of_next_focused_app)
997{
998 static int focused_layer = 0;
999 static const int focused_layer_increment = 10;
1000
1001 if (apps.size() > 1 &&
1002 focused_application < apps.size() &&
1003 focused_application < apps_as_added.size() &&
1004 focused_application != index_of_next_focused_app)
1005 {
1006 ALOGI("Lowering current application now for idx: %d \n", focused_application);
1007 const android::sp<ubuntu::detail::ApplicationSession>& session =
1008 apps.valueFor(apps_as_added[focused_application]);
1009
1010 const android::sp<ubuntu::detail::ApplicationSession>& next_session =
1011 apps.valueFor(apps_as_added[index_of_next_focused_app]);
1012
1013 if (next_session->session_type == ubuntu::application::ui::system_session_type)
1014 return;
1015
1016 if (session->session_type != ubuntu::application::ui::system_session_type)
1017 {
1018 // Stop the session
1019 if (!is_session_allowed_to_run_in_background(session))
1020 {
1021 if ((session->stage_hint == ubuntu::application::ui::main_stage &&
1022 next_session->stage_hint != ubuntu::application::ui::side_stage) ||
1023 (session->stage_hint == ubuntu::application::ui::side_stage &&
1024 next_session->stage_hint != ubuntu::application::ui::main_stage))
1025 {
1026 notify_observers_about_session_unfocused(session->remote_pid,
1027 session->stage_hint,
1028 session->desktop_file);
1029
1030 session_set_state(session, ubuntu::application::ui::process_suspended);
1031 } else
1032 {
1033 if (session->stage_hint == ubuntu::application::ui::side_stage &&
1034 next_session->stage_hint == ubuntu::application::ui::main_stage &&
1035 main_stage_application < apps.size())
1036 {
1037 const android::sp<ubuntu::detail::ApplicationSession>& main_session =
1038 apps.valueFor(apps_as_added[main_stage_application]);
1039
1040 if (main_session->session_type != ubuntu::application::ui::system_session_type)
1041 session_set_state(main_session, ubuntu::application::ui::process_suspended);
1042 }
1043 }
1044 }
1045 }
1046 }
1047
1048 focused_application = index_of_next_focused_app;
1049 is_osk_visible = false;
1050 notify_observers_about_keyboard_geometry_changed(0, 0, 0, 0);
1051
1052 if (focused_application < apps.size())
1053 {
1054
1055 focused_layer += focused_layer_increment;
1056
1057 const android::sp<ubuntu::detail::ApplicationSession>& session =
1058 apps.valueFor(apps_as_added[focused_application]);
1059
1060 ALOGI("Raising application now for idx: %d (stage_hint: %d)\n", focused_application, session->stage_hint);
1061
1062 if (session->session_type == ubuntu::application::ui::system_session_type)
1063 {
1064 ALOGI("\t system session - not raising it.");
1065 return;
1066 }
1067
1068 // Continue the session
1069 if (!is_session_allowed_to_run_in_background(session))
1070 session_set_state(session, ubuntu::application::ui::process_running);
1071
1072 if (session->stage_hint == ubuntu::application::ui::side_stage)
1073 side_stage_application = focused_application;
1074 else
1075 main_stage_application = focused_application;
1076
1077 session->raise_application_surfaces_to_layer(focused_layer);
1078 input_setup->input_manager->getDispatcher()->setFocusedApplication(
1079 session->input_application_handle());
1080
1081 android::Vector< android::sp<android::InputWindowHandle> > input_windows;
1082
1083 if (are_notifications_visible)
1084 input_windows.push(shell_input_setup->notifications_window.input_window);
1085 if (!shell_input_setup->trap_windows.isEmpty())
1086 {
1087 int key = 0;
1088 for (size_t i = 0; i < shell_input_setup->trap_windows.size(); i++)
1089 {
1090 key = shell_input_setup->trap_windows.keyAt(i);
1091 input_windows.push(shell_input_setup->trap_windows.valueFor(key));
1092 }
1093 }
1094
1095 input_windows.appendVector(session->input_window_handles());
1096
1097 if (session->stage_hint == ubuntu::application::ui::side_stage)
1098 {
1099 if (main_stage_application)
1100 {
1101 const android::sp<ubuntu::detail::ApplicationSession>& main_session =
1102 apps.valueFor(apps_as_added[main_stage_application]);
1103 session_set_state(main_session, ubuntu::application::ui::process_running);
1104 input_windows.appendVector(main_session->input_window_handles());
1105 }
1106 }
1107
1108 input_setup->input_manager->getDispatcher()->setInputWindows(
1109 input_windows);
1110
1111 notify_observers_about_session_focused(session->remote_pid,
1112 session->stage_hint,
1113 session->desktop_file);
1114
1115 shell_input_setup->shell_has_focus = false;
1116 }
1117}
1118
1119void ApplicationManager::switch_focus_to_next_application_locked()
1120{
1121 size_t new_idx = (focused_application + 1) % apps.size();
1122
1123 ALOGI("current: %d, next: %d \n", focused_application, new_idx);
1124
1125 switch_focused_application_locked(new_idx);
1126}
1127
1128void ApplicationManager::kill_focused_application_locked()
1129{
1130 if (focused_application < apps.size())
1131 {
1132 const android::sp<ubuntu::detail::ApplicationSession>& session =
1133 apps.valueFor(apps_as_added[focused_application]);
1134
1135 kill(session->pid, SIGKILL);
1136 }
1137}
1138
1139size_t ApplicationManager::session_id_to_index(int id)
1140{
1141 size_t idx = 0;
1142
1143 for(idx = 0; idx < apps_as_added.size(); idx++)
1144 {
1145 const android::sp<ubuntu::detail::ApplicationSession>& session =
1146 apps.valueFor(apps_as_added[idx]);
1147
1148 if (session->remote_pid == id)
1149 break;
1150 }
1151
1152 return idx;
1153}
1154
1155void ApplicationManager::notify_observers_about_session_requested(uint32_t app)
1156{
1157 android::Mutex::Autolock al(observer_guard);
1158 for(unsigned int i = 0; i < app_manager_observers.size(); i++)
1159 {
1160 app_manager_observers[i]->on_session_requested(app);
1161 }
1162}
1163
1164void ApplicationManager::notify_observers_about_session_born(int id, int stage_hint, const android::String8& desktop_file)
1165{
1166 android::Mutex::Autolock al(observer_guard);
1167 for(unsigned int i = 0; i < app_manager_observers.size(); i++)
1168 {
1169 app_manager_observers[i]->on_session_born(id, stage_hint, desktop_file);
1170 }
1171}
1172
1173void ApplicationManager::notify_observers_about_session_unfocused(int id, int stage_hint, const android::String8& desktop_file)
1174{
1175 android::Mutex::Autolock al(observer_guard);
1176 for(unsigned int i = 0; i < app_manager_observers.size(); i++)
1177 {
1178 app_manager_observers[i]->on_session_unfocused(id, stage_hint, desktop_file);
1179 }
1180}
1181
1182void ApplicationManager::notify_observers_about_session_focused(int id, int stage_hint, const android::String8& desktop_file)
1183{
1184 android::Mutex::Autolock al(observer_guard);
1185 for(unsigned int i = 0; i < app_manager_observers.size(); i++)
1186 {
1187 app_manager_observers[i]->on_session_focused(id, stage_hint, desktop_file);
1188 }
1189}
1190
1191void ApplicationManager::notify_observers_about_keyboard_geometry_changed(int x, int y, int width, int height)
1192{
1193 android::Mutex::Autolock al(observer_guard);
1194 for(unsigned int i = 0; i < app_manager_observers.size(); i++)
1195 {
1196 app_manager_observers[i]->on_keyboard_geometry_changed(x, y, width, height);
1197 }
1198}
1199
1200void ApplicationManager::notify_observers_about_session_requested_fullscreen(int id, int stage_hint, const android::String8& desktop_file)
1201{
1202 android::Mutex::Autolock al(observer_guard);
1203 for(unsigned int i = 0; i < app_manager_observers.size(); i++)
1204 {
1205 app_manager_observers[i]->on_session_requested_fullscreen(id, stage_hint, desktop_file);
1206 }
1207}
1208
1209void ApplicationManager::notify_observers_about_session_died(int id, int stage_hint, const android::String8& desktop_file)
1210{
1211 android::Mutex::Autolock al(observer_guard);
1212 for(unsigned int i = 0; i < app_manager_observers.size(); i++)
1213 {
1214 app_manager_observers[i]->on_session_died(id, stage_hint, desktop_file);
1215 }
1216}
1217
1218struct ClipboardService : public android::BnClipboardService
1219{
1220 void set_content(const android::IClipboardService::Content& content)
1221 {
1222 this->content = content;
1223 }
1224
1225 void get_content(android::IClipboardService::Content& content)
1226 {
1227 content = this->content;
1228 }
1229
1230 android::IClipboardService::Content content;
1231};
1232
1233}
1234}
1235int main(int argc, char** argv)
1236{
1237 android::sp<ubuntu::detail::ApplicationManager> app_manager(new ubuntu::detail::ApplicationManager());
1238 android::sp<ubuntu::detail::ClipboardService> clipboard_service(new ubuntu::detail::ClipboardService());
1239 // Register service
1240 android::sp<android::IServiceManager> service_manager = android::defaultServiceManager();
1241 if (android::NO_ERROR != service_manager->addService(
1242 android::String16(android::IApplicationManager::exported_service_name()),
1243 app_manager))
1244 {
1245 return EXIT_FAILURE;
1246 }
1247
1248 if (android::NO_ERROR != service_manager->addService(
1249 android::String16(android::IClipboardService::exported_service_name()),
1250 clipboard_service))
1251 {
1252 return EXIT_FAILURE;
1253 }
1254
1255 android::ProcessState::self()->startThreadPool();
1256 android::IPCThreadState::self()->joinThreadPool();
1257}
12580
=== removed file 'android/hybris/default_application_manager.h'
--- android/hybris/default_application_manager.h 2014-01-22 05:28:18 +0000
+++ android/hybris/default_application_manager.h 1970-01-01 00:00:00 +0000
@@ -1,255 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18#ifndef DEFAULT_APPLICATION_MANAGER_H_
19#define DEFAULT_APPLICATION_MANAGER_H_
20
21#include "application_manager.h"
22#include "default_application_manager_input_setup.h"
23#include "default_application_session.h"
24#include "event_loop.h"
25#include "lifecycle_helpers.h"
26
27#include <binder/IPCThreadState.h>
28#include <binder/IServiceManager.h>
29#include <binder/ProcessState.h>
30
31#include <input/InputListener.h>
32#include <input/InputReader.h>
33#if ANDROID_VERSION_MAJOR==4 && ANDROID_VERSION_MINOR<=2
34#include <androidfw/InputTransport.h>
35#else
36#include <input/InputTransport.h>
37#endif
38#include <utils/threads.h>
39
40namespace ubuntu { namespace detail
41{
42struct ApplicationManager :
43 public android::BnApplicationManager,
44 public android::IBinder::DeathRecipient
45{
46 static const int default_shell_component_layer = 1000000;
47
48 static const int default_dash_layer = default_shell_component_layer + 1;
49 static const int default_indicator_layer = default_shell_component_layer + 2;
50 static const int default_notifications_layer = default_shell_component_layer + 3;
51 static const int default_greeter_layer = default_shell_component_layer + 4;
52 static const int default_launcher_layer = default_shell_component_layer + 5;
53 static const int default_osk_layer = default_shell_component_layer + 6;
54 static const int default_shutdown_dialog_layer = default_shell_component_layer + 7;
55
56 static const int focused_application_base_layer = 100;
57 static const int wallpaper_layer = 0;
58 static const int non_focused_application_layer = -1;
59
60 struct ShellInputSetup : public android::RefBase
61 {
62 struct DisplayInfo
63 {
64 DisplayInfo();
65
66 android::DisplayInfo info;
67 };
68
69 template<int x, int y, int w, int h>
70 struct Window : public android::RefBase
71 {
72 static int looper_callback(int receiveFd, int events, void* ctxt);
73
74 Window(ShellInputSetup* parent,
75 int _x = x,
76 int _y = y,
77 int _w = w,
78 int _h = h);
79
80 android::sp<android::InputSetup::DummyApplicationWindow> input_window;
81
82 ShellInputSetup* parent;
83 android::sp<android::InputChannel> server_channel;
84 android::sp<android::InputChannel> client_channel;
85 android::InputConsumer input_consumer;
86 android::PreallocatedInputEventFactory event_factory;
87 };
88
89 ShellInputSetup(const android::sp<android::InputManager>& input_manager);
90
91 bool shell_has_focus;
92
93 DisplayInfo display_info;
94
95 android::sp<android::InputManager> input_manager;
96 android::sp<android::InputApplicationHandle> shell_application;
97
98 android::sp<android::Looper> looper;
99 ubuntu::application::EventLoop event_loop;
100
101 android::KeyedVector<int32_t, android::sp<android::InputWindowHandle> > trap_windows;
102
103 // TODO(tvoss): Get rid of hard coded values.
104 Window<0, 0, 720, 1280> event_trap_window;
105 // TODO(tvoss): This is really hacky, but we need to
106 // synchronize/reflect state changes across multiple processes
107 // here, i.e.:
108 // * maliit-server, which takes care of hiding and showing the osk
109 // * notify-osd, which takes care of hiding and showing notifications
110 Window<0, 812, 720, 468> osk_window;
111 Window<36, 18, 684, 216> notifications_window;
112 };
113
114 class InputFilter : public android::InputFilter
115 {
116 public:
117 InputFilter(ApplicationManager* manager);
118
119 bool filter_event(const android::InputEvent* event);
120
121 private:
122 ApplicationManager* manager;
123
124 bool handle_key_event(const android::KeyEvent* event);
125 };
126
127 class LockingIterator : public android::RefBase
128 {
129 public:
130 void advance() ;
131
132 bool is_valid() const;
133
134 void make_current();
135
136 const android::sp<ubuntu::detail::ApplicationSession>& operator*();
137
138 protected:
139 friend class ApplicationManager;
140
141 LockingIterator(
142 ApplicationManager* manager,
143 size_t index);
144
145 virtual ~LockingIterator();
146
147 private:
148 ApplicationManager* manager;
149 size_t it;
150 };
151
152 ApplicationManager();
153
154 void update_app_lists();
155
156 // From DeathRecipient
157 void binderDied(const android::wp<android::IBinder>& who);
158
159 void lock();
160
161 void unlock();
162
163 android::sp<LockingIterator> iterator();
164
165 void session_set_state(const android::sp<ubuntu::detail::ApplicationSession>& session,
166 int32_t new_state);
167
168 void start_a_new_session(
169 int32_t session_type,
170 int32_t stage_hint,
171 const android::String8& app_name,
172 const android::String8& desktop_file,
173 const android::sp<android::IApplicationManagerSession>& session,
174 int fd,
175 uint32_t remote_pid);
176
177 void register_a_surface(
178 const android::String8& title,
179 const android::sp<android::IApplicationManagerSession>& session,
180 int32_t surface_role,
181 int32_t token,
182 int fd);
183
184 void request_fullscreen(const android::sp<android::IApplicationManagerSession>& session);
185
186 void register_an_observer(const android::sp<android::IApplicationManagerObserver>& observer);
187
188 void register_task_controller(const android::sp<android::IAMTaskController>& controller);
189
190 int get_session_pid(const android::sp<android::IApplicationManagerSession>& session);
191
192 void request_update_for_session(const android::sp<android::IApplicationManagerSession>& session);
193
194 void focus_running_session_with_id(int id);
195
196 void unfocus_running_sessions();
197
198 int32_t query_snapshot_layer_for_session_with_id(int id);
199
200 android::IApplicationManagerSession::SurfaceProperties query_surface_properties_for_session_id(int id);
201
202 void switch_to_well_known_application(int32_t app);
203
204 int32_t set_surface_trap(int32_t x, int32_t y, int32_t width, int32_t height);
205
206 void unset_surface_trap(int32_t handle);
207
208 void report_osk_visible(int32_t x, int32_t y, int32_t width, int32_t height);
209
210 void report_osk_invisible();
211
212 void report_notification_visible();
213
214 void report_notification_invisible();
215
216 void switch_focused_application_locked(size_t index_of_next_focused_app);
217 void switch_focus_to_next_application_locked();
218
219 void kill_focused_application_locked();
220
221 private:
222 void update_input_setup_locked();
223
224 size_t session_id_to_index(int id);
225 void notify_observers_about_session_requested(uint32_t app);
226 void notify_observers_about_session_born(int id, int stage_hint, const android::String8& desktop_file);
227 void notify_observers_about_session_unfocused(int id, int stage_hint, const android::String8& desktop_file);
228 void notify_observers_about_session_focused(int id, int stage_hint, const android::String8& desktop_file);
229 void notify_observers_about_keyboard_geometry_changed(int x, int y, int width, int height);
230 void notify_observers_about_session_requested_fullscreen(int id, int stage_hint, const android::String8& desktop_file);
231 void notify_observers_about_session_died(int id, int stage_hint, const android::String8& desktop_file);
232
233 android::sp<android::InputListenerInterface> input_listener;
234 android::sp<InputFilter> input_filter;
235 android::sp<android::InputSetup> input_setup;
236 android::sp<ShellInputSetup> shell_input_setup;
237 bool is_osk_visible;
238 bool are_notifications_visible;
239 android::Condition state_cond;
240 android::Mutex state_lock;
241 android::Mutex guard;
242 android::KeyedVector< android::sp<android::IBinder>, android::sp<ubuntu::detail::ApplicationSession> > apps;
243 android::Vector< android::sp<android::IBinder> > apps_as_added;
244 android::Mutex observer_guard;
245 android::Vector< android::sp<android::IApplicationManagerObserver> > app_manager_observers;
246 android::sp<android::IAMTaskController> app_manager_task_controller;
247 size_t focused_application;
248 size_t side_stage_application;
249 size_t main_stage_application;
250};
251
252}
253}
254
255#endif // DEFAULT_APPLICATION_MANAGER_H_
2560
=== removed file 'android/hybris/default_application_manager_input_setup.h'
--- android/hybris/default_application_manager_input_setup.h 2014-01-22 05:28:18 +0000
+++ android/hybris/default_application_manager_input_setup.h 1970-01-01 00:00:00 +0000
@@ -1,452 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18#ifndef DEFAULT_APPLICATION_MANAGER_INPUT_SETUP_H_
19#define DEFAULT_APPLICATION_MANAGER_INPUT_SETUP_H_
20
21#include <input/InputDispatcher.h>
22#include <input/InputListener.h>
23#include <input/InputManager.h>
24#include <input/InputReader.h>
25#include <input/PointerController.h>
26#include <input/SpriteController.h>
27#include <gui/ISurfaceComposer.h>
28#include <gui/SurfaceComposerClient.h>
29
30#include <cstdio>
31
32#define REPORT_FUNCTION_CALL()// printf("%s \n", __PRETTY_FUNCTION__);
33
34namespace android
35{
36class DefaultPointerControllerPolicy : public android::PointerControllerPolicyInterface
37{
38public:
39
40 static const size_t bitmap_width = 64;
41 static const size_t bitmap_height = 64;
42
43 DefaultPointerControllerPolicy()
44 {
45 bitmap.setConfig(
46 SkBitmap::kARGB_8888_Config,
47 bitmap_width,
48 bitmap_height);
49 bitmap.allocPixels();
50
51 // Icon for spot touches
52 bitmap.eraseARGB(125, 0, 255, 0);
53 spotTouchIcon = android::SpriteIcon(
54 bitmap,
55 bitmap_width/2,
56 bitmap_height/2);
57 // Icon for anchor touches
58 bitmap.eraseARGB(125, 0, 0, 255);
59 spotAnchorIcon = android::SpriteIcon(
60 bitmap,
61 bitmap_width/2,
62 bitmap_height/2);
63 // Icon for hovering touches
64 bitmap.eraseARGB(125, 255, 0, 0);
65 spotHoverIcon = android::SpriteIcon(
66 bitmap,
67 bitmap_width/2,
68 bitmap_height/2);
69 }
70
71 void loadPointerResources(android::PointerResources* outResources)
72 {
73 outResources->spotHover = spotHoverIcon.copy();
74 outResources->spotTouch = spotTouchIcon.copy();
75 outResources->spotAnchor = spotAnchorIcon.copy();
76 }
77
78 android::SpriteIcon spotHoverIcon;
79 android::SpriteIcon spotTouchIcon;
80 android::SpriteIcon spotAnchorIcon;
81 SkBitmap bitmap;
82};
83
84class DefaultInputReaderPolicyInterface : public android::InputReaderPolicyInterface
85{
86public:
87 static const int32_t internal_display_id = android::ISurfaceComposer::eDisplayIdMain;
88 static const int32_t external_display_id = android::ISurfaceComposer::eDisplayIdHdmi;
89
90 DefaultInputReaderPolicyInterface(const android::sp<android::Looper>& looper)
91 : looper(looper),
92 default_layer_for_touch_point_visualization(INT_MAX)
93 {
94 default_configuration.showTouches = false;
95
96 auto display = android::SurfaceComposerClient::getBuiltInDisplay(
97 android::ISurfaceComposer::eDisplayIdMain);
98 android::DisplayInfo info;
99 android::SurfaceComposerClient::getDisplayInfo(
100 display,
101 &info);
102
103 android::DisplayViewport viewport;
104 viewport.setNonDisplayViewport(info.w, info.h);
105 viewport.displayId = android::ISurfaceComposer::eDisplayIdMain;
106 default_configuration.setDisplayInfo(
107 false, /* external */
108 viewport);
109
110 }
111
112 void getReaderConfiguration(android::InputReaderConfiguration* outConfig)
113 {
114 *outConfig = default_configuration;
115 }
116
117 android::sp<android::PointerControllerInterface> obtainPointerController(int32_t deviceId)
118 {
119 (void) deviceId;
120
121 android::sp<android::SpriteController> sprite_controller(
122 new android::SpriteController(
123 looper,
124 default_layer_for_touch_point_visualization));
125 android::sp<android::PointerController> pointer_controller(
126 new android::PointerController(
127 android::sp<DefaultPointerControllerPolicy>(new DefaultPointerControllerPolicy()),
128 looper,
129 sprite_controller));
130 pointer_controller->setPresentation(
131 android::PointerControllerInterface::PRESENTATION_SPOT);
132 int32_t w, h, o;
133 auto display = android::SurfaceComposerClient::getBuiltInDisplay(
134 android::ISurfaceComposer::eDisplayIdMain);
135 android::DisplayInfo info;
136 android::SurfaceComposerClient::getDisplayInfo(
137 display,
138 &info);
139
140 pointer_controller->setDisplayViewport(info.w, info.h, info.orientation);
141 return pointer_controller;
142 }
143
144 virtual void notifyInputDevicesChanged(const Vector<InputDeviceInfo>& inputDevices) {
145 mInputDevices = inputDevices;
146 }
147
148 virtual sp<KeyCharacterMap> getKeyboardLayoutOverlay(const String8& inputDeviceDescriptor) {
149 return NULL;
150 }
151
152 virtual String8 getDeviceAlias(const InputDeviceIdentifier& identifier) {
153 return String8::empty();
154 }
155private:
156 android::sp<android::Looper> looper;
157 int default_layer_for_touch_point_visualization;
158 android::InputReaderConfiguration default_configuration;
159 Vector<InputDeviceInfo> mInputDevices;
160};
161
162class InputFilter : public android::RefBase
163{
164public:
165 virtual bool filter_event(const android::InputEvent* event) = 0;
166
167protected:
168 InputFilter() {}
169 virtual ~InputFilter() {}
170
171 InputFilter(const InputFilter&) = delete;
172 InputFilter& operator=(const InputFilter&) = delete;
173};
174
175class DefaultInputDispatcherPolicy : public InputDispatcherPolicyInterface
176{
177public:
178 DefaultInputDispatcherPolicy(const android::sp<InputFilter>& input_filter)
179 : input_filter(input_filter)
180 {
181 }
182
183 ~DefaultInputDispatcherPolicy()
184 {
185 }
186
187 void notifyConfigurationChanged(nsecs_t when)
188 {
189 REPORT_FUNCTION_CALL();
190 (void) when;
191 }
192
193 nsecs_t notifyANR(const sp<InputApplicationHandle>& inputApplicationHandle,
194#if ANDROID_VERSION_MAJOR==4 && ANDROID_VERSION_MINOR<4
195 const sp<InputWindowHandle>& inputWindowHandle)
196#else
197 const sp<InputWindowHandle>& inputWindowHandle,
198 const android::String8& reason)
199#endif
200 {
201 REPORT_FUNCTION_CALL();
202 (void) inputApplicationHandle;
203 (void) inputWindowHandle;
204#if ANDROID_VERSION_MAJOR==4 && ANDROID_VERSION_MINOR>=4
205 (void) reason;
206#endif
207
208 return 0;
209 }
210
211 void notifyInputChannelBroken(const sp<InputWindowHandle>& inputWindowHandle)
212 {
213 REPORT_FUNCTION_CALL();
214 (void) inputWindowHandle;
215 }
216
217 void getDispatcherConfiguration(InputDispatcherConfiguration* outConfig)
218 {
219 REPORT_FUNCTION_CALL();
220 static InputDispatcherConfiguration config;
221 //config.maxEventsPerSecond = INT_MAX;
222 *outConfig = config;
223 }
224
225 bool isKeyRepeatEnabled()
226 {
227 REPORT_FUNCTION_CALL();
228 return true;
229 }
230
231 bool filterInputEvent(const InputEvent* event, uint32_t policyFlags)
232 {
233 REPORT_FUNCTION_CALL();
234 (void) event;
235 (void) policyFlags;
236 return input_filter->filter_event(event);
237 }
238
239 void interceptKeyBeforeQueueing(const KeyEvent* event, uint32_t& policyFlags)
240 {
241 REPORT_FUNCTION_CALL();
242 (void) event;
243 policyFlags |= POLICY_FLAG_PASS_TO_USER;
244 }
245
246 void interceptMotionBeforeQueueing(nsecs_t when, uint32_t& policyFlags)
247 {
248 REPORT_FUNCTION_CALL();
249 (void) when;
250 (void) policyFlags;
251 policyFlags |= POLICY_FLAG_PASS_TO_USER;
252 }
253
254 nsecs_t interceptKeyBeforeDispatching(
255 const sp<InputWindowHandle>& inputWindowHandle,
256 const KeyEvent* keyEvent,
257 uint32_t policyFlags)
258 {
259 REPORT_FUNCTION_CALL();
260 (void) inputWindowHandle;
261 (void) keyEvent;
262 (void) policyFlags;
263
264 return 0;
265 }
266
267 bool dispatchUnhandledKey(
268 const sp<InputWindowHandle>& inputWindowHandle,
269 const KeyEvent* keyEvent,
270 uint32_t policyFlags,
271 KeyEvent* outFallbackKeyEvent)
272 {
273 REPORT_FUNCTION_CALL();
274 (void) inputWindowHandle;
275 (void) keyEvent;
276 (void) policyFlags;
277 (void) outFallbackKeyEvent;
278 return false;
279 }
280
281 virtual void notifySwitch(
282 nsecs_t when,
283 uint32_t switchCode,
284 uint32_t switchValue,
285 uint32_t policyFlags)
286 {
287 REPORT_FUNCTION_CALL();
288 (void) when;
289 (void) switchCode;
290 (void) switchValue;
291 (void) policyFlags;
292 }
293
294 void pokeUserActivity(nsecs_t eventTime, int32_t eventType)
295 {
296 REPORT_FUNCTION_CALL();
297 (void) eventTime;
298 (void) eventType;
299 }
300
301 bool checkInjectEventsPermissionNonReentrant(
302 int32_t injectorPid,
303 int32_t injectorUid)
304 {
305 REPORT_FUNCTION_CALL();
306 (void) injectorPid;
307 (void) injectorUid;
308
309 return true;
310 }
311
312 android::sp<InputFilter> input_filter;
313};
314
315class LooperThread : public android::Thread
316{
317public:
318 static const int default_poll_timeout_ms = 500;
319
320 LooperThread(const android::sp<android::Looper>& looper) : looper(looper)
321 {
322 }
323
324private:
325 bool threadLoop()
326 {
327 if (ALOOPER_POLL_ERROR == looper->pollAll(default_poll_timeout_ms))
328 return false;
329 return true;
330 }
331
332 android::sp<android::Looper> looper;
333};
334
335struct InputSetup : public android::RefBase
336{
337 struct DummyApplication : public android::InputApplicationHandle
338 {
339 bool updateInfo()
340 {
341 ALOGI("%s", __PRETTY_FUNCTION__);
342 if (mInfo == NULL)
343 {
344 mInfo = new android::InputApplicationInfo();
345 mInfo->name = "Shell";
346 mInfo->dispatchingTimeout = INT_MAX;
347 }
348
349 return true;
350 }
351 };
352
353 struct DummyApplicationWindow : public android::InputWindowHandle
354 {
355 DummyApplicationWindow(
356 const android::sp<android::InputApplicationHandle>& app_handle,
357 int x = 0,
358 int y = 0,
359 int w = 720,
360 int h = 1280)
361 : android::InputWindowHandle(app_handle),
362 x(x),
363 y(y),
364 w(w),
365 h(h)
366 {
367 }
368
369 bool updateInfo()
370 {
371 ALOGI("%s", __PRETTY_FUNCTION__);
372 if (mInfo == NULL)
373 {
374 mInfo = new android::InputWindowInfo();
375 SkRegion touchable_region;
376 touchable_region.setRect(x, y, x+w, y+h);
377
378 mInfo->name = "ShellInputWindow";
379 mInfo->layoutParamsFlags = android::InputWindowInfo::FLAG_NOT_TOUCH_MODAL | android::InputWindowInfo::FLAG_SPLIT_TOUCH;
380 mInfo->layoutParamsType = android::InputWindowInfo::TYPE_APPLICATION;
381 mInfo->touchableRegion = touchable_region;
382 mInfo->frameLeft = x;
383 mInfo->frameTop = y;
384 mInfo->frameRight = x + w;
385 mInfo->frameBottom = y + h;
386 mInfo->scaleFactor = 1.f;
387 mInfo->visible = true;
388 mInfo->canReceiveKeys = true;
389 mInfo->hasFocus = true;
390 mInfo->hasWallpaper = false;
391 mInfo->paused = false;
392 mInfo->layer = 0;
393 mInfo->dispatchingTimeout = INT_MAX;
394 mInfo->ownerPid = 0;
395 mInfo->ownerUid = 0;
396 mInfo->inputFeatures = 0;
397 mInfo->inputChannel = input_channel;
398 }
399
400 return true;
401 }
402
403 android::sp<android::InputChannel> input_channel;
404 int x;
405 int y;
406 int w;
407 int h;
408 };
409
410 InputSetup(const android::sp<InputFilter>& input_filter)
411 : looper(new android::Looper(false)),
412 looper_thread(new LooperThread(looper)),
413 event_hub(new android::EventHub()),
414 input_reader_policy(new DefaultInputReaderPolicyInterface(looper)),
415 input_dispatcher_policy(new DefaultInputDispatcherPolicy(input_filter)),
416 input_manager(new InputManager(event_hub, input_reader_policy, input_dispatcher_policy))
417 {
418 input_manager->getDispatcher()->setInputFilterEnabled(true);
419 }
420
421 void start()
422 {
423 input_manager->start();
424 looper_thread->run(__PRETTY_FUNCTION__,
425 android::PRIORITY_URGENT_DISPLAY);
426 }
427
428 void stop()
429 {
430 input_manager->stop();
431 looper_thread->requestExitAndWait();
432 }
433
434 ~InputSetup()
435 {
436 stop();
437 }
438 android::sp<android::Looper> looper;
439 android::sp<LooperThread> looper_thread;
440
441 android::sp<android::EventHubInterface> event_hub;
442 android::sp<android::InputReaderPolicyInterface> input_reader_policy;
443 android::sp<android::InputDispatcherPolicyInterface> input_dispatcher_policy;
444 android::sp<android::InputManager> input_manager;
445
446 android::Condition wait_condition;
447 android::Mutex wait_guard;
448};
449
450}
451
452#endif // DEFAULT_APPLICATION_MANAGER_INPUT_SETUP_H_
4530
=== removed file 'android/hybris/default_application_manager_test.cpp'
--- android/hybris/default_application_manager_test.cpp 2013-07-25 19:50:52 +0000
+++ android/hybris/default_application_manager_test.cpp 1970-01-01 00:00:00 +0000
@@ -1,146 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18#include "application_manager.h"
19
20#include <binder/IPCThreadState.h>
21#include <binder/IServiceManager.h>
22#include <binder/ProcessState.h>
23
24#include <sys/types.h>
25#include <sys/stat.h>
26#include <fcntl.h>
27
28namespace
29{
30struct ApplicationManagerSession : public android::BnApplicationManagerSession
31{
32 ApplicationManagerSession()
33 {
34 }
35
36 void on_application_resumed()
37 {
38 printf("%s \n", __PRETTY_FUNCTION__);
39 }
40
41 void on_application_about_to_stop()
42 {
43 printf("%s \n", __PRETTY_FUNCTION__);
44 }
45
46 void raise_application_surfaces_to_layer(int layer)
47 {
48 printf("%s \n", __PRETTY_FUNCTION__);
49 printf("%d \n", layer);
50 }
51
52 void raise_surface_to_layer(int32_t token, int layer)
53 {
54 printf("%s: %d, %d \n", __PRETTY_FUNCTION__, token, layer);
55 }
56
57 SurfaceProperties query_surface_properties_for_token(int32_t token)
58 {
59 static const int layer = 100;
60 SurfaceProperties props = { layer, 0, 0, 960, 1280 };
61 return props;
62 }
63};
64
65struct ApplicationManagerObserver : public android::BnApplicationManagerObserver
66{
67 void on_session_requested(uint32_t app)
68 {
69 printf("%s: %d \n", __PRETTY_FUNCTION__, app);
70 }
71
72 void on_session_born(int id,
73 int stage_hint,
74 const android::String8& desktop_file)
75 {
76 printf("%s: %d, %d, %s \n", __PRETTY_FUNCTION__, id, stage_hint, desktop_file.string());
77 }
78
79 void on_session_unfocused(int id,
80 int stage_hint,
81 const android::String8& desktop_file)
82 {
83 printf("%s: %d, %d, %s \n", __PRETTY_FUNCTION__, id, stage_hint, desktop_file.string());
84 }
85
86 void on_session_focused(int id,
87 int stage_hint,
88 const android::String8& desktop_file)
89 {
90 printf("%s: %d, %d, %s \n", __PRETTY_FUNCTION__, id, stage_hint, desktop_file.string());
91 }
92
93 void on_keyboard_geometry_changed(int x,
94 int y,
95 int width,
96 int height)
97 {
98 printf("%s: %d, %d, %d, %d \n", __PRETTY_FUNCTION__, x, y, width, height);
99 }
100
101 void on_session_requested_fullscreen(int id,
102 int stage_hint,
103 const android::String8& desktop_file)
104 {
105 printf("%s: %d, %s \n", __PRETTY_FUNCTION__, id, desktop_file.string());
106 }
107
108 void on_session_died(int id,
109 int stage_hint,
110 const android::String8& desktop_file)
111 {
112 printf("%s: %d, %d, %s \n", __PRETTY_FUNCTION__, id, stage_hint, desktop_file.string());
113 }
114};
115
116}
117
118int main(int argc, char** argv)
119{
120 android::ProcessState::self()->startThreadPool();
121
122 int test_fd = open("test.file", O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
123
124 android::sp<ApplicationManagerObserver> observer(new ApplicationManagerObserver());
125 android::sp<ApplicationManagerSession> session(new ApplicationManagerSession());
126 android::sp<android::IServiceManager> service_manager = android::defaultServiceManager();
127 android::sp<android::IBinder> service = service_manager->getService(
128 android::String16(android::IApplicationManager::exported_service_name()));
129 android::BpApplicationManager app_manager(service);
130
131 app_manager.register_an_observer(observer);
132
133 static const int32_t session_type = 0;
134 static const int32_t stage_hint = 0;
135
136 app_manager.start_a_new_session(
137 session_type,
138 stage_hint,
139 android::String8("default_application_manager_test"),
140 android::String8("default_application_manager_test"),
141 session,
142 test_fd,
143 0);
144
145 for(;;) {}
146}
1470
=== removed file 'android/hybris/default_application_session.h'
--- android/hybris/default_application_session.h 2013-05-22 00:38:39 +0000
+++ android/hybris/default_application_session.h 1970-01-01 00:00:00 +0000
@@ -1,250 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18#ifndef DEFAULT_APPLICATION_SESSION_H_
19#define DEFAULT_APPLICATION_SESSION_H_
20
21#include "application_manager.h"
22
23#include "private/application/ui/session_credentials.h"
24#include "private/application/ui/surface_role.h"
25#include "private/application/ui/stage_hint.h"
26
27#include <binder/IPCThreadState.h>
28#include <binder/IServiceManager.h>
29#include <binder/ProcessState.h>
30
31namespace ubuntu { namespace detail
32{
33
34struct ApplicationSession : public android::RefBase
35{
36 struct Surface : public android::RefBase
37 {
38 Surface(ApplicationSession* parent,
39 const android::sp<android::InputChannel>& input_channel,
40 int32_t surface_role,
41 int32_t token)
42 : parent(parent),
43 input_channel(input_channel),
44 role(static_cast<ubuntu::application::ui::SurfaceRole>(surface_role)),
45 token(token)
46 {
47 }
48
49 android::IApplicationManagerSession::SurfaceProperties query_properties()
50 {
51 android::IApplicationManagerSession::SurfaceProperties props =
52 parent->remote_session->query_surface_properties_for_token(token);
53
54 return props;
55 }
56
57 android::sp<android::InputWindowHandle> make_input_window_handle()
58 {
59 return android::sp<android::InputWindowHandle>(new InputWindowHandle(parent, android::sp<Surface>(this)));
60 }
61
62 ApplicationSession* parent;
63 android::sp<android::InputChannel> input_channel;
64 ubuntu::application::ui::SurfaceRole role;
65 int32_t token;
66 };
67
68 ApplicationSession(
69 pid_t pid,
70 pid_t remote_pid,
71 android::sp<android::IApplicationManagerSession> remote_session,
72 int32_t session_type,
73 int32_t stage_hint,
74 const android::String8& app_name,
75 const android::String8& desktop_file)
76 : running_state(ubuntu::application::ui::process_destroyed),
77 pid(pid),
78 remote_pid(remote_pid),
79 app_layer(0),
80 remote_session(remote_session),
81 session_type(static_cast<ubuntu::application::ui::SessionType>(session_type)),
82 stage_hint(stage_hint),
83 app_name(app_name),
84 desktop_file(desktop_file)
85 {
86 }
87
88 struct InputApplicationHandle : public android::InputApplicationHandle
89 {
90 InputApplicationHandle(ApplicationSession* parent) : parent(parent)
91 {
92 updateInfo();
93 }
94
95 bool updateInfo()
96 {
97 if (mInfo == NULL)
98 {
99 mInfo = new android::InputApplicationInfo();
100 mInfo->name = parent->app_name;
101 mInfo->dispatchingTimeout = INT_MAX;
102 }
103
104 return true;
105 }
106
107 ApplicationSession* parent;
108 };
109
110 struct InputWindowHandle : public android::InputWindowHandle
111 {
112 InputWindowHandle(ApplicationSession* parent, const android::sp<Surface>& surface)
113 : android::InputWindowHandle(
114 android::sp<InputApplicationHandle>(
115 new InputApplicationHandle(parent))),
116 parent(parent),
117 surface(surface)
118 {
119 updateInfo();
120 }
121
122 bool updateInfo()
123 {
124 if (mInfo == NULL)
125 {
126 mInfo = new android::InputWindowInfo();
127 }
128
129 android::IApplicationManagerSession::SurfaceProperties props;
130 if (parent->running_state == ubuntu::application::ui::process_suspended)
131 {
132 kill(parent->pid, SIGCONT);
133 props = surface->query_properties();
134 kill(parent->pid, SIGSTOP);
135 } else
136 props = surface->query_properties();
137
138 ALOGI("%s: touchable_region = (%d, %d, %d, %d)",
139 __PRETTY_FUNCTION__,
140 props.left,
141 props.top,
142 props.right,
143 props.bottom);
144
145 SkRegion touchable_region;
146 touchable_region.setRect(props.left, props.top, props.right+1, props.bottom+1);
147
148 mInfo->name = parent->app_name;
149 mInfo->layoutParamsFlags = android::InputWindowInfo::FLAG_NOT_TOUCH_MODAL;
150 mInfo->layoutParamsType = android::InputWindowInfo::TYPE_APPLICATION;
151 mInfo->touchableRegion = touchable_region;
152 mInfo->frameLeft = props.left;
153 mInfo->frameTop = props.top;
154 mInfo->frameRight = props.right+1;
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches