38 m_eikonEnv(CEikonEnv::Static()), |
38 m_eikonEnv(CEikonEnv::Static()), |
39 m_carModeEnabled(false), |
39 m_carModeEnabled(false), |
40 m_hideDeviceDialogs(false), |
40 m_hideDeviceDialogs(false), |
41 m_deviceLockEnabled(false), |
41 m_deviceLockEnabled(false), |
42 m_carModeSubscriber(0), |
42 m_carModeSubscriber(0), |
43 m_carModePublisher(0) |
43 m_carModePublisher(0), |
44 { |
44 m_phoneVisible(false) |
45 PHONE_TRACE; |
45 { |
46 sendToBackground(false); // Send phone to background |
46 PHONE_TRACE |
|
47 sendToBackground(); // Send phone to background |
47 |
48 |
48 m_carModePublisher = new QValueSpacePublisher("/phone",this); |
49 m_carModePublisher = new QValueSpacePublisher("/phone",this); |
49 m_carModePublisher->setValue(QString("/carmode"),QVariant(false)); |
50 m_carModePublisher->setValue(QString("/carmode"),QVariant(false)); |
50 |
51 |
51 m_carModeSubscriber = new QValueSpaceSubscriber("/phone/carmode", this); |
52 m_carModeSubscriber = new QValueSpaceSubscriber("/phone/carmode", this); |
61 QT_TRAP_THROWING(CPhonePubSubProxy::Instance()->NotifyChangeL( |
62 QT_TRAP_THROWING(CPhonePubSubProxy::Instance()->NotifyChangeL( |
62 KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, this)); |
63 KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, this)); |
63 |
64 |
64 QT_TRAP_THROWING(CPhonePubSubProxy::Instance()->NotifyChangeL( |
65 QT_TRAP_THROWING(CPhonePubSubProxy::Instance()->NotifyChangeL( |
65 KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, this)); |
66 KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, this)); |
66 |
|
67 } |
67 } |
68 |
68 |
69 |
69 |
70 /*! |
70 /*! |
71 PhoneVisibilityHandler::~PhoneVisibilityHandler. |
71 PhoneVisibilityHandler::~PhoneVisibilityHandler. |
72 */ |
72 */ |
73 PhoneVisibilityHandler::~PhoneVisibilityHandler() |
73 PhoneVisibilityHandler::~PhoneVisibilityHandler() |
74 { |
74 { |
75 PHONE_TRACE; |
75 PHONE_TRACE |
76 CPhonePubSubProxy::Instance()->CancelAllNotifications(this); |
76 CPhonePubSubProxy::Instance()->CancelAllNotifications(this); |
77 } |
77 } |
78 |
78 |
79 /*! |
79 /*! |
80 PhoneVisibilityHandler::bringToForeground. |
80 PhoneVisibilityHandler::bringToForeground. |
81 */ |
81 */ |
82 void PhoneVisibilityHandler::bringToForeground() |
82 void PhoneVisibilityHandler::bringToForeground() |
83 { |
83 { |
84 PHONE_TRACE2("m_carModeEnabled=", m_carModeEnabled); |
84 PHONE_TRACE2("m_carModeEnabled=", m_carModeEnabled) |
85 |
85 |
86 if (!m_carModeEnabled) { |
86 if (!m_carModeEnabled) { |
87 disableKeyGuard(); |
87 disableKeyGuard(); |
88 m_view.bringToForeground(); |
88 adjustVisibility(BringForwards); // change coe priority |
89 adjustVisibility(BringForwards); |
89 m_view.bringToForeground(); // change z-order |
90 } |
90 } |
|
91 } |
|
92 |
|
93 /*! |
|
94 PhoneVisibilityHandler::bringVideoCallToForeground. |
|
95 */ |
|
96 void PhoneVisibilityHandler::bringVideoCallToForeground() |
|
97 { |
|
98 PHONE_TRACE |
|
99 TApaTaskList taskList(m_eikonEnv->WsSession()); |
|
100 const TUid KVideoTelUid = TUid::Uid(0x101F8681); |
|
101 TApaTask task = taskList.FindApp(KVideoTelUid); |
|
102 task.BringToForeground(); |
91 } |
103 } |
92 |
104 |
93 /*! |
105 /*! |
94 PhoneVisibilityHandler::hideDeviceDialogs. |
106 PhoneVisibilityHandler::hideDeviceDialogs. |
95 */ |
107 */ |
96 void PhoneVisibilityHandler::hideDeviceDialogs(bool hide) |
108 void PhoneVisibilityHandler::hideDeviceDialogs(bool hide) |
97 { |
109 { |
98 PHONE_TRACE2(": hide =", hide); |
110 PHONE_TRACE2(": hide =", hide) |
99 m_hideDeviceDialogs = hide; |
111 m_hideDeviceDialogs = hide; |
100 adjustVisibility(KeepCurrentPos); |
112 adjustVisibility(KeepCurrentPos); |
101 } |
113 } |
102 |
114 |
103 /*! |
115 /*! |
104 PhoneVisibilityHandler::phoneVisible. |
116 PhoneVisibilityHandler::phoneVisible. |
105 */ |
117 */ |
106 bool PhoneVisibilityHandler::phoneVisible() |
118 bool PhoneVisibilityHandler::phoneVisible() const |
107 { |
119 { |
108 PHONE_TRACE |
120 PHONE_TRACE |
109 // Should we check if there is phone's devicedialogs visible? |
121 return m_phoneVisible; |
110 return (m_eikonEnv->RootWin().OrdinalPosition() == 0); |
122 } |
|
123 |
|
124 /*! |
|
125 PhoneVisibilityHandler::windowVisibilityChange |
|
126 */ |
|
127 void PhoneVisibilityHandler::windowVisibilityChange(bool visible) |
|
128 { |
|
129 PHONE_TRACE2(": visible =", visible) |
|
130 m_phoneVisible = visible; |
111 } |
131 } |
112 |
132 |
113 /*! |
133 /*! |
114 PhoneVisibilityHandler::sendToBackground. |
134 PhoneVisibilityHandler::sendToBackground. |
115 */ |
135 */ |
116 void PhoneVisibilityHandler::sendToBackground(bool homeScreenForeground) |
136 void PhoneVisibilityHandler::sendToBackground() |
117 { |
137 { |
118 PHONE_TRACE4(": homeScreenForeground =", homeScreenForeground, |
138 PHONE_TRACE2(":m_carModeEnabled =", m_carModeEnabled) |
119 ", m_carModeEnabled =", m_carModeEnabled); |
|
120 |
139 |
121 if(m_carModeEnabled) { |
140 if(m_carModeEnabled) { |
122 // Don't bring homescreen to foreground |
141 // Don't bring homescreen to foreground |
123 return; |
142 return; |
124 } |
143 } |
125 |
|
126 enableKeyGuard(); |
144 enableKeyGuard(); |
127 |
|
128 bool setHsToForeground = homeScreenForeground && phoneVisible(); |
|
129 // Send phone back on WSERV stack |
145 // Send phone back on WSERV stack |
130 adjustVisibility(SendToBack); |
146 m_view.hide(); // change z-order |
131 |
147 adjustVisibility(SendToBack); // change coe priority |
132 // Fetch homescreen to foreground if needed |
|
133 if (setHsToForeground) { |
|
134 _LIT(KPhoneHsAppName,"hsapplication"); |
|
135 TApaTaskList taskList(m_eikonEnv->WsSession()); |
|
136 TApaTask task = taskList.FindApp(KPhoneHsAppName); |
|
137 task.BringToForeground(); |
|
138 } |
|
139 } |
148 } |
140 |
149 |
141 /*! |
150 /*! |
142 PhoneVisibilityHandler::HandlePropertyChangedL. |
151 PhoneVisibilityHandler::HandlePropertyChangedL. |
143 */ |
152 */ |
221 - Ongoing call, ECoeWinPriorityNormal |
228 - Ongoing call, ECoeWinPriorityNormal |
222 */ |
229 */ |
223 void PhoneVisibilityHandler::adjustVisibility(AdjustAction action) |
230 void PhoneVisibilityHandler::adjustVisibility(AdjustAction action) |
224 { |
231 { |
225 PHONE_TRACE |
232 PHONE_TRACE |
|
233 int ordinalPos = m_eikonEnv->RootWin().OrdinalPosition(); |
226 if (m_carModeEnabled || (action == SendToBack)) { |
234 if (m_carModeEnabled || (action == SendToBack)) { |
227 PHONE_TRACE1(": SendPhoneToBackground"); |
235 PHONE_TRACE1(": SendPhoneToBackground") |
228 m_eikonEnv->RootWin().SetOrdinalPosition(-1, ECoeWinPriorityNeverAtFront); |
236 m_eikonEnv->RootWin().SetOrdinalPosition(-1, ECoeWinPriorityNeverAtFront); |
229 |
|
230 } else if ((KeepCurrentPos == action) && |
237 } else if ((KeepCurrentPos == action) && |
231 (m_eikonEnv->RootWin().OrdinalPriority() == ECoeWinPriorityNeverAtFront)) { |
238 (m_eikonEnv->RootWin().OrdinalPriority() == ECoeWinPriorityNeverAtFront)) { |
232 // Skip situations where phone is put to back |
239 // Skip situations where phone is put to back |
233 // and action is not to bring it up |
240 // and action is not to bring it up |
234 // Execution must come here if there is no calls |
241 // Execution must come here if there is no calls |
235 PHONE_TRACE1(": Skip"); |
242 PHONE_TRACE1(": Skip") |
236 |
243 |
237 } else if (m_hideDeviceDialogs) { |
244 } else if (m_hideDeviceDialogs) { |
238 PHONE_TRACE1(": Hide dialogs"); |
245 PHONE_TRACE1(": Hide dialogs") |
239 m_eikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront + 100); |
246 m_eikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront + 100); |
240 |
247 |
241 } else if (m_deviceLockEnabled) { |
248 } else if (m_deviceLockEnabled) { |
242 // critical notes are allowed to show on top of Phone application |
249 // critical notes are allowed to show on top of Phone application |
243 PHONE_TRACE1(": Devicelock"); |
250 PHONE_TRACE1(": Devicelock") |
244 m_eikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront + 1); |
251 m_eikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront + 1); |
245 |
252 |
246 } else if (BringForwards == action) { |
253 } else if (BringForwards == action) { |
247 // Try to show phone with normal priority |
254 // Try to show phone with normal priority |
248 PHONE_TRACE1(": Bring forward"); |
255 PHONE_TRACE1(": Bring forward") |
249 m_eikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityNormal); |
256 m_eikonEnv->RootWin().SetOrdinalPosition(ordinalPos, ECoeWinPriorityNormal); |
250 |
|
251 } else { |
257 } else { |
252 // Normalize visiblity after ie. device lock |
258 // Normalize visiblity after ie. device lock |
253 PHONE_TRACE1(": Normalize"); |
259 PHONE_TRACE1(": Normalize") |
254 int ordinalPos = m_eikonEnv->RootWin().OrdinalPosition(); |
|
255 |
|
256 m_eikonEnv->RootWin().SetOrdinalPosition(ordinalPos, ECoeWinPriorityNormal); |
260 m_eikonEnv->RootWin().SetOrdinalPosition(ordinalPos, ECoeWinPriorityNormal); |
257 // Flush is needed here, because otherwise launching an application may fail |
261 // Flush is needed here, because otherwise launching an application may fail |
258 // if done same time with normalization. |
262 // if done same time with normalization. |
259 m_eikonEnv->WsSession().Flush(); |
263 m_eikonEnv->WsSession().Flush(); |
260 } |
264 } |
261 } |
265 } |
262 |
266 |
263 void PhoneVisibilityHandler::carModeChanged() |
267 void PhoneVisibilityHandler::carModeChanged() |
264 { |
268 { |
265 PHONE_TRACE; |
269 PHONE_TRACE |
266 m_carModeEnabled = m_carModeSubscriber->value().toBool(); |
270 m_carModeEnabled = m_carModeSubscriber->value().toBool(); |
267 |
271 |
268 if(!m_carModeEnabled && (ongoingCalls() > 0)) { |
272 if(!m_carModeEnabled && (ongoingCalls() > 0)) { |
269 bringToForeground(); |
273 bringToForeground(); |
270 } |
274 } |
271 |
|
272 // Adjust visibility according mode (TODO!) |
275 // Adjust visibility according mode (TODO!) |
273 PHONE_TRACE2(": m_carModeEnabled=", m_carModeEnabled); |
276 PHONE_TRACE2(": m_carModeEnabled=", m_carModeEnabled) |
274 //adjustVisibility(KeepCurrentPos); |
277 } |
275 } |
|