/
conf.java
executable file
·915 lines (868 loc) · 33.9 KB
/
conf.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
package com.android.gaospconf;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
public class conf extends Activity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Define variables
String record = null;
int recCount = 0;
Boolean compcache = false;
String compcache_disksize = null;
Boolean overclocking = false;
Boolean overclocking2 = false;
int cpu_sampling = 0;
int sensors_sampling = 0;
Boolean ssh = false;
Boolean inadyn = false;
Boolean renice = false;
Boolean prov = false;
Boolean vnc = false;
Boolean swap = false;
Boolean bootani = false;
// Define objects
Button Default_Button = (Button) findViewById(R.id.defaults);
Button Apply_Button = (Button) findViewById(R.id.apply);
Button Service_Button = (Button) findViewById(R.id.service);
Button Kitchen_Button = (Button) findViewById(R.id.kitchen);
final ToggleButton Toggle_Compcache = (ToggleButton) findViewById(R.id.comp);
final EditText compcache_disksize_edit = (EditText) findViewById(R.id.disksize);
final CheckBox Check_sampling_eco = (CheckBox) findViewById(R.id.sampling01);
final CheckBox Check_sampling_mix = (CheckBox) findViewById(R.id.sampling02);
final CheckBox Check_sampling_perf = (CheckBox) findViewById(R.id.sampling03);
final ToggleButton Toggle_SSH = (ToggleButton) findViewById(R.id.ssh);
final ToggleButton Toggle_Renice = (ToggleButton) findViewById(R.id.renice);
final ToggleButton Toggle_Prov = (ToggleButton) findViewById(R.id.Prov);
final ToggleButton Toggle_VNC = (ToggleButton) findViewById(R.id.vnc);
final ToggleButton Toggle_Swap = (ToggleButton) findViewById(R.id.swap);
final ToggleButton Toggle_OverClocking = (ToggleButton) findViewById(R.id.oc1);
final ToggleButton Toggle_OverClocking2 = (ToggleButton) findViewById(R.id.oc2);
final CheckBox Check_sensors_sampling_eco = (CheckBox) findViewById(R.id.sensors04);
final CheckBox Check_sensors_sampling_mix = (CheckBox) findViewById(R.id.sensors05);
final CheckBox Check_sensors_sampling_perf = (CheckBox) findViewById(R.id.sensors06);
final ToggleButton Toggle_Bootani = (ToggleButton) findViewById(R.id.bootani);
TextView Desccomptext = (TextView) findViewById(R.id.Textcomp);
TextView Desccompedit = (TextView) findViewById(R.id.Textcompedit);
TextView Descswap = (TextView) findViewById(R.id.Textswap);
TextView Descoverclock1 = (TextView) findViewById(R.id.Textoverclock1);
TextView Descoverclock2 = (TextView) findViewById(R.id.Textoverclock2);
TextView Descsampling = (TextView) findViewById(R.id.Textsampling);
TextView Descsensors = (TextView) findViewById(R.id.Textsensors);
TextView Descssh = (TextView) findViewById(R.id.Textssh);
TextView Descrenice = (TextView) findViewById(R.id.Textrenice);
TextView Descprovisionned = (TextView) findViewById(R.id.Textprovisionned);
TextView Descvnc = (TextView) findViewById(R.id.Textvnc);
TextView Descbootani = (TextView) findViewById(R.id.Textbootani);
TextView Descservice = (TextView) findViewById(R.id.Textservice);
TextView Desckitchen = (TextView) findViewById(R.id.Textkitchen);
final AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
// Open config file
FileReader FR = null;
try {
FR = new FileReader("/system/etc/gaosp.conf");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
BufferedReader BR = new BufferedReader(FR);
// Read config file
try {
while ((record = BR.readLine()) != null) {
recCount++;
if (record.equals("compcache=yes")) {
compcache = true;
}
if (record.equals("compcache=no")) {
compcache = false;
}
if (record.startsWith("compcache_disksize=")) {
compcache_disksize = record.substring(19);
}
if (record.startsWith("cpu_sampling=")) {
cpu_sampling = Integer.parseInt(record.substring(13));
}
if (record.equals("sshd=no")) {
ssh = false;
}
if (record.equals("sshd=yes")) {
ssh = true;
}
if (record.equals("inadyn=no")) {
inadyn = false;
}
if (record.equals("inadyn=yes")) {
inadyn = true;
}
if (record.equals("renice=no")) {
renice = false;
}
if (record.equals("renice=yes")) {
renice = true;
}
if (record.equals("provisionned=no")) {
prov = false;
}
if (record.equals("provisionned=yes")) {
prov = true;
}
if (record.equals("vnc=no")) {
vnc = false;
}
if (record.equals("vnc=yes")) {
vnc = true;
}
if (record.equals("swap=no")) {
swap = false;
}
if (record.equals("swap=yes")) {
swap = true;
}
if (record.equals("bootani=no")) {
bootani = false;
}
if (record.equals("bootani=yes")) {
bootani = true;
}
if (record.equals("overclocking=yes")) {
overclocking = true;
}
if (record.equals("overclocking=no")) {
overclocking = false;
}
if (record.equals("overclocking2=yes")) {
overclocking2 = true;
}
if (record.equals("overclocking2=no")) {
overclocking2 = false;
}
if (record.startsWith("sensors_sampling=")) {
sensors_sampling = Integer.parseInt(record.substring(17));
}
}
} catch (IOException e) {
e.printStackTrace();
}
// Complete and validate the fields and other
compcache_disksize_edit.setText(compcache_disksize);
if (compcache == true) {
Toggle_Compcache.setChecked(true);
}
// Enable Disk size if Compcache is enabled
if (Toggle_Compcache.isChecked()) {
compcache_disksize_edit.setEnabled(true);
compcache_disksize_edit.setFocusable(true);
compcache_disksize_edit.setFocusableInTouchMode(true);
}
if (! Toggle_Compcache.isChecked()) {
compcache_disksize_edit.setEnabled(false);
compcache_disksize_edit.setFocusable(false);
}
if (cpu_sampling == 0) {
Check_sampling_eco.setChecked(true);
}
if (cpu_sampling == 1) {
Check_sampling_mix.setChecked(true);
}
if (cpu_sampling == 2) {
Check_sampling_perf.setChecked(true);
}
if (ssh == true) {
Toggle_SSH.setChecked(true);
}
if (renice == true) {
Toggle_Renice.setChecked(true);
}
if (prov == true) {
Toggle_Prov.setChecked(true);
}
if (vnc == true) {
Toggle_VNC.setChecked(true);
}
if (swap == true) {
Toggle_Swap.setChecked(true);
}
// Disable Compcache if Swap only is enabled
if (Toggle_Swap.isChecked()) {
Toggle_Compcache.setEnabled(false);
Toggle_Compcache.setChecked(false);
}
if (! Toggle_Swap.isChecked()) {
Toggle_Compcache.setEnabled(true);
}
if (bootani == true) {
Toggle_Bootani.setChecked(true);
}
if (overclocking == true) {
Toggle_OverClocking.setChecked(true);
}
if (overclocking2 == true) {
Toggle_OverClocking2.setChecked(true);
}
// Enable only 1 Overclocking option
if (Toggle_OverClocking.isChecked()) {
Toggle_OverClocking2.setChecked(false);
}
if (Toggle_OverClocking2.isChecked()) {
Toggle_OverClocking.setChecked(false);
}
if (sensors_sampling == 0) {
Check_sensors_sampling_eco.setChecked(true);
}
if (sensors_sampling == 1) {
Check_sensors_sampling_mix.setChecked(true);
}
if (sensors_sampling == 2) {
Check_sensors_sampling_perf.setChecked(true);
}
// Listener
Desccomptext.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
alertbox.setTitle(R.string.TVcompcache);
alertbox.setMessage(R.string.compcache);
alertbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
try {
return; }
catch (Throwable e) {
}
}
});
alertbox.show();
}
});
Desccompedit.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
alertbox.setTitle(R.string.TVcompcachedisk);
alertbox.setMessage(R.string.compcachedisk);
alertbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
try {
return; }
catch (Throwable e) {
}
}
});
alertbox.show();
}
});
Descswap.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
alertbox.setTitle(R.string.TVswap);
alertbox.setMessage(R.string.swap);
alertbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
try {
return; }
catch (Throwable e) {
}
}
});
alertbox.show();
}
});
Descoverclock1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
alertbox.setTitle(R.string.TVoverclock1);
alertbox.setMessage(R.string.overclock1);
alertbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
try {
return; }
catch (Throwable e) {
}
}
});
alertbox.show();
}
});
Descoverclock2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
alertbox.setTitle(R.string.TVoverclock2);
alertbox.setMessage(R.string.overclock2);
alertbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
try {
return; }
catch (Throwable e) {
}
}
});
alertbox.show();
}
});
Descsampling.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
alertbox.setTitle(R.string.TVsampling);
alertbox.setMessage(R.string.sampling);
alertbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
try {
return; }
catch (Throwable e) {
}
}
});
alertbox.show();
}
});
Descsensors.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
alertbox.setTitle(R.string.TVsensors);
alertbox.setMessage(R.string.sensors);
alertbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
try {
return; }
catch (Throwable e) {
}
}
});
alertbox.show();
}
});
Descssh.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
alertbox.setTitle(R.string.TVssh);
alertbox.setMessage(R.string.ssh);
alertbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
try {
return; }
catch (Throwable e) {
}
}
});
alertbox.show();
}
});
Descrenice.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
alertbox.setTitle(R.string.TVrenice);
alertbox.setMessage(R.string.renice);
alertbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
try {
return; }
catch (Throwable e) {
}
}
});
alertbox.show();
}
});
Descprovisionned.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
alertbox.setTitle(R.string.TVprovisionned);
alertbox.setMessage(R.string.provisionned);
alertbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
try {
return; }
catch (Throwable e) {
}
}
});
alertbox.show();
}
});
Descvnc.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
alertbox.setTitle(R.string.TVvnc);
alertbox.setMessage(R.string.vnc);
alertbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
try {
return; }
catch (Throwable e) {
}
}
});
alertbox.show();
}
});
Descbootani.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
alertbox.setTitle(R.string.TVbootani);
alertbox.setMessage(R.string.bootani);
alertbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
try {
return; }
catch (Throwable e) {
}
}
});
alertbox.show();
}
});
Descservice.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
alertbox.setTitle(R.string.TVservicemode);
alertbox.setMessage(R.string.servicemode);
alertbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
try {
return; }
catch (Throwable e) {
}
}
});
alertbox.show();
}
});
Desckitchen.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
alertbox.setTitle(R.string.TVkitchen);
alertbox.setMessage(R.string.kitchen);
alertbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
try {
return; }
catch (Throwable e) {
}
}
});
alertbox.show();
}
});
Service_Button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String encodedHash = Uri.encode("#");
Intent intent = new Intent("android.intent.action.DIAL", Uri.parse("tel:*"+encodedHash+"*"+encodedHash+"197328640"+encodedHash+"*"+encodedHash+"*"));
startActivity(intent);
// Thanks Samsung to code with your foot ;)
// Intent intent = new Intent();
// intent.setClassName("com.android.serviceModeApp","com.android.serviceModeApp.serviceModeApp");
// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
});
Kitchen_Button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://kitchen.yaam.mobi/"));
startActivity(intent);
}
});
Default_Button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Toggle_Compcache.setChecked(false);
compcache_disksize_edit.setEnabled(false);
compcache_disksize_edit.setFocusable(false);
compcache_disksize_edit.setText("25600");
Check_sampling_eco.setChecked(false);
Check_sampling_mix.setChecked(false);
Check_sampling_perf.setChecked(true);
Toggle_SSH.setChecked(false);
Toggle_Renice.setChecked(true);
Toggle_Prov.setChecked(true);
Toggle_VNC.setChecked(false);
Toggle_OverClocking.setChecked(false);
Toggle_OverClocking2.setChecked(false);
Check_sensors_sampling_eco.setChecked(true);
Check_sensors_sampling_mix.setChecked(false);
Check_sensors_sampling_perf.setChecked(false);
Toggle_Swap.setChecked(false);
Toggle_Bootani.setChecked(true);
Toast.makeText(getBaseContext(), R.string.defaults, Toast.LENGTH_LONG).show();
}
});
Apply_Button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
PrintWriter out = null;
if (Integer.parseInt(compcache_disksize_edit.getText().toString()) > 90000) {
Toast.makeText(getBaseContext(), R.string.comptobig, Toast.LENGTH_LONG).show();
}
else {
// Remount in read/write
String[] rw = { "/system/xbin/su -c /system/xbin/remountrw", "echo done"};
shell.doExec(rw, true);
//NativeTask.runCommand("/system/xbin/su -c /system/xbin/remountrw");
try {
out = new PrintWriter(new FileWriter("/system/etc/gaosp.conf"));
} catch (IOException e) {
e.printStackTrace();
}
out.println("################################");
out.println("##### Gaosp config file ########");
out.println("################################");
out.println(" ");
out.println("# Compcache");
// Copying compcache setting to conf file
if (Toggle_Compcache.isChecked()) {
out.println("compcache=yes");
/* NativeTask.runCommand("/system/xbin/su -c 'swapoff /dev/block/ramzswap0'");
NativeTask.runCommand("/system/xbin/su -c 'rmmod ramzswap'");
NativeTask.runCommand("/system/xbin/su -c 'rmmod xvmalloc'");
NativeTask.runCommand("/system/xbin/su -c 'insmod /system/libmodules/xvmalloc.ko'");
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'");
NativeTask.runCommand("/system/xbin/su -c 'swapon /dev/block/ramzswap0 -p 100'");
*/
}
else {
out.println("compcache=no");
/*
NativeTask.runCommand("/system/xbin/su -c 'swapoff /dev/block/ramzswap0'");
NativeTask.runCommand("/system/xbin/su -c 'rmmod ramzswap'");
NativeTask.runCommand("/system/xbin/su -c 'rmmod xvmalloc'");
*/
}
out.println("compcache_disksize=" + compcache_disksize_edit.getText());
out.println(" ");
// Copying cpu sampling setting to conf file
int final_sampling = 0;
//NativeTask.runCommand("/system/xbin/su -c 'echo 2000000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'");
if (Check_sampling_eco.isChecked()) {
final_sampling = 0;
// NativeTask.runCommand("/system/xbin/su -c 'echo 2000000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'");
}
if (Check_sampling_mix.isChecked()) {
final_sampling = 1;
// NativeTask.runCommand("/system/xbin/su -c 'echo 500000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'");
}
if (Check_sampling_perf.isChecked()) {
final_sampling = 2;
// NativeTask.runCommand("/system/xbin/su -c 'echo 100000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'");
}
out.println("# CpuFreq sampling rate");
out.println("# Set to 0 to eco mode, 1 to mixte mode, 2 to Performance mode ");
out.println("cpu_sampling=" + final_sampling);
out.println(" ");
// Copying SSH setting to conf file
out.println("# SSH server");
if (Toggle_SSH.isChecked()) {
out.println("sshd=yes");
/*
NativeTask.runCommand("/system/xbin/su -c 'kill -9 `pidof dropbear`'");
NativeTask.runCommand("/system/xbin/su -c 'if [ ! -d /data/ssh/ ]; then /system/bin/mkdir /data/ssh/; fi'");
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'");
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'");
NativeTask.runCommand("/system/xbin/su -c '/system/bin/logwrapper /system/xbin/dropbear &'");
*/
}
else {
out.println("sshd=no");
/*
NativeTask.runCommand("/system/xbin/su -c 'kill -9 `pidof dropbear`'");
*/
}
out.println(" ");
// Copying inadyn setting to conf file
out.println("# Inadyn");
out.println("inadyn=no");
out.println(" ");
// Copying Renice setting to conf file
out.println("# Renice");
if (Toggle_Renice.isChecked()) {
out.println("renice=yes");
/*
NativeTask.runCommand("/system/xbin/su -c 'renice -20 `pidof com.android.mms'");
NativeTask.runCommand("/system/xbin/su -c 'renice -19 `pidof com.android.phone`'");
NativeTask.runCommand("/system/xbin/su -c 'renice -18 `pidof mediaserver`");
NativeTask.runCommand("/system/xbin/su -c 'renice 0 `pidof com.google.process.gapps`'");
*/
}
else {
out.println("renice=no");
/*
NativeTask.runCommand("/system/xbin/su -c 'renice 0 `pidof com.android.mms'");
NativeTask.runCommand("/system/xbin/su -c 'renice 0 `pidof com.android.phone`'");
NativeTask.runCommand("/system/xbin/su -c 'renice 0 `pidof mediaserver`");
NativeTask.runCommand("/system/xbin/su -c 'renice 0 `pidof com.google.process.gapps`'");
*/
}
out.println(" ");
// Copying Provisioned setting to conf file
out.println("# Device provisionned");
if (Toggle_Renice.isChecked()) {
out.println("provisionned=yes");
}
else {
out.println("provisionned=no");
}
out.println(" ");
// Copying VNC Server setting to conf file
out.println("# VNC Server");
if (Toggle_VNC.isChecked()) {
out.println("vnc=yes");
/*
NativeTask.runCommand("/system/xbin/su -c 'kill -9 `pidof fbvncserver`'");
NativeTask.runCommand("/system/xbin/su -c '/system/bin/logwrapper /system/xbin/fbvncserver &'");
*/
}
else {
out.println("vnc=no");
/*
NativeTask.runCommand("/system/xbin/su -c 'kill -9 `pidof fbvncserver`'");
*/
}
out.println(" ");
// Copying Swap setting to conf file
out.println("# Swap");
if (Toggle_Swap.isChecked()) {
out.println("swap=yes");
/*
NativeTask.runCommand("/system/xbin/su -c 'swapon /dev/block/mmcblk1p2'"); and some more ;)
*/
}
else {
out.println("swap=no");
/*
NativeTask.runCommand("/system/xbin/su -c 'swapoff /dev/block/mmcblk1p2'"); and some more ;)
*/
}
out.println(" ");
// Copying Bootanimation setting to conf file
out.println("# Bootanimation");
if (Toggle_Bootani.isChecked()) {
out.println("bootani=yes");
File boot = new File("/system/media/bootanimation.zip");
if (boot.length() > 3000000 ) {
String[] change1 = { "/system/xbin/su -c 'mv /system/media/bootanimation.zip /system/media/bootanimation_temp.zip'"};
String[] change2 = { "/system/xbin/su -c 'mv /system/media/bootanimation_old.zip /system/media/bootanimation.zip'"};
String[] change3 = { "/system/xbin/su -c 'mv /system/media/bootanimation_temp.zip /system/media/bootanimation_old.zip'"};
shell.doExec(change1, true);
shell.doExec(change2, true);
shell.doExec(change3, true);
/*
NativeTask.runCommand("/system/xbin/su -c 'mv /system/media/bootanimation.zip /system/media/bootanimation_temp.zip'");
NativeTask.runCommand("/system/xbin/su -c 'mv /system/media/bootanimation_old.zip /system/media/bootanimation.zip'");
NativeTask.runCommand("/system/xbin/su -c 'mv /system/media/bootanimation_temp.zip /system/media/bootanimation_old.zip'");
*/
}
}
else {
out.println("bootani=no");
File boot = new File("/system/media/bootanimation.zip");
if (boot.length() < 3000000 ) {
String[] change1 = { "/system/xbin/su -c 'mv /system/media/bootanimation.zip /system/media/bootanimation_temp.zip'"};
String[] change2 = { "/system/xbin/su -c 'mv /system/media/bootanimation_old.zip /system/media/bootanimation.zip'"};
String[] change3 = { "/system/xbin/su -c 'mv /system/media/bootanimation_temp.zip /system/media/bootanimation_old.zip'"};
shell.doExec(change1, true);
shell.doExec(change2, true);
shell.doExec(change3, true);
/*
NativeTask.runCommand("/system/xbin/su -c 'mv /system/media/bootanimation.zip /system/media/bootanimation_temp.zip'");
NativeTask.runCommand("/system/xbin/su -c 'mv /system/media/bootanimation_old.zip /system/media/bootanimation.zip'");
NativeTask.runCommand("/system/xbin/su -c 'mv /system/media/bootanimation_temp.zip /system/media/bootanimation_old.zip'");
*/
}
}
out.println(" ");
// Copying Overclocking setting to conf file
out.println("# Overclocking");
if (Toggle_OverClocking.isChecked()) {
out.println("overclocking=yes");
/*
NativeTask.runCommand("/system/xbin/su -c 'echo 614400 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq'");
*/
}
else {
out.println("overclocking=no");
/*
NativeTask.runCommand("/system/xbin/su -c 'echo 528000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq'");
*/
}
out.println(" ");
// Copying Overclocking2 setting to conf file
out.println("# Overclocking2");
if (Toggle_OverClocking2.isChecked()) {
out.println("overclocking2=yes");
/*
NativeTask.runCommand("/system/xbin/su -c 'echo 614400 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq'");
*/
}
else {
out.println("overclocking2=no");
/*
NativeTask.runCommand("/system/xbin/su -c 'echo 528000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq'");
*/
}
out.println(" ");
// Copying Sensors setting to conf file
int final_sensors_sampling = 0;
//NativeTask.runCommand("/system/xbin/su -c 'echo 2000000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'");
if (Check_sensors_sampling_eco.isChecked()) {
final_sensors_sampling = 0;
// NativeTask.runCommand("/system/xbin/su -c 'echo 2000000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'");
}
if (Check_sensors_sampling_mix.isChecked()) {
final_sensors_sampling = 1;
// NativeTask.runCommand("/system/xbin/su -c 'echo 500000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'");
}
if (Check_sensors_sampling_perf.isChecked()) {
final_sensors_sampling = 2;
// NativeTask.runCommand("/system/xbin/su -c 'echo 100000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate'");
}
out.println("# Sensors sampling rate");
out.println("# Set to 0 to eco mode, 1 to mixte mode, 2 to Performance mode ");
out.println("sensors_sampling=" + final_sensors_sampling);
out.println(" ");
// Executing rc with scrolling
new Task().execute();
// Close file
out.flush();
out.close();
// Remount in read only
String[] ro = { "/system/xbin/su -c /system/xbin/remountro", "echo done" };
shell.doExec(ro, true);
// NativeTask.runCommand("/system/xbin/su -c /system/xbin/remountro");
}
}
});
Check_sampling_eco.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Check_sampling_mix.setChecked(false);
Check_sampling_perf.setChecked(false);
}
});
Check_sampling_mix.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Check_sampling_eco.setChecked(false);
Check_sampling_perf.setChecked(false);
}
});
Check_sampling_perf.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Check_sampling_mix.setChecked(false);
Check_sampling_eco.setChecked(false);
}
});
Check_sensors_sampling_eco.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Check_sensors_sampling_mix.setChecked(false);
Check_sensors_sampling_perf.setChecked(false);
}
});
Check_sensors_sampling_mix.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Check_sensors_sampling_eco.setChecked(false);
Check_sensors_sampling_perf.setChecked(false);
}
});
Check_sensors_sampling_perf.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Check_sensors_sampling_mix.setChecked(false);
Check_sensors_sampling_eco.setChecked(false);
}
});
Toggle_Swap.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (Toggle_Swap.isChecked()) {
Toast.makeText(getBaseContext(), R.string.swapwarning, Toast.LENGTH_LONG).show();
Toggle_Compcache.setEnabled(false);
Toggle_Compcache.setChecked(false);
}
if (! Toggle_Swap.isChecked()) {
Toggle_Compcache.setEnabled(true);
}
}
});
Toggle_OverClocking.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (Toggle_OverClocking.isChecked()) {
Toggle_OverClocking2.setChecked(false);
}
}
});
Toggle_OverClocking2.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (Toggle_OverClocking2.isChecked()) {
Toggle_OverClocking.setChecked(false);
}
}
});
Toggle_Compcache.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (Toggle_Compcache.isChecked()) {
compcache_disksize_edit.setEnabled(true);
compcache_disksize_edit.setFocusable(true);
compcache_disksize_edit.setFocusableInTouchMode(true);
}
if (! Toggle_Compcache.isChecked()) {
compcache_disksize_edit.setEnabled(false);
compcache_disksize_edit.setFocusable(false);
}
}
});
}
public boolean onCreateOptionsMenu(Menu menu)
{
super.onCreateOptionsMenu(menu);
MenuItem item = menu.add("About");
item = menu.add("Exit");
return true;
}
public boolean onOptionsItemSelected(MenuItem item)
{
if (item.hasSubMenu() == false)
{
if (item.getTitle() == "About") {
// Print the about
AlertDialog.Builder dialogBuilder = new
AlertDialog.Builder(this);
dialogBuilder.setTitle("About");
dialogBuilder.setMessage("GAOSP Configuration 2 by drakaz and Obihoernchen");
dialogBuilder.setCancelable(true);
dialogBuilder.create().show();
}
if (item.getTitle() == "Exit") {
this.finish();
}
}
// Consume the selection event.
return true;
}
final class Task extends UserTask<String, Void, Void> {
ProgressDialog myProgressDialog;
protected void onPreExecute() {
myProgressDialog = ProgressDialog.show(conf.this,"", getString(R.string.wait), true, true);
}
@Override
protected Void doInBackground(String... params) {
String[] rc = { "/system/xbin/su -c /system/bin/rc"};
shell.doExec(rc, true);
//NativeTask.runCommand("/system/xbin/su -c /system/bin/rc");
return null;
}
protected void onPostExecute(Void unused) {
if (myProgressDialog.isShowing()) {
myProgressDialog.dismiss();
Toast.makeText(getBaseContext(), R.string.applied, Toast.LENGTH_LONG).show();
}
}
}
}