Back to top

How to enable and change the SIM card PINs on a dual SIM device

Environment

  • Samsung Knox devices
  • Knox SDK
  • Dual-SIM devices

Overview

This article guides you on how to use the Knox API to enable and change the PINs of the SIM cards on a dual-SIM device.

The sample code in this KBA is generic and provided mainly for illustrative purposes to help explain how to use SIM-related methods in the Knox SDK in more detail, and isn’t written with a particular environment or development context in mind. You will need to build additional context into the snippets to integrate them into a sample app or a debugging session.

How to enable the PIN of a SIM card

To enable the PIN of a specific SIM:

  1. Fetch the SIM card’s ICCID from SubscriptionManager by passing the slot number (0 or 1) that the card occupies. The slot number varies between devices and manufacturers, and slot 0 isn’t always the first slot:
SubscriptionManager subManager = (SubscriptionManager) getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
String iccId = subManager.getActiveSubscriptionInfoForSimSlotIndex(0).getIccId();
  1. Retrieve the phoneRestrictionPolicy of the SIM card by passing its ICCID:
PhoneRestrictionPolicy phoneRestrictionPolicyForSpecificSIM = edm.getPhoneRestrictionPolicy(iccId);
  1. Enable the SIM card’s PIN by calling enableSimPinLock and providing the current PIN:
string currentPinCode = "1234"
int resultForDefaultSim = phoneRestrictionPolicyForSpecificSIM.enableSimPinLock(currentpinCode);

How to change the PIN of a SIM card

To change the PIN for a SIM card:

  1. Fetch the SIM’s ICCID from SubscriptionManager by passing the slot number (0 or 1) that the SIM occupies:
SubscriptionManager subManager = (SubscriptionManager) getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
String iccId = subManager.getActiveSubscriptionInfoForSimSlotIndex(0).getIccId();
  1. Retrieve the phoneRestrictionPolicy of the SIM card by passing its ICCID:
PhoneRestrictionPolicy phoneRestrictionPolicyForSpecificSIM = edm.getPhoneRestrictionPolicy(iccId);
  1. Change the PIN of the SIM card with the changeSimPinCode method:
int resultForSpecificSIm = phoneRestrictionPolicyForSpecificSIM.changeSimPinCode(oldPinCodeForSpecificSIM,newPinCodeForSpecificSIM);

Additional information

For information about the default PINs of the SIM cards deployed in your device fleet, contact your telecom operator or carrier.

To learn more about the SIM policy methods in the Knox SDK, see PhoneRestrictionPolicy in the Knox SDK API reference.

Back to KBAs

Is this page helpful?