// Path: app/src/main/java/com/ryansteckler/nlpunbounce/helpers/RootHelper.java
// public class RootHelper {
//     /**
//      * @author Kevin Kowalewski
//      */
// 
//     private RootHelper() {
//     }
// 
//     public static boolean isDeviceRooted() {
//         return checkRootMethod1() || checkRootMethod2() || checkRootMethod3() || checkRootMethod4();
//     }
// 
//     public static boolean checkRootMethod1() {
//         String buildTags = android.os.Build.TAGS;
//         return buildTags != null && buildTags.contains("test-keys");
//     }
// 
//     public static boolean checkRootMethod2() {
//         try {
//             File file = new File("/system/app/Superuser.apk");
//             return file.exists();
//         } catch (Exception e) {
//             return false;
//         }
//     }
// 
//     public static boolean checkRootMethod4() {
//         try {
//             File file = new File("/system/xbin/su");
//             return file.exists();
//         } catch (Exception e) {
//             return false;
//         }
//     }
// 
//     public static boolean checkRootMethod3() {
//         return new ExecShell().executeCommand(ExecShell.SHELL_CMD.check_su_binary) != null;
//     }
// 
// 
//     public static void handleSELinux() {
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//             Process localProcess = null;
//             try {
// 
//                 Process process = Runtime.getRuntime().exec(new String[]{"su"});
//                 DataOutputStream os = new DataOutputStream(process.getOutputStream());
//                 os.writeBytes("/system/bin/chcon u:object_r:system_data_file:s0 /data/data/com.ryansteckler.nlpunbounce \n");
//                 os.flush();
//                 os.writeBytes("chcon u:object_r:system_data_file:s0 /data/data/com.ryansteckler.nlpunbounce/files \n");
//                 os.flush();
//                 os.writeBytes("chcon u:object_r:system_data_file:s0 /data/data/com.ryansteckler.nlpunbounce/files/nlp* \n");
//                 os.flush();
//                 os.writeBytes("chcon u:object_r:system_data_file:s0 /data/data/com.ryansteckler.nlpunbounce/files/nlp* \n");
//                 os.flush();
//                 os.writeBytes("exit\n");
//                 os.flush();
//                 os.close();
// 
//                 BufferedReader in = new BufferedReader(new InputStreamReader(
//                         process.getInputStream()));
//                 String line;
//                 String fullResponse = "";
//                 try {
//                     while ((line = in.readLine()) != null) {
//                         fullResponse += ("\n" + (line));
//                     }
//                 } catch (Exception e) {
//                     e.printStackTrace();
//                 }
// 
//                 int i = 0;
// 
//             } catch (Exception e) {
//                 e.printStackTrace();
//             }
//         }
//     }
// }


import android.app.IntentService;
import android.content.Intent;
import com.ryansteckler.nlpunbounce.helpers.RootHelper;
package com.ryansteckler.nlpunbounce;



/**
 * Created by rsteckler on 3/2/15.
 */
public class SELinuxService extends IntentService {

    public SELinuxService() {
        super("SeLinuxService");
    }
    /**
     * Creates an IntentService.  Invoked by your subclass's constructor.
     *
     * @param name Used to name the worker thread, important only for debugging.
     */
    public SELinuxService(String name) {
        super(name);
    }

    @Override
    protected void onHandleIntent(Intent workIntent) {
// Path: app/src/main/java/com/ryansteckler/nlpunbounce/helpers/RootHelper.java
// public class RootHelper {
//     /**
//      * @author Kevin Kowalewski
//      */
// 
//     private RootHelper() {
//     }
// 
//     public static boolean isDeviceRooted() {
//         return checkRootMethod1() || checkRootMethod2() || checkRootMethod3() || checkRootMethod4();
//     }
// 
//     public static boolean checkRootMethod1() {
//         String buildTags = android.os.Build.TAGS;
//         return buildTags != null && buildTags.contains("test-keys");
//     }
// 
//     public static boolean checkRootMethod2() {
//         try {
//             File file = new File("/system/app/Superuser.apk");
//             return file.exists();
//         } catch (Exception e) {
//             return false;
//         }
//     }
// 
//     public static boolean checkRootMethod4() {
//         try {
//             File file = new File("/system/xbin/su");
//             return file.exists();
//         } catch (Exception e) {
//             return false;
//         }
//     }
// 
//     public static boolean checkRootMethod3() {
//         return new ExecShell().executeCommand(ExecShell.SHELL_CMD.check_su_binary) != null;
//     }
// 
// 
//     public static void handleSELinux() {
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//             Process localProcess = null;
//             try {
// 
//                 Process process = Runtime.getRuntime().exec(new String[]{"su"});
//                 DataOutputStream os = new DataOutputStream(process.getOutputStream());
//                 os.writeBytes("/system/bin/chcon u:object_r:system_data_file:s0 /data/data/com.ryansteckler.nlpunbounce \n");
//                 os.flush();
//                 os.writeBytes("chcon u:object_r:system_data_file:s0 /data/data/com.ryansteckler.nlpunbounce/files \n");
//                 os.flush();
//                 os.writeBytes("chcon u:object_r:system_data_file:s0 /data/data/com.ryansteckler.nlpunbounce/files/nlp* \n");
//                 os.flush();
//                 os.writeBytes("chcon u:object_r:system_data_file:s0 /data/data/com.ryansteckler.nlpunbounce/files/nlp* \n");
//                 os.flush();
//                 os.writeBytes("exit\n");
//                 os.flush();
//                 os.close();
// 
//                 BufferedReader in = new BufferedReader(new InputStreamReader(
//                         process.getInputStream()));
//                 String line;
//                 String fullResponse = "";
//                 try {
//                     while ((line = in.readLine()) != null) {
//                         fullResponse += ("\n" + (line));
//                     }
//                 } catch (Exception e) {
//                     e.printStackTrace();
//                 }
// 
//                 int i = 0;
// 
//             } catch (Exception e) {
//                 e.printStackTrace();
//             }
//         }
//     }
// }


// Path: app/src/main/java/com/ryansteckler/nlpunbounce/SELinuxService.java
import android.app.IntentService;
import android.content.Intent;
import com.ryansteckler.nlpunbounce.helpers.RootHelper;

package com.ryansteckler.nlpunbounce;



/**
 * Created by rsteckler on 3/2/15.
 */
public class SELinuxService extends IntentService {

    public SELinuxService() {
        super("SeLinuxService");
    }
    /**
     * Creates an IntentService.  Invoked by your subclass's constructor.
     *
     * @param name Used to name the worker thread, important only for debugging.
     */
    public SELinuxService(String name) {
        super(name);
    }

    @Override
    protected void onHandleIntent(Intent workIntent) {
        RootHelper.handleSELinux();