coreapplicationuis/SysAp/Src/SysApLightsController.cpp
changeset 77 b01c07dfcf84
parent 46 eea20ed08f4b
equal deleted inserted replaced
74:1505405bc645 77:b01c07dfcf84
     1 /*
     1 /*
     2 * Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    27 #ifdef RD_LIGHT_CONTROL_CHANGE
    27 #ifdef RD_LIGHT_CONTROL_CHANGE
    28 #include "sysaplightpluginhandler.h"
    28 #include "sysaplightpluginhandler.h"
    29 #endif // RD_LIGHT_CONTROL_CHANGE
    29 #endif // RD_LIGHT_CONTROL_CHANGE
    30 
    30 
    31 #include "SysApFeatureManager.h"
    31 #include "SysApFeatureManager.h"
       
    32 #include <startupdomainpskeys.h>
       
    33 #include <hwrmpowerstatesdkpskeys.h>
    32 
    34 
    33 // CONSTANTS
    35 // CONSTANTS
    34 
    36 
    35 const TInt KLightsOffPeriodLockJustActivated ( 5 ); // 5 sec
    37 const TInt KLightsOffPeriodLockJustActivated ( 5 ); // 5 sec
    36 const TInt KMaxLightsOffPeriodForScreenSaverAnimation ( 30 ); // 30 sec
    38 const TInt KMaxLightsOffPeriodForScreenSaverAnimation ( 30 ); // 30 sec
   969         return;
   971         return;
   970         }
   972         }
   971 
   973 
   972     TInt err(KErrNone);
   974     TInt err(KErrNone);
   973     
   975     
   974 #ifdef RD_LIGHT_CONTROL_CHANGE
   976     TInt state( 0 );
   975     if ( !iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandOff ) )
   977     TInt error = RProperty::Get( KPSUidStartup, KPSGlobalSystemState, state );
       
   978     
       
   979     if ( error == KErrNone && state != ESwStateCharging ) 
       
   980         {
       
   981         #ifdef RD_LIGHT_CONTROL_CHANGE
       
   982             if ( !iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandOff ) )
       
   983                 {
       
   984                 TRAP(err, iLight->LightOffL(CHWRMLight::ESystemTarget));
       
   985                 }
       
   986         #else //  RD_LIGHT_CONTROL_CHANGE
       
   987             TRAP(err, iLight->LightOffL(CHWRMLight::ESystemTarget));
       
   988         #endif // RD_LIGHT_CONTROL_CHANGE       
       
   989         }
       
   990     else
   976         {
   991         {
   977         TRAP(err, iLight->LightOffL(CHWRMLight::ESystemTarget));
   992         TRAP(err, iLight->LightOffL(CHWRMLight::ESystemTarget));
   978         }
   993         TRAP_IGNORE(iSysApAppUi.StopChargingAnimationL());
   979 #else //  RD_LIGHT_CONTROL_CHANGE
   994         }
   980     TRAP(err, iLight->LightOffL(CHWRMLight::ESystemTarget));
   995          
   981 #endif // RD_LIGHT_CONTROL_CHANGE            
       
   982     // Ignore unreserved in use warnings.
   996     // Ignore unreserved in use warnings.
   983     if ( err != KErrNone && err != KErrInUse )
   997     if ( err != KErrNone && err != KErrInUse )
   984         {
   998         {
   985         // Only trace as leaving here accomplishes nothing.
   999         // Only trace as leaving here accomplishes nothing.
   986         TRACES( RDebug::Print( _L( "CSysApLightsController::SetLightsOffL  failed: err: %d" ), err ) );
  1000         TRACES( RDebug::Print( _L( "CSysApLightsController::SetLightsOffL  failed: err: %d" ), err ) );
  1076             if ( err == KErrNone )
  1090             if ( err == KErrNone )
  1077                 {
  1091                 {
  1078                 iLightsCurrentlyOn = ETrue;
  1092                 iLightsCurrentlyOn = ETrue;
  1079                 iLastLightsOnTime.HomeTime(); 
  1093                 iLastLightsOnTime.HomeTime(); 
  1080                 }
  1094                 }
       
  1095             
       
  1096             TInt state( 0 );
       
  1097             TInt error = RProperty::Get( KPSUidStartup, KPSGlobalSystemState, state );
       
  1098             TRACES( RDebug::Print( _L( "CSysApLightsController::SetLightsOnL - KPSGlobalSystemState: %d  Error: %d"), state,error) );
       
  1099             if ( error == KErrNone && state == ESwStateCharging ) 
       
  1100                 {
       
  1101                 TInt value = iSysApAppUi.StateOfProperty( KPSUidHWRMPowerState, KHWRMChargingStatus );
       
  1102                 TRACES( RDebug::Print( _L( "CSysApLightsController::SetLightsOnL - KHWRMChargingStatus: %d"), value) );
       
  1103                 
       
  1104                 if (value == EChargingStatusChargingComplete )
       
  1105                     {
       
  1106                     TRAP_IGNORE(iSysApAppUi.StartChargingFullAnimationL());
       
  1107                     }
       
  1108                 else if((value==EChargingStatusCharging)||
       
  1109                         (value==EChargingStatusAlmostComplete)||
       
  1110                         (value==EChargingStatusChargingContinued))
       
  1111                     {
       
  1112                     TRAP_IGNORE(iSysApAppUi.StartChargingAnimationL());
       
  1113                     }
       
  1114                 }   
       
  1115             
  1081             }
  1116             }
  1082         else
  1117         else
  1083             {
  1118             {
  1084             TRACES( RDebug::Print( _L( "CSysApLightsController::SetLightsOnL - LIGHTS ON denied - Not necessary" ) ) );
  1119             TRACES( RDebug::Print( _L( "CSysApLightsController::SetLightsOnL - LIGHTS ON denied - Not necessary" ) ) );
  1085 #ifdef RD_LIGHT_CONTROL_CHANGE
  1120 #ifdef RD_LIGHT_CONTROL_CHANGE