×
Namespaces

Variants
Actions

Get current SIM card status using Symbian C++

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): All (S60)
Compatibility
Platform(s): S60 3rd Edition, FP1
S60 3rd Edition, FP2
S60 5th Edition
S60 5th Edition
S60 3rd Edition FP2
Article
Keywords: KPSUidStartup, KPSSimStatus, KPSSimChanged
Created: User:Kbwiki (18 Jun 2010)
Last edited: hamishwillee (01 Aug 2012)

Description

The SIM Utils API can be used to obtain the current status of the SIM card, as well as other information such as the reason for the latest device restart.


Note.pngNote: :The SIM Utils API is not part of the public SDK. It can be found in the SDK API Plug-in.

Solution

Required header files

 #include <simutils.h> // for S60 5th Edition
#include <startupdomainpskeys.h>

Required Capabilities

 CAPABILITY	  ReadDeviceData

The current SIM card status can be obtained by using the KPSSimStatus Publish & Subscribe key.

  void GetCurrentSIMStatus()
{
TInt status( ESimStatusUninitialized );
TInt error = RProperty::Get( KPSUidStartup, KPSSimStatus, status );
if ( error != KErrNone )
{
// Getting the status failed, handle errors here
return;
}
 
switch ( status )
{
 
case ESimStatusUninitialized:
{
// SIM card status uninitialized
break;
}
 
case ESimUsable:
{
// Sim card is fully usable
break;
}
 
case ESimReadable:
{
// SIM card is not fully usable,
// but the emergency number can be read
break;
}
 
case ESimNotReady:
{
// SIM card is present but not ready or usable
break;
}
 
case ESimNotPresent:
{
// SIM card is not present
break;
}
 
case ESimNotSupported:
{
// SIM/RUIM is not supported
break;
}
 
default:
{
break;
}
}
}

The KPSSimChanged key can be used to obtain the SIM change status, i.e whether the current SIM card is the same as the previous one.

  void GetSimChangedStatus()
{
TInt status( ESimChangedUninitialized );
TInt errorCode = RProperty::Get( KPSUidStartup, KPSSimChanged, status );
if ( errorCode != KErrNone )
{
// Getting the change status failed, handle errors here
return;
}
 
switch ( status )
{
 
case ESimChangedUninitialized:
{
// SIM not present
break;
}
 
case ESimChanged:
{
// SIM card changed from the previous
break;
}
 
case ESimNotChanged:
{
// SIM card has not changed
break;
}
 
default:
{
break;
}
}
}

KPSStartupReason from startupreason.h can be used for obtaining the system startup reason, as in the following code:

 #include <startupreason.h>
 
void GetRestartStatus()
{
TInt value;
TInt errorCode = RProperty::Get( KPSUidStartup, KPSStartupReason, value );
 
if ( errorCode != KErrNone )
{
// Error getting the startup reason, handle errors here
return;
}
 
switch ( value )
{
case ENormalStartup:
// Normal restart
break;
 
case ELanguageSwitchReset:
// A reset due to display language change
break;
 
case ENormalRFSReset:
// A reset due to restoring factory settings
break;
 
case EDeepRFSReset:
// A reset due to restoring factory settings
// (deep reset)
break;
 
case EFirmwareUpdate:
// A reset due to firmware update
break;
 
case EUnknownReset:
// A reset due to an unknown error
break;
 
case EOperatorSettingReset:
// A reset due to removing operator settings
break;
 
case ENetworkModeChangeReset:
// A reset due to network mode change
break;
 
case ESIMStatusChangeReset:
// A reset due to removing/inserting SIM card
break;
 
case EDataRestoreReset:
// A reset after restoring backed-up data
break;
 
case EFieldTestReset:
// A reset required by Field Test software
break;
 
default:
break;
}
}

Related articles

Creating a DM profile using Symbian C++

This page was last modified on 1 August 2012, at 07:40.
87 page views in the last 30 days.
×