// 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/AdminDeactivatedEvent.java
// public class AdminDeactivatedEvent { }


import com.akexorcist.knoxactivator.event.AdminDeactivatedEvent;
import android.app.admin.DeviceAdminReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import com.akexorcist.knoxactivator.KnoxActivationBus;
import com.akexorcist.knoxactivator.R;
/**
 * DISCLAIMER: PLEASE TAKE NOTE THAT THE SAMPLE APPLICATION AND
 * SOURCE CODE DESCRIBED HEREIN IS PROVIDED FOR TESTING PURPOSES ONLY.
 * <p/>
 * Samsung expressly disclaims any and all warranties of any kind,
 * whether express or implied, including but not limited to the implied warranties and conditions
 * of merchantability, fitness for a particular purpose and non-infringement.
 * Further, Samsung does not represent or warrant that any portion of the sample application and
 * source code is free of inaccuracies, errors, bugs or interruptions, or is reliable,
 * accurate, complete, or otherwise valid. The sample application and source code is provided
 * "as is" and "as available", without any warranty of any kind from Samsung.
 * <p/>
 * Your use of the sample application and source code is at its own discretion and risk,
 * and licensee will be solely responsible for any damage that results from the use of the sample
 * application and source code including, but not limited to, any damage to your computer system or
 * platform. For the purpose of clarity, the sample code is licensed “as is” and
 * licenses bears the risk of using it.
 * <p/>
 * Samsung shall not be liable for any direct, indirect or consequential damages or
 * costs of any type arising out of any action taken by you or others related to the sample application
 * and source code.
 */

package com.akexorcist.knoxactivator.receiver;



//This BroadcastReceiver handles device admin activation and deactivation

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() {
// 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/AdminDeactivatedEvent.java
// public class AdminDeactivatedEvent { }


// Path: KNOXSampleApp/knoxActivator/src/main/java/com/akexorcist/knoxactivator/receiver/AdminActivationReceiver.java
import com.akexorcist.knoxactivator.event.AdminDeactivatedEvent;
import android.app.admin.DeviceAdminReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import com.akexorcist.knoxactivator.KnoxActivationBus;
import com.akexorcist.knoxactivator.R;

/**
 * DISCLAIMER: PLEASE TAKE NOTE THAT THE SAMPLE APPLICATION AND
 * SOURCE CODE DESCRIBED HEREIN IS PROVIDED FOR TESTING PURPOSES ONLY.
 * <p/>
 * Samsung expressly disclaims any and all warranties of any kind,
 * whether express or implied, including but not limited to the implied warranties and conditions
 * of merchantability, fitness for a particular purpose and non-infringement.
 * Further, Samsung does not represent or warrant that any portion of the sample application and
 * source code is free of inaccuracies, errors, bugs or interruptions, or is reliable,
 * accurate, complete, or otherwise valid. The sample application and source code is provided
 * "as is" and "as available", without any warranty of any kind from Samsung.
 * <p/>
 * Your use of the sample application and source code is at its own discretion and risk,
 * and licensee will be solely responsible for any damage that results from the use of the sample
 * application and source code including, but not limited to, any damage to your computer system or
 * platform. For the purpose of clarity, the sample code is licensed “as is” and
 * licenses bears the risk of using it.
 * <p/>
 * Samsung shall not be liable for any direct, indirect or consequential damages or
 * costs of any type arising out of any action taken by you or others related to the sample application
 * and source code.
 */

package com.akexorcist.knoxactivator.receiver;



//This BroadcastReceiver handles device admin activation and deactivation

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());