28
|
1 |
/*
|
58
|
2 |
* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
|
28
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <QObject>
|
|
19 |
|
|
20 |
#ifdef Q_OS_SYMBIAN
|
|
21 |
#include <e32cmn.h>
|
|
22 |
#include <w32std.h>
|
|
23 |
#include <apgwgnam.h>
|
|
24 |
#include <apgtask.h>
|
|
25 |
#include <eikenv.h>
|
|
26 |
#include <avkondomainpskeys.h> // keyguard state
|
|
27 |
#include <hwrmpowerstatesdkpskeys.h> // battery status
|
40
|
28 |
#include <UsbWatcherInternalPSKeys.h> // usb status
|
|
29 |
#include <usbman.h>
|
|
30 |
#include <usbpersonalityids.h>
|
58
|
31 |
#include <tspropertydefs.h>
|
28
|
32 |
|
|
33 |
#include <QMetaEnum>
|
|
34 |
#include <QString>
|
|
35 |
#include <QVariant>
|
52
|
36 |
#include <QTimer>
|
28
|
37 |
#include <qsymbianevent.h>
|
40
|
38 |
|
28
|
39 |
#endif // Q_OS_SYMBIAN
|
|
40 |
|
|
41 |
#include "cxutils.h"
|
40
|
42 |
#include "cxuieventlog.h"
|
28
|
43 |
#include "cxuiapplication.h"
|
|
44 |
#include "cxesettings.h"
|
|
45 |
#include "cxuiapplicationframeworkmonitorprivate.h"
|
|
46 |
|
58
|
47 |
namespace
|
|
48 |
{
|
52
|
49 |
const int CXUI_USB_MODE_CHECK_TIMER_DELAY = 1000; // 1 second
|
28
|
50 |
|
|
51 |
#ifdef Q_OS_SYMBIAN
|
|
52 |
inline QString convertTDesC2QString(const TDesC& aDescriptor)
|
|
53 |
{
|
|
54 |
#ifdef QT_NO_UNICODE
|
|
55 |
return QString::fromLocal8Bit(aDescriptor.Ptr(), aDescriptor.Length());
|
|
56 |
#else
|
|
57 |
return QString::fromUtf16(aDescriptor.Ptr(), aDescriptor.Length());
|
|
58 |
#endif
|
|
59 |
}
|
|
60 |
|
|
61 |
inline QString windowGroupName(RWsSession& ws, int id)
|
|
62 |
{
|
|
63 |
TBuf<CApaWindowGroupName::EMaxLength> name;
|
|
64 |
ws.GetWindowGroupNameFromIdentifier(id, name);
|
|
65 |
// Window group name contains "null" characters,
|
|
66 |
// which are considered end-of-string if not replaced.
|
|
67 |
for (int i=0; i < name.Length(); i++) {
|
|
68 |
if (name[i] == NULL) {
|
|
69 |
name[i] = ' ';
|
|
70 |
}
|
|
71 |
}
|
|
72 |
return convertTDesC2QString(name);
|
|
73 |
}
|
|
74 |
|
|
75 |
// Phone ui
|
|
76 |
static const unsigned int UID_PHONEUI = 0x100058B3;
|
|
77 |
// Task switcher
|
|
78 |
static const unsigned int UID_TASKSWITCHER = 0x2002677D;
|
|
79 |
// Dialog server
|
|
80 |
static const unsigned int UID_DIALOGAPPSERVER = 0x20022FC5;
|
40
|
81 |
|
|
82 |
// Log event types
|
|
83 |
static const char *EVENT_USB = "usb";
|
|
84 |
static const char *EVENT_FOREGROUND = "foreground";
|
58
|
85 |
|
28
|
86 |
#endif // Q_OS_SYMBIAN
|
58
|
87 |
} // namespace
|
28
|
88 |
|
|
89 |
|
|
90 |
/*!
|
|
91 |
* Constructor
|
|
92 |
*/
|
40
|
93 |
CxuiApplicationFrameworkMonitorPrivate::CxuiApplicationFrameworkMonitorPrivate(CxuiApplicationFrameworkMonitor *parent,
|
|
94 |
CxuiApplication &application,
|
|
95 |
CxeSettings& settings)
|
|
96 |
: q(parent),
|
|
97 |
mApplication(application),
|
28
|
98 |
mSettings(settings),
|
|
99 |
#ifdef Q_OS_SYMBIAN
|
|
100 |
mWsSession(CCoeEnv::Static()->WsSession()),
|
|
101 |
mWindowGroup(CCoeEnv::Static()->RootWin()),
|
|
102 |
mWindowGroupId(mWindowGroup.Identifier()),
|
|
103 |
mWindowGroupName(),
|
|
104 |
mKeyLockState(EKeyguardNotActive),
|
|
105 |
mBatteryStatus(EBatteryStatusUnknown),
|
40
|
106 |
mUsbPersonality(0),
|
58
|
107 |
mTaskManagerVisibility(false),
|
52
|
108 |
mUsbModeCheckTimer(this),
|
40
|
109 |
mEventLog(NULL),
|
28
|
110 |
#endif // Q_OS_SYMBIAN
|
|
111 |
mState(CxuiApplicationFrameworkMonitor::ForegroundOwned)
|
|
112 |
{
|
|
113 |
CX_DEBUG_ENTER_FUNCTION();
|
|
114 |
#ifdef Q_OS_SYMBIAN
|
|
115 |
mWindowGroup.EnableFocusChangeEvents();
|
|
116 |
mWindowGroupName = windowGroupName(mWsSession, mWindowGroupId);
|
40
|
117 |
mEventLog = new CxuiEventLog("CxuiApplicationFrameworkMonitorPrivate");
|
58
|
118 |
|
28
|
119 |
init();
|
58
|
120 |
|
52
|
121 |
mUsbModeCheckTimer.setSingleShot(true);
|
|
122 |
mUsbModeCheckTimer.setInterval(CXUI_USB_MODE_CHECK_TIMER_DELAY);
|
|
123 |
connect(&mUsbModeCheckTimer, SIGNAL(timeout()),
|
|
124 |
this, SLOT(usbModeCheckTimerCallback()));
|
28
|
125 |
#endif // Q_OS_SYMBIAN
|
|
126 |
CX_DEBUG_EXIT_FUNCTION();
|
|
127 |
}
|
|
128 |
|
|
129 |
/*!
|
|
130 |
* Destructor
|
|
131 |
*/
|
|
132 |
CxuiApplicationFrameworkMonitorPrivate::~CxuiApplicationFrameworkMonitorPrivate()
|
|
133 |
{
|
40
|
134 |
CX_DEBUG_ENTER_FUNCTION();
|
|
135 |
#ifdef Q_OS_SYMBIAN
|
|
136 |
delete mEventLog;
|
|
137 |
#endif // Q_OS_SYMBIAN
|
|
138 |
CX_DEBUG_EXIT_FUNCTION();
|
28
|
139 |
}
|
|
140 |
|
|
141 |
/*!
|
|
142 |
* Current foreground owning state of this application.
|
|
143 |
* @return Foreground owning state.
|
|
144 |
*/
|
|
145 |
CxuiApplicationFrameworkMonitor::ForegroundState CxuiApplicationFrameworkMonitorPrivate::foregroundState() const
|
|
146 |
{
|
|
147 |
return mState;
|
|
148 |
}
|
|
149 |
|
40
|
150 |
/*!
|
|
151 |
* Is USB connected in mass memory mode?
|
|
152 |
* @return True if USB mass memory mode is active and connected, false otherwise.
|
|
153 |
*/
|
|
154 |
bool CxuiApplicationFrameworkMonitorPrivate::isUsbMassMemoryModeActive() const
|
|
155 |
{
|
|
156 |
bool active(false);
|
|
157 |
#ifdef Q_OS_SYMBIAN
|
|
158 |
// Mass memory mode activity can be seen from the KUsbWatcherSelectedPersonality property.
|
|
159 |
// When USB is connected in Mass Memory Mode, we get KUsbPersonalityIdMS as personality id.
|
|
160 |
// If USB is not connected, personality id is KUsbWatcherSelectedPersonalityNone.
|
|
161 |
active = (mUsbPersonality == KUsbPersonalityIdMS);
|
|
162 |
#endif // Q_OS_SYMBIAN
|
|
163 |
return active;
|
|
164 |
}
|
|
165 |
|
|
166 |
|
|
167 |
|
28
|
168 |
#ifdef Q_OS_SYMBIAN
|
|
169 |
/*!
|
|
170 |
* Slot to handle Symbian event.
|
|
171 |
* @param event Symbian event to be handled. (Ownership not taken.)
|
|
172 |
*/
|
|
173 |
void CxuiApplicationFrameworkMonitorPrivate::handleEvent(const QSymbianEvent *event)
|
|
174 |
{
|
|
175 |
// We receive tons of these events, so function start and end traces
|
|
176 |
// are intentionally left out.
|
|
177 |
|
|
178 |
if (event) {
|
|
179 |
switch (event->type()) {
|
|
180 |
case QSymbianEvent::WindowServerEvent:
|
|
181 |
handleWindowServerEvent(event);
|
|
182 |
break;
|
|
183 |
}
|
|
184 |
}
|
|
185 |
}
|
|
186 |
|
|
187 |
/*!
|
|
188 |
* Handle changes in RProperty values of keylock state and battery status.
|
|
189 |
* @param uid Category uid of the changed property.
|
|
190 |
* @param key Integer key of the changed property.
|
|
191 |
* @param value New value of the changed property.
|
|
192 |
*/
|
|
193 |
void CxuiApplicationFrameworkMonitorPrivate::handlePropertyEvent(long int uid, unsigned long int key, QVariant value)
|
|
194 |
{
|
|
195 |
CX_DEBUG_ENTER_FUNCTION();
|
|
196 |
|
|
197 |
if (uid == KPSUidAvkonDomain.iUid && key == KAknKeyguardStatus) {
|
40
|
198 |
CX_DEBUG(("CxuiApplicationFrameworkMonitor - keylock status changed: %d -> %d", mKeyLockState, value.toInt()));
|
28
|
199 |
|
|
200 |
// Check if the keylock value has actually changed
|
|
201 |
const int newKeyLockState = value.toInt();
|
|
202 |
if (newKeyLockState != mKeyLockState) {
|
|
203 |
mKeyLockState = newKeyLockState;
|
|
204 |
// Set foreground state based on keylock status and focused application info.
|
|
205 |
setState(getCurrentState());
|
|
206 |
}
|
|
207 |
} else if (uid == KPSUidHWRMPowerState.iUid && key == KHWRMBatteryStatus ) {
|
40
|
208 |
CX_DEBUG(("CxuiApplicationFrameworkMonitor - battery status changed: %d -> %d", mBatteryStatus, value.toInt() ));
|
28
|
209 |
|
|
210 |
// If status changed, check if battery is going empty.
|
|
211 |
const int newBatteryStatus = value.toInt();
|
|
212 |
if (newBatteryStatus != mBatteryStatus) {
|
|
213 |
mBatteryStatus = newBatteryStatus;
|
|
214 |
|
|
215 |
// Notify that battery is almost empty,
|
|
216 |
// need to stop any recordings etc.
|
40
|
217 |
if(mBatteryStatus == EBatteryStatusEmpty) {
|
|
218 |
emit q->batteryEmpty();
|
|
219 |
}
|
|
220 |
}
|
|
221 |
} else if (uid == KPSUidUsbWatcher.iUid && key == KUsbWatcherSelectedPersonality) {
|
|
222 |
CX_DEBUG(("CxuiApplicationFrameworkMonitor - usb personality changed: %d -> %d", mUsbPersonality, value.toInt()));
|
|
223 |
|
|
224 |
const int newUsbPersonality(value.toInt());
|
|
225 |
if (newUsbPersonality != mUsbPersonality) {
|
|
226 |
// Check before saving the new state if mass memory mode was active,
|
|
227 |
// so we know when to emit the unactivated signal.
|
|
228 |
const bool wasUsbMassMemoryModeActive(isUsbMassMemoryModeActive());
|
|
229 |
// Store new state.
|
|
230 |
mUsbPersonality = newUsbPersonality;
|
|
231 |
|
|
232 |
// Save state to log.
|
|
233 |
if (mEventLog) {
|
|
234 |
mEventLog->append(EVENT_USB, QString::number(mUsbPersonality));
|
|
235 |
}
|
|
236 |
|
|
237 |
// Check if mass memory mode activity changed.
|
|
238 |
if (wasUsbMassMemoryModeActive != isUsbMassMemoryModeActive()) {
|
52
|
239 |
|
|
240 |
// If the massmemory mode switched from on to off,
|
|
241 |
// the signal is emitted immediately.
|
|
242 |
// If the switch is from off to on, we need to use a timer
|
|
243 |
// as a workaround because plugging in the USB charger
|
|
244 |
// sends a mass memory mode change event.
|
|
245 |
if (wasUsbMassMemoryModeActive) {
|
|
246 |
emit q->usbMassMemoryModeToggled(isUsbMassMemoryModeActive());
|
|
247 |
} else {
|
|
248 |
// (Re)starting the timer
|
|
249 |
mUsbModeCheckTimer.stop();
|
|
250 |
mUsbModeCheckTimer.start();
|
|
251 |
}
|
|
252 |
|
28
|
253 |
}
|
|
254 |
}
|
58
|
255 |
} else if (uid == TsProperty::KCategory.iUid && key == TsProperty::KVisibilityKey) {
|
|
256 |
CX_DEBUG(("CxuiApplicationFrameworkMonitor - Task Manager visibility: %d -> %d", mTaskManagerVisibility, value.toBool()));
|
|
257 |
const bool newTsVisibility(value.toBool());
|
|
258 |
|
|
259 |
// If the task switcher state is changed, then emit signal to inform client(s).
|
|
260 |
if (mTaskManagerVisibility != newTsVisibility) {
|
|
261 |
mTaskManagerVisibility = newTsVisibility;
|
|
262 |
emit q->taskSwitcherStateChanged(mTaskManagerVisibility);
|
|
263 |
}
|
28
|
264 |
}
|
|
265 |
|
|
266 |
CX_DEBUG_EXIT_FUNCTION();
|
|
267 |
}
|
|
268 |
|
|
269 |
/*!
|
52
|
270 |
* Callback function for the timer used to seperate USB charging
|
|
271 |
* from USB mass memory mode
|
|
272 |
*/
|
|
273 |
void CxuiApplicationFrameworkMonitorPrivate::usbModeCheckTimerCallback()
|
|
274 |
{
|
|
275 |
CX_DEBUG_ENTER_FUNCTION();
|
|
276 |
|
|
277 |
// if the device is still in mass memory mode after the timer has finished,
|
|
278 |
// the device really is in massmemory mode and not plugged into the charger
|
|
279 |
if (isUsbMassMemoryModeActive()){
|
|
280 |
emit q->usbMassMemoryModeToggled(isUsbMassMemoryModeActive());
|
|
281 |
}
|
|
282 |
|
|
283 |
CX_DEBUG_EXIT_FUNCTION();
|
|
284 |
}
|
|
285 |
|
|
286 |
/*!
|
28
|
287 |
* Set initial values.
|
|
288 |
*/
|
|
289 |
void CxuiApplicationFrameworkMonitorPrivate::init()
|
|
290 |
{
|
|
291 |
CX_DEBUG_ENTER_FUNCTION();
|
|
292 |
|
58
|
293 |
// To be able to release resources fast enough, we need foreground
|
|
294 |
// priority also when moving to background. Once we have moved to
|
|
295 |
// background fully, we re-adjust Window Server "compute mode"
|
|
296 |
// to the normal value.
|
|
297 |
mWsSession.ComputeMode(RWsSession::EPriorityControlDisabled);
|
|
298 |
|
28
|
299 |
// Connect to application (window server) events.
|
|
300 |
connect(&mApplication, SIGNAL(symbianEvent(const QSymbianEvent *)), this, SLOT(handleEvent(const QSymbianEvent *)));
|
|
301 |
|
|
302 |
QVariant value;
|
|
303 |
|
|
304 |
// Get initial battery status.
|
|
305 |
mSettings.get(KPSUidHWRMPowerState.iUid, KHWRMBatteryStatus, Cxe::PublishAndSubscribe, value);
|
|
306 |
mBatteryStatus = value.toInt();
|
|
307 |
|
|
308 |
// Get initial keylock status.
|
|
309 |
mSettings.get(KPSUidAvkonDomain.iUid, KAknKeyguardStatus, Cxe::PublishAndSubscribe, value);
|
|
310 |
mKeyLockState = value.toInt();
|
|
311 |
|
40
|
312 |
// Get current USB personality
|
|
313 |
mSettings.get(KPSUidUsbWatcher.iUid, KUsbWatcherSelectedPersonality, Cxe::PublishAndSubscribe, value);
|
|
314 |
mUsbPersonality = value.toInt();
|
|
315 |
|
58
|
316 |
// Get current Task Switcher foreground status
|
|
317 |
mSettings.get(TsProperty::KCategory.iUid, TsProperty::KVisibilityKey, Cxe::PublishAndSubscribe, value);
|
|
318 |
mTaskManagerVisibility = value.toBool();
|
|
319 |
|
28
|
320 |
bool ok = connect(&mSettings, SIGNAL(settingValueChanged(long int, unsigned long int, QVariant)),
|
|
321 |
this, SLOT(handlePropertyEvent(long int, unsigned long int, QVariant)));
|
|
322 |
CX_DEBUG_ASSERT(ok);
|
|
323 |
|
|
324 |
// Get foreground state. Depends on keyguard status, so that needs to be read first.
|
|
325 |
mState = getCurrentState();
|
|
326 |
|
|
327 |
CX_DEBUG_EXIT_FUNCTION();
|
|
328 |
}
|
|
329 |
|
|
330 |
/*!
|
|
331 |
* Helper method to handle Symbian event that specificly is of type QSymbianEvent::WindowServerEvent.
|
|
332 |
* @param event Symbian event to be handled. (Ownership not taken.)
|
|
333 |
*/
|
40
|
334 |
void CxuiApplicationFrameworkMonitorPrivate::handleWindowServerEvent(const QSymbianEvent *event)
|
28
|
335 |
{
|
|
336 |
// We receive tons of these events, so function start and end traces
|
|
337 |
// are intentionally left out.
|
|
338 |
|
|
339 |
const TWsEvent *wsEvent = event->windowServerEvent();
|
|
340 |
if (wsEvent) {
|
|
341 |
switch (wsEvent->Type()) {
|
|
342 |
case EEventFocusGroupChanged: {
|
|
343 |
CX_DEBUG(("CxuiApplicationFrameworkMonitor - EEventFocusGroupChanged event"));
|
|
344 |
setState(getCurrentState());
|
|
345 |
break;
|
|
346 |
}
|
|
347 |
case EEventFocusGained: {
|
|
348 |
CX_DEBUG(("CxuiApplicationFrameworkMonitor - EEventFocusGained event"));
|
|
349 |
setState(getCurrentState());
|
|
350 |
break;
|
|
351 |
}
|
|
352 |
case EEventFocusLost: {
|
|
353 |
CX_DEBUG(("CxuiApplicationFrameworkMonitor - EEventFocusLost event"));
|
|
354 |
setState(getCurrentState());
|
|
355 |
break;
|
|
356 |
}
|
|
357 |
default:
|
|
358 |
break;
|
|
359 |
}
|
|
360 |
}
|
|
361 |
}
|
|
362 |
|
|
363 |
/*!
|
|
364 |
* Set state and emit signal if state really changes.
|
|
365 |
* @param state New state.
|
|
366 |
*/
|
|
367 |
void CxuiApplicationFrameworkMonitorPrivate::setState(CxuiApplicationFrameworkMonitor::ForegroundState state)
|
|
368 |
{
|
|
369 |
if (mState != state) {
|
|
370 |
const CxuiApplicationFrameworkMonitor::ForegroundState original(mState);
|
|
371 |
// Check if state transition is acceptable in current state.
|
|
372 |
switch (mState) {
|
|
373 |
case CxuiApplicationFrameworkMonitor::ForegroundOwned:
|
|
374 |
case CxuiApplicationFrameworkMonitor::ForegroundPartiallyLost:
|
|
375 |
// All changes accepted.
|
|
376 |
mState = state;
|
|
377 |
break;
|
|
378 |
case CxuiApplicationFrameworkMonitor::ForegroundFullyLost:
|
|
379 |
// If foreground application is changed to note when we are already
|
|
380 |
// fully in background, cannot accept state change to "partial foreground".
|
|
381 |
if (state != CxuiApplicationFrameworkMonitor::ForegroundPartiallyLost) {
|
|
382 |
mState = state;
|
|
383 |
} else {
|
|
384 |
CX_DEBUG(("CxuiApplicationFrameworkMonitor - state change full bg -> partial bg ignored"));
|
|
385 |
}
|
|
386 |
}
|
|
387 |
|
|
388 |
if (mState != original) {
|
58
|
389 |
if (mState == CxuiApplicationFrameworkMonitor::ForegroundOwned) {
|
|
390 |
// Keep foreground priority until fully in background.
|
|
391 |
// See init() for more comments.
|
|
392 |
mWsSession.ComputeMode(RWsSession::EPriorityControlDisabled);
|
|
393 |
}
|
|
394 |
|
|
395 |
// If state was changed, signal it to listeners.
|
|
396 |
emit q->foregroundStateChanged(mState);
|
|
397 |
|
|
398 |
if (mState == CxuiApplicationFrameworkMonitor::ForegroundFullyLost) {
|
|
399 |
// Background has been entered.
|
|
400 |
// Return Window Server "compute mode" to the normal value.
|
|
401 |
mWsSession.ComputeMode(RWsSession::EPriorityControlComputeOff);
|
|
402 |
}
|
|
403 |
|
|
404 |
#ifdef CX_DEBUG
|
40
|
405 |
// Print the event log with this foreground event included.
|
|
406 |
if (mEventLog) {
|
|
407 |
mEventLog->append(
|
|
408 |
EVENT_FOREGROUND,
|
|
409 |
CxuiApplicationFrameworkMonitor::staticMetaObject.enumerator(
|
|
410 |
CxuiApplicationFrameworkMonitor::staticMetaObject.indexOfEnumerator("ForegroundState")).valueToKey(mState));
|
|
411 |
mEventLog->print();
|
|
412 |
}
|
58
|
413 |
#endif // CX_DEBUG
|
28
|
414 |
}
|
|
415 |
}
|
|
416 |
}
|
|
417 |
|
|
418 |
/*!
|
|
419 |
* Get the current foreground state.
|
|
420 |
* @return Current state for foreground ownership.
|
|
421 |
*/
|
|
422 |
CxuiApplicationFrameworkMonitor::ForegroundState CxuiApplicationFrameworkMonitorPrivate::getCurrentState()
|
|
423 |
{
|
|
424 |
CX_DEBUG_ENTER_FUNCTION();
|
|
425 |
|
|
426 |
CxuiApplicationFrameworkMonitor::ForegroundState state(CxuiApplicationFrameworkMonitor::ForegroundOwned);
|
|
427 |
int focusWindowGroupId(mWsSession.GetFocusWindowGroup());
|
|
428 |
|
|
429 |
if (mKeyLockState != EKeyguardNotActive) {
|
|
430 |
// Keylock enabled is the same as if other application is in foreground.
|
40
|
431 |
CX_DEBUG(("CxuiApplicationFrameworkMonitor - key lock on"));
|
28
|
432 |
state = CxuiApplicationFrameworkMonitor::ForegroundFullyLost;
|
|
433 |
} else if (focusWindowGroupId == mWindowGroupId) {
|
|
434 |
// If our window group has focus, we clearly are the foreground owning application.
|
|
435 |
CX_DEBUG(("CxuiApplicationFrameworkMonitor - Foreground window group matches ours."));
|
|
436 |
state = CxuiApplicationFrameworkMonitor::ForegroundOwned;
|
|
437 |
|
|
438 |
} else {
|
|
439 |
// Need to check if foreground is owned by known apps.
|
|
440 |
unsigned int uid(focusedApplicationUid());
|
|
441 |
|
|
442 |
// Check the app uid.
|
|
443 |
switch (uid) {
|
|
444 |
case UID_TASKSWITCHER:
|
|
445 |
case UID_DIALOGAPPSERVER:
|
|
446 |
// Note or task switcher in foreground.
|
|
447 |
state = CxuiApplicationFrameworkMonitor::ForegroundPartiallyLost;
|
|
448 |
break;
|
|
449 |
case UID_PHONEUI:
|
|
450 |
default:
|
|
451 |
// Foreground owned by other app.
|
|
452 |
state = CxuiApplicationFrameworkMonitor::ForegroundFullyLost;
|
|
453 |
break;
|
|
454 |
}
|
|
455 |
}
|
|
456 |
|
|
457 |
CX_DEBUG_EXIT_FUNCTION();
|
|
458 |
return state;
|
|
459 |
}
|
|
460 |
|
|
461 |
/*!
|
|
462 |
* Get the uid of application in foreground.
|
|
463 |
* @return Application uid for the foreground application.
|
|
464 |
*/
|
|
465 |
unsigned int CxuiApplicationFrameworkMonitorPrivate::focusedApplicationUid()
|
|
466 |
{
|
|
467 |
unsigned int uid(0);
|
|
468 |
int focusWgId(mWsSession.GetFocusWindowGroup());
|
|
469 |
|
|
470 |
TRAP_IGNORE({
|
|
471 |
CApaWindowGroupName* wgn = CApaWindowGroupName::NewLC(mWsSession, focusWgId);
|
|
472 |
uid = wgn->AppUid().iUid;
|
|
473 |
CleanupStack::PopAndDestroy(wgn);
|
|
474 |
});
|
|
475 |
|
|
476 |
// If the window group identifier does not have the application uid set,
|
|
477 |
// get it via thread secure id.
|
|
478 |
if (uid == 0) {
|
|
479 |
TApaTask task(mWsSession);
|
|
480 |
task.SetWgId(focusWgId);
|
|
481 |
|
|
482 |
RThread t;
|
|
483 |
int err = t.Open(task.ThreadId());
|
|
484 |
if (err == KErrNone) {
|
|
485 |
uid = t.SecureId().iId;
|
|
486 |
CX_DEBUG(("CxuiApplicationFrameworkMonitor - uid resolved from thread"));
|
|
487 |
}
|
|
488 |
t.Close();
|
|
489 |
}
|
|
490 |
|
|
491 |
#ifdef CX_DEBUG
|
|
492 |
QString name(windowGroupName(mWsSession, focusWgId));
|
|
493 |
CX_DEBUG(("CxuiApplicationFrameworkMonitor - Own window group id: 0x%08x", mWindowGroupId));
|
|
494 |
CX_DEBUG(("CxuiApplicationFrameworkMonitor - Focused window group id: 0x%08x", focusWgId));
|
|
495 |
CX_DEBUG(("CxuiApplicationFrameworkMonitor - Own window group name: [%s]", mWindowGroupName.toAscii().constData()));
|
|
496 |
CX_DEBUG(("CxuiApplicationFrameworkMonitor - Focused window group name: [%s]", name.toAscii().constData()));
|
|
497 |
CX_DEBUG(("CxuiApplicationFrameworkMonitor - Focused application uid: 0x%08x", uid));
|
|
498 |
#endif
|
|
499 |
|
|
500 |
return uid;
|
|
501 |
}
|
|
502 |
|
|
503 |
#endif // Q_OS_SYMBIAN
|
|
504 |
|
|
505 |
// end of file
|