|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Hardware Resource Manager Default Light Target Modifier Plugin |
|
15 * implementation file |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <e32property.h> |
|
21 #include <featmgr.h> |
|
22 #include <hwrmlight.h> |
|
23 #include <hwrmdomainpskeys.h> |
|
24 #include "hwrmdefaultlighttargetmodifierplugin.h" |
|
25 #include "Trace.h" |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 // Value for all defined non-custom targets. Used to determine system target. |
|
30 const TInt KHWRMNonCustomTargets(CHWRMLight::EPrimaryDisplay | |
|
31 CHWRMLight::EPrimaryKeyboard | |
|
32 CHWRMLight::ESecondaryDisplay | |
|
33 CHWRMLight::ESecondaryKeyboard ); |
|
34 |
|
35 // Values for switch IO group and switch functions. These values are licensee specific. |
|
36 const TInt KHWSwitchGroup( 29 ); |
|
37 const TInt KHWSwitchGrip( 2 ); |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CHWRMDefaultLightTargetModifierPlugin::NewL |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CHWRMDefaultLightTargetModifierPlugin* CHWRMDefaultLightTargetModifierPlugin::NewL() |
|
44 { |
|
45 CHWRMDefaultLightTargetModifierPlugin* self = new(ELeave) CHWRMDefaultLightTargetModifierPlugin(); |
|
46 CleanupStack::PushL(self); |
|
47 self->ConstructL(); |
|
48 CleanupStack::Pop(); |
|
49 return self; |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CHWRMDefaultLightTargetModifierPlugin::~CHWRMDefaultLightTargetModifierPlugin |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CHWRMDefaultLightTargetModifierPlugin::~CHWRMDefaultLightTargetModifierPlugin() |
|
57 { |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CHWRMDefaultLightTargetModifierPlugin::CHWRMDefaultLightTargetModifierPlugin |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CHWRMDefaultLightTargetModifierPlugin::CHWRMDefaultLightTargetModifierPlugin() |
|
65 { |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CHWRMDefaultLightTargetModifierPlugin::ConstructL |
|
70 // |
|
71 // Check relevant features initial states (if any) for target modification. |
|
72 // |
|
73 // Customer specific lights related initialization needed at startup |
|
74 // can be done in ConstructL of customer implementation. |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void CHWRMDefaultLightTargetModifierPlugin::ConstructL() |
|
78 { |
|
79 FeatureManager::InitializeLibL(); |
|
80 iCoverDisplaySupported = FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ); |
|
81 iGripSupported = !(FeatureManager::FeatureSupported( KFeatureIdKeypadNoSlider )); |
|
82 FeatureManager::UnInitializeLib(); |
|
83 |
|
84 TInt err( KErrNone ); |
|
85 TInt status; |
|
86 |
|
87 err = RProperty::Get( KPSUidHWRM, KHWRMGripStatus, status ); |
|
88 if( err == KErrNone && status == EPSHWRMGripStatusUninitialized ) |
|
89 { |
|
90 // Initialize grip status of HWRM Device Switch API |
|
91 err = UserSvr::HalFunction( KHWSwitchGroup, KHWSwitchGrip, &status, 0 ); |
|
92 if( err == KErrNone) |
|
93 { |
|
94 RProperty::Set( KPSUidHWRM, KHWRMGripStatus, status ? EPSHWRMGripOpen : EPSHWRMGripClosed ); |
|
95 } |
|
96 COMPONENT_TRACE( ( _L( "CHWRMDefaultLightTargetModifierPlugin::ConstructL() - grip, err: %d, status: %d" ), |
|
97 err, status ) ); |
|
98 } |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CHWRMDefaultLightTargetModifierPlugin::ModifyTargetL |
|
103 // |
|
104 // Default implementation provides handling for devices that have one of the |
|
105 // following supported light target configurations: |
|
106 // - Primary display + Primary keyboard, no flip |
|
107 // - Primary and secondary display + Primary (and optionally secondary) keyboard |
|
108 // - Requires KFeatureIdCoverDisplay feature to be defined |
|
109 // - Either of the above with grip that covers primary keyboard |
|
110 // - Requires KFeatureIdKeypadNoSlider feature to not be defined |
|
111 // |
|
112 // Default implementation will not leave. |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 TInt CHWRMDefaultLightTargetModifierPlugin::ModifyTargetL( TInt aTarget ) |
|
116 { |
|
117 COMPONENT_TRACE((_L("CHWRMDefaultLightTargetModifierPlugin::ModifyTargetL(aTarget: 0x%x)"), aTarget )); |
|
118 |
|
119 TInt modifiedTarget(aTarget); |
|
120 |
|
121 // Figure out the active targets |
|
122 TInt err(KErrNone); |
|
123 TInt gripOpen(EPSHWRMGripOpen); |
|
124 |
|
125 if ( iGripSupported ) |
|
126 { |
|
127 err = RProperty::Get( KPSUidHWRM, KHWRMGripStatus, gripOpen ); |
|
128 if ( err != KErrNone ) |
|
129 { |
|
130 gripOpen = EPSHWRMGripOpen; |
|
131 COMPONENT_TRACE( ( _L( "CHWRMDefaultLightTargetModifierPlugin::ModifyTargetL - KHWRMGripStatus reading failed: %d " ), err ) ); |
|
132 } |
|
133 } |
|
134 |
|
135 if ( iCoverDisplaySupported ) |
|
136 { |
|
137 TInt flipOpen(EPSHWRMFlipOpen); |
|
138 err = RProperty::Get(KPSUidHWRM, KHWRMFlipStatus, flipOpen); // returns 0 or 1, no enums defined |
|
139 |
|
140 if ( err == KErrNone ) |
|
141 { |
|
142 if ( flipOpen == EPSHWRMFlipOpen ) |
|
143 { |
|
144 if ( gripOpen == EPSHWRMGripOpen ) |
|
145 { |
|
146 modifiedTarget &= ~CHWRMLight::ESecondaryDisplayAndKeyboard; |
|
147 COMPONENT_TRACE( ( _L( "CHWRMDefaultLightTargetModifierPlugin::ModifyTargetL - Flip and grip open, removed secondary display and keyboard" ) ) ); |
|
148 } |
|
149 else |
|
150 { |
|
151 modifiedTarget &= ~(CHWRMLight::EPrimaryKeyboard | CHWRMLight::ESecondaryDisplayAndKeyboard); |
|
152 COMPONENT_TRACE( ( _L( "CHWRMDefaultLightTargetModifierPlugin::ModifyTargetL - Flip open, grip closed, removed primary keyboard and secondary display and keyboard" ) ) ); |
|
153 } |
|
154 } |
|
155 else |
|
156 { |
|
157 // If cover UI and flip closed: Remove all primary components |
|
158 modifiedTarget &= ~CHWRMLight::EPrimaryDisplayAndKeyboard; |
|
159 COMPONENT_TRACE( ( _L( "CHWRMDefaultLightTargetModifierPlugin::ModifyTargetL - Flip closed, removed primary display and keyboard" ) ) ); |
|
160 } |
|
161 } |
|
162 else |
|
163 { |
|
164 COMPONENT_TRACE( ( _L( "CHWRMDefaultLightTargetModifierPlugin::ModifyTargetL - KHWRMFlipStatus reading failed: %d, no further modification to target " ), err ) ); |
|
165 } |
|
166 } |
|
167 else |
|
168 { |
|
169 if ( gripOpen == EPSHWRMGripOpen ) |
|
170 { |
|
171 TInt flipOpen(EPSHWRMFlipOpen); |
|
172 err = RProperty::Get(KPSUidHWRM, KHWRMFlipStatus, flipOpen); // returns 0 or 1, no enums defined |
|
173 if ( err == KErrNone ) |
|
174 { |
|
175 if ( flipOpen == EPSHWRMFlipClosed ) |
|
176 { |
|
177 // Removing the primary keyboard from the light target of a device with |
|
178 // the primary keyboard hidden under a slider which can generate flip events. |
|
179 modifiedTarget &= ~CHWRMLight::EPrimaryKeyboard; |
|
180 COMPONENT_TRACE( ( _L( "CHWRMDefaultLightTargetModifierPlugin::ModifyTargetL - Flip closed, removed primary keyboard" ) ) ); |
|
181 } |
|
182 else |
|
183 { |
|
184 COMPONENT_TRACE( ( _L( "CHWRMDefaultLightTargetModifierPlugin::ModifyTargetL - Grip open, no further modification to target" ) ) ); |
|
185 } |
|
186 } |
|
187 else |
|
188 { |
|
189 COMPONENT_TRACE( ( _L( "CHWRMDefaultLightTargetModifierPlugin::ModifyTargetL - KHWRMFlipStatus reading failed: %d" ), err ) ); |
|
190 } |
|
191 } |
|
192 else |
|
193 { |
|
194 modifiedTarget &= ~CHWRMLight::EPrimaryKeyboard; |
|
195 COMPONENT_TRACE( ( _L( "CHWRMDefaultLightTargetModifierPlugin::ModifyTargetL - Grip closed, removed primary keyboard" ) ) ); |
|
196 } |
|
197 } |
|
198 |
|
199 COMPONENT_TRACE((_L("CHWRMDefaultLightTargetModifierPlugin::ModifyTargetL - Return: 0x%x (Original target: 0x%x)"), modifiedTarget, aTarget)); |
|
200 |
|
201 return modifiedTarget; |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // CHWRMDefaultLightTargetModifierPlugin::GetFullSystemTarget |
|
206 // |
|
207 // Assume all supported non-custom targets are system targets |
|
208 // in default implementation. |
|
209 // In customer implementations KHWRMNonCustomTargets needs to be replaced |
|
210 // with product specific mask or logic to determine a mask. |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 TInt CHWRMDefaultLightTargetModifierPlugin::GetFullSystemTarget() |
|
214 { |
|
215 return KHWRMNonCustomTargets; |
|
216 } |
|
217 |
|
218 |