// Path: KNOXSampleApp/knoxActivator/src/main/java/com/akexorcist/knoxactivator/KnoxActivationBus.java
// public class KnoxActivationBus {
//     private static KnoxActivationBus knoxActivationBus;
// 
//     public static KnoxActivationBus getInstance() {
//         if (knoxActivationBus == null) {
//             knoxActivationBus = new KnoxActivationBus();
//         }
//         return knoxActivationBus;
//     }
// 
//     private Bus bus;
// 
//     public Bus getBus() {
//         if (bus == null) {
//             bus = new Bus();
//         }
//         return bus;
//     }
// }
// 
// Path: KNOXSampleApp/knoxActivator/src/main/java/com/akexorcist/knoxactivator/event/LicenseActivatedEvent.java
// public class LicenseActivatedEvent { }
// 
// Path: KNOXSampleApp/knoxActivator/src/main/java/com/akexorcist/knoxactivator/event/LicenseActivationFailedEvent.java
// public class LicenseActivationFailedEvent {
//     int errorType;
// 
//     public LicenseActivationFailedEvent(int errorType) {
//         this.errorType = errorType;
//     }
// 
//     public int getErrorType() {
//         return errorType;
//     }
// }


import com.akexorcist.knoxactivator.event.LicenseActivatedEvent;
import com.akexorcist.knoxactivator.event.LicenseActivationFailedEvent;
import android.app.enterprise.license.EnterpriseLicenseManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import com.akexorcist.knoxactivator.KnoxActivationBus;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent != null) {
            String action = intent.getAction();
            if (action != null && action.equals(EnterpriseLicenseManager.ACTION_LICENSE_STATUS)) {
                int errorCode = intent.getIntExtra(EnterpriseLicenseManager.EXTRA_LICENSE_ERROR_CODE, EnterpriseLicenseManager.ERROR_UNKNOWN);
                if (errorCode == EnterpriseLicenseManager.ERROR_NONE) {
                    onLicenseActivated();
                } else {
                    onLicenseActivationFailed(errorCode);
                }
            }
        }
    }

    private void onLicenseActivated() {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                KnoxActivationBus.getInstance().getBus().post(new LicenseActivatedEvent());
            }
        }, EVENT_LISTENER_DELAY);
    }

    private void onLicenseActivationFailed(final int errorCode) {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
// Path: KNOXSampleApp/knoxActivator/src/main/java/com/akexorcist/knoxactivator/KnoxActivationBus.java
// public class KnoxActivationBus {
//     private static KnoxActivationBus knoxActivationBus;
// 
//     public static KnoxActivationBus getInstance() {
//         if (knoxActivationBus == null) {
//             knoxActivationBus = new KnoxActivationBus();
//         }
//         return knoxActivationBus;
//     }
// 
//     private Bus bus;
// 
//     public Bus getBus() {
//         if (bus == null) {
//             bus = new Bus();
//         }
//         return bus;
//     }
// }
// 
// Path: KNOXSampleApp/knoxActivator/src/main/java/com/akexorcist/knoxactivator/event/LicenseActivatedEvent.java
// public class LicenseActivatedEvent { }
// 
// Path: KNOXSampleApp/knoxActivator/src/main/java/com/akexorcist/knoxactivator/event/LicenseActivationFailedEvent.java
// public class LicenseActivationFailedEvent {
//     int errorType;
// 
//     public LicenseActivationFailedEvent(int errorType) {
//         this.errorType = errorType;
//     }
// 
//     public int getErrorType() {
//         return errorType;
//     }
// }


// Path: KNOXSampleApp/knoxActivator/src/main/java/com/akexorcist/knoxactivator/receiver/LicenseActivationReceiver.java
import com.akexorcist.knoxactivator.event.LicenseActivatedEvent;
import com.akexorcist.knoxactivator.event.LicenseActivationFailedEvent;
import android.app.enterprise.license.EnterpriseLicenseManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import com.akexorcist.knoxactivator.KnoxActivationBus;

    }

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent != null) {
            String action = intent.getAction();
            if (action != null && action.equals(EnterpriseLicenseManager.ACTION_LICENSE_STATUS)) {
                int errorCode = intent.getIntExtra(EnterpriseLicenseManager.EXTRA_LICENSE_ERROR_CODE, EnterpriseLicenseManager.ERROR_UNKNOWN);
                if (errorCode == EnterpriseLicenseManager.ERROR_NONE) {
                    onLicenseActivated();
                } else {
                    onLicenseActivationFailed(errorCode);
                }
            }
        }
    }

    private void onLicenseActivated() {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                KnoxActivationBus.getInstance().getBus().post(new LicenseActivatedEvent());
            }
        }, EVENT_LISTENER_DELAY);
    }

    private void onLicenseActivationFailed(final int errorCode) {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                KnoxActivationBus.getInstance().getBus().post(new LicenseActivationFailedEvent(errorCode));