1 /* |
1 /* |
2 * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2005-2008 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> |
|
35 |
32 |
36 // CONSTANTS |
33 // CONSTANTS |
37 |
34 |
38 const TInt KLightsOffPeriodLockJustActivated ( 5 ); // 5 sec |
35 const TInt KLightsOffPeriodLockJustActivated ( 5 ); // 5 sec |
39 const TInt KMaxLightsOffPeriodForScreenSaverAnimation ( 30 ); // 30 sec |
36 const TInt KMaxLightsOffPeriodForScreenSaverAnimation ( 30 ); // 30 sec |
151 iLightPluginHandler->HandleEvent( SysApLightExtension::EAlarmState, TPckgBuf<TBool>(aAlarmActive) ); |
148 iLightPluginHandler->HandleEvent( SysApLightExtension::EAlarmState, TPckgBuf<TBool>(aAlarmActive) ); |
152 #endif // RD_LIGHT_CONTROL_CHANGE |
149 #endif // RD_LIGHT_CONTROL_CHANGE |
153 |
150 |
154 TBool blinkEnabled = ETrue; |
151 TBool blinkEnabled = ETrue; |
155 |
152 |
156 if( iSysApFeatureManager->Supported( KSysApFeatureIdNoFlasUiInSilentMode ) ) |
153 if( iSysApFeatureManager->Supported( KSysApFeatureIdNoFlasUiInSilentMode )) |
157 { |
154 { |
158 blinkEnabled = EFalse; |
155 blinkEnabled = EFalse; |
159 } |
156 } |
160 |
157 |
161 // Incoming call overrides alarm when lights are concerned |
158 // Incoming call overrides alarm when lights are concerned |
217 #ifdef RD_LIGHT_CONTROL_CHANGE |
214 #ifdef RD_LIGHT_CONTROL_CHANGE |
218 else |
215 else |
219 { |
216 { |
220 iLightPluginHandler->HandleEventNoAction( SysApLightExtension::EChargerConnection, TPckgBuf<TBool>(aConnected) ); |
217 iLightPluginHandler->HandleEventNoAction( SysApLightExtension::EChargerConnection, TPckgBuf<TBool>(aConnected) ); |
221 } |
218 } |
222 #endif // RD_LIGHT_CONTROL_CHANGE |
219 #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 } |
|
229 } |
220 } |
230 |
221 |
231 // ---------------------------------------------------------------------------- |
222 // ---------------------------------------------------------------------------- |
232 // CSysApLightsController::ChargingCompleteL() |
223 // CSysApLightsController::ChargingCompleteL() |
233 // ---------------------------------------------------------------------------- |
224 // ---------------------------------------------------------------------------- |
976 iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandNoAction ); |
967 iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandNoAction ); |
977 #endif // RD_LIGHT_CONTROL_CHANGE |
968 #endif // RD_LIGHT_CONTROL_CHANGE |
978 return; |
969 return; |
979 } |
970 } |
980 |
971 |
981 TInt err(KErrNone); |
972 TInt err(KErrNone); |
982 TInt state( 0 ); |
973 |
983 TInt error = RProperty::Get( KPSUidStartup, KPSGlobalSystemState, state ); |
974 #ifdef RD_LIGHT_CONTROL_CHANGE |
984 |
975 if ( !iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandOff ) ) |
985 if ( error == KErrNone && state != ESwStateCharging ) |
976 { |
986 { |
977 TRAP(err, iLight->LightOffL(CHWRMLight::ESystemTarget)); |
987 #ifdef RD_LIGHT_CONTROL_CHANGE |
978 } |
988 if ( !iLightPluginHandler->HandleCommand( SysApLightExtension::ELightCommandOff ) ) |
|
989 { |
|
990 TRAP(err, iLight->LightOffL(CHWRMLight::ESystemTarget)); |
|
991 } |
|
992 #else // RD_LIGHT_CONTROL_CHANGE |
979 #else // RD_LIGHT_CONTROL_CHANGE |
993 TRAP(err, iLight->LightOffL(CHWRMLight::ESystemTarget)); |
980 TRAP(err, iLight->LightOffL(CHWRMLight::ESystemTarget)); |
994 #endif // RD_LIGHT_CONTROL_CHANGE |
981 #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 } |
|
1003 // Ignore unreserved in use warnings. |
982 // Ignore unreserved in use warnings. |
1004 if ( err != KErrNone && err != KErrInUse ) |
983 if ( err != KErrNone && err != KErrInUse ) |
1005 { |
984 { |
1006 // Only trace as leaving here accomplishes nothing. |
985 // Only trace as leaving here accomplishes nothing. |
1007 TRACES( RDebug::Print( _L( "CSysApLightsController::SetLightsOffL failed: err: %d" ), err ) ); |
986 TRACES( RDebug::Print( _L( "CSysApLightsController::SetLightsOffL failed: err: %d" ), err ) ); |
1097 if ( err == KErrNone ) |
1076 if ( err == KErrNone ) |
1098 { |
1077 { |
1099 iLightsCurrentlyOn = ETrue; |
1078 iLightsCurrentlyOn = ETrue; |
1100 iLastLightsOnTime.HomeTime(); |
1079 iLastLightsOnTime.HomeTime(); |
1101 } |
1080 } |
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 } |
|
1119 } |
1081 } |
1120 else |
1082 else |
1121 { |
1083 { |
1122 TRACES( RDebug::Print( _L( "CSysApLightsController::SetLightsOnL - LIGHTS ON denied - Not necessary" ) ) ); |
1084 TRACES( RDebug::Print( _L( "CSysApLightsController::SetLightsOnL - LIGHTS ON denied - Not necessary" ) ) ); |
1123 #ifdef RD_LIGHT_CONTROL_CHANGE |
1085 #ifdef RD_LIGHT_CONTROL_CHANGE |