2

I've just gone through the motions of making a Knox Enabled App (KEA) and nothing seems to happen on the device - it just runs like another app. How do I tell if is in-fact Knox Enabled? I understand that my apps should be in their own Knox Container? - is there a way to find that out or test it?

noelicus
  • 14,468
  • 3
  • 92
  • 111

2 Answers2

2

Per the Knox API (Standard or Premium), there is no way to simply query if Knox is already activated. Specifically there is no simple boolean return "knoxlib.isKnoxActivated();"

First of all, let me review how the Knox activation process works:

  1. Your Knox Enabled app needs to call 'activateLicense' for both the ELM & KLM (Enterprise License Management and Knox License Management classes).

  2. The device needs to have a network path to the Knox license server, whether that's Samsung's central one online, or your organizations on-premise Knox license server.

  3. Your Knox Enabled app must have a broadcast receiver to receive a reply from the Knox license server.

Also don't forget to register the broadcast receiver in the Manifest, like this:

<receiver>
    android:name=".KnoxLicenseReceiver"
    android:enabled="true"
    android:exported="true"
    <intent-filter>
        <action android:name="edm.intent.action.license.status" />
        <action android:name="edm.intent.action.knox_license.status" />
    </intent-filter>
</receiver>

Your broadcast receiver class should look something like this below.

public class KnoxLicenseReceiver extends BroadcastReceiver {

    private final String LOGTAG = KnoxLicenseReceiver.class.getSimpleName();

    @Override
    public void onReceive(Context context, Intent intent) {
        SharedPreferences.Editor sharedPrefEditor = context.getSharedPreferences(Constants.SHARED_PREF_NAME, Context.MODE_PRIVATE).edit();
        String action;
        int errorCode;
        if (intent != null) {
            action = intent.getAction();
            if (action != null) {
                // If received an ELM response
                if (EnterpriseLicenseManager.ACTION_LICENSE_STATUS.equals(action)) {
                    errorCode = intent.getIntExtra(EnterpriseLicenseManager.EXTRA_LICENSE_ERROR_CODE, Constants.DEFAULT_ERROR);
                    // If successfully activated
                    if (errorCode == EnterpriseLicenseManager.ERROR_NONE) {
                        Log.i(LOGTAG, "ELM activated successfully.");
                        sharedPrefEditor.putBoolean(Constants.ELM_ACTIVATED, true);
                    } else {
                        Log.i(LOGTAG, "ELM failed to activate with error code: " + errorCode);
                        sharedPrefEditor.putBoolean(Constants.ELM_ACTIVATED, false);
                    }
                }

                // If received a KLM response
                if (KnoxEnterpriseLicenseManager.ACTION_LICENSE_STATUS.equals(action)) {
                    errorCode = intent.getIntExtra(KnoxEnterpriseLicenseManager.EXTRA_LICENSE_ERROR_CODE, Constants.DEFAULT_ERROR);
                    // If successfully activated
                    if (errorCode == KnoxEnterpriseLicenseManager.ERROR_NONE) {
                        Log.i(LOGTAG, "KLM activated successfully.");
                        sharedPrefEditor.putBoolean(Constants.KLM_ACTIVATED, true);
                    } else {
                        Log.i(LOGTAG, "KLM failed to activate with error code: " + errorCode);
                        sharedPrefEditor.putBoolean(Constants.KLM_ACTIVATED, false);
                    }
                }
            }
        }
        // Store shared pref changes
        sharedPrefEditor.apply();
    }
}
Wesley Bunton
  • 135
  • 1
  • 11
  • Another thing you should keep in mind is that Samsung has confirmed on their dev forums (see link), that your Knox enabled app MUST call 'activateLicense', even if another Knox enabled app has already done so on that same device. The licenses do not simply activate Knox for any Knox enabled app on the device, it's specific to the app who calls 'activateLicense'. This does mean that if you have two Knox enabled apps, then you need two Knox licenses to fully activate that single device. https://seap.samsung.com/forum-topic/piggy-backing-activation-possible – Wesley Bunton Oct 13 '17 at 14:33
  • I don't understand, can't you just check if the knox permissions you're requesting have been grant? – Matt Feb 03 '21 at 23:04
0

Just a note - The previous answers requires internet connectivity.
If you deployed solution uses the KNOX OnPremise license server (and not the Cloud Based/Internet option) you will need network connectivity to the On-Premise server.

Jim Row
  • 41
  • 4