phoneapp/phoneuiqtviewadapter/src/phonevisibilityhandler.cpp
changeset 76 cfea66083b62
parent 65 2a5d4ab426d3
child 78 baacf668fe89
equal deleted inserted replaced
74:d1c62c765e48 76:cfea66083b62
    86     if (!m_carModeEnabled) {
    86     if (!m_carModeEnabled) {
    87         disableKeyGuard();
    87         disableKeyGuard();
    88         m_view.bringToForeground();
    88         m_view.bringToForeground();
    89         adjustVisibility(BringForwards);
    89         adjustVisibility(BringForwards);
    90     }
    90     }
    91     
       
    92 
       
    93 }
    91 }
    94 
    92 
    95 /*!
    93 /*!
    96     PhoneVisibilityHandler::hideDeviceDialogs.
    94     PhoneVisibilityHandler::hideDeviceDialogs.
    97  */
    95  */
   105 /*!
   103 /*!
   106     PhoneVisibilityHandler::phoneVisible.
   104     PhoneVisibilityHandler::phoneVisible.
   107  */
   105  */
   108 bool PhoneVisibilityHandler::phoneVisible()
   106 bool PhoneVisibilityHandler::phoneVisible()
   109 {
   107 {
       
   108     PHONE_TRACE
   110     // Should we check if there is phone's devicedialogs visible?
   109     // Should we check if there is phone's devicedialogs visible?
   111     return (m_eikonEnv->RootWin().OrdinalPosition() == 0);
   110     return (m_eikonEnv->RootWin().OrdinalPosition() == 0);
   112 }
   111 }
   113 
   112 
   114 /*!
   113 /*!
   115     PhoneVisibilityHandler::sendToBackground.
   114     PhoneVisibilityHandler::sendToBackground.
   116  */
   115  */
   117 void PhoneVisibilityHandler::sendToBackground(bool homeScreenForeground)
   116 void PhoneVisibilityHandler::sendToBackground(bool homeScreenForeground)
   118 {
   117 {
   119     PHONE_TRACE2(": homeScreenForeground =", homeScreenForeground);
   118     PHONE_TRACE4(": homeScreenForeground =", homeScreenForeground, 
   120     PHONE_TRACE2(": m_carModeEnabled =", m_carModeEnabled);
   119         ", m_carModeEnabled =", m_carModeEnabled);
       
   120     
   121     if(m_carModeEnabled) {
   121     if(m_carModeEnabled) {
   122         // Don't bring homescreen to foreground
   122         // Don't bring homescreen to foreground
   123         return;
   123         return;
   124     }
   124     }
   125     
   125     
   126     enableKeyGuard();
   126     enableKeyGuard();
   127     
   127     
       
   128     bool setHsToForeground = homeScreenForeground && phoneVisible();
   128     // Send phone back on WSERV stack
   129     // Send phone back on WSERV stack
   129     adjustVisibility(SendToBack);
   130     adjustVisibility(SendToBack);
   130     
   131     
   131     // Fetch homescreen to foreground if needed
   132     // Fetch homescreen to foreground if needed
   132     if (homeScreenForeground) {
   133     if (setHsToForeground) {
   133         _LIT(KPhoneHsAppName,"hsapplication");
   134         _LIT(KPhoneHsAppName,"hsapplication");
   134         TApaTaskList taskList(m_eikonEnv->WsSession());
   135         TApaTaskList taskList(m_eikonEnv->WsSession());
   135         TApaTask task = taskList.FindApp(KPhoneHsAppName);
   136         TApaTask task = taskList.FindApp(KPhoneHsAppName);
   136         task.BringToForeground();
   137         task.BringToForeground();
   137     }
   138     }
   157 /*!
   158 /*!
   158  *  PhoneVisibilityHandler::disableKeyGuard().
   159  *  PhoneVisibilityHandler::disableKeyGuard().
   159  */
   160  */
   160 bool PhoneVisibilityHandler::disableKeyGuard()
   161 bool PhoneVisibilityHandler::disableKeyGuard()
   161 {
   162 {
       
   163     PHONE_TRACE
   162     TRAP_IGNORE(
   164     TRAP_IGNORE(
   163         CKeyguardAccessApi* keyguardAccess = CKeyguardAccessApi::NewL( );
   165         CKeyguardAccessApi* keyguardAccess = CKeyguardAccessApi::NewL( );
   164         if (!m_keyguardOnBeforeForeground) {
   166         if (!m_keyguardOnBeforeForeground) {
   165             // Check if keyguard previous status only when it is not set
   167             // Check if keyguard previous status only when it is not set
   166             // Keyguard status will be restored when phone is ordered to background
   168             // Keyguard status will be restored when phone is ordered to background
   176 /*!
   178 /*!
   177  *  PhoneVisibilityHandler::enableKeyGuard().
   179  *  PhoneVisibilityHandler::enableKeyGuard().
   178  */
   180  */
   179 void PhoneVisibilityHandler::enableKeyGuard()
   181 void PhoneVisibilityHandler::enableKeyGuard()
   180 {
   182 {
       
   183     PHONE_TRACE
   181     if (phoneVisible() && m_keyguardOnBeforeForeground) {
   184     if (phoneVisible() && m_keyguardOnBeforeForeground) {
   182         // If phone is visible return to previous keyguard status
   185         // If phone is visible return to previous keyguard status
   183         TRAP_IGNORE(
   186         TRAP_IGNORE(
   184             CKeyguardAccessApi* keyguardAccess = CKeyguardAccessApi::NewL( );
   187             CKeyguardAccessApi* keyguardAccess = CKeyguardAccessApi::NewL( );
   185             keyguardAccess->EnableKeyguard( EFalse );
   188             keyguardAccess->EnableKeyguard( EFalse );
   186             delete keyguardAccess;
   189             delete keyguardAccess;
   187             );
   190             );
   188     }
   191     }
   189     
       
   190     m_keyguardOnBeforeForeground = false;
   192     m_keyguardOnBeforeForeground = false;
   191 }
   193 }
   192 
   194 
   193 /*!
   195 /*!
   194  *  PhoneVisibilityHandler::ongoingCalls().
   196  *  PhoneVisibilityHandler::ongoingCalls().
   218      - Ongoing call + security, ECoeWinPriorityAlwaysAtFront + 1
   220      - Ongoing call + security, ECoeWinPriorityAlwaysAtFront + 1
   219      - Ongoing call, ECoeWinPriorityNormal
   221      - Ongoing call, ECoeWinPriorityNormal
   220  */
   222  */
   221 void PhoneVisibilityHandler::adjustVisibility(AdjustAction action)
   223 void PhoneVisibilityHandler::adjustVisibility(AdjustAction action)
   222 {
   224 {
   223     PHONE_TRACE1(": START");
   225     PHONE_TRACE
   224     int ordinalPos = m_eikonEnv->RootWin().OrdinalPosition();
       
   225     PHONE_TRACE2(": current pos:", ordinalPos);
       
   226 
       
   227     if (m_carModeEnabled || (action == SendToBack)) {
   226     if (m_carModeEnabled || (action == SendToBack)) {
   228         PHONE_TRACE1(": SendPhoneToBackground");
   227         PHONE_TRACE1(": SendPhoneToBackground");
   229         m_eikonEnv->RootWin().SetOrdinalPosition(-1, ECoeWinPriorityNeverAtFront);
   228         m_eikonEnv->RootWin().SetOrdinalPosition(-1, ECoeWinPriorityNeverAtFront);
   230         
   229         
   231     } else if ((KeepCurrentPos == action) &&
   230     } else if ((KeepCurrentPos == action) &&
   250         m_eikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityNormal);
   249         m_eikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityNormal);
   251         
   250         
   252     } else {
   251     } else {
   253         // Normalize visiblity after ie. device lock
   252         // Normalize visiblity after ie. device lock
   254         PHONE_TRACE1(": Normalize");
   253         PHONE_TRACE1(": Normalize");
       
   254         int ordinalPos = m_eikonEnv->RootWin().OrdinalPosition();
       
   255         
   255         m_eikonEnv->RootWin().SetOrdinalPosition(ordinalPos, ECoeWinPriorityNormal);
   256         m_eikonEnv->RootWin().SetOrdinalPosition(ordinalPos, ECoeWinPriorityNormal);
   256         // Flush is needed here, because otherwise launching an application may fail
   257         // Flush is needed here, because otherwise launching an application may fail
   257         // if done same time with normalization.
   258         // if done same time with normalization.
   258         m_eikonEnv->WsSession().Flush();        
   259         m_eikonEnv->WsSession().Flush();        
   259     }
   260     }
   260 
       
   261     PHONE_TRACE1(": END");
       
   262 }
   261 }
   263 
   262 
   264 void PhoneVisibilityHandler::carModeChanged()
   263 void PhoneVisibilityHandler::carModeChanged()
   265 {
   264 {
   266     PHONE_TRACE;
   265     PHONE_TRACE;