Back to top

Manage COM and CL Workspaces

Dual Persona and Corporate Liable (CL) containers were deprecated on the Note 10 and later devices. COM containers were deprecated in S10s running Knox 3.3 and higher. For more information, see Unsupported COM and CL Workspaces. Deprecated container types that were created on existing devices in your fleet will continue to work until the official end of life (EOL) of the devices. However, we recommend that you use the new Device management modes to take advantage of the latest security and personal privacy features.

Create a container

To create a Knox container, you only need to call one API as follows.

KnoxContainerManager.createContainer("knox-b2b");

There are different types of containers you can create, depending on your needs. To change the container type, replace the knox-b2b string with your required container type.

When you push the container, the user must complete a series of steps on the phone to complete to process.

Remove a container

To remove a Knox container do as follows.

EnterpriseContainerManager.removeContainer(containerId, new RemoteStatusCallback());

Choose the container UI layout

You can customize the "knox-b2b" UI to appear as a folder containing apps or as a desktop with app launcher icons.

To do this, use setContainerLayout, which accepts the layout types:

  • CONTAINER_LAYOUT_TYPE_FOLDER
  • CONTAINER_LAYOUT_TYPE_CLASSIC

To prevent end users from changing this UI layout through the Knox Settings menu, use allowLayoutSwitching(boolean allow).

Handle container error messages

Register a broadcast receiver.

By default, the container creation process does not provide any error messages. To see error messages, you must create a broadcast receiver and receive INTENT_CONTAINER_CREATION_STATUS through a toast message.

This call returns the CREATION_STATUS_CODE, which you can use to determine the type of error you are receiving.

Example:

public class SampleContainerReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (action.equals(KnoxContainerManager.INTENT_CONTAINER_CREATION_STATUS)) {
            Bundle extras = intent.getExtras();
            int statusCode = extras.getInt(KnoxContainerManager.CONTAINER_CREATION_STATUS_CODE);

            if (statusCode > 0) {
                Toast.makeText(context, context.getString(R.string.created_container, statusCode), Toast.LENGTH_LONG).show();
            } else {
                switch (statusCode) {
                    case KnoxContainerManager.ERROR_FILESYSTEM_ERROR:
                        Toast.makeText(context, context.getString(R.string.error_filesystem), Toast.LENGTH_LONG).show();
                        break;
                    case KnoxContainerManager.ERROR_NO_ADMIN_APK:
                        Toast.makeText(context, context.getString(R.string.error_no_admin_apk), Toast.LENGTH_LONG).show();
                        break;
                    case KnoxContainerManager.ERROR_MAX_LIMIT_REACHED:
                        Toast.makeText(context, context.getString(R.string.error_max_limit_reached), Toast.LENGTH_LONG).show();
                        break;
                    case KnoxContainerManager.ERROR_INTERNAL_ERROR:
                        Toast.makeText(context, context.getString(R.string.error_internal), Toast.LENGTH_LONG).show();
                        break;
                    case KnoxContainerManager.CONTAINER_CREATION_IN_PROGRESS:
                        Toast.makeText(context, context.getString(R.string.error_creation_in_progress), Toast.LENGTH_LONG).show();
                        break;
                    case KnoxContainerManager.ERROR_CREATION_CANCELLED:
                        Toast.makeText(context, context.getString(R.string.container_cancelled), Toast.LENGTH_LONG).show();
                        break;
                    default:
                        Toast.makeText(context, context.getString(R.string.unknown_error), Toast.LENGTH_LONG).show();
                        break;
                }
            }
        }
    }
}

Examples

Create a container with custom settings

Here is a sample use case that creates a Knox container and sets up an email account.

  1. Create Knox container.
  2. Create the EnterpriseKnoxManager and Knox Container Manager objects.
  3. Call emailAccountPolicy.addNewAccount with required configurations.
KnoxContainerManager.createContainer("knox-b2b");
EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(ctx);
KnoxContainerManager kcm = ekm.getKnoxContainerManager(KnoxContainerManager.getContainers().get(0));

EmailAccountPolicy emailAccountPolicy = kcm.getEmailAccountPolicy()
emailAccountPolicy.addNewAccount(new EmailAccount(
    "testemail@gmail.com","pop3","pop.gmail.com", 995,
    "testemail@gmail.com", null,"smtp", "smtp.gmail.com",465,
    "testemail@gmail.com",null));

Create COM container with default settings

This sample use case creates a COM container with the default settings.

  1. Create a Knox container using the Container Only Mode.
  2. Call hideSystemBar() to hide the system bar.
KnoxContainerManager.createContainer("knox-b2b-com");
KnoxContainerManager kcm = EnterpriseKnoxManager.getInstance().getKnoxContainerManager(context, containerid);
KioskMode kMode = kcm.getKioskMode();
kMode.hideSystemBar(true);

Clone a COM container

You can also create and customize a container with the clone method. When you clone a container, you select one of the default container types and then add your desired features to it. For example, you may want to change the default password length from 8 characters to 4, or add some custom apps upon creation.

  1. Create a new KnoxConfigurationType.
  2. Install the Calendar and Contacts apps:
  3. Hide the system bar:
  4. Create the custom COM container:
  5. Disable an app such that it is not visible on the launcher:
  6. Install an app from SD card:
  7. Install an app that is already downloaded or sideloaded onto the device:
KnoxConfigurationType typeobj = KnoxContainerManager.getConfigurationTypeByName("knox-b2b-com");
KnoxConfigurationType  newType  = typeobj.clone("custom-b2b-com");

List appList = new ArrayList();
appList.add("com.android.calendar");
appList.add("com.android.contacts");
newType.setAppInstallationList(appList);

if(newType instanceOf ContainerModeConfigurationType){
newType.setHideSystemBar(true); }

KnoxContainerManager.addConfigurationType(Context, newType);
KnoxContainerManager.createContainer("custom-b2b-com");

KnoxContainerManager kcm = EnterpriseKnoxManager.getInstance().getKnoxContainerManager(context, containerid);
ApplicationPolicy aPolicy = mcm.getApplicationPolicy();
aPolicy.setDisableApplication("");

KnoxContainerManager mcm = EnterpriseKnoxManager.getInstance().getKnoxContainerManager(context, containerid);
ApplicationPolicy aPolicy = mcm.getApplicationPolicy();
aPolicy.installApplication("/mnt/sdcard/test.apk", true/false);

KnoxContainerManager mcm = EnterpriseKnoxManager.getInstance().getKnoxContainerManager(context, containerid);
ApplicationPolicy aPolicy = mcm.getApplicationPolicy();
aPolicy.installApplication("package name");

Is this page helpful?