Menu

How do I use the Knox SDK to allow or block phone numbers?

To allow phone numbers or block the incoming and outgoing calls, use the Knox SDK class com.samsung.android.knox.restriction.PhoneRestrictionPolicy.

In order to set a list of phone numbers that would be able to call your device, you must first block all phone numbers (using .* pattern) and then add desired pattern to whitelist which will allow only specific numbers to call your device. Whitelist has a higher priority than blacklist, that is, if you add a specific phone number to the whitelist, it will not be affected by the blacklist pattern.

To allow numbers based on last 3 digits (for example, numbers ending with "111"), use the following API methods:

  • setIncomingCallRestriction — use the ".*" pattern. This will block all calls to the device.
  • setIncomingCallExceptionPattern — use the ".*111" pattern. This will allow calls (allow) from numbers ending with "111".

Note: Adding pattern using setIncomingCallExceptionPattern without setting the restriction pattern will have no effect on the device.

To allow phone numbers based on first 3 digits, you must add appropriate prefixes depending on the country when applying the pattern. For example, "+" (plus) symbol is a special character that must be taken into consideration when creating regular expression pattern.

The correct pattern to block or allow all US numbers should be "\+1[0-9]*". where, "\+" (plus will be interpreted as character), 1 (number one), [0-9]* (can match 0-9) occurring none or more than one time. For example, enter "XXX.* | 1XXX.* | \+1XXX (where XXX are first 3 digits of any phone number and 1 or +1 is the prefix number, for example: "972.*").

All the regular expressions available in Java can be used in this API method.

Share it: