Reporting on all Features on a Device Dynamically Using RFeatureControl

How to list all supported features on a device using RFeatureControl dynamically.

To list all supported features on a device using RFeatureControl dynamically, take the following steps.


  1. Create an instance of RFeatureControl,
    
    // replace <featureUID> with a real Uid ) 
    #include <featurecontrol.h>
    #include <featureinfo.h> // for feature definitions
    CMyClass::MyMethodL()
         {
         // Replace KFeatureUidx with real feature Uid.
         // Open() must be called before calling any other methods. 
         // Disconnect is done by calling the Close() method.
         RFeatureControl featureControl;
    

  2. call its Open() function,
    
         TInt err = featureControl.Open();
    

  3. create an instance of RFeatureArray (an array of TFeatureEntry objects),
    
             // List all supported features.
    
             // A client owned RFeatureUidArray array which will be filled with 
             // the UIDs of supported features. 
             RFeatureUidArray supportedFeatures;
    
    

  4. call its ListSupportedFeatures() function with a reference to the RFeatureArray as argument,
    
             // ListSupportedFeatures() returns one of the Symbian error codes.
             err = featureControl.ListSupportedFeatures( supportedFeatures );
    
             // do something
    
    

  5. call its Close() function,
    
             // Closes the array and frees all memory allocated to the array.
             supportedFeatures.Close();
    

  6. call the Close() function of the RFeatureArray object.
    
             // Remember to call CloseL after using RFeatureControl.
             // It disconnects the Feature Manager server.
             featureControl.Close();  
             }
    
         }
    

ListSupportedFeatures() causes the passed in array to be filled with the Uids of supported features. It returns:

  • KErrNone if the RFeatureArray was successfully filled with Uids,

  • KServerBusy if the call failed because features were being enabled or disabled (so creating a lock), and

  • otherwise returns an error code.