Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 22.68 KB | None | 0 0
  1. package com.android.gaospconf;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.File;
  5. import java.io.FileNotFoundException;
  6. import java.io.FileReader;
  7. import java.io.FileWriter;
  8. import java.io.IOException;
  9. import java.io.PrintWriter;
  10. import android.app.Activity;
  11. import android.app.AlertDialog;
  12. import android.app.ProgressDialog;
  13. import android.content.Context;
  14. import android.content.pm.ActivityInfo;
  15. import android.os.Bundle;
  16. import android.os.PowerManager;
  17. import android.os.SystemClock;
  18. import android.util.Log;
  19. import android.view.Menu;
  20. import android.view.MenuInflater;
  21. import android.view.MenuItem;
  22. import android.view.View;
  23. import android.widget.ArrayAdapter;
  24. import android.widget.Button;
  25. import android.widget.CheckBox;
  26. import android.widget.CompoundButton;
  27. import android.widget.EditText;
  28. import android.widget.TextView;
  29. import android.widget.Toast;
  30. import android.widget.ToggleButton;
  31. import android.widget.CompoundButton.OnCheckedChangeListener;
  32.  
  33. public class conf extends Activity {
  34.     /** Called when the activity is first created. */
  35.    
  36.     public void onCreate(Bundle savedInstanceState) {
  37.         super.onCreate(savedInstanceState);
  38.         setContentView(R.layout.main);
  39.        
  40.         // Define variables
  41.         String record = null;
  42.         int recCount = 0;
  43.        
  44.         Boolean compcache = false;
  45.         String compcache_disksize = null;
  46.         int cpu_sampling = 0;
  47.         Boolean swap = false;
  48.         Boolean ssh = false;
  49.         Boolean inadyn = false;
  50.         Boolean renice = false;
  51.         Boolean prov = false;
  52.         Boolean vnc = false;
  53.         Boolean overclocking = false;
  54.         Boolean overclocking2 = false;
  55.         int sensors_sampling = 0;
  56.  
  57.         // Define objects
  58.         Button Default_Button = (Button) findViewById(R.id.defaults);
  59.         Button Apply_Button = (Button) findViewById(R.id.apply);
  60.         Button OK_Button = (Button) findViewById(R.id.Buttondesc);
  61.         final ToggleButton Toggle_Compcache = (ToggleButton) findViewById(R.id.comp);
  62.         final EditText compcache_disksize_edit = (EditText) findViewById(R.id.disksize);
  63.         final CheckBox Check_sampling_eco = (CheckBox) findViewById(R.id.sampling01);
  64.         final CheckBox Check_sampling_mix = (CheckBox) findViewById(R.id.sampling02);
  65.         final CheckBox Check_sampling_perf = (CheckBox) findViewById(R.id.sampling03);
  66.         final ToggleButton Toggle_SSH = (ToggleButton) findViewById(R.id.ssh);
  67.         final ToggleButton Toggle_Renice = (ToggleButton) findViewById(R.id.renice);
  68.         final ToggleButton Toggle_Prov = (ToggleButton) findViewById(R.id.Prov);
  69.         final ToggleButton Toggle_VNC = (ToggleButton) findViewById(R.id.vnc);
  70.         final ToggleButton Toggle_Swap = (ToggleButton) findViewById(R.id.swap);    
  71.         final ToggleButton Toggle_OverClocking = (ToggleButton) findViewById(R.id.oc1);
  72.         final ToggleButton Toggle_OverClocking2 = (ToggleButton) findViewById(R.id.oc2);
  73.         final CheckBox Check_sensors_sampling_eco = (CheckBox) findViewById(R.id.sensors04);
  74.         final CheckBox Check_sensors_sampling_mix = (CheckBox) findViewById(R.id.sensors05);
  75.         final CheckBox Check_sensors_sampling_perf = (CheckBox) findViewById(R.id.sensors06);
  76.                
  77.         // On ouvre le fichier de config
  78.         FileReader FR = null;
  79.         try {
  80.             FR = new FileReader("/system/etc/gaosp.conf");
  81.         } catch (FileNotFoundException e) {
  82.             e.printStackTrace();
  83.         }
  84.         BufferedReader BR = new BufferedReader(FR);
  85.        
  86.         // On stocke les varialbe du fichier de conf
  87.         try {
  88.             while ((record = BR.readLine()) != null) {
  89.                 recCount++;
  90.                 if (record.equals("compcache=yes")) {
  91.                     compcache = true;
  92.                 }
  93.                 if (record.equals("compcache=no")) {
  94.                     compcache = false;
  95.                 }
  96.                 if (record.startsWith("compcache_disksize=")) {
  97.                     compcache_disksize = record.substring(19);
  98.                 }
  99.                 if (record.startsWith("cpu_sampling=")) {
  100.                     cpu_sampling = Integer.parseInt(record.substring(13));
  101.                 }
  102.                 if (record.equals("sshd=no")) {
  103.                     ssh = false;
  104.                 }
  105.                 if (record.equals("sshd=yes")) {
  106.                     ssh = true;
  107.                 }
  108.                 if (record.equals("inadyn=no")) {
  109.                     inadyn = false;
  110.                 }
  111.                 if (record.equals("inadyn=yes")) {
  112.                     inadyn = true;
  113.                 }
  114.                 if (record.equals("renice=no")) {
  115.                     renice = false;
  116.                 }
  117.                 if (record.equals("renice=yes")) {
  118.                     renice = true;
  119.                 }
  120.                 if (record.equals("provisionned=no")) {
  121.                     prov = false;
  122.                 }
  123.                 if (record.equals("provisionned=yes")) {
  124.                     prov = true;
  125.                 }
  126.                 if (record.equals("vnc=no")) {
  127.                     vnc = false;
  128.                 }
  129.                 if (record.equals("vnc=yes")) {
  130.                     vnc = true;
  131.                 }
  132.                 if (record.equals("overclocking=yes")) {
  133.                     overclocking = true;
  134.                 }
  135.                 if (record.equals("overclocking=no")) {
  136.                     overclocking = false;
  137.                 }
  138.                 if (record.equals("overclocking2=yes")) {
  139.                     overclocking2 = true;
  140.                 }
  141.                 if (record.equals("overclocking2=no")) {
  142.                     overclocking2 = false;
  143.                 }
  144.                 if (record.startsWith("sensors_sampling=")) {
  145.                     sensors_sampling = Integer.parseInt(record.substring(17));
  146.                 }
  147.                 if (record.equals("swap=no")) {
  148.                     swap = false;
  149.                 }
  150.                 if (record.equals("swap=yes")) {
  151.                     swap = true;
  152.                 }
  153.              }
  154.         } catch (IOException e) {
  155.             e.printStackTrace();
  156.         }
  157.  
  158.         // On remplit et valide les champs et autres
  159.         compcache_disksize_edit.setText(compcache_disksize);
  160.         if (compcache == true) {
  161.             Toggle_Compcache.setChecked(true);
  162.         }
  163.         if (cpu_sampling == 0) {
  164.             Check_sampling_eco.setChecked(true);
  165.         }
  166.         if (cpu_sampling == 1) {
  167.             Check_sampling_mix.setChecked(true);
  168.         }
  169.         if (cpu_sampling == 2) {
  170.             Check_sampling_perf.setChecked(true);
  171.         }
  172.         if (ssh == true) {
  173.             Toggle_SSH.setChecked(true);
  174.         }
  175.         if (renice == true) {
  176.             Toggle_Renice.setChecked(true);
  177.         }
  178.         if (prov == true) {
  179.             Toggle_Prov.setChecked(true);
  180.         }
  181.         if (vnc == true) {
  182.             Toggle_VNC.setChecked(true);
  183.         }
  184.         // Enable Disk size if Compcache is enabled
  185.         if (Toggle_Compcache.isChecked()) {
  186.             compcache_disksize_edit.setEnabled(true);
  187.         }
  188.         if (! Toggle_Compcache.isChecked()) {
  189.             compcache_disksize_edit.setEnabled(false);
  190.         }
  191.         if (overclocking == true) {
  192.             Toggle_OverClocking.setChecked(true);
  193.         }
  194.         if (overclocking2 == true) {
  195.             Toggle_OverClocking2.setChecked(true);
  196.         }
  197.         // Enable only 1 Overclocking option
  198.         if (Toggle_OverClocking.isChecked()) {
  199.             Toggle_OverClocking2.setChecked(false);
  200.         }
  201.         if (Toggle_OverClocking2.isChecked()) {
  202.             Toggle_OverClocking.setChecked(false);
  203.         }
  204.         if (sensors_sampling == 0) {
  205.             Check_sensors_sampling_eco.setChecked(true);
  206.         }
  207.         if (sensors_sampling == 1) {
  208.             Check_sensors_sampling_mix.setChecked(true);
  209.         }
  210.         if (sensors_sampling == 2) {
  211.             Check_sensors_sampling_perf.setChecked(true);
  212.         }
  213.         if (swap == true) {
  214.             Toggle_Swap.setChecked(true);
  215.         }
  216.         // Disable Compcache if Swap only is enabled
  217.         if (Toggle_Swap.isChecked()) {
  218.             Toggle_Compcache.setEnabled(false);
  219.             Toggle_Compcache.setChecked(false);
  220.         }
  221.         if (! Toggle_Swap.isChecked()) {
  222.             Toggle_Compcache.setEnabled(true);
  223.         }
  224.        
  225.         // Listener
  226.         final onClick self = this;
  227.         TextView comptext = (TextView) findViewById(R.id.comptext);
  228.         comptext.setOnClickListener(new View.OnClickListener() {
  229.         public void onClick(View v){
  230.             AlertDialog.Builder alertbox = new AlertDialog.Builder(this).create();
  231.             alertbox.setTitle("Compcache");
  232.             alertbox.setMessage("Description ....");
  233.        
  234.             public void onClick(DialogInterface dialog, int which) {
  235.                 return;
  236.             }      
  237.             alertbox.show();
  238.             }
  239.         });      
  240.        
  241.         Default_Button.setOnClickListener(new View.OnClickListener() {
  242.             public void onClick(View v) {
  243.                 Toggle_Compcache.setChecked(false);
  244.                 compcache_disksize_edit.setEnabled(false);
  245.                 compcache_disksize_edit.setText("25600");
  246.                 Check_sampling_eco.setChecked(false);
  247.                 Check_sampling_mix.setChecked(false);
  248.                 Check_sampling_perf.setChecked(true);
  249.                 Toggle_SSH.setChecked(false);
  250.                 Toggle_Renice.setChecked(true);
  251.                 Toggle_Prov.setChecked(true);
  252.                 Toggle_VNC.setChecked(false);
  253.                 Toggle_OverClocking.setChecked(false);
  254.                 Toggle_OverClocking2.setChecked(false);
  255.                 Check_sensors_sampling_eco.setChecked(true);
  256.                 Check_sensors_sampling_mix.setChecked(false);
  257.                 Check_sensors_sampling_perf.setChecked(false);
  258.                 Toggle_Swap.setChecked(false);
  259.             }
  260.         });  
  261.         Apply_Button.setOnClickListener(new View.OnClickListener() {
  262.             public void onClick(View v) {
  263.                 PrintWriter out = null;
  264.                
  265.                 CharSequence str = "Applying parameters, please wait..";
  266.                 Toast.makeText(getBaseContext(), str,
  267.                 Toast.LENGTH_SHORT).show();
  268.                
  269.                 if (Integer.parseInt(compcache_disksize_edit.getText().toString()) > 90000) {
  270.                     CharSequence strpre = "Compcache disksize is too big";
  271.                     Toast.makeText(getBaseContext(), strpre,
  272.                     Toast.LENGTH_SHORT).show();
  273.                 }
  274.                 else {
  275.                                                
  276.                     // Remount en rw
  277.                    
  278.                     String[] commande = { "/system/xbin/su -c /system/xbin/remountrw", "echo done"};
  279.                     shell.doExec(commande, true);
  280.                    
  281.                     //NativeTask.runCommand("/system/xbin/su -c /system/xbin/remountrw");
  282.                    
  283.                     try {
  284.                         out  = new PrintWriter(new FileWriter("/system/etc/gaosp.conf"));
  285.                     } catch (IOException e) {
  286.                         e.printStackTrace();
  287.                     }
  288.                    
  289.                     out.println("################################");
  290.                     out.println("##### Gaosp config file ########");
  291.                     out.println("################################");
  292.                     out.println(" ");
  293.                     out.println("# Compcache");
  294.                    
  295.                     // Ecriture de la conf compcache
  296.                     if (Toggle_Compcache.isChecked()) {
  297.                         out.println("compcache=yes");  
  298.                     /*  NativeTask.runCommand("/system/xbin/su -c 'swapoff /dev/block/ramzswap0'");
  299.                         NativeTask.runCommand("/system/xbin/su -c 'rmmod ramzswap'");
  300.                         NativeTask.runCommand("/system/xbin/su -c 'rmmod xvmalloc'");  
  301.                         NativeTask.runCommand("/system/xbin/su -c 'insmod /system/libmodules/xvmalloc.ko'");
  302.                         NativeTask.runCommand("/system/xbin/su -c 'if [ -r /dev/block/mmcblk1p2 ]; then mkswap /dev/block/mmcblk1p2; insmod /system/libmodules/ramzswap.ko memlimit_kb= " + compcache_disksize_edit.getText() + " backing_swap=/dev/block/mmcblk1p2;    else insmod /system/libmodules/ramzswap.ko disksize_kb=" + compcache_disksize_edit.getText() + "; fi; sleep 5'");      
  303.                         NativeTask.runCommand("/system/xbin/su -c 'swapon /dev/block/ramzswap0 -p 100'");
  304.                     */
  305.                     }
  306.                     else {
  307.                         out.println("compcache=no");
  308.                     /*
  309.                         NativeTask.runCommand("/system/xbin/su -c 'swapoff /dev/block/ramzswap0'");
  310.                         NativeTask.runCommand("/system/xbin/su -c 'rmmod ramzswap'");
  311.                         NativeTask.runCommand("/system/xbin/su -c 'rmmod xvmalloc'");  
  312.                     */
  313.                     }
  314.                    
  315.                     out.println("compcache_disksize=" + compcache_disksize_edit.getText());
  316.                     out.println(" ");
  317.                     // Ecriture de la conf cpufreq
  318.                     int final_sampling = 0;
  319.                    
  320.                     //NativeTask.runCommand("/system/xbin/su -c 'echo 2000000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'");            
  321.                    
  322.                     if (Check_sampling_eco.isChecked()) {
  323.                         final_sampling = 0;
  324.                     //  NativeTask.runCommand("/system/xbin/su -c 'echo 2000000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'");
  325.                     }
  326.                     if (Check_sampling_mix.isChecked()) {
  327.                         final_sampling = 1;
  328.                     //  NativeTask.runCommand("/system/xbin/su -c 'echo 500000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'");
  329.                     }
  330.                     if (Check_sampling_perf.isChecked()) {
  331.                         final_sampling = 2;
  332.                     //  NativeTask.runCommand("/system/xbin/su -c 'echo 100000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'");
  333.  
  334.                     }
  335.                     out.println("# CpuFreq sampling rate");
  336.                     out.println("# Set to 0 to eco mode, 1 to mixte mode, 2 to Performance mode ");
  337.                     out.println("cpu_sampling=" + final_sampling);
  338.                     out.println(" ");
  339.    
  340.                     // Ecriture de la conf sshd et execution
  341.                     out.println("# SSH server");
  342.                     if (Toggle_SSH.isChecked()) {
  343.                         out.println("sshd=yes");
  344.                         /*
  345.                         NativeTask.runCommand("/system/xbin/su -c 'kill -9 `pidof dropbear`'");
  346.                         NativeTask.runCommand("/system/xbin/su -c 'if [ ! -d /data/ssh/ ]; then /system/bin/mkdir /data/ssh/; fi'");
  347.                         NativeTask.runCommand("/system/xbin/su -c 'if [ ! -f /data/ssh/rsa_host_key ]; then /system/xbin/dropbearkey -t rsa -f /data/ssh/rsa_host_key; fi'");
  348.                         NativeTask.runCommand("/system/xbin/su -c 'if [ ! -f /data/ssh/dss_host_key ]; then /system/xbin/dropbearkey -t dss -f /data/ssh/dss_host_key; fi'");
  349.                         NativeTask.runCommand("/system/xbin/su -c '/system/bin/logwrapper /system/xbin/dropbear &'");
  350.                         */
  351.                     }
  352.                     else {
  353.                         out.println("sshd=no");
  354.                         /*
  355.                         NativeTask.runCommand("/system/xbin/su -c 'kill -9 `pidof dropbear`'");
  356.                         */
  357.                     }
  358.                     out.println(" ");
  359.                    
  360.                     // Ecriture de la conf inadyn
  361.                     out.println("# Inadyn");
  362.                     out.println("inadyn=no");
  363.                     out.println(" ");
  364.                    
  365.                     // Ecriture de la conf Renice
  366.                     out.println("# Renice");
  367.                     if (Toggle_Renice.isChecked()) {
  368.                         out.println("renice=yes");
  369.                         /*
  370.                         NativeTask.runCommand("/system/xbin/su -c 'renice -20 `pidof com.android.mms'");
  371.                         NativeTask.runCommand("/system/xbin/su -c 'renice -19 `pidof com.android.phone`'");
  372.                         NativeTask.runCommand("/system/xbin/su -c 'renice -18 `pidof mediaserver`");
  373.                         NativeTask.runCommand("/system/xbin/su -c 'renice 0 `pidof com.google.process.gapps`'");
  374.                         */
  375.                     }
  376.                     else {
  377.                         out.println("renice=no");
  378.                         /*
  379.                         NativeTask.runCommand("/system/xbin/su -c 'renice 0 `pidof com.android.mms'");
  380.                         NativeTask.runCommand("/system/xbin/su -c 'renice 0 `pidof com.android.phone`'");
  381.                         NativeTask.runCommand("/system/xbin/su -c 'renice 0 `pidof mediaserver`");
  382.                         NativeTask.runCommand("/system/xbin/su -c 'renice 0 `pidof com.google.process.gapps`'");
  383.                         */
  384.                     }
  385.                     out.println(" ");
  386.                    
  387.                     // Ecriture de la conf provisionned
  388.                     out.println("# Device provisionned");
  389.                     if (Toggle_Renice.isChecked()) {
  390.                         out.println("provisionned=yes");
  391.                     }
  392.                     else {
  393.                         out.println("provisionned=no");
  394.                     }
  395.                     out.println(" ");
  396.                    
  397.                     // Ecriture de la conf vnc et execution
  398.                     out.println("# VNC Server");
  399.                     if (Toggle_VNC.isChecked()) {
  400.                         out.println("vnc=yes");
  401.                         /*
  402.                         NativeTask.runCommand("/system/xbin/su -c 'kill -9 `pidof fbvncserver`'");
  403.                         NativeTask.runCommand("/system/xbin/su -c '/system/bin/logwrapper /system/xbin/fbvncserver &'");
  404.                         */
  405.                     }
  406.                     else {
  407.                         out.println("vnc=no");
  408.                         /*
  409.                         NativeTask.runCommand("/system/xbin/su -c 'kill -9 `pidof fbvncserver`'");
  410.                         */
  411.                     }
  412.                     out.println(" ");
  413.                    
  414.                     // Copying swap setting to conf file
  415.                     out.println("# Swap");
  416.                     if (Toggle_Swap.isChecked()) {
  417.                         out.println("swap=yes");
  418.                     }
  419.                     else {
  420.                         out.println("swap=no");
  421.                     }
  422.                     out.println(" ");
  423.                    
  424.                     // Ecriture de la conf overclocking et execution
  425.                     out.println("# Overclocking");
  426.                     if (Toggle_OverClocking.isChecked()) {
  427.                         out.println("overclocking=yes");
  428.                         /*
  429.                         NativeTask.runCommand("/system/xbin/su -c 'echo 614400 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq'");
  430.                         */
  431.                     }
  432.                     else {
  433.                         out.println("overclocking=no");
  434.                         /*
  435.                         NativeTask.runCommand("/system/xbin/su -c 'echo 528000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq'");
  436.                         */
  437.                     }
  438.                     out.println(" ");
  439.                     // Ecriture de la conf overclocking2 et execution
  440.                     out.println("# Overclocking2");
  441.                     if (Toggle_OverClocking2.isChecked()) {
  442.                         out.println("overclocking2=yes");
  443.                         /*
  444.                         NativeTask.runCommand("/system/xbin/su -c 'echo 614400 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq'");
  445.                         */
  446.                     }
  447.                     else {
  448.                         out.println("overclocking2=no");
  449.                         /*
  450.                         NativeTask.runCommand("/system/xbin/su -c 'echo 528000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq'");
  451.                         */
  452.                     }
  453.                     out.println(" ");
  454.                     // Ecriture de la conf cpufreq
  455.                     int final_sensors_sampling = 0;
  456.                    
  457.                     //NativeTask.runCommand("/system/xbin/su -c 'echo 2000000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'");            
  458.                    
  459.                     if (Check_sensors_sampling_eco.isChecked()) {
  460.                         final_sensors_sampling = 0;
  461.                     //  NativeTask.runCommand("/system/xbin/su -c 'echo 2000000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'");
  462.                     }
  463.                     if (Check_sensors_sampling_mix.isChecked()) {
  464.                         final_sensors_sampling = 1;
  465.                     //  NativeTask.runCommand("/system/xbin/su -c 'echo 500000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'");
  466.                     }
  467.                     if (Check_sensors_sampling_perf.isChecked()) {
  468.                         final_sensors_sampling = 2;
  469.                     //  NativeTask.runCommand("/system/xbin/su -c 'echo 100000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'");
  470.  
  471.                     }
  472.                     out.println("# Sensors sampling rate");
  473.                     out.println("# Set to 0 to eco mode, 1 to mixte mode, 2 to Performance mode ");
  474.                     out.println("sensors_sampling=" + final_sensors_sampling);
  475.                     out.println(" ");
  476.                    
  477.                    
  478.                     // Execution du rc avec defilement
  479.                     new Task().execute();
  480.                
  481.                     // Fermeture du fichier
  482.                     out.flush();
  483.                     out.close();
  484.                    
  485.                     // Remount en ro
  486.                     NativeTask.runCommand("/system/xbin/su -c /system/xbin/remountro");
  487.  
  488.                 }
  489.             }
  490.         });  
  491.        
  492.        
  493.         Check_sampling_eco.setOnCheckedChangeListener(new OnCheckedChangeListener()
  494.         {
  495.                 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  496.                     Check_sampling_mix.setChecked(false);
  497.                     Check_sampling_perf.setChecked(false); 
  498.             }
  499.         });
  500.         Check_sampling_mix.setOnCheckedChangeListener(new OnCheckedChangeListener()
  501.         {
  502.                 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  503.                     Check_sampling_eco.setChecked(false);
  504.                     Check_sampling_perf.setChecked(false);
  505.             }
  506.         });
  507.         Check_sampling_perf.setOnCheckedChangeListener(new OnCheckedChangeListener()
  508.         {
  509.                 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  510.                     Check_sampling_mix.setChecked(false);
  511.                     Check_sampling_eco.setChecked(false);
  512.             }
  513.         });
  514.         Check_sensors_sampling_eco.setOnCheckedChangeListener(new OnCheckedChangeListener()
  515.         {
  516.                 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  517.                     Check_sensors_sampling_mix.setChecked(false);
  518.                     Check_sensors_sampling_perf.setChecked(false); 
  519.             }
  520.         });
  521.         Check_sensors_sampling_mix.setOnCheckedChangeListener(new OnCheckedChangeListener()
  522.         {
  523.                 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  524.                     Check_sensors_sampling_eco.setChecked(false);
  525.                     Check_sensors_sampling_perf.setChecked(false);
  526.             }
  527.         });
  528.         Check_sensors_sampling_perf.setOnCheckedChangeListener(new OnCheckedChangeListener()
  529.         {
  530.                 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  531.                     Check_sensors_sampling_mix.setChecked(false);
  532.                     Check_sensors_sampling_eco.setChecked(false);
  533.             }
  534.         });
  535.         Toggle_Swap.setOnCheckedChangeListener(new OnCheckedChangeListener()
  536.         {
  537.             public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  538.                 if (Toggle_Swap.isChecked()) {
  539.                     Toggle_Compcache.setEnabled(false);
  540.                     Toggle_Compcache.setChecked(false);
  541.                 }
  542.                 if (! Toggle_Swap.isChecked()) {
  543.                     Toggle_Compcache.setEnabled(true);
  544.                 }
  545.             }
  546.         });
  547.         Toggle_OverClocking.setOnCheckedChangeListener(new OnCheckedChangeListener()
  548.         {
  549.             public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  550.                 if (Toggle_OverClocking.isChecked()) {
  551.                     Toggle_OverClocking2.setChecked(false);
  552.                 }
  553.             }
  554.         });    
  555.         Toggle_OverClocking2.setOnCheckedChangeListener(new OnCheckedChangeListener()
  556.         {
  557.             public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  558.                 if (Toggle_OverClocking2.isChecked()) {
  559.                     Toggle_OverClocking.setChecked(false);
  560.                 }
  561.             }
  562.         });
  563.         Toggle_Compcache.setOnCheckedChangeListener(new OnCheckedChangeListener()
  564.         {
  565.                 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  566.                     if (Toggle_Compcache.isChecked()) {
  567.                         compcache_disksize_edit.setEnabled(true);
  568.                     }
  569.                     if (! Toggle_Compcache.isChecked()) {
  570.                         compcache_disksize_edit.setEnabled(false);
  571.                     }
  572.             }
  573.         });
  574.     }
  575.    
  576.  
  577.     public boolean onCreateOptionsMenu(Menu menu)
  578.     {
  579.         super.onCreateOptionsMenu(menu);
  580.         MenuItem item = menu.add("About");
  581.         item = menu.add("Exit");
  582.         MenuInflater inflater = new MenuInflater(this);
  583.         return true;
  584.     }
  585.    
  586.     public boolean onOptionsItemSelected(MenuItem item)
  587.       {
  588.          if (item.hasSubMenu() == false)
  589.          {
  590.             if (item.getTitle() == "About") {
  591.                 // Print the about
  592.                 AlertDialog.Builder dialogBuilder = new
  593.                 AlertDialog.Builder(this);
  594.                 dialogBuilder.setMessage("GAOSP Configuration by drakaz and Obihoernchen");
  595.                 dialogBuilder.setCancelable(true);
  596.                 dialogBuilder.create().show();
  597.             }
  598.             if (item.getTitle() == "Exit") {
  599.                 this.finish();
  600.             }
  601.          }
  602.          // Consume the selection event.
  603.          return true;
  604.        }
  605.    
  606.     final class Task extends UserTask<String, Void, Void> {
  607.  
  608.         ProgressDialog myProgressDialog;
  609.        
  610.          protected void onPreExecute() {
  611.                  myProgressDialog = ProgressDialog.show(conf.this,"", "Please wait..", true, true);
  612.             }
  613.        
  614.         @Override
  615.         protected Void doInBackground(String... params) {
  616.             String[] commande = { "/system/xbin/su -c /system/bin/rc"};
  617.             shell.doExec(commande, true);
  618.             //NativeTask.runCommand("/system/xbin/su -c /system/bin/rc");
  619.             return null;
  620.         }
  621.        
  622.         protected void onPostExecute(Void unused) {
  623.                
  624.                 if (myProgressDialog.isShowing()) {
  625.                     myProgressDialog.dismiss();
  626.                     CharSequence str2 = "New config saved and applied";
  627.                     Toast.makeText(getBaseContext(), str2,
  628.                     Toast.LENGTH_SHORT).show();
  629.                     try {
  630.                         Thread.sleep(5000);
  631.                         finish();
  632.                     } catch (Throwable e) {
  633.                         // TODO Auto-generated catch block
  634.                         e.printStackTrace();
  635.                     }
  636.                 }
  637.         }
  638.     }
  639. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement