|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 #include <e32property.h> |
|
19 #include <featurecontrol.h> |
|
20 #include <featureuids.h> |
|
21 #include <hwrmlight.h> |
|
22 #include <hwrmdomainpskeys.h> |
|
23 #include "hwrmdefaultlighttargetmodifierplugin.h" |
|
24 #include "HWRMtrace.h" |
|
25 |
|
26 // CONSTANTS |
|
27 |
|
28 // Value for all defined non-custom targets. Used to determine system target. |
|
29 const TInt KHWRMNonCustomTargets(CHWRMLight::EPrimaryDisplay | |
|
30 CHWRMLight::EPrimaryKeyboard | |
|
31 CHWRMLight::ESecondaryDisplay | |
|
32 CHWRMLight::ESecondaryKeyboard ); |
|
33 |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CHWRMDefaultLightTargetModifierPlugin::NewL |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CHWRMDefaultLightTargetModifierPlugin* CHWRMDefaultLightTargetModifierPlugin::NewL() |
|
40 { |
|
41 CHWRMDefaultLightTargetModifierPlugin* self = new(ELeave) CHWRMDefaultLightTargetModifierPlugin(); |
|
42 CleanupStack::PushL(self); |
|
43 self->ConstructL(); |
|
44 CleanupStack::Pop(); |
|
45 return self; |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CHWRMDefaultLightTargetModifierPlugin::~CHWRMDefaultLightTargetModifierPlugin |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CHWRMDefaultLightTargetModifierPlugin::~CHWRMDefaultLightTargetModifierPlugin() |
|
53 { |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CHWRMDefaultLightTargetModifierPlugin::CHWRMDefaultLightTargetModifierPlugin |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 CHWRMDefaultLightTargetModifierPlugin::CHWRMDefaultLightTargetModifierPlugin() |
|
61 { |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CHWRMDefaultLightTargetModifierPlugin::ConstructL |
|
66 // |
|
67 // Check relevant features initial states (if any) for target modification. |
|
68 // |
|
69 // Customer specific lights related initialization needed at startup |
|
70 // can be done in ConstructL of customer implementation. |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 void CHWRMDefaultLightTargetModifierPlugin::ConstructL() |
|
74 { |
|
75 iCoverDisplaySupported = IsFeatureSupported( NFeature::KCoverDisplay ); |
|
76 iGripSupported = ! IsFeatureSupported( NFeature::KKeypadNoSlider ); |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CHWRMDefaultLightTargetModifierPlugin::ModifyTargetL |
|
81 // |
|
82 // Default implementation simply returns the received target without modifying it, |
|
83 // unless the flip P&S key has been set to EPSHWRMFlipOpen, in which case it removes |
|
84 // the primary display from aTarget. |
|
85 // This is merely a trivial example of how the physical status of the device can be used to |
|
86 // modify the targets. This function will need to be adapted to a product's physical |
|
87 // configuration by filtering out the inactive targets according to its status at the moment |
|
88 // (e.g., "flip" closed or open, "slider" closed or open, etc.) |
|
89 // |
|
90 // Default implementation will not leave. |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 TInt CHWRMDefaultLightTargetModifierPlugin::ModifyTargetL( TInt aTarget ) |
|
94 { |
|
95 COMPONENT_TRACE2(_L("CHWRMDefaultLightTargetModifierPlugin::ModifyTargetL(aTarget: 0x%x)"), aTarget ); |
|
96 |
|
97 TInt modifiedTarget(aTarget); |
|
98 |
|
99 User::LeaveIfError(KErrNone); // avoid LeaveScan error in dummy default version |
|
100 |
|
101 TInt flipStatus(EPSHWRMFlipStatusUninitialized); |
|
102 RProperty::Get(KPSUidHWRM, KHWRMFlipStatus, flipStatus); |
|
103 if (flipStatus == EPSHWRMFlipOpen) |
|
104 { |
|
105 modifiedTarget &= ~CHWRMLight::EPrimaryDisplay; |
|
106 } |
|
107 |
|
108 COMPONENT_TRACE3(_L("CHWRMDefaultLightTargetModifierPlugin::ModifyTargetL - Return: 0x%x (Original target: 0x%x)"), modifiedTarget, aTarget); |
|
109 |
|
110 return modifiedTarget; |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CHWRMDefaultLightTargetModifierPlugin::GetFullSystemTarget |
|
115 // |
|
116 // Assume all supported non-custom targets are system targets |
|
117 // in default implementation. |
|
118 // In customer implementations KHWRMNonCustomTargets needs to be replaced |
|
119 // with product specific mask or logic to determine a mask. |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 TInt CHWRMDefaultLightTargetModifierPlugin::GetFullSystemTarget() |
|
123 { |
|
124 return KHWRMNonCustomTargets; |
|
125 } |
|
126 |
|
127 TBool CHWRMDefaultLightTargetModifierPlugin::IsFeatureSupported(const TUid aFeatureUid) |
|
128 { |
|
129 RFeatureControl featureControl; |
|
130 |
|
131 TInt err = featureControl.Open(); |
|
132 |
|
133 TBool featureSupported(EFalse); |
|
134 |
|
135 if(err == KErrNone) |
|
136 { |
|
137 featureSupported = featureControl.FeatureSupported(aFeatureUid); |
|
138 } |
|
139 |
|
140 featureControl.Close(); |
|
141 |
|
142 return featureSupported; |
|
143 } |
|
144 |