Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

How to Know Capability of an Application Dynamically

From Wiki
Jump to: navigation, search
Article Metadata
Article
Created: WikiChecked (28 Nov 2007)
Last edited: hamishwillee (30 May 2013)

The following code shows how to know the capabilities granted to your application Dynamically.

This code will get the current Process id and Checks if the process has a given capability using HasCapability(). When a check fails the action taken is determined by the system wide Platform Security configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. If PlatSecEnforcement is OFF, then this function will return ETrue even though the check failed.

#include <e32std.h>
 
void CCapability::ConstructL
{
.......
RProcess process(KCurrentProcessHandle);
process.Id().Id();
for(TInt i=0; i<ECapability_Limit; i++)
{
DisplayCapaInfo(i, process.HasCapability( (TCapability)i) );
}
}
void CCapability::DisplayCapaInfo(const TInt& capa, TBool enabled) 
{
TBuf<40> line1;
TBuf<40> line2;
switch (capa)
{
case ECapabilityTCB:
line1.Copy(_L("TCB"));
break;
case ECapabilityCommDD:
line1.Copy(_L("CommDD"));
break;
case ECapabilityPowerMgmt:
line1.Copy(_L("PowerMgmt"));
break;
case ECapabilityMultimediaDD:
line1.Copy(_L("MultimediaDD"));
break;
case ECapabilityReadDeviceData:
line1.Copy(_L("ReadDeviceData"));
break;
case ECapabilityWriteDeviceData:
line1.Copy(_L("WriteDeviceData"));
break;
case ECapabilityDRM:
line1.Copy(_L("DRM"));
break;
case ECapabilityTrustedUI:
line1.Copy(_L("TrustedUI"));
break;
case ECapabilityProtServ:
line1.Copy(_L("ProtServ"));
break;
case ECapabilityDiskAdmin:
line1.Copy(_L("DiskAdmin"));
break;
case ECapabilityNetworkControl:
line1.Copy(_L("NetworkControl"));
break;
case ECapabilityAllFiles:
line1.Copy(_L("AllFiles"));
break;
case ECapabilitySwEvent:
line1.Copy(_L("SwEvent"));
break;
case ECapabilityNetworkServices:
line1.Copy(_L("NetworkServices"));
break;
case ECapabilityLocalServices:
line1.Copy(_L("LocalServices"));
break;
case ECapabilityReadUserData:
line1.Copy(_L("ReadUserData"));
break;
case ECapabilityWriteUserData:
line1.Copy(_L("WriteUserData"));
break;
case ECapabilityLocation:
line1.Copy(_L("Location"));
break;
case ECapabilitySurroundingsDD:
line1.Copy(_L("SurroundingsDD"));
break;
case ECapabilityUserEnvironment:
line1.Copy(_L("UserEnvironment"));
break;
case ECapability_None:
line1.Copy(_L("None"));
break;
case ECapability_Denied:
line1.Copy(_L("Denied"));
break;
default:
line1.Copy(_L("Unknown case"));
break;
}
if ( enabled )
{
line2.Append(_L("is granted"));
}
else
{
line2.Append(_L("is NOT granted"));
}
CEikonEnv::InfoWinL(line1, line2);
}

Note: This code snippet does not give any capability information while running on emulator. If you want to grant capabilities on emulator, check with the emulator's platform security preferences.

Internal Links

This page was last modified on 30 May 2013, at 04:33.
32 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×