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". |
18 |
18 |
19 // INCLUDE FILES |
19 // INCLUDE FILES |
20 #include <activitymanager.h> |
20 #include <activitymanager.h> |
21 #include "SysApLightsController.h" |
21 #include "SysApLightsController.h" |
22 #include "SysApAppUi.h" |
22 #include "SysApAppUi.h" |
23 #include "coreapplicationuisinternalpskeys.h" |
23 #include "CoreApplicationUIsInternalPSKeys.h" |
24 #include <e32svr.h> |
24 #include <e32svr.h> |
25 #include <hwrmdomainpskeys.h> |
25 #include <hwrmdomainpskeys.h> |
26 #include "SysApFeatureManager.h" |
26 #include "SysApFeatureManager.h" |
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 <hal.h> |
|
34 #include <hwrmpowerstatesdkpskeys.h> |
32 |
35 |
33 // CONSTANTS |
36 // CONSTANTS |
34 |
37 |
35 const TInt KLightsOffPeriodLockJustActivated ( 5 ); // 5 sec |
38 const TInt KLightsOffPeriodLockJustActivated ( 5 ); // 5 sec |
36 const TInt KMaxLightsOffPeriodForScreenSaverAnimation ( 30 ); // 30 sec |
39 const TInt KMaxLightsOffPeriodForScreenSaverAnimation ( 30 ); // 30 sec |
148 iLightPluginHandler->HandleEvent( SysApLightExtension::EAlarmState, TPckgBuf<TBool>(aAlarmActive) ); |
151 iLightPluginHandler->HandleEvent( SysApLightExtension::EAlarmState, TPckgBuf<TBool>(aAlarmActive) ); |
149 #endif // RD_LIGHT_CONTROL_CHANGE |
152 #endif // RD_LIGHT_CONTROL_CHANGE |
150 |
153 |
151 TBool blinkEnabled = ETrue; |
154 TBool blinkEnabled = ETrue; |
152 |
155 |
153 if( iSysApFeatureManager->Supported( KSysApFeatureIdNoFlasUiInSilentMode )) |
156 if( iSysApFeatureManager->Supported( KSysApFeatureIdNoFlasUiInSilentMode ) ) |
154 { |
157 { |
155 blinkEnabled = EFalse; |
158 blinkEnabled = EFalse; |
156 } |
159 } |
157 |
160 |
158 // Incoming call overrides alarm when lights are concerned |
161 // Incoming call overrides alarm when lights are concerned |
214 #ifdef RD_LIGHT_CONTROL_CHANGE |
217 #ifdef RD_LIGHT_CONTROL_CHANGE |
215 else |
218 else |
216 { |
219 { |
217 iLightPluginHandler->HandleEventNoAction( SysApLightExtension::EChargerConnection, TPckgBuf<TBool>(aConnected) ); |
220 iLightPluginHandler->HandleEventNoAction( SysApLightExtension::EChargerConnection, TPckgBuf<TBool>(aConnected) ); |
218 } |
221 } |
219 #endif // RD_LIGHT_CONTROL_CHANGE |
222 #endif // RD_LIGHT_CONTROL_CHANGE |
|
223 TInt state( 0 ); |
|
224 TInt error = RProperty::Get( KPSUidStartup, KPSGlobalSystemState, state ); |
|
225 if ( error == KErrNone && state == ESwStateCharging ) |
|
226 { |
|
227 EnableActivityManagerL(); |
|
228 } |
220 } |
229 } |
221 |
230 |
222 // ---------------------------------------------------------------------------- |
231 // ---------------------------------------------------------------------------- |
223 // CSysApLightsController::ChargingCompleteL() |
232 // CSysApLightsController::ChargingCompleteL() |
224 // ---------------------------------------------------------------------------- |
233 // ---------------------------------------------------------------------------- |
967 iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandNoAction ); |
976 iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandNoAction ); |
968 #endif // RD_LIGHT_CONTROL_CHANGE |
977 #endif // RD_LIGHT_CONTROL_CHANGE |
969 return; |
978 return; |
970 } |
979 } |
971 |
980 |
972 TInt err(KErrNone); |
981 TInt err(KErrNone); |
973 |
982 TInt state( 0 ); |
974 #ifdef RD_LIGHT_CONTROL_CHANGE |
983 TInt error = RProperty::Get( KPSUidStartup, KPSGlobalSystemState, state ); |
975 if ( !iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandOff ) ) |
984 |
976 { |
985 if ( error == KErrNone && state != ESwStateCharging ) |
977 TRAP(err, iLight->LightOffL(CHWRMLight::ESystemTarget)); |
986 { |
978 } |
987 #ifdef RD_LIGHT_CONTROL_CHANGE |
|
988 if ( !iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandOff ) ) |
|
989 { |
|
990 TRAP(err, iLight->LightOffL(CHWRMLight::ESystemTarget)); |
|
991 } |
979 #else // RD_LIGHT_CONTROL_CHANGE |
992 #else // RD_LIGHT_CONTROL_CHANGE |
980 TRAP(err, iLight->LightOffL(CHWRMLight::ESystemTarget)); |
993 TRAP(err, iLight->LightOffL(CHWRMLight::ESystemTarget)); |
981 #endif // RD_LIGHT_CONTROL_CHANGE |
994 #endif // RD_LIGHT_CONTROL_CHANGE |
|
995 } |
|
996 else |
|
997 { |
|
998 TRAP(err, iLight->LightOffL(CHWRMLight::ESystemTarget)); |
|
999 iSysApAppUi.StopChargingBatteryL(); |
|
1000 //To switch off the display |
|
1001 TInt result = HAL::Set( HALData::EDisplayState, 0 ); |
|
1002 } |
982 // Ignore unreserved in use warnings. |
1003 // Ignore unreserved in use warnings. |
983 if ( err != KErrNone && err != KErrInUse ) |
1004 if ( err != KErrNone && err != KErrInUse ) |
984 { |
1005 { |
985 // Only trace as leaving here accomplishes nothing. |
1006 // Only trace as leaving here accomplishes nothing. |
986 TRACES( RDebug::Print( _L( "CSysApLightsController::SetLightsOffL failed: err: %d" ), err ) ); |
1007 TRACES( RDebug::Print( _L( "CSysApLightsController::SetLightsOffL failed: err: %d" ), err ) ); |
1076 if ( err == KErrNone ) |
1097 if ( err == KErrNone ) |
1077 { |
1098 { |
1078 iLightsCurrentlyOn = ETrue; |
1099 iLightsCurrentlyOn = ETrue; |
1079 iLastLightsOnTime.HomeTime(); |
1100 iLastLightsOnTime.HomeTime(); |
1080 } |
1101 } |
|
1102 |
|
1103 TInt state( 0 ); |
|
1104 TInt error = RProperty::Get( KPSUidStartup, KPSGlobalSystemState, state ); |
|
1105 if ( error == KErrNone && state == ESwStateCharging ) |
|
1106 { |
|
1107 TInt value = iSysApAppUi.StateOfProperty( KPSUidHWRMPowerState, KHWRMChargingStatus ); |
|
1108 if (value == EChargingStatusChargingComplete ) |
|
1109 { |
|
1110 iSysApAppUi.StopChargingBatteryL(); |
|
1111 } |
|
1112 else |
|
1113 { |
|
1114 iSysApAppUi.StartChargingBatteryL(); |
|
1115 //To switch on the display |
|
1116 TInt result = HAL::Set( HALData::EDisplayState, 1 ); |
|
1117 } |
|
1118 } |
1081 } |
1119 } |
1082 else |
1120 else |
1083 { |
1121 { |
1084 TRACES( RDebug::Print( _L( "CSysApLightsController::SetLightsOnL - LIGHTS ON denied - Not necessary" ) ) ); |
1122 TRACES( RDebug::Print( _L( "CSysApLightsController::SetLightsOnL - LIGHTS ON denied - Not necessary" ) ) ); |
1085 #ifdef RD_LIGHT_CONTROL_CHANGE |
1123 #ifdef RD_LIGHT_CONTROL_CHANGE |