Phone Lock Settings Tutorial

This tutorial describes how to get and set the phone locks using the RMobilePhone functions.

  1. Use RMobilePhone::GetLockInfo() to get the current phone lock setting. The lock is specified by a RMobilePhone::TMobilePhoneLock flag.
  2. Use RMobilePhone::NotifyLockInfoChange() to get the notification of any changes in lock settings.
  3. Use RMobilePhone::SetLockSetting() to set a phone lock.

Information about a lock status whether the lock is on or off, and the setting lock enabled or disabled is encapsulated in an RMobilePhone::TMobilePhoneLockInfoV1 object. An enabled lock setting means that the lock is active and can be locked or unlocked if the user enters the security code. If the lock is enabled, it returns to the locked state if certain event such as the phone power down occurs.

Phone lock example

The following code checks if phone lock information can be accessed and get that information. The example code also checks if the phone lock is enabled.

The code assumes iMobilePhone is an RMobilePhone object.

TUint32 securityCaps;
User::LeaveIfError(iMobilePhone.GetSecurityCaps(securityCaps));

if (securityCaps & RMobilePhone::KCapsLockPhone)
    {
    RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
    RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPckg(lockInfo);

    RMobilePhone::TMobilePhoneLock lock = RMobilePhone::ELockPhoneDevice;

    TRequestStatus status;

    iMobilePhone.GetLockInfo(status, lock, lockInfoPckg);
    User::WaitForRequest(status);
    User::LeaveIfError(status.Int());

    if (lockInfo.iStatus == RMobilePhone::EStatusLocked)
        {
            //do something
        }