// Path: KNOXSampleApp/knoxActivator/src/main/java/com/akexorcist/knoxactivator/event/AdminDeactivatedEvent.java
// public class AdminDeactivatedEvent { }
// 
// 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/AdminActivationReceiver.java
// public class AdminActivationReceiver extends DeviceAdminReceiver {
//     private static final long EVENT_LISTENER_DELAY = 500;
// 
//     @Override
//     public void onEnabled(Context context, Intent intent) {
//     }
// 
//     @Override
//     public CharSequence onDisableRequested(Context context, Intent intent) {
//         return context.getString(R.string.deactivate_device_admin_warning);
//     }
// 
//     @Override
//     public void onDisabled(Context context, Intent intent) {
//         new Handler().postDelayed(new Runnable() {
//             @Override
//             public void run() {
//                 KnoxActivationBus.getInstance().getBus().post(new AdminDeactivatedEvent());
//             }
//         }, EVENT_LISTENER_DELAY);
//     }
// }


import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.app.enterprise.EnterpriseDeviceManager;
import android.app.enterprise.license.EnterpriseLicenseManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import com.akexorcist.knoxactivator.event.AdminDeactivatedEvent;
import com.akexorcist.knoxactivator.event.LicenseActivatedEvent;
import com.akexorcist.knoxactivator.event.LicenseActivationFailedEvent;
import com.akexorcist.knoxactivator.receiver.AdminActivationReceiver;
import com.squareup.otto.Subscribe;
        }
        return knoxActivationManager;
    }

    private ActivationCallback activationCallback;

    public void register(ActivationCallback callback) {
        activationCallback = callback;
        KnoxActivationBus.getInstance().getBus().register(this);
    }

    public void unregister() {
        activationCallback = null;
        KnoxActivationBus.getInstance().getBus().unregister(this);
    }

    public boolean isDeviceAdminActivated(Context context) {
        DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
        ComponentName componentName = new ComponentName(context, AdminActivationReceiver.class);
        return devicePolicyManager.isAdminActive(componentName);
    }

    @Subscribe
    public void onDeviceAdminDeactivated(AdminDeactivatedEvent event) {
        if (activationCallback != null) {
            activationCallback.onDeviceAdminDeactivated();
        }
    }

    @Subscribe
// Path: KNOXSampleApp/knoxActivator/src/main/java/com/akexorcist/knoxactivator/event/AdminDeactivatedEvent.java
// public class AdminDeactivatedEvent { }
// 
// 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/AdminActivationReceiver.java
// public class AdminActivationReceiver extends DeviceAdminReceiver {
//     private static final long EVENT_LISTENER_DELAY = 500;
// 
//     @Override
//     public void onEnabled(Context context, Intent intent) {
//     }
// 
//     @Override
//     public CharSequence onDisableRequested(Context context, Intent intent) {
//         return context.getString(R.string.deactivate_device_admin_warning);
//     }
// 
//     @Override
//     public void onDisabled(Context context, Intent intent) {
//         new Handler().postDelayed(new Runnable() {
//             @Override
//             public void run() {
//                 KnoxActivationBus.getInstance().getBus().post(new AdminDeactivatedEvent());
//             }
//         }, EVENT_LISTENER_DELAY);
//     }
// }


// Path: KNOXSampleApp/knoxActivator/src/main/java/com/akexorcist/knoxactivator/KnoxActivationManager.java
import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.app.enterprise.EnterpriseDeviceManager;
import android.app.enterprise.license.EnterpriseLicenseManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import com.akexorcist.knoxactivator.event.AdminDeactivatedEvent;
import com.akexorcist.knoxactivator.event.LicenseActivatedEvent;
import com.akexorcist.knoxactivator.event.LicenseActivationFailedEvent;
import com.akexorcist.knoxactivator.receiver.AdminActivationReceiver;
import com.squareup.otto.Subscribe;

        }
        return knoxActivationManager;
    }

    private ActivationCallback activationCallback;

    public void register(ActivationCallback callback) {
        activationCallback = callback;
        KnoxActivationBus.getInstance().getBus().register(this);
    }

    public void unregister() {
        activationCallback = null;
        KnoxActivationBus.getInstance().getBus().unregister(this);
    }

    public boolean isDeviceAdminActivated(Context context) {
        DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
        ComponentName componentName = new ComponentName(context, AdminActivationReceiver.class);
        return devicePolicyManager.isAdminActive(componentName);
    }

    @Subscribe
    public void onDeviceAdminDeactivated(AdminDeactivatedEvent event) {
        if (activationCallback != null) {
            activationCallback.onDeviceAdminDeactivated();
        }
    }

    @Subscribe
    public void onLicenseActivated(LicenseActivatedEvent event) {