Update contrib.
1 // Copyright (c) 1997-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
18 #include "SaPrivate.h"
20 #include <saclsdefines.h>
21 #include <saclscommon.h>
24 Count of the properties registered at startup.
25 50 Uids issued from 0x100052C3 to 0x100052F4
26 0x100052C3 is not used, 0x100052C4 is used for KUidSystemAgentExe
27 leaving 48 for property uids
30 const TInt KPropertyCount = 48;
32 //Security policy definitions for the KPropertyCount predefined properties.
33 _LIT_SECURITY_POLICY_C1(KSecurityPolicyNone, ECapability_None);
34 _LIT_SECURITY_POLICY_C1(KSecurityPolicyWriteDeviceData, ECapabilityWriteDeviceData);
35 _LIT_SECURITY_POLICY_S1(KSecurityPolicySwiSIDTrustedUi, 0x101F7295, ECapabilityTrustedUI);
36 _LIT_SECURITY_POLICY_S0(KSecurityPolicyJavaSID, 0x1020329F);
38 // Security policy for secure backup engine
39 const TInt KSBESID = 0x10202D56;
40 _LIT_SECURITY_POLICY_S0(KSBEWritePolicy, KSBESID);
41 _LIT_SECURITY_POLICY_PASS(KSBEReadPolicy);
43 // Security policy definitions for LBS
44 _LIT_SECURITY_POLICY_C1(KLBSLastKnownLocationReadPolicy, ECapabilityReadDeviceData);
45 _LIT_SECURITY_POLICY_S0(KLBSLastKnownLocationWritePolicy, 0x101f97b2);
46 _LIT_SECURITY_POLICY_PASS(KLBSGpsHwStatusReadPolicy);
47 _LIT_SECURITY_POLICY_C1(KLBSGpsHwStatusWritePolicy, ECapabilityWriteDeviceData);
49 //The function initializes aWritePolicy parameter with the appropriate
50 //value, depending on the value of aPropertyUid parameter.
51 static void GetPropertyPolicies(const TUid& aPropertyUid, const TSecurityPolicy*& aWritePolicy)
53 switch(aPropertyUid.iUid)
55 case KUidPhonePwrValue:
56 case KUidSIMStatusValue:
57 case KUidNetworkStatusValue:
58 case KUidNetworkStrengthValue:
59 case KUidChargerStatusValue:
60 case KUidBatteryStrengthValue:
61 case KUidCurrentCallValue:
62 aWritePolicy = &KSecurityPolicyWriteDeviceData;
65 aWritePolicy = &KSecurityPolicyNone;
71 This function tries to define a property, and if it is not already defined, it sets its value to a default value.
73 @leave Some of the system-wide error codes.
74 @param aCategory The UID that identifies the property category.
75 @param aKey The property sub-key, i.e. the key that identifies the specific property within the category.
76 @param aAttr This describes the property type, a TType value; persistence, as defined by the KPersistent bit, may be ORed in.
77 @param aReadPolicy A security policy defining the security attributes a process must have in order to read this value.
78 @param aWritePolicy A security policy defining the security attributes a process must have in order to write this value.
79 @param aDefaultValue The default value to assign to the property, if the property does not already exist and we define it. If the default value is zero (0) the property will not be set, since this is the default.
81 static void DefinePSPropertyL(TUid aCategory, TInt aKey, TInt aAttr, const TSecurityPolicy &aReadPolicy, const TSecurityPolicy &aWritePolicy, TInt aDefaultValue)
83 TInt err = RProperty::Define(aCategory, aKey, aAttr, aReadPolicy, aWritePolicy);
85 if (err != KErrAlreadyExists)
87 // Leave if the error is not one of KErrNone or KErrAlreadyExists
88 User::LeaveIfError(err);
91 if (err == KErrNone && aDefaultValue != 0)
93 // Initialise the value if it was not already defined, and the value is not already set
94 User::LeaveIfError(RProperty::Set(aCategory, aKey, aDefaultValue));
101 The function creates P&S properties with uid's from 0x100052C5 to 0x100052C5 + KPropertyCount.
102 They were (and are) used by the implementation of SystemAgent server.
103 If a property is registered for the first time, its initial value will be set to KErrUnknown.
105 @leave Some of the system-wide error codes.
107 static void CreatePSPropertiesL()
109 TUid saUid = TUid::Uid(KUidPhonePwrValue);
110 for(TInt i=0;i<KPropertyCount;++i)
112 const TSecurityPolicy* writePolicy = NULL;
113 ::GetPropertyPolicies(saUid, writePolicy);
115 DefinePSPropertyL(KUidSystemCategory, saUid.iUid, RProperty::EInt, KSecurityPolicyNone, *writePolicy, KErrUnknown);
121 The function creates P&S properties with uids KUidJavaInstallKey and Swi::KUidSoftwareInstallKey.
122 If a property is registered for the first time, its initial value will be set to 0, indicating
123 no operations are currently being performed.
125 @leave Some of the system-wide error codes.
127 static void CreateSwiPropertiesL()
130 // Java properties are policed on the JavaHelperServer SID
132 DefinePSPropertyL(KUidSystemCategory, KSAUidJavaInstallKeyValue, RProperty::EInt, KSecurityPolicyNone, KSecurityPolicyJavaSID, 0);
133 DefinePSPropertyL(KUidSystemCategory, KUidJmiLatestInstallation, RProperty::EInt, KSecurityPolicyNone, KSecurityPolicyJavaSID, 0);
135 // Native properties are policed on the TrustedUI capability
137 DefinePSPropertyL(KUidSystemCategory, KSAUidSoftwareInstallKeyValue, RProperty::EInt, KSecurityPolicyNone, KSecurityPolicySwiSIDTrustedUi, 0);
138 DefinePSPropertyL(KUidSystemCategory, KUidSwiLatestInstallation, RProperty::EInt, KSecurityPolicyNone, KSecurityPolicySwiSIDTrustedUi, 0);
140 DefinePSPropertyL(KUidSystemCategory, KSWIUidsCurrentlyBeingProcessed, RProperty::EByteArray, KSecurityPolicyNone, KSecurityPolicySwiSIDTrustedUi, 0);
145 The function creates the P&S property with uid KUidUnifiedCertstoreFlag
146 If a property is registered for the first time, its initial value will be set to 0, indicating
147 no operations are currently being performed.
149 @leave Some of the system-wide error codes.
151 static void CreateUnifiedCertstorePropertiesL()
153 // Allow any process to read or write this value
154 // initial value of zero
155 DefinePSPropertyL(KUidSystemCategory, KUidUnifiedCertstoreFlag, RProperty::EInt, KSecurityPolicyNone, KSecurityPolicyNone, 0);
160 The function creates P&S properties with uids KUidBackupRestoreKey.
161 If a property is registered for the first time, its initial value will be set to 0, indicating
162 no operations are currently being performed.
164 @leave Some of the system-wide error codes.
166 static void CreateSBEPropertiesL()
168 // We define two properties currently, one for Java MIDlet install and one for native
172 KUidBackupRestoreKey // backup and restore key
175 for (TInt i=0; i < sizeof(properties)/sizeof(properties[0]); ++i)
177 DefinePSPropertyL(KUidSystemCategory, properties[i], RProperty::EInt, KSBEReadPolicy, KSBEWritePolicy, 0);
183 The function creates the P&S property with uids KSAPosLastKnownLocation & KSAPosIntGpsHwStatus
184 If a property is registered for the first time, its initial value will be set to 0, indicating
185 no operations are currently being performed.
187 @leave Some of the system-wide error codes.
189 static void CreateLBSPropertiesL()
191 DefinePSPropertyL(KSAPosLastKnownLocationCategory, KSAPosLastKnownLocation, RProperty::EText, KLBSLastKnownLocationReadPolicy, KLBSLastKnownLocationWritePolicy, 0);
192 DefinePSPropertyL(KSAPosIndicatorCategory, KSAPosIntGpsHwStatus, RProperty::EInt, KLBSGpsHwStatusReadPolicy, KLBSGpsHwStatusWritePolicy, 0);
196 static void RunServerL()
198 // naming the server thread after the server helps to debug panics
199 User::LeaveIfError(User::RenameThread(KSystemAgentServerName));
201 ::CreatePSPropertiesL();
202 ::CreateSwiPropertiesL();
203 ::CreateUnifiedCertstorePropertiesL();
204 ::CreateSBEPropertiesL();
205 ::CreateLBSPropertiesL();
207 RProcess::Rendezvous(KErrNone);
210 // Server process entry-point
211 // Recover the startup parameters and run the server
216 CTrapCleanup* cleanup=CTrapCleanup::New();
220 TRAP(r,RunServerL());