This document shows you how to enable USB On-The-Go (OTG) host driver loading.
USB OTG host-driver loading is the automatic loading by the USB host software of drivers for an attached peripheral.
The USB Manager library includes functions that allow the USB control application to enable and disable host-driver loading. The main purpose of this functionality is to allow host-driver loading to be disabled whenever the phone is in a locked state. This prevents a peripheral from being physically connected to it (possibly without its users knowledge) and the host-drivers then automatically loading to permit (possibly un-authorized) data transfers between the devices.
By default, host-driver loading is disabled. Therefore your USB control application needs to enable it explicitly soon after starting USB services. It must then disable it whenever the phone is in a locked state and re-enable it when the phone emerges from a locked state.
Intended Audience
This document is for Symbian licensees who are implementing USB services, including host and On-The-Go services, on a Symbian platform phone.
Required Background
For details of, and links to, the USB and On-The-Go (OTG) specifications on the USB Implementers Forum website, see The USB Manager library.
You also need to be aware that, on a Symbian platform USB host/OTG phone, host-driver loading is not enabled by default. This is a security feature. It means that you have control of when host-driver loading is enabled and when it is disabled.
Setup and Configuration Requirements
To perform the instructions in this document you need to have an application that you are using as the USB control application. The device you are designing needs to have had Symbian's low-level host/OTG stack ported to it.
You can only call the functionality for enabling and disabling host-driver loading from the USB control application. For information about making an application into the control application, see Locking applications out of the USB Manager.
Basic Procedure
The high level steps for using USB host-driver loading functionality are shown here:
Starting USB Services
For more information about starting USB services, see Starting USB services.
For information about making the application you are writing into the USB control application, see Locking applications out of the USB Manager.
Enabling host-driver loading
To enable host-driver loading, call the RUsb::EnableFunctionDriverLoading() function. Note that you will need to be able to track the status of host-driver loading. In the example below, a Boolean value is used for this called functionDriverLoadingEnabled.
TBool functionDriverLoadingEnabled; functionDriverLoadingEnabled = EFalse; TInt err = usb.EnableFunctionDriverLoading(); //Enable function driver loading if err == KErrNone { //Handle error } else { functionDriverLoadingEnabled = ETrue; }
Host drivers for peripherals that attach to the Symbian platform phone will now be loaded automatically by the Function Driver Framework (as long as suitable host drivers exist on the phone).
Disabling host-driver loading
To disable host-driver loading, call the RUsb::DisableFunctionDriverLoading() function. For example:
usb.DisableFunctionDriverLoading(); functionDriverLoadingEnabled = EFalse;
Host drivers from any peripheral that attaches to the Symbian platform phone will not have drivers loaded for them while host-driver loading is disabled. We strongly recommend you disable host-driver loading whenever the phone is in a locked state.