Menu

How to allow incoming and outgoing calls only to specific call numbers

Environment

  • Knox SDK
  • Samsung Knox devices

Overview

This article provides information on how to allow incoming and outgoing calls to specific numbers and block incoming/outgoing calls to all other numbers using Knox SDK APIs.

To allow incoming and outgoing calls to specific numbers, you need to:

  1. Block incoming/outgoing calls for all numbers
  2. Allow specific numbers for incoming/outgoing calls

How do I block incoming/outgoing calls for all numbers?

Use Knox SDK’s setOutgoingCallRestriction and setIncomingCallRestriction APIs to block all incoming and outgoing calls, as specified below:

            EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
            PhoneRestrictionPolicy phoneRestrictionPolicy = edm.getPhoneRestrictionPolicy();
            try {
              phoneRestrictionPolicy.setOutgoingCallRestriction(".*");
              phoneRestrictionPolicy.setIncomingCallRestriction(".*");
            } catch (SecurityException e) {
              Log.w(TAG, "SecurityException: " + e);
            }

How do I allow only specific numbers for incoming/outgoing calls?

Use addOutgoingCallExceptionPattern and addIncomingCallExceptionPattern to allow calls to specific numbers only, as shown below:

If the country code is +9 and mobile number that needs to be allowed for incoming and outgoing calls is 9999999999, use the below code:

            EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance (context);
            PhoneRestrictionPolicy phoneRestrictionPolicy = edm.getPhoneRestrictionPolicy();
            try {
              phoneRestrictionPolicy.setOutgoingCallRestriction (".*");
              phoneRestrictionPolicy.addOutgoingCallExceptionPattern("\\+919999999999");
              phoneRestrictionPolicy.setIncomingCallRestriction(".*");
              phoneRestrictionPolicy.addIncomingCallExceptionsPattern("\\+919999999999");
            } catch (SecurityException e) {
              Log.w(TAG, "SecurityException: " + e);
            }

Additional information

To read more about the Knox SDK, please refer to the Knox SDK API Reference.

Share it: