Installing Features with Feature Manager

Provides instructions for adding features when installing a new software component.

A phone is typically built with many features either disabled or not included. When you install a new software component which requires disabled or excluded features you need to enable or add them for the first time. You do this using the feature installer, a C++ program which calls the Feature Manager API. To install the required features you customise and install the source code.


  1. customise the source code in featureinstaller.cpp,

    1. Set the TUid featureUid to the UId of the required feature as defined in featureUIDs.h,
          // TODO: Replace UID 0x00000000 with real value
          TUid featureUid( TUid::Uid( 0x00000000 ) ); 
      

    2. set the TBitFlags32 featureFlags to the status flags which should be set for the required feature, and
          // If set, feature is supported and available for use; 
          // if not, feature is not supported.
          // TODO: Comment when needed!
          featureFlags.Set( EFeatureSupported );
          ...
      
    3. set the TUint32 featureData to the user-defined data.
          // TODO: Set feature data. Replace <featureData> with real value!
          // TODO: Comment when needed!
          TUint32 featureData( 0x00000000 );
      
    This is the source code to be modified.
    
    
    // INCLUDE FILES
    #include <featurecontrol.h>
    
    // LOCAL CONSTANTS AND MACROS
    _LIT(KTxt,"featureinstaller: mainL failed");
    
    
    // ============================= LOCAL FUNCTIONS ===============================
    
    // -----------------------------------------------------------------------------
    // mainL
    // -----------------------------------------------------------------------------
    //  
    LOCAL_C void mainL()
        {
        // Open Feature Control.
        RFeatureControl featureControl;
        User::LeaveIfError( featureControl.Open() );
        
        // Example code adds a new persisted feature to the device.
        // TODO: Comment or uncomment code when needed. 
        
        // TODO: Specify in your .pkg file:
        // @"featureinstaller.sisx", (0x10283303)
    
        
        // TODO: Replace UID 0x00000000 with real value
        TUid featureUid( TUid::Uid( 0x00000000 ) ); 
        
        // TODO: Set feature flags of the feature!
       
        // Set all flags to zero.
        // TODO: Comment when needed!
        TBitFlags32 featureFlags( 0 );
    
        // If set, feature is supported and available for use; 
        // if not, feature is not supported.
        // TODO: Comment when needed!
        featureFlags.Set( EFeatureSupported );
        
        // If set, feature is upgradeable. The feature is known to the device
        // but it must be upgraded to enable it. If a feature s blacklisted, 
        // its upgradeable flag is unset. 
        // TODO: Uncomment when needed!
        // featureFlags.Set( EFeatureUpgradeable );
        
        // If set, the feature is modifiable and may be enabled/disabled 
        // at run-time. The initial flag values for such a feature flag are
        // defined in a ROM image obey file.
        // TODO: Comment when needed!
        featureFlags.Set( EFeatureModifiable );
        
        // If set, the feature has been blacklisted, and may not be changed at 
        // run-time. This also prevents a feature from being upgraded.
        // TODO: Uncomment when needed!
        // featureFlags.Set( EFeatureBlackListed );
    
        // If set, only clients with WriteDeviceData capability can modify it.
        // This ensures only trusted software can set the feature Supported flag.
        // TODO: Uncomment when needed!
        // featureFlags.Set( EFeatureProtected );
        
        // If set, this flag is saved to the system drive when modified 
        // preserving its value across reboots/power downs.
        // TODO: Comment when needed!
        featureFlags.Set( EFeaturePersisted );
        
        // If set, this flag Supported state is unknown at build-time and is
        // initialised at run-time by system software. The Feature Manager will
        // ignore the Supported flag in the file. A run-time call to RFeatureControl
        // will be needed to set the feature's supported flag. Look ups of 
        // uninitialised features result in a KErrNotReady error code
        // TODO: Uncomment when needed!
        // featureFlags.Set( EFeatureUninitialized );
    
        // Feature data is 32-bit quantity for client read and write. Feature data is
        // defined by owner of the feature and can contain for example flags, 
        // enumeratons and/or integers.
        // TODO: Set feature data. Replace <featureData> with real value!
        // TODO: Comment when needed!
        TUint32 featureData( 0x00000000 );
        
        // TODO: Comment when needed!
        TFeatureEntry entry( featureUid, featureFlags, featureData );
        
        TInt err( KErrNone );
        
        // Add a new feature to the device.
        // TODO: Comment when needed!
        err = featureControl.AddFeature( entry );
        
        if ( err == KErrAlreadyExists ) // Existing feature cannot be added as a new feature.
            {
            // Enable an existing feature.
            User::LeaveIfError( featureControl.EnableFeature( featureUid ) );
            
            // OR enable an exsiting feature and set feature data.
            // TODO: Uncomment when needed!
            //User::LeaveIfError( featureControl.SetFeature( featureUid, ETrue, featureData ) );
            }
      
        featureControl.Close();
        }
    

  2. compile the code to featureinstaller.exe,
  3. customise the package file featureinstaller.pkg with the filepath of featureinstaller.exe, and
    ; This file installs an exe that is run asynchronously on installation, 
    
    ;Languages
    &EN
    
    ;Header
    #{"featureinstaller"}, (0x10283303), 1, 2, 3,TYPE=SA
    
    %{"Vendor"}
    :"Unique Vendor Name"
    
    "\epoc32\release\winscw\udeb\featureinstaller.exe"-"!:\sys\bin\featureinstaller.exe", FR, RI
  4. convert featureinstaller.pkg into a .sis file to be placed on the phone in accordance with the normal installation process. The .sis file will cause the .exe to run when the .sis file is installed on the device.

The features you have installed will now be enabled on the device.

Related concepts
Feature Manager Overview