├── .classpath
├── .gitignore
├── .project
├── Android.mk
├── AndroidManifest.xml
├── LICENSE
├── PerformanceControl.iml
├── README.md
├── assets
├── fix_permissions
├── run
├── sql_optimize
├── sqlite3
└── utils
├── libs
└── android-support-v13.jar
├── proguard-project.txt
├── project.properties
├── res
├── anim
│ ├── push_right_in.xml
│ └── push_right_out.xml
├── drawable-hdpi
│ ├── battery_0.png
│ ├── battery_1.png
│ ├── battery_2.png
│ ├── battery_3.png
│ ├── battery_4.png
│ ├── battery_5.png
│ ├── ic_fastcharge.png
│ ├── ic_launcher.png
│ ├── ic_menu_overflow.png
│ ├── ic_menu_refresh.png
│ └── ic_notify.png
├── drawable-mdpi
│ ├── ic_fastcharge.png
│ ├── ic_launcher.png
│ ├── ic_menu_overflow.png
│ ├── ic_menu_refresh.png
│ └── ic_notify.png
├── drawable-xhdpi
│ ├── ic_fastcharge.png
│ ├── ic_launcher.png
│ ├── ic_menu_overflow.png
│ ├── ic_menu_refresh.png
│ └── ic_notify.png
├── drawable
│ ├── background_holo_dark.xml
│ ├── background_holo_light.xml
│ ├── clickable.xml
│ └── ic_attn.png
├── layout-land
│ ├── battery_info.xml
│ ├── cpu_settings.xml
│ ├── flasher.xml
│ ├── pack_list.xml
│ └── zram_settings.xml
├── layout
│ ├── activity_main.xml
│ ├── advanced.xml
│ ├── backup_view.xml
│ ├── battery_info.xml
│ ├── build_prop_dialog.xml
│ ├── calib_dialog.xml
│ ├── check_su.xml
│ ├── cpu_advanced.xml
│ ├── cpu_settings.xml
│ ├── cpu_view.xml
│ ├── dialog_color_picker.xml
│ ├── disk_info.xml
│ ├── file_item.xml
│ ├── flasher.xml
│ ├── freezer_list.xml
│ ├── hide_tabs.xml
│ ├── ksm_settings.xml
│ ├── list_volt.xml
│ ├── mem_item.xml
│ ├── mem_settings.xml
│ ├── mem_usage.xml
│ ├── pack_item.xml
│ ├── pack_list.xml
│ ├── pfk_settings.xml
│ ├── prop_edit_dialog.xml
│ ├── prop_item.xml
│ ├── prop_view.xml
│ ├── residual_list.xml
│ ├── seekbar_dialog.xml
│ ├── sh_dialog.xml
│ ├── state_row.xml
│ ├── su_dialog.xml
│ ├── tab_item.xml
│ ├── time_in_state.xml
│ ├── tools.xml
│ ├── touch_screen.xml
│ ├── ver_dialog.xml
│ ├── voltage_dialog.xml
│ ├── voltage_settings.xml
│ ├── widget.xml
│ └── zram_settings.xml
├── menu
│ ├── backup_menu.xml
│ ├── batt_menu.xml
│ ├── build_prop_menu.xml
│ ├── cpu_settings_menu.xml
│ ├── disk_info_menu.xml
│ ├── filechooser_menu.xml
│ ├── flasher_menu.xml
│ ├── mem_menu.xml
│ ├── menu.xml
│ ├── sysctl_menu.xml
│ ├── time_in_state_menu.xml
│ ├── vm_menu.xml
│ └── voltage_control_menu.xml
├── raw
│ └── devices.xml
├── values-de
│ └── strings.xml
├── values-es
│ └── strings.xml
├── values-it
│ └── strings.xml
├── values-ro
│ └── strings.xml
├── values-ru
│ └── strings.xml
├── values-uk
│ ├── arrays.xml
│ └── strings.xml
├── values-zh-rCN
│ └── strings.xml
├── values
│ ├── arrays.xml
│ ├── colors.xml
│ ├── dimens.xml
│ ├── dslv_attrs.xml
│ ├── ids.xml
│ ├── strings.xml
│ ├── styles.xml
│ └── themes.xml
└── xml
│ ├── pc_settings.xml
│ └── widget_info.xml
└── src
├── com
└── brewcrewfoo
│ └── performance
│ ├── activities
│ ├── BackupRestore.java
│ ├── BuildPropEditor.java
│ ├── FileChooser.java
│ ├── FlasherActivity.java
│ ├── FreezerActivity.java
│ ├── GovSetActivity.java
│ ├── HideTabs.java
│ ├── IOSetActivity.java
│ ├── KSMActivity.java
│ ├── KSMSetActivity.java
│ ├── MainActivity.java
│ ├── MemUsageActivity.java
│ ├── PCSettings.java
│ ├── PFKActivity.java
│ ├── PackActivity.java
│ ├── ParamActivity.java
│ ├── ResidualsActivity.java
│ ├── SysctlEditor.java
│ ├── TouchScreenSettings.java
│ ├── VMSettings.java
│ ├── ZramActivity.java
│ ├── checkSU.java
│ └── iResidualsActivity.java
│ ├── fragments
│ ├── Advanced.java
│ ├── BatteryInfo.java
│ ├── CPUAdvanced.java
│ ├── CPUSettings.java
│ ├── DiskInfo.java
│ ├── MemSettings.java
│ ├── TimeInState.java
│ ├── Tools.java
│ └── VoltageControlSettings.java
│ ├── service
│ ├── BootReceiver.java
│ └── BootService.java
│ ├── util
│ ├── ActivityThemeChangeInterface.java
│ ├── BootClass.java
│ ├── CMDProcessor.java
│ ├── CPUStateMonitor.java
│ ├── Constants.java
│ ├── DragSortController.java
│ ├── DragSortItemView.java
│ ├── DragSortItemViewCheckable.java
│ ├── DragSortListView.java
│ ├── FileArrayAdapter.java
│ ├── GPUClass.java
│ ├── Helpers.java
│ ├── Item.java
│ ├── PackAdapter.java
│ ├── PackItem.java
│ ├── Prop.java
│ ├── PropAdapter.java
│ ├── PropUtil.java
│ ├── SimpleFloatViewManager.java
│ ├── Tab.java
│ ├── TabAdapter.java
│ ├── UnzipUtility.java
│ ├── VibratorClass.java
│ └── Voltage.java
│ └── widget
│ └── PCWidget.java
└── net
└── margaritov
└── preference
└── colorpicker
├── AlphaPatternDrawable.java
├── ColorPickerDialog.java
├── ColorPickerPanelView.java
├── ColorPickerPreference.java
└── ColorPickerView.java
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | gen/
3 | out/
4 | .idea/
5 | .settings/
6 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | PerformanceControl
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH:= $(call my-dir)
2 |
3 | include $(CLEAR_VARS)
4 |
5 | LOCAL_MODULE_TAGS := optional
6 |
7 | LOCAL_SRC_FILES := \
8 | $(call all-java-files-under, src)
9 |
10 | LOCAL_PACKAGE_NAME := PerformanceControl
11 |
12 | LOCAL_STATIC_JAVA_LIBRARIES := android-support-v13
13 |
14 | include $(BUILD_PACKAGE)
15 |
16 | include $(call all-makefiles-under,$(LOCAL_PATH))
17 |
--------------------------------------------------------------------------------
/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
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 |
61 |
62 |
63 |
64 |
65 |
66 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/PerformanceControl.iml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Performance Control
2 | ===================
3 |
4 | A CPU Control application (free) bundled with AOKP (http://github.com/AOKP)
5 |
6 | Licensed under GPL v3
7 |
8 | LICENSE - https://github.com/xoomdev/PerformanceControl/blob/v1.0.1/LICENSE
9 |
10 |
11 |
--------------------------------------------------------------------------------
/assets/fix_permissions:
--------------------------------------------------------------------------------
1 | ##
2 | ### PERFORMANCE CONTROL ###
3 |
4 | sysrw() {
5 | mount -o rw,remount /system
6 | }
7 | sysro() {
8 | mount -o ro,remount /system
9 | }
10 |
11 | get_runtime() {
12 | starttime=$1
13 | stoptime=$2
14 | runtime=`busybox expr $stoptime - $starttime`
15 | hours=`busybox expr $runtime / 3600`
16 | remainder=`busybox expr $runtime % 3600`
17 | mins=`busybox expr $remainder / 60`
18 | secs=`busybox expr $remainder % 60`
19 | busybox printf "%02d:%02d:%02d\n" "$hours" "$mins" "$secs"
20 | }
21 |
22 | fp_print(){
23 | MSG="$*";
24 | if busybox [ $LOGGING -eq 1 ]; then
25 | busybox echo "$MSG" >> $LOG_FILE;
26 | fi
27 | }
28 |
29 | set_package_permission() {
30 | packagename=$1
31 | apk_path=$2
32 | packageuid=`busybox grep $apk_path /data/system/packages.xml | busybox sed 's%.*serId="\(.*\)".*%\1%' | busybox cut -d '"' -f1 `
33 | data_path=/data/data/$packagename
34 |
35 | if busybox [ -e $apk_path ]; then
36 |
37 | appdir=`busybox dirname $apk_path `
38 |
39 | if busybox [ $appdir == /system/app ]; then
40 | busybox chown 0 $apk_path
41 | busybox chown :0 $apk_path
42 | busybox chmod 644 $apk_path
43 | fp_print "${apk_path}:0:0:rw-r--r--";
44 |
45 | elif busybox [ $appdir == /data/app ]; then
46 | busybox chown 1000 $apk_path
47 | busybox chown :1000 $apk_path
48 | busybox chmod 644 $apk_path
49 | fp_print "${apk_path}:1000:1000:rw-r--r--";
50 |
51 | elif busybox [ $appdir == /sd-ext/app ]; then
52 | busybox chown 1000 $apk_path
53 | busybox chown :1000 $apk_path
54 | busybox chmod 644 $apk_path
55 | fp_print "${apk_path}:1000:1000:rw-r--r--";
56 |
57 | elif busybox [ $appdir == /data/app-private ]; then
58 | busybox chown 1000 $apk_path
59 | busybox chown :$packageuid $apk_path
60 | busybox chmod 640 $apk_path
61 | fp_print "${apk_path}:1000:${packageuid}:rw-r-----";
62 |
63 | elif busybox [ $appdir == /sd-ext/app-private ]; then
64 | busybox chown 1000 $apk_path
65 | busybox chown :$packageuid $apk_path
66 | busybox chmod 640 $apk_path
67 | fp_print "${apk_path}:1000:${packageuid}:rw-r-----";
68 | fi
69 |
70 | if busybox [ -d $data_path ]; then
71 |
72 | busybox chmod 755 $data_path
73 | busybox chown $packageuid $data_path
74 | busybox chown :$packageuid $data_path
75 | fp_print "${data_path}:${packageuid}:${packageuid}:rwxr-xr-x";
76 | dirs=`busybox find $data_path -mindepth 1 -type d `
77 |
78 | for file in $dirs; do
79 | perm=755
80 | newuid=$packageuid
81 | newgid=$packageuid
82 | fname=`busybox basename $file `
83 | case $fname in
84 | lib)
85 | busybox chmod 755 $file
86 | newuid=1000
87 | newgid=1000
88 | perm=755
89 | ;;
90 | shared_prefs)
91 | busybox chmod 771 $file
92 | perm=660
93 | ;;
94 | databases)
95 | busybox chmod 771 $file
96 | perm=660
97 | ;;
98 | cache)
99 | busybox chmod 771 $file
100 | perm=600
101 | ;;
102 | *)
103 | busybox chmod 771 $file
104 | perm=771
105 | ;;
106 | esac
107 |
108 | busybox chown $newuid $file
109 | busybox chown :$newgid $file
110 |
111 | busybox find $file -type f -maxdepth 1 ! -perm $perm -exec busybox chmod $perm {} ';'
112 | busybox find $file -type f -maxdepth 1 ! -user $newuid -exec busybox chown $newuid {} ';'
113 | busybox find $file -type f -maxdepth 1 ! -group $newgid -exec busybox chown :$newgid {} ';'
114 |
115 | done
116 | fi
117 | fi
118 | }
119 |
120 | fp_all() {
121 | starttime=`busybox date +%s `
122 | packages=`pm list packages -f | busybox cut -d: -f2 `
123 |
124 | fp_print "Fixing permissions start at $FPSTART";
125 |
126 | sysrw
127 |
128 | for package in $packages; do
129 | packagename=`echo $package | busybox cut -d '=' -f2 `
130 | apk_path=`echo $package | busybox cut -d '=' -f1 `
131 | set_package_permission $packagename $apk_path
132 | done
133 |
134 | sysro
135 | sync
136 |
137 | stoptime=`busybox date +%s `
138 | runtime=`get_runtime $starttime $stoptime `
139 |
140 | fp_print "Fix permissions complete! Runtime: ${runtime}";
141 |
142 | }
143 | FPSTART=$( busybox date +"%m-%d-%Y %H:%M:%S" );
144 | SD=`busybox mount | busybox egrep -v "asec|android_secure|external_sd|sdcard1" | busybox egrep -i "(sdcard|sdcard0)" | busybox awk '{print $3}'`;
145 | if busybox [ "$SD" == "" ]; then
146 | LOG_FILE="/data/fix_permissions.log"
147 | else
148 | LOG_FILE="$SD/fix_permissions.log"
149 | fi
150 | busybox rm -f "$LOG_FILE";
151 |
152 | arg=$1;
153 | if busybox [ "$arg" == "-l" ]; then
154 | LOGGING=1;
155 | else
156 | LOGGING=0;
157 | fi;
158 | if busybox [ $LOGGING -eq 1 ]; then
159 | busybox touch "$LOG_FILE";
160 | fi
161 | fp_all;
--------------------------------------------------------------------------------
/assets/run:
--------------------------------------------------------------------------------
1 | ##
2 | ### PERFORMANCE CONTROL ###
3 | set_val() {
4 | if busybox [ "`busybox find \"$1\" -prune -perm -200`" ]; then
5 | busybox echo $2 > $1;
6 | else
7 | busybox chmod u+w $1;
8 | busybox echo $2 > $1;
9 | busybox chmod u-w $1;
10 | fi;
11 | }
12 | mpdecisionstart(){
13 | if busybox [ -f /system/bin/thermald ] && busybox [ `busybox cat /sys/module/msm_thermal/parameters/enabled | busybox tr '[YN]' '[10]'` -eq 0 ]; then
14 | start thermald;
15 | fi;
16 | start mpdecision `busybox grep 'service.*mpdecision' /*.rc | busybox grep -m 1 -o '\-\-.*'`;
17 | }
18 | zramstart(){
19 | local cpus=$1;
20 | local val=$2;
21 | local v=$(( val/cpus ));
22 | local ncpus=$(( cpus - 1 ));
23 |
24 | if busybox [ -f /system/lib/modules/zram.ko ]; then
25 | if busybox [ -z "`busybox lsmod | busybox grep zram`" ]; then
26 | busybox insmod /system/lib/modules/zram.ko;
27 | fi;
28 | busybox modprobe zram zram_num_devices=$cpus;
29 | fi;
30 |
31 | for i in `busybox seq 0 $ncpus`; do
32 | busybox echo $v > /sys/block/zram$i/disksize;
33 | done;
34 | for i in `busybox seq 0 $ncpus`; do
35 | busybox mkswap /dev/block/zram$i;
36 | busybox swapon /dev/block/zram$i;
37 | done;
38 | return;
39 | }
40 | zramstop(){
41 | local cpus=$1;
42 | if busybox [ "`busybox grep zram /proc/swaps`" != "" ]; then
43 | ncpus=`busybox expr $cpus - 1`;
44 | for i in `busybox seq 0 $ncpus`; do
45 | if busybox [ "`busybox grep zram$i /proc/swaps`" != "" ]; then
46 | busybox swapoff /dev/block/zram$i;
47 | fi;
48 | done;
49 | sleep 0.5;
50 | for i in `busybox seq 0 $ncpus`; do
51 | busybox echo 1 > /sys/block/zram$i/reset;
52 | done;
53 | if busybox [ -f /system/lib/modules/zram.ko ]; then
54 | busybox modprobe -rf zram;
55 | fi;
56 | fi;
57 | return;
58 | }
59 |
--------------------------------------------------------------------------------
/assets/sql_optimize:
--------------------------------------------------------------------------------
1 | ##
2 | ### PERFORMANCE CONTROL ###
3 |
4 | function optimize(){
5 | sql3=`busybox which sqlite3`;
6 | db=0;
7 | if busybox [ -d "/data" ]; then
8 | for i in `busybox find /data -iname "*.db"`; do
9 | $sql3 $i 'VACUUM;';
10 | db=`busybox expr $db + 1`;
11 | done;
12 | fi;
13 | if busybox [ -d "/dbdata" ]; then
14 | for i in `busybox find /dbdata -iname "*.db"`; do
15 | $sql3 $i 'VACUUM;';
16 | db=`busybox expr $db + 1`;
17 | done;
18 | fi;
19 | #if busybox [ -d "/system" ]; then
20 | # for i in `busybox find /system -iname "*.db"`; do
21 | # $sql3 $i 'VACUUM;';
22 | # db=`busybox expr $db + 1`;
23 | # done;
24 | #fi;
25 | if busybox [ -d "/datadata" ]; then
26 | for i in `busybox find /datadata -iname "*.db"`; do
27 | $sql3 $i 'VACUUM;';
28 | db=`busybox expr $db + 1`;
29 | done;
30 | fi;
31 |
32 | SD=`busybox mount | busybox egrep -v "asec|android_secure" | busybox egrep -i "(sdcard|sdcard0|external_sd|sdcard1)" | busybox awk '{print $3}' `;
33 |
34 | for d in $SD; do
35 | for i in `busybox find $d -iname "*.db"`; do
36 | $sql3 $i 'VACUUM;';
37 | db=`busybox expr $db + 1`;
38 | done;
39 | done;
40 | busybox echo $db;
41 | }
42 |
43 | #optimize 2>&1 >> /sdcard/sql.log
44 | optimize;
45 |
46 |
47 |
--------------------------------------------------------------------------------
/assets/sqlite3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/assets/sqlite3
--------------------------------------------------------------------------------
/assets/utils:
--------------------------------------------------------------------------------
1 | ##
2 | ### PERFORMANCE CONTROL ###
3 |
4 | sysrw() {
5 | mount -o rw,remount /system
6 | }
7 | sysro() {
8 | mount -o ro,remount /system
9 | }
10 | get_prop(){
11 | local d="$1";
12 | local n="$2";
13 | if busybox [ "X$n"=="X" ]; then
14 | busybox find $d -type f -prune -perm -600 -print0;
15 | else
16 | busybox find $d -type f -prune -perm -600 -maxdepth $n -print0;
17 | fi;
18 | }
19 | set_prop() {
20 | local prop_key=$(busybox echo "$1" | cut -d'=' -f1);
21 | local prop_value=$(busybox echo "$1" | cut -d'=' -f2);
22 | local prop_file=${2:-/system/build.prop}
23 | local seperator="=";
24 | if busybox [ -e $prop_file ];then
25 | sysrw
26 | prop_line=`busybox grep -m 1 $prop_key $prop_file`;
27 | if busybox [ -n "${prop_line}" ];then
28 | if busybox [ -n "$( echo $prop_line | busybox grep ' = ' )" ];then
29 | seperator=" = ";
30 | fi
31 | busybox sed -i "s|${prop_key}${seperator}.*|${prop_key}${seperator}${prop_value}|g" $prop_file;
32 | else
33 | busybox echo "$prop_key$seperator$prop_value" >> $prop_file;
34 | fi;
35 | sysro;
36 | fi;
37 | return;
38 | }
39 |
40 | count_files(){
41 | local ext="$2";
42 | local r="";
43 | if busybox [ "X$2" == "X" ]; then
44 | ext="*";
45 | fi;
46 | for d in $1; do
47 | if busybox [ -d $d ]; then
48 | i=$( busybox find $d -type f -name "$ext" | busybox wc -l );
49 | else
50 | i=0;
51 | fi;
52 | if busybox [ "X$r" == "X" ]; then
53 | r="$i";
54 | else
55 | r="$r::$i";
56 | fi;
57 | done;
58 | echo "$r";
59 | }
60 |
61 | get_cpu(){
62 | local cpus=$1;
63 | local ncpus=`busybox expr $cpus - 1`;
64 | local r="";
65 | local gov=`busybox cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor`;
66 | local io=`busybox awk -F'[][]' '{print $2}' /sys/block/mmcblk0/queue/scheduler`;
67 | local oc="";
68 | if busybox [ -f /sys/class/misc/liveoc/oc_value ]; then
69 | oc=`busybox cat /sys/class/misc/liveoc/oc_value`;
70 | busybox echo 100 > /sys/class/misc/liveoc/oc_value;
71 | fi;
72 | local allfreq="";
73 | if busybox [ -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies ]; then
74 | allfreq=`busybox cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies`;
75 | elif busybox [ -f /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state ]; then
76 | allfreq=`busybox cut -d' ' -f1 /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state | busybox sort -n | busybox xargs`;
77 | else
78 | allfreq="`cat sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq` `cat sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq`";
79 | fi;
80 | for c in `busybox seq 0 $ncpus`; do
81 |
82 | if busybox [ -f "/sys/devices/system/cpu/cpu$c/cpufreq/scaling_max_freq" ]; then
83 | max=`busybox cat "/sys/devices/system/cpu/cpu$c/cpufreq/scaling_max_freq" `;
84 | fi;
85 | if busybox [ -f /sys/module/cpu_tegra/parameters/cpu_user_cap ]; then
86 | max=`busybox cat /sys/module/cpu_tegra/parameters/cpu_user_cap`;
87 | fi;
88 | if busybox [ -f /sys/power/cpufreq_max_limit ]; then
89 | max=`busybox cat /sys/power/cpufreq_max_limit`;
90 | fi;
91 | if busybox [ -f /sys/kernel/cpufreq/hardlimit ]; then
92 | max=`busybox cat /sys/kernel/cpufreq/hardlimit`;
93 | fi;
94 | if busybox [ "X$max" == "X" ]; then
95 | max=0;
96 | fi;
97 |
98 | if busybox [ -f "/sys/devices/system/cpu/cpu$c/cpufreq/scaling_min_freq" ]; then
99 | min=`busybox cat "/sys/devices/system/cpu/cpu$c/cpufreq/scaling_min_freq" `;
100 | fi;
101 | if busybox [ -f /sys/power/cpufreq_min_limit ]; then
102 | min=`busybox cat /sys/power/cpufreq_min_limit`;
103 | fi;
104 | if busybox [ "X$min" == "X" ]; then
105 | min=0;
106 | fi;
107 |
108 | on=1;
109 | if busybox [ -f "/sys/devices/system/cpu/cpu$c/online" ]; then
110 | on=`busybox cat "/sys/devices/system/cpu/cpu$c/online" `;
111 | fi;
112 | if busybox [ "X$on" == "X" ]; then
113 | on=0;
114 | fi;
115 |
116 | if busybox [ "X$r" == "X" ]; then
117 | r="$min:$max:$gov:$io:$on";
118 | else
119 | r="$r:$min:$max:$gov:$io:$on";
120 | fi;
121 | done;
122 | if busybox [ -f /sys/class/misc/liveoc/oc_value ]; then
123 | busybox echo $oc > /sys/class/misc/liveoc/oc_value;
124 | fi;
125 | echo "$r:$allfreq";
126 | }
127 |
128 | arg=$1;
129 | if busybox [ "$arg" == "-count" ]; then
130 | count_files "$DIRS";
131 | elif busybox [ "$arg" == "-setprop" ]; then
132 | set_prop "$2" $3;
133 | elif busybox [ "$arg" == "-getcpu" ]; then
134 | get_cpu $2;
135 | elif busybox [ "$arg" == "-getprop" ]; then
136 | get_prop "$2";
137 | fi;
138 |
139 | exit;
140 |
--------------------------------------------------------------------------------
/libs/android-support-v13.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/libs/android-support-v13.jar
--------------------------------------------------------------------------------
/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-17
15 |
--------------------------------------------------------------------------------
/res/anim/push_right_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/res/anim/push_right_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/res/drawable-hdpi/battery_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/res/drawable-hdpi/battery_0.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/battery_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/res/drawable-hdpi/battery_1.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/battery_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/res/drawable-hdpi/battery_2.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/battery_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/res/drawable-hdpi/battery_3.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/battery_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/res/drawable-hdpi/battery_4.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/battery_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/res/drawable-hdpi/battery_5.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_fastcharge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/res/drawable-hdpi/ic_fastcharge.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_menu_overflow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/res/drawable-hdpi/ic_menu_overflow.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_menu_refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/res/drawable-hdpi/ic_menu_refresh.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_notify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/res/drawable-hdpi/ic_notify.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_fastcharge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/res/drawable-mdpi/ic_fastcharge.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_menu_overflow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/res/drawable-mdpi/ic_menu_overflow.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_menu_refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/res/drawable-mdpi/ic_menu_refresh.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_notify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/res/drawable-mdpi/ic_notify.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_fastcharge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/res/drawable-xhdpi/ic_fastcharge.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_menu_overflow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/res/drawable-xhdpi/ic_menu_overflow.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_menu_refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/res/drawable-xhdpi/ic_menu_refresh.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_notify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/res/drawable-xhdpi/ic_notify.png
--------------------------------------------------------------------------------
/res/drawable/background_holo_dark.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 |
22 |
23 |
--------------------------------------------------------------------------------
/res/drawable/background_holo_light.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 |
22 |
23 |
--------------------------------------------------------------------------------
/res/drawable/clickable.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
--------------------------------------------------------------------------------
/res/drawable/ic_attn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/horn3t/PerformanceControl/530607c259eb115a1bbc5f68756e5ab7b6499f60/res/drawable/ic_attn.png
--------------------------------------------------------------------------------
/res/layout-land/flasher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
16 |
21 |
27 |
33 |
34 |
43 |
44 |
49 |
50 |
59 |
60 |
67 |
68 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/res/layout-land/pack_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
15 |
16 |
20 |
21 |
22 |
31 |
32 |
33 |
40 |
41 |
49 |
50 |
55 |
56 |
57 |
66 |
67 |
78 |
79 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
24 |
25 |
30 |
31 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/res/layout/backup_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
15 |
16 |
24 |
25 |
26 |
30 |
31 |
37 |
38 |
44 |
45 |
51 |
52 |
53 |
54 |
59 |
60 |
--------------------------------------------------------------------------------
/res/layout/build_prop_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
11 |
15 |
16 |
21 |
22 |
29 |
30 |
37 |
38 |
39 |
45 |
46 |
53 |
54 |
61 |
62 |
63 |
69 |
70 |
77 |
78 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/res/layout/calib_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
15 |
16 |
--------------------------------------------------------------------------------
/res/layout/check_su.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
16 |
17 |
22 |
23 |
30 |
31 |
--------------------------------------------------------------------------------
/res/layout/cpu_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
14 |
15 |
23 |
28 |
29 |
--------------------------------------------------------------------------------
/res/layout/dialog_color_picker.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
18 |
19 |
24 |
25 |
34 |
35 |
40 |
41 |
46 |
47 |
55 |
56 |
61 |
62 |
63 |
68 |
69 |
76 |
77 |
85 |
86 |
91 |
92 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/res/layout/file_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
17 |
18 |
19 |
28 |
29 |
30 |
31 |
41 |
42 |
43 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/res/layout/flasher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
16 |
22 |
28 |
34 |
35 |
36 |
42 |
43 |
53 |
54 |
61 |
62 |
69 |
70 |
--------------------------------------------------------------------------------
/res/layout/freezer_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
15 |
16 |
20 |
21 |
22 |
30 |
37 |
38 |
39 |
40 |
49 |
50 |
57 |
58 |
65 |
66 |
70 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/res/layout/hide_tabs.xml:
--------------------------------------------------------------------------------
1 |
2 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/res/layout/list_volt.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
27 |
28 |
32 |
33 |
40 |
41 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/res/layout/mem_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
18 |
19 |
29 |
--------------------------------------------------------------------------------
/res/layout/mem_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
23 |
24 |
27 |
30 |
33 |
36 |
39 |
42 |
45 |
50 |
55 |
56 |
57 |
60 |
64 |
68 |
73 |
74 |
75 |
78 |
82 |
86 |
87 |
92 |
93 |
94 |
95 |
98 |
103 |
107 |
114 |
115 |
118 |
122 |
127 |
128 |
129 |
--------------------------------------------------------------------------------
/res/layout/mem_usage.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
16 |
17 |
25 |
26 |
30 |
31 |
35 |
--------------------------------------------------------------------------------
/res/layout/pack_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
13 |
14 |
19 |
20 |
28 |
29 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/res/layout/pack_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
15 |
16 |
20 |
21 |
22 |
30 |
31 |
32 |
39 |
40 |
49 |
50 |
56 |
57 |
58 |
67 |
68 |
80 |
81 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/res/layout/prop_edit_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
17 |
18 |
27 |
28 |
--------------------------------------------------------------------------------
/res/layout/prop_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
21 |
22 |
23 |
24 |
33 |
--------------------------------------------------------------------------------
/res/layout/prop_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
13 |
14 |
18 |
19 |
20 |
28 |
29 |
36 |
37 |
38 |
48 |
57 |
58 |
59 |
69 |
70 |
77 |
78 |
79 |
91 |
95 |
104 |
105 |
111 |
112 |
122 |
123 |
124 |
125 |
--------------------------------------------------------------------------------
/res/layout/residual_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
15 |
16 |
20 |
21 |
22 |
30 |
31 |
38 |
39 |
48 |
49 |
55 |
56 |
57 |
66 |
67 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/res/layout/seekbar_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
27 |
28 |
34 |
35 |
42 |
43 |
--------------------------------------------------------------------------------
/res/layout/sh_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
24 |
25 |
--------------------------------------------------------------------------------
/res/layout/state_row.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
26 |
27 |
31 |
32 |
39 |
40 |
47 |
48 |
55 |
56 |
57 |
63 |
70 |
71 |
--------------------------------------------------------------------------------
/res/layout/su_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
25 |
26 |
30 |
31 |
--------------------------------------------------------------------------------
/res/layout/tab_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
10 |
16 |
17 |
25 |
26 |
--------------------------------------------------------------------------------
/res/layout/time_in_state.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
27 |
28 |
32 |
33 |
37 |
38 |
45 |
46 |
49 |
50 |
56 |
57 |
66 |
67 |
72 |
73 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/res/layout/tools.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
23 |
24 |
27 |
31 |
32 |
33 |
36 |
39 |
40 |
41 |
44 |
47 |
48 |
49 |
52 |
56 |
57 |
58 |
59 |
62 |
65 |
66 |
67 |
70 |
73 |
74 |
77 |
81 |
85 |
86 |
89 |
93 |
94 |
97 |
100 |
101 |
104 |
107 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/res/layout/ver_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
16 |
17 |
--------------------------------------------------------------------------------
/res/layout/voltage_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
22 |
29 |
30 |
37 |
38 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/res/layout/voltage_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
24 |
25 |
32 |
33 |
38 |
39 |
44 |
45 |
46 |
53 |
54 |
55 |
56 |
65 |
69 |
79 |
80 |
85 |
86 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/res/layout/widget.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
25 |
26 |
31 |
32 |
36 |
37 |
43 |
44 |
50 |
51 |
57 |
58 |
64 |
65 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/res/menu/backup_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/res/menu/batt_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/res/menu/build_prop_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/res/menu/cpu_settings_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/res/menu/disk_info_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/res/menu/filechooser_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/res/menu/flasher_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/res/menu/mem_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/res/menu/menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/res/menu/sysctl_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/res/menu/time_in_state_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/res/menu/vm_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/res/menu/voltage_control_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
24 |
--------------------------------------------------------------------------------
/res/values-uk/arrays.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
23 | - @string/size_25_mb
24 | - @string/size_50_mb
25 | - @string/size_75_mb
26 | - @string/size_80_mb
27 | - @string/size_100_mb
28 |
29 |
30 | - 1536,2048,4096,5120,5632,6144
31 | - 2560,3840,6400,7680,10240,12800
32 | - 2560,3840,6400,10240,12800,19200
33 | - 2048,3072,6144,15360,17920,20480
34 | - 2560,3840,6400,12800,12800,25600
35 |
36 |
37 | - @string/size_128_kb
38 | - @string/size_256_kb
39 | - @string/size_512_kb
40 | - @string/size_1024_kb
41 | - @string/size_2048_kb
42 | - @string/size_3072_kb
43 | - @string/size_4096_kb
44 |
45 |
46 | - 128
47 | - 256
48 | - 512
49 | - 1024
50 | - 2048
51 | - 3072
52 | - 4096
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | #ff3b3b3b
6 | #ff4d4d4d
7 | #ffb0b0b0
8 | #ff333333
9 | #ff0099cc
10 | #ff224687
11 | #ffffffff
12 | #ff141414
13 | #ffff0000
14 | #409f9f9f
15 |
--------------------------------------------------------------------------------
/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 | 0dp
23 |
24 |
--------------------------------------------------------------------------------
/res/values/dslv_attrs.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
33 |
34 |
39 |
40 |
43 |
44 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 |
16 |
22 |
23 |
29 |
30 |
--------------------------------------------------------------------------------
/res/xml/pc_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
23 |
24 |
25 |
26 |
29 |
30 |
33 |
34 |
38 |
39 |
42 |
43 |
46 |
47 |
51 |
52 |
56 |
57 |
61 |
65 |
66 |
--------------------------------------------------------------------------------
/res/xml/widget_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
26 |
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/activities/MemUsageActivity.java:
--------------------------------------------------------------------------------
1 | package com.brewcrewfoo.performance.activities;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.content.SharedPreferences;
6 | import android.os.Bundle;
7 | import android.os.Handler;
8 | import android.os.Message;
9 | import android.preference.PreferenceManager;
10 | import android.widget.ListView;
11 | import android.widget.TextView;
12 |
13 | import com.brewcrewfoo.performance.R;
14 | import com.brewcrewfoo.performance.util.ActivityThemeChangeInterface;
15 | import com.brewcrewfoo.performance.util.Constants;
16 | import com.brewcrewfoo.performance.util.Prop;
17 | import com.brewcrewfoo.performance.util.PropAdapter;
18 |
19 | import org.w3c.dom.Text;
20 |
21 | import java.io.BufferedReader;
22 | import java.io.FileReader;
23 | import java.io.IOException;
24 | import java.util.ArrayList;
25 | import java.util.List;
26 |
27 |
28 | /**
29 | * Created by h0rn3t on 10.02.2014.
30 | * http://forum.xda-developers.com/member.php?u=4674443
31 | */
32 | public class MemUsageActivity extends Activity implements ActivityThemeChangeInterface,Constants {
33 | private boolean mIsLightTheme;
34 | SharedPreferences mPreferences;
35 | private ListView packList;
36 | private List props = new ArrayList();
37 | private PropAdapter adapter;
38 | private CurThread mCurThread;
39 | private String path;
40 | private String titlu;
41 |
42 | @Override
43 | public void onCreate(Bundle savedInstanceState) {
44 | super.onCreate(savedInstanceState);
45 | mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
46 | setTheme();
47 | Intent intent=getIntent();
48 | final String tip=intent.getStringExtra("tip");
49 | if(tip.equals("mem")){
50 | path=MEM_INFO_PATH;
51 | titlu=getString(R.string.mt_mem_usage);
52 | }
53 | else{
54 | path=CPU_INFO_PATH;
55 | titlu=getString(R.string.cpu_info);
56 | }
57 |
58 | setContentView(R.layout.mem_usage);
59 | TextView t=(TextView) findViewById(R.id.infotxt);
60 | t.setText(titlu);
61 | packList = (ListView) findViewById(R.id.memlist);
62 | readFile(path);
63 | adapter = new PropAdapter(MemUsageActivity.this, R.layout.mem_item, props);
64 | packList.setAdapter(adapter);
65 | }
66 | @Override
67 | public boolean isThemeChanged() {
68 | final boolean is_light_theme = mPreferences.getBoolean(PREF_USE_LIGHT_THEME, false);
69 | return is_light_theme != mIsLightTheme;
70 | }
71 |
72 | @Override
73 | public void setTheme() {
74 | final boolean is_light_theme = mPreferences.getBoolean(PREF_USE_LIGHT_THEME, false);
75 | mIsLightTheme = is_light_theme;
76 | setTheme(is_light_theme ? R.style.Theme_Light : R.style.Theme_Dark);
77 | }
78 | @Override
79 | public void onResume() {
80 | if (mCurThread == null) {
81 | mCurThread = new CurThread();
82 | mCurThread.start();
83 | }
84 | super.onResume();
85 | }
86 | @Override
87 | public void onDestroy() {
88 | if (mCurThread != null) {
89 | if (mCurThread.isAlive()) {
90 | mCurThread.interrupt();
91 | try {
92 | mCurThread.join();
93 | }
94 | catch (InterruptedException e) {
95 | }
96 | }
97 | }
98 | super.onDestroy();
99 | }
100 |
101 | protected class CurThread extends Thread {
102 | private boolean mInterrupt = false;
103 |
104 | public void interrupt() {
105 | mInterrupt = true;
106 | }
107 |
108 | @Override
109 | public void run() {
110 | try {
111 | while (!mInterrupt) {
112 | sleep(1200);
113 | mCurHandler.sendMessage(mCurHandler.obtainMessage(0,null));
114 | }
115 | }
116 | catch (InterruptedException e) {
117 | //return;
118 | }
119 | }
120 | }
121 | protected Handler mCurHandler = new Handler() {
122 | public void handleMessage(Message msg) {
123 | readFile(path);
124 | adapter.notifyDataSetChanged();
125 | }
126 | };
127 | public void readFile(String fName) {
128 | props.clear();
129 | FileReader fr = null;
130 | try {
131 | fr = new FileReader(fName);
132 | BufferedReader br = new BufferedReader(fr);
133 | String line = br.readLine();
134 | while (null != line) {
135 | if(line!=null && line.contains(":"))
136 | props.add(new Prop(line.split(":")[0].trim(),line.split(":")[1].trim()));
137 | line = br.readLine();
138 | }
139 | }
140 | catch (IOException ex) {
141 | }
142 | finally {
143 | if (null != fr) {
144 | try {
145 | fr.close();
146 | }
147 | catch (IOException e) {
148 | }
149 | }
150 | }
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/activities/checkSU.java:
--------------------------------------------------------------------------------
1 | package com.brewcrewfoo.performance.activities;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.content.SharedPreferences;
6 | import android.os.AsyncTask;
7 | import android.os.Bundle;
8 | import android.os.SystemClock;
9 | import android.preference.PreferenceManager;
10 | import android.view.View;
11 | import android.widget.ImageView;
12 | import android.widget.ProgressBar;
13 | import android.widget.TextView;
14 |
15 | import com.brewcrewfoo.performance.R;
16 | import com.brewcrewfoo.performance.util.ActivityThemeChangeInterface;
17 | import com.brewcrewfoo.performance.util.Constants;
18 | import com.brewcrewfoo.performance.util.Helpers;
19 |
20 | /**
21 | * Created by h0rn3t on 09.02.2014.
22 | * http://forum.xda-developers.com/member.php?u=4674443
23 | */
24 | public class checkSU extends Activity implements Constants, ActivityThemeChangeInterface {
25 | private boolean mIsLightTheme;
26 | private ProgressBar wait;
27 | private TextView info;
28 | private ImageView attn;
29 | SharedPreferences mPreferences;
30 |
31 | @Override
32 | public void onCreate(Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
35 | setTheme();
36 | setContentView(R.layout.check_su);
37 | wait=(ProgressBar) findViewById(R.id.wait);
38 | info=(TextView) findViewById(R.id.info);
39 | attn=(ImageView) findViewById(R.id.attn);
40 |
41 | if(mPreferences.getBoolean("booting",false)) {
42 | info.setText(getString(R.string.boot_wait));
43 | wait.setVisibility(View.GONE);
44 | attn.setVisibility(View.VISIBLE);
45 | }
46 | else {
47 |
48 | new TestSU().execute();
49 | }
50 | }
51 |
52 | private class TestSU extends AsyncTask {
53 | @Override
54 | protected String doInBackground(String... params) {
55 | SystemClock.sleep(1000);
56 | final Boolean canSu = Helpers.checkSu();
57 | final Boolean canBb = Helpers.binExist("busybox")!=null;
58 | if (canSu && canBb) return "ok";
59 | else return "nok";
60 | }
61 | @Override
62 | protected void onPostExecute(String result) {
63 |
64 | if(result.equals("nok")){
65 | //mPreferences.edit().putBoolean("firstrun", true).commit();
66 | info.setText(getString(R.string.su_failed_su_or_busybox));
67 | wait.setVisibility(View.GONE);
68 | attn.setVisibility(View.VISIBLE);
69 | }
70 | else{
71 | //mPreferences.edit().putBoolean("firstrun", false).commit();
72 | Intent returnIntent = new Intent();
73 | returnIntent.putExtra("r",result);
74 | setResult(RESULT_OK,returnIntent);
75 | finish();
76 | }
77 |
78 | }
79 | @Override
80 | protected void onPreExecute() {
81 | }
82 | @Override
83 | protected void onProgressUpdate(Void... values) {
84 | }
85 | }
86 | @Override
87 | public boolean isThemeChanged() {
88 | final boolean is_light_theme = mPreferences.getBoolean(PREF_USE_LIGHT_THEME, false);
89 | return is_light_theme != mIsLightTheme;
90 | }
91 |
92 | @Override
93 | public void setTheme() {
94 | final boolean is_light_theme = mPreferences.getBoolean(PREF_USE_LIGHT_THEME, false);
95 | mIsLightTheme = is_light_theme;
96 | setTheme(is_light_theme ? R.style.Theme_Light : R.style.Theme_Dark);
97 | }
98 | @Override
99 | public void onResume() {
100 | super.onResume();
101 | }
102 |
103 | }
104 |
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/service/BootReceiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Performance Control - An Android CPU Control application Copyright (C) 2012
3 | * James Roberts
4 | *
5 | * This program is free software: you can redistribute it and/or modify it under
6 | * the terms of the GNU General Public License as published by the Free Software
7 | * Foundation, either version 3 of the License, or (at your option) any later
8 | * version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 | * details.
14 | *
15 | * You should have received a copy of the GNU General Public License along with
16 | * this program. If not, see .
17 | */
18 |
19 | package com.brewcrewfoo.performance.service;
20 |
21 | import android.content.BroadcastReceiver;
22 | import android.content.Context;
23 | import android.content.Intent;
24 | import android.content.SharedPreferences;
25 | import android.preference.PreferenceManager;
26 |
27 | import com.brewcrewfoo.performance.util.Constants;
28 |
29 |
30 | public class BootReceiver extends BroadcastReceiver implements Constants {
31 | @Override
32 | public void onReceive(Context context, Intent intent) {
33 | final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
34 | if (intent.getAction().equals(Intent.ACTION_SHUTDOWN)||intent.getAction().equals("android.intent.action.QUICKBOOT_POWEROFF")) {
35 | preferences.edit().putBoolean("booting",true).commit();
36 | }
37 | else if(intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
38 | Intent service = new Intent(context, BootService.class);
39 | context.startService(service);
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/service/BootService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Performance Control - An Android CPU Control application Copyright (C) 2012
3 | * James Roberts
4 | *
5 | * This program is free software: you can redistribute it and/or modify it under
6 | * the terms of the GNU General Public License as published by the Free Software
7 | * Foundation, either version 3 of the License, or (at your option) any later
8 | * version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 | * details.
14 | *
15 | * You should have received a copy of the GNU General Public License along with
16 | * this program. If not, see .
17 | */
18 |
19 | package com.brewcrewfoo.performance.service;
20 |
21 | import android.app.Notification;
22 | import android.app.NotificationManager;
23 | import android.app.Service;
24 | import android.content.Context;
25 | import android.content.Intent;
26 | import android.content.SharedPreferences;
27 | import android.os.AsyncTask;
28 | import android.os.IBinder;
29 | import android.preference.PreferenceManager;
30 |
31 | import com.brewcrewfoo.performance.R;
32 | import com.brewcrewfoo.performance.util.BootClass;
33 | import com.brewcrewfoo.performance.util.Constants;
34 | import com.brewcrewfoo.performance.util.Helpers;
35 |
36 |
37 | public class BootService extends Service implements Constants {
38 |
39 | @Override
40 | public int onStartCommand(Intent intent, int flags, int startId) {
41 | if (intent == null) stopSelf();
42 | new BootWorker(this).execute();
43 | return START_STICKY;
44 | }
45 |
46 | @Override
47 | public IBinder onBind(Intent intent) {
48 | return null;
49 | }
50 |
51 | class BootWorker extends AsyncTask {
52 | Context c;
53 | SharedPreferences preferences;
54 |
55 | public BootWorker(Context c) {
56 | this.c = c;
57 | this.preferences = PreferenceManager.getDefaultSharedPreferences(c);
58 | }
59 |
60 | @Override
61 | protected String doInBackground(Void... args) {
62 | if(!preferences.getBoolean("boot_mode",false)){
63 | //bootservice
64 | preferences.edit().putString(MINFREE_DEFAULT,Helpers.readOneLine(MINFREE_PATH)).commit();
65 | Helpers.shExec(new BootClass(c,preferences).getScript(),c,true);
66 | }
67 | else{
68 | //initd script
69 | if(preferences.getBoolean(PREF_MINFREE_BOOT,false)) {
70 | preferences.edit().putString(MINFREE_DEFAULT,Helpers.readOneLine(MINFREE_PATH)).commit();
71 | }
72 | }
73 | return null;
74 | }
75 | @Override
76 | protected void onPreExecute() {
77 | if(preferences.getBoolean("boot_mode",false)) return;
78 | final NotificationManager nm = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
79 | Notification n = new Notification.Builder(c)
80 | .setContentTitle(c.getText(R.string.app_name))
81 | .setContentText("apply boot sequence")
82 | .setTicker("apply boot sequence")
83 | .setSmallIcon(R.drawable.ic_notify)
84 | .setWhen(System.currentTimeMillis()).getNotification();
85 | nm.notify(1338, n);
86 | //Toast.makeText(c, TAG+ " start boot sequence", Toast.LENGTH_SHORT).show();
87 | }
88 | @Override
89 | protected void onPostExecute(String result) {
90 | super.onPostExecute(result);
91 | final String FASTCHARGE_PATH=Helpers.fastcharge_path();
92 | final NotificationManager nm = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
93 | nm.cancelAll();
94 | //Toast.makeText(c, TAG+ " boot complete", Toast.LENGTH_SHORT).show();
95 | if (FASTCHARGE_PATH!=null) {
96 | if(Helpers.readOneLine(FASTCHARGE_PATH).equals("1")){
97 | Notification n = new Notification.Builder(c)
98 | .setContentTitle(c.getText(R.string.app_name))
99 | .setContentText(c.getText(R.string.fast_charge_notification_title))
100 | .setTicker(c.getText(R.string.fast_charge_notification_title))
101 | .setSmallIcon(R.drawable.ic_fastcharge)
102 | .setWhen(System.currentTimeMillis()).getNotification();
103 | //n.flags = Notification.FLAG_NO_CLEAR;
104 | nm.notify(1337, n);
105 | }
106 | }
107 | preferences.edit().putBoolean("booting",false).commit();
108 | stopSelf();
109 | }
110 | }
111 |
112 | @Override
113 | public void onDestroy() {
114 | super.onDestroy();
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/util/ActivityThemeChangeInterface.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 Mariotaku Lee
3 | *
4 | * This program is free software: you can redistribute it and/or modify it under
5 | * the terms of the GNU General Public License as published by the Free Software
6 | * Foundation, either version 3 of the License, or (at your option) any later
7 | * version.
8 | *
9 | * This program is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12 | * details.
13 | *
14 | * You should have received a copy of the GNU General Public License along with
15 | * this program. If not, see .
16 | */
17 |
18 | package com.brewcrewfoo.performance.util;
19 |
20 | import android.os.Bundle;
21 |
22 | public interface ActivityThemeChangeInterface {
23 |
24 | public boolean isThemeChanged();
25 |
26 | public void onCreate(Bundle savedInstanceState);
27 |
28 | public void onResume();
29 |
30 | public void setTheme();
31 | }
32 |
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/util/CMDProcessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Performance Control - An Android CPU Control application Copyright (C) 2012
3 | * Jared Rummler Copyright (C) 2012 James Roberts
4 | *
5 | * This program is free software: you can redistribute it and/or modify it under
6 | * the terms of the GNU General Public License as published by the Free Software
7 | * Foundation, either version 3 of the License, or (at your option) any later
8 | * version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 | * details.
14 | *
15 | * You should have received a copy of the GNU General Public License along with
16 | * this program. If not, see .
17 | */
18 |
19 | package com.brewcrewfoo.performance.util;
20 |
21 | import android.util.Log;
22 |
23 | import java.io.DataInputStream;
24 | import java.io.DataOutputStream;
25 | import java.io.InputStream;
26 |
27 | public class CMDProcessor implements Constants {
28 |
29 | private Boolean can_su;
30 | public SH sh;
31 | public SH su;
32 |
33 | public CMDProcessor() {
34 | sh = new SH("sh");
35 | su = new SH("su");
36 | }
37 |
38 | public SH suOrSH() {
39 | return canSU() ? su : sh;
40 | }
41 |
42 | public boolean canSU() {
43 | return canSU(false);
44 | }
45 |
46 | public class CommandResult {
47 | public final String stdout;
48 | public final String stderr;
49 | public final Integer exit_value;
50 |
51 | CommandResult(final Integer exit_value_in) {
52 | this(exit_value_in, null, null);
53 | }
54 |
55 | CommandResult(final Integer exit_value_in, final String stdout_in,final String stderr_in) {
56 | exit_value = exit_value_in;
57 | stdout = stdout_in;
58 | stderr = stderr_in;
59 | }
60 |
61 | public boolean success() {
62 | return exit_value != null && exit_value == 0;
63 | }
64 | }
65 |
66 | public class SH {
67 | private String SHELL = "sh";
68 |
69 | public SH(final String SHELL_in) {
70 | SHELL = SHELL_in;
71 | }
72 |
73 | @SuppressWarnings("deprecation")
74 | private String getStreamLines(final InputStream is) {
75 | String out = null;
76 | StringBuffer buffer = null;
77 | final DataInputStream dis = new DataInputStream(is);
78 |
79 | try {
80 | if (dis.available() > 0) {
81 | buffer = new StringBuffer(dis.readLine());
82 | while (dis.available() > 0) {
83 | buffer.append("\n").append(dis.readLine());
84 | }
85 | }
86 | dis.close();
87 | } catch (final Exception ex) {
88 | Log.e(TAG, ex.getMessage());
89 | }
90 | if (buffer != null) {
91 | out = buffer.toString();
92 | }
93 | return out;
94 | }
95 |
96 | public Process run(final String s) {
97 | Process process = null;
98 | try {
99 | process = Runtime.getRuntime().exec(SHELL);
100 | final DataOutputStream toProcess = new DataOutputStream(process.getOutputStream());
101 | toProcess.writeBytes("exec " + s + "\n");
102 | toProcess.flush();
103 | } catch (final Exception e) {
104 | Log.e(TAG,"Exception while trying to run: '" + s + "' " + e.getMessage());
105 | process = null;
106 | }
107 | return process;
108 | }
109 |
110 | public CommandResult runWaitFor(final String s) {
111 | final Process process = run(s);
112 | Integer exit_value = null;
113 | String stdout = null;
114 | String stderr = null;
115 | if (process != null) {
116 | try {
117 | exit_value = process.waitFor();
118 |
119 | stdout = getStreamLines(process.getInputStream());
120 | stderr = getStreamLines(process.getErrorStream());
121 |
122 | } catch (final InterruptedException e) {
123 | Log.e(TAG, "runWaitFor " + e.toString());
124 | } catch (final NullPointerException e) {
125 | Log.e(TAG, "runWaitFor " + e.toString());
126 | }
127 | }
128 | return new CommandResult(exit_value, stdout, stderr);
129 | }
130 | }
131 |
132 | public boolean canSU(final boolean force_check) {
133 | if (can_su == null || force_check) {
134 | final CommandResult r = su.runWaitFor("id");
135 | final StringBuilder out = new StringBuilder();
136 |
137 | if (r.stdout != null) {
138 | out.append(r.stdout).append(" ; ");
139 | }
140 | if (r.stderr != null) {
141 | out.append(r.stderr);
142 | }
143 |
144 | Log.d(TAG, "canSU() su[" + r.exit_value + "]: " + out);
145 | can_su = r.success();
146 | }
147 | return can_su;
148 | }
149 | }
150 |
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/util/CPUStateMonitor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Performance Control - An Android CPU Control application Copyright (C)
3 | * Brandon Valosek, 2011 Copyright (C) Modified by 2012
4 | * James Roberts
5 | *
6 | * This program is free software: you can redistribute it and/or modify it under
7 | * the terms of the GNU General Public License as published by the Free Software
8 | * Foundation, either version 3 of the License, or (at your option) any later
9 | * version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | * details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * this program. If not, see .
18 | */
19 |
20 | package com.brewcrewfoo.performance.util;
21 |
22 | import android.os.SystemClock;
23 |
24 | import java.io.*;
25 | import java.util.*;
26 |
27 | //@SuppressLint("UseSparseArrays")
28 | public class CPUStateMonitor implements Constants {
29 |
30 | private List mStates = new ArrayList();
31 | private Map mOffsets = new HashMap();
32 |
33 | @SuppressWarnings("serial")
34 | public class CPUStateMonitorException extends Exception {
35 | public CPUStateMonitorException(String s) {
36 | super(s);
37 | }
38 | }
39 |
40 | //@SuppressLint({"UseValueOf", "UseValueOf"})
41 | public class CpuState implements Comparable {
42 | public CpuState(int a, long b) {
43 | freq = a;
44 | duration = b;
45 | }
46 |
47 | public int freq = 0;
48 | public long duration = 0;
49 |
50 | public int compareTo(CpuState state) {
51 | Integer a = new Integer(freq);
52 | Integer b = new Integer(state.freq);
53 | return a.compareTo(b);
54 | }
55 | }
56 |
57 | public List getStates() {
58 | List states = new ArrayList();
59 |
60 | for (CpuState state : mStates) {
61 | long duration = state.duration;
62 | if (mOffsets.containsKey(state.freq)) {
63 | long offset = mOffsets.get(state.freq);
64 | if (offset <= duration) {
65 | duration -= offset;
66 | } else {
67 | mOffsets.clear();
68 | return getStates();
69 | }
70 | }
71 | states.add(new CpuState(state.freq, duration));
72 | }
73 | return states;
74 | }
75 |
76 | public long getTotalStateTime() {
77 | long sum = 0;
78 | long offset = 0;
79 |
80 | for (CpuState state : mStates) {
81 | sum += state.duration;
82 | }
83 |
84 | for (Map.Entry entry : mOffsets.entrySet()) {
85 | offset += entry.getValue();
86 | }
87 | return sum - offset;
88 | }
89 |
90 | public Map getOffsets() {
91 | return mOffsets;
92 | }
93 |
94 | public void setOffsets(Map offsets) {
95 | mOffsets = offsets;
96 | }
97 |
98 | public void setOffsets() throws CPUStateMonitorException {
99 | mOffsets.clear();
100 | updateStates();
101 |
102 | for (CpuState state : mStates) {
103 | mOffsets.put(state.freq, state.duration);
104 | }
105 | }
106 |
107 | public void removeOffsets() {
108 | mOffsets.clear();
109 | }
110 |
111 | public List updateStates() throws CPUStateMonitorException {
112 | try {
113 | InputStream is = new FileInputStream(TIME_IN_STATE_PATH);
114 | InputStreamReader ir = new InputStreamReader(is);
115 | BufferedReader br = new BufferedReader(ir);
116 | mStates.clear();
117 | readInStates(br);
118 | is.close();
119 | } catch (IOException e) {
120 | throw new CPUStateMonitorException(
121 | "Problem opening time-in-states file");
122 | }
123 |
124 | long sleepTime = (SystemClock.elapsedRealtime() - SystemClock.uptimeMillis()) / 10;
125 | mStates.add(new CpuState(0, sleepTime));
126 |
127 | Collections.sort(mStates, Collections.reverseOrder());
128 |
129 | return mStates;
130 | }
131 |
132 | private void readInStates(BufferedReader br)
133 | throws CPUStateMonitorException {
134 | try {
135 | String line;
136 | while ((line = br.readLine()) != null) {
137 | String[] nums = line.split(" ");
138 | mStates.add(new CpuState(Integer.parseInt(nums[0]), Long.parseLong(nums[1])));
139 | }
140 | } catch (IOException e) {
141 | throw new CPUStateMonitorException(
142 | "Problem processing time-in-states file");
143 | }
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/util/DragSortItemView.java:
--------------------------------------------------------------------------------
1 | package com.brewcrewfoo.performance.util;
2 | /*
3 | A subclass of the Android ListView component that enables drag
4 | and drop re-ordering of list items.
5 |
6 | Copyright 2012 Carl Bauer
7 |
8 | Licensed under the Apache License, Version 2.0 (the "License");
9 | you may not use this file except in compliance with the License.
10 | You may obtain a copy of the License at
11 |
12 | http://www.apache.org/licenses/LICENSE-2.0
13 |
14 | Unless required by applicable law or agreed to in writing, software
15 | distributed under the License is distributed on an "AS IS" BASIS,
16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 | See the License for the specific language governing permissions and
18 | limitations under the License.
19 | */
20 |
21 | import android.content.Context;
22 | import android.view.Gravity;
23 | import android.view.View;
24 | import android.view.ViewGroup;
25 | import android.widget.AbsListView;
26 | public class DragSortItemView extends ViewGroup {
27 |
28 | private int mGravity = Gravity.TOP;
29 |
30 | public DragSortItemView(Context context) {
31 | super(context);
32 |
33 | // always init with standard ListView layout params
34 | setLayoutParams(new AbsListView.LayoutParams(
35 | ViewGroup.LayoutParams.FILL_PARENT,
36 | ViewGroup.LayoutParams.WRAP_CONTENT));
37 |
38 | //setClipChildren(true);
39 | }
40 |
41 | public void setGravity(int gravity) {
42 | mGravity = gravity;
43 | }
44 |
45 | public int getGravity() {
46 | return mGravity;
47 | }
48 |
49 | @Override
50 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
51 | final View child = getChildAt(0);
52 |
53 | if (child == null) {
54 | return;
55 | }
56 |
57 | if (mGravity == Gravity.TOP) {
58 | child.layout(0, 0, getMeasuredWidth(), child.getMeasuredHeight());
59 | } else {
60 | child.layout(0, getMeasuredHeight() - child.getMeasuredHeight(), getMeasuredWidth(), getMeasuredHeight());
61 | }
62 | }
63 |
64 | /**
65 | *
66 | */
67 | @Override
68 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
69 |
70 | int height = MeasureSpec.getSize(heightMeasureSpec);
71 | int width = MeasureSpec.getSize(widthMeasureSpec);
72 |
73 | int heightMode = MeasureSpec.getMode(heightMeasureSpec);
74 |
75 | final View child = getChildAt(0);
76 | if (child == null) {
77 | setMeasuredDimension(0, width);
78 | return;
79 | }
80 |
81 | if (child.isLayoutRequested()) {
82 | // Always let child be as tall as it wants.
83 | measureChild(child, widthMeasureSpec,
84 | MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
85 | }
86 |
87 | if (heightMode == MeasureSpec.UNSPECIFIED) {
88 | ViewGroup.LayoutParams lp = getLayoutParams();
89 |
90 | if (lp.height > 0) {
91 | height = lp.height;
92 | } else {
93 | height = child.getMeasuredHeight();
94 | }
95 | }
96 |
97 | setMeasuredDimension(width, height);
98 | }
99 |
100 | }
101 |
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/util/DragSortItemViewCheckable.java:
--------------------------------------------------------------------------------
1 | package com.brewcrewfoo.performance.util;
2 |
3 | /*
4 | A subclass of the Android ListView component that enables drag
5 | and drop re-ordering of list items.
6 |
7 | Copyright 2012 Carl Bauer
8 |
9 | Licensed under the Apache License, Version 2.0 (the "License");
10 | you may not use this file except in compliance with the License.
11 | You may obtain a copy of the License at
12 |
13 | http://www.apache.org/licenses/LICENSE-2.0
14 |
15 | Unless required by applicable law or agreed to in writing, software
16 | distributed under the License is distributed on an "AS IS" BASIS,
17 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | See the License for the specific language governing permissions and
19 | limitations under the License.
20 | */
21 | import android.content.Context;
22 | import android.view.View;
23 | import android.widget.Checkable;
24 |
25 | public class DragSortItemViewCheckable extends DragSortItemView implements Checkable {
26 |
27 | public DragSortItemViewCheckable(Context context) {
28 | super(context);
29 | }
30 |
31 | @Override
32 | public boolean isChecked() {
33 | View child = getChildAt(0);
34 | if (child instanceof Checkable)
35 | return ((Checkable) child).isChecked();
36 | else
37 | return false;
38 | }
39 |
40 | @Override
41 | public void setChecked(boolean checked) {
42 | View child = getChildAt(0);
43 | if (child instanceof Checkable)
44 | ((Checkable) child).setChecked(checked);
45 | }
46 |
47 | @Override
48 | public void toggle() {
49 | View child = getChildAt(0);
50 | if (child instanceof Checkable)
51 | ((Checkable) child).toggle();
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/util/FileArrayAdapter.java:
--------------------------------------------------------------------------------
1 | package com.brewcrewfoo.performance.util;
2 |
3 | /**
4 | * Created by h0rn3t on 22.07.2013.
5 | */
6 |
7 | import java.util.List;
8 |
9 | import android.content.Context;
10 | import android.graphics.Typeface;
11 | import android.view.LayoutInflater;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 | import android.widget.ArrayAdapter;
15 | import android.widget.TextView;
16 |
17 | import com.brewcrewfoo.performance.R;
18 |
19 |
20 | public class FileArrayAdapter extends ArrayAdapter- {
21 |
22 | private Context c;
23 | private int id;
24 | private List
- items;
25 |
26 | public FileArrayAdapter(Context context, int textViewResourceId,List
- objects) {
27 | super(context, textViewResourceId, objects);
28 | c = context;
29 | id = textViewResourceId;
30 | items = objects;
31 | }
32 | public Item getItem(int i){
33 | return items.get(i);
34 | }
35 | public void setItem(Item o,String d){
36 | o.setDate(d);
37 | notifyDataSetChanged();
38 | }
39 | @Override
40 | public View getView(int position, View convertView, ViewGroup parent) {
41 | View v = convertView;
42 |
43 | if (v == null) {
44 | LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
45 | v = vi.inflate(id, parent,false);
46 | }
47 |
48 | final Item o = items.get(position);
49 | if (o != null) {
50 | TextView t1 = (TextView) v.findViewById(R.id.TextView01);
51 | TextView t2 = (TextView) v.findViewById(R.id.TextView02);
52 | TextView t3 = (TextView) v.findViewById(R.id.TextViewDate);
53 |
54 | if(t1!=null){
55 | if(o.getImage().equalsIgnoreCase("dir")){t1.setTypeface(null, Typeface.BOLD);}
56 | else{t1.setTypeface(null, Typeface.NORMAL);}
57 | t1.setText(o.getName());
58 | }
59 | if(t2!=null){
60 | if(o.getData()==null){
61 | t2.setVisibility(View.GONE);
62 | }
63 | else{
64 | t2.setText(o.getData());
65 | t2.setVisibility(View.VISIBLE);
66 | }
67 | }
68 | if(t3!=null){
69 | if(o.getDate()==null){
70 | t3.setVisibility(View.GONE);
71 | }
72 | else{
73 | t3.setText(o.getDate());
74 | t3.setVisibility(View.VISIBLE);
75 | }
76 | }
77 | }
78 | return v;
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/util/GPUClass.java:
--------------------------------------------------------------------------------
1 | package com.brewcrewfoo.performance.util;
2 |
3 | import android.util.Log;
4 |
5 | import java.io.File;
6 |
7 | /**
8 | * Created by h0rn3t on 13.02.2014.
9 | * http://forum.xda-developers.com/member.php?u=4674443
10 | */
11 | public class GPUClass implements Constants{
12 | private String clkpath=null;
13 | private String clkvals="";
14 |
15 | public GPUClass(){
16 | gpu_clk();
17 | Log.d(TAG, "detect gpu freq path: " + this.clkpath);
18 | }
19 | public String gpuclk_path(){
20 | return this.clkpath;
21 | }
22 | public CharSequence[] gpuclk_values(){
23 | return this.clkvals.split("\\s");
24 | }
25 | public CharSequence[] gpuclk_names(){
26 | CharSequence[] v=gpuclk_values();
27 | for(int i=0;i{
8 | private String name;
9 | private String data;
10 | private String date;
11 | private String path;
12 | private String image;
13 |
14 | public Item(String n,String d, String dt, String p, String img){
15 | name = n;
16 | data = d;
17 | date = dt;
18 | path = p;
19 | image = img;
20 |
21 | }
22 | public String getName(){
23 | return name;
24 | }
25 | public void setName(String d){
26 | this.name=d;
27 | }
28 | public String getData(){
29 | return data;
30 | }
31 | public void setData(String d){
32 | this.data=d;
33 | }
34 | public String getDate(){
35 | return date;
36 | }
37 | public void setDate(String d){
38 | this.date=d;
39 | }
40 | public String getPath(){
41 | return path;
42 | }
43 | public String getImage() {
44 | return image;
45 | }
46 | public int compareTo(Item o) {
47 | if(this.name != null)
48 | return this.name.toLowerCase().compareTo(o.getName().toLowerCase());
49 | else
50 | throw new IllegalArgumentException();
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/util/PackAdapter.java:
--------------------------------------------------------------------------------
1 | package com.brewcrewfoo.performance.util;
2 |
3 | /**
4 | * Created by h0rn3t on 17.07.2013.
5 | */
6 | import android.app.Activity;
7 | import android.content.pm.PackageInfo;
8 | import android.content.pm.PackageManager;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.widget.ArrayAdapter;
13 | import android.widget.ImageView;
14 | import android.widget.TextView;
15 |
16 | import com.brewcrewfoo.performance.R;
17 |
18 | import java.util.ArrayList;
19 |
20 | public class PackAdapter extends ArrayAdapter {
21 |
22 | private final ArrayList list;
23 | private final Activity context;
24 |
25 | public PackAdapter(Activity context, ArrayList list) {
26 | super(context, R.layout.pack_item, list);
27 | this.context = context;
28 | this.list = list;
29 | }
30 | public void delItem(int p){
31 | list.remove(p);
32 | notifyDataSetChanged();
33 | }
34 | public ArrayList getList(){
35 | return list;
36 | }
37 | static class ViewHolder {
38 | public TextView app,pack;
39 | public ImageView image;
40 | }
41 | @Override
42 | public View getView(int position, View convertView, ViewGroup parent) {
43 | View rowView = convertView;
44 | if (rowView == null) {
45 | LayoutInflater inflater = context.getLayoutInflater();
46 | rowView = inflater.inflate(R.layout.pack_item, parent,false);
47 | ViewHolder viewHolder = new ViewHolder();
48 | viewHolder.app = (TextView) rowView.findViewById(R.id.packname);
49 | viewHolder.pack = (TextView) rowView.findViewById(R.id.packraw);
50 | viewHolder.image = (ImageView) rowView.findViewById(R.id.icon);
51 | rowView.setTag(viewHolder);
52 | }
53 |
54 | ViewHolder holder = (ViewHolder) rowView.getTag();
55 | final String npack=getItem(position).getPackName();
56 | holder.pack.setText(npack);
57 | holder.app.setText(getItem(position).getAppName());
58 | try {
59 | PackageInfo packageInfo = context.getPackageManager().getPackageInfo(npack, 0);
60 | holder.image.setImageDrawable(context.getPackageManager().getApplicationIcon(packageInfo.applicationInfo));
61 | }
62 | catch (PackageManager.NameNotFoundException e) {
63 | e.printStackTrace();
64 | }
65 | return rowView;
66 | }
67 |
68 |
69 | }
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/util/PackItem.java:
--------------------------------------------------------------------------------
1 | package com.brewcrewfoo.performance.util;
2 |
3 | import android.content.pm.PackageInfo;
4 | import android.content.pm.PackageManager;
5 |
6 | import com.brewcrewfoo.performance.activities.MainActivity;
7 |
8 | /**
9 | * Created by h0rn3t on 29.05.2014.
10 | * http://forum.xda-developers.com/member.php?u=4674443
11 | */
12 | public class PackItem {
13 | private String packname,appname;
14 |
15 | public PackItem(String p) {
16 | try {
17 | PackageInfo packageInfo = MainActivity.c.getPackageManager().getPackageInfo(p, 0);
18 | this.appname = MainActivity.c.getPackageManager().getApplicationLabel(packageInfo.applicationInfo).toString();
19 | }
20 | catch (PackageManager.NameNotFoundException e) {
21 | //e.printStackTrace();
22 | this.appname = "";
23 | }
24 | this.packname = p;
25 | }
26 |
27 | public String getPackName() {
28 | return packname;
29 | }
30 | public String getAppName() {
31 | return appname;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/util/Prop.java:
--------------------------------------------------------------------------------
1 | package com.brewcrewfoo.performance.util;
2 |
3 | /**
4 | * Created by h0rn3t on 22.09.2013.
5 | */
6 | public class Prop implements Comparable {
7 |
8 | private String name;
9 | private String data;
10 |
11 | public Prop(String n,String d){
12 | name = n;
13 | data = d;
14 | }
15 | public String getName(){
16 | return name;
17 | }
18 | public void setName(String d){
19 | this.name=d;
20 |
21 | }
22 | public String getVal(){
23 | return data;
24 | }
25 | public void setVal(String d){
26 | this.data=d;
27 | }
28 | public int compareTo(Prop o) {
29 | if(this.name != null)
30 | return this.name.toLowerCase().compareTo(o.getName().toLowerCase());
31 | else
32 | throw new IllegalArgumentException();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/util/PropAdapter.java:
--------------------------------------------------------------------------------
1 | package com.brewcrewfoo.performance.util;
2 | /**
3 | * Created by h0rn3t on 22.09.2013.
4 | */
5 |
6 | import android.content.Context;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.ArrayAdapter;
11 | import android.widget.Filter;
12 | import android.widget.TextView;
13 |
14 | import com.brewcrewfoo.performance.R;
15 |
16 | import java.util.ArrayList;
17 | import java.util.List;
18 |
19 | public class PropAdapter extends ArrayAdapter {
20 | private Context c;
21 | private int id;
22 | private List props;
23 | private Filter filter;
24 |
25 | public PropAdapter(Context context, int textViewResourceId,List objects) {
26 | super(context, textViewResourceId, objects);
27 | c = context;
28 | id = textViewResourceId;
29 | props = objects;
30 | }
31 | public Prop getItem(int i){
32 | return props.get(i);
33 | }
34 |
35 | @Override
36 | public View getView(int position, View convertView, ViewGroup parent) {
37 | View v = convertView;
38 |
39 | if (v == null) {
40 | LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
41 | v = vi.inflate(id, parent,false);
42 | }
43 |
44 | final Prop p = props.get(position);
45 | if (p != null) {
46 | TextView pp = (TextView) v.findViewById(R.id.prop);
47 | TextView pv = (TextView) v.findViewById(R.id.pval);
48 | if(pp!=null){
49 | pp.setText(p.getName());
50 | }
51 | if(pv!=null){
52 | pv.setText(p.getVal());
53 | }
54 |
55 | }
56 | return v;
57 | }
58 |
59 | @Override
60 | public Filter getFilter(){
61 | if(filter == null)
62 | filter = new AppFilter(props);
63 | return filter;
64 | }
65 |
66 | private class AppFilter extends Filter {
67 | private List sourceObjects;
68 | public AppFilter(List props) {
69 | sourceObjects = new ArrayList();
70 | synchronized (this) {
71 | sourceObjects.addAll(props);
72 | }
73 | }
74 |
75 | @Override
76 | protected FilterResults performFiltering(CharSequence chars) {
77 | String filterSeq = chars.toString().toLowerCase();
78 | FilterResults result = new FilterResults();
79 | if (filterSeq != null && filterSeq.length() > 0) {
80 | List filter = new ArrayList();
81 | for (Prop o : props) {
82 | if (o.getName().toLowerCase().contains(filterSeq))
83 | filter.add(o);
84 | }
85 | result.count = filter.size();
86 | result.values = filter;
87 | }
88 | else {
89 | synchronized (this) {
90 | result.values = sourceObjects;
91 | result.count = sourceObjects.size();
92 | }
93 | }
94 | return result;
95 | }
96 |
97 | @Override
98 | protected void publishResults(CharSequence constraint,FilterResults results) {
99 | List filtered = (List) results.values;
100 | notifyDataSetChanged();
101 | clear();
102 | for (Prop aFiltered : filtered) add(aFiltered);
103 | notifyDataSetInvalidated();
104 | }
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/util/PropUtil.java:
--------------------------------------------------------------------------------
1 | package com.brewcrewfoo.performance.util;
2 |
3 | import android.content.SharedPreferences;
4 |
5 | import java.util.ArrayList;
6 | import java.util.Arrays;
7 | import java.util.HashSet;
8 | import java.util.List;
9 | import java.util.Set;
10 |
11 | /**
12 | * Created by h0rn3t on 10.02.2014.
13 | * http://forum.xda-developers.com/member.php?u=4674443
14 | */
15 | public class PropUtil implements Constants {
16 | private static Set exclude = new HashSet();
17 |
18 | public static void add_exclude(String s){
19 | exclude.add(s);
20 | }
21 |
22 | public static List load_prop(String s){
23 | List props = new ArrayList();
24 | props.clear();
25 | if(s==null) return props;
26 | final String p[]=s.split("\0");
27 | for (String aP : p) {
28 | try{
29 | //if(aP!=null && aP.contains("::")){
30 | if(aP!=null){
31 | String pn=aP;
32 | pn=pn.substring(pn.lastIndexOf("/") + 1, pn.length()).trim();
33 | if(!exclude.contains(pn))
34 | props.add(new Prop(pn,Helpers.readOneLine(aP).trim()));
35 | }
36 | }
37 | catch (Exception e){
38 | }
39 | }
40 | return props;
41 | }
42 |
43 | public static void set_pref(String n, String v,String pref,SharedPreferences mPreferences){
44 | final String s=mPreferences.getString(pref,"");
45 | final StringBuilder sb = new StringBuilder();
46 | if(!s.equals("")){
47 | String p[]=s.split(";");
48 | for (String aP : p) {
49 | if(aP!=null && aP.contains(":")){
50 | final String pn[]=aP.split(":");
51 | if(!pn[0].equals(n)) sb.append(pn[0]).append(':').append(pn[1]).append(';');
52 | }
53 | }
54 | }
55 | sb.append(n).append(':').append(v).append(';');
56 | mPreferences.edit().putString(pref, sb.toString()).commit();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/util/SimpleFloatViewManager.java:
--------------------------------------------------------------------------------
1 | package com.brewcrewfoo.performance.util;
2 | /*
3 | A subclass of the Android ListView component that enables drag
4 | and drop re-ordering of list items.
5 |
6 | Copyright 2012 Carl Bauer
7 |
8 | Licensed under the Apache License, Version 2.0 (the "License");
9 | you may not use this file except in compliance with the License.
10 | You may obtain a copy of the License at
11 |
12 | http://www.apache.org/licenses/LICENSE-2.0
13 |
14 | Unless required by applicable law or agreed to in writing, software
15 | distributed under the License is distributed on an "AS IS" BASIS,
16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 | See the License for the specific language governing permissions and
18 | limitations under the License.
19 | */
20 | import android.graphics.Bitmap;
21 | import android.graphics.Point;
22 | import android.graphics.Color;
23 | import android.widget.ListView;
24 | import android.widget.ImageView;
25 | import android.view.View;
26 | import android.view.ViewGroup;
27 |
28 | public class SimpleFloatViewManager implements DragSortListView.FloatViewManager {
29 |
30 | private Bitmap mFloatBitmap;
31 |
32 | private ImageView mImageView;
33 |
34 | private int mFloatBGColor = Color.BLACK;
35 |
36 | private ListView mListView;
37 |
38 | public SimpleFloatViewManager(ListView lv) {
39 | mListView = lv;
40 | }
41 |
42 | public void setBackgroundColor(int color) {
43 | mFloatBGColor = color;
44 | }
45 |
46 | /**
47 | * This simple implementation creates a Bitmap copy of the
48 | * list item currently shown at ListView
position
.
49 | */
50 | @Override
51 | public View onCreateFloatView(int position) {
52 | // Guaranteed that this will not be null? I think so. Nope, got
53 | // a NullPointerException once...
54 | View v = mListView.getChildAt(position + mListView.getHeaderViewsCount() - mListView.getFirstVisiblePosition());
55 |
56 | if (v == null) {
57 | return null;
58 | }
59 |
60 | v.setPressed(false);
61 |
62 | // Create a copy of the drawing cache so that it does not get
63 | // recycled by the framework when the list tries to clean up memory
64 | //v.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
65 | v.setDrawingCacheEnabled(true);
66 | mFloatBitmap = Bitmap.createBitmap(v.getDrawingCache());
67 | v.setDrawingCacheEnabled(false);
68 |
69 | if (mImageView == null) {
70 | mImageView = new ImageView(mListView.getContext());
71 | }
72 | mImageView.setBackgroundColor(mFloatBGColor);
73 | mImageView.setPadding(0, 0, 0, 0);
74 | mImageView.setImageBitmap(mFloatBitmap);
75 | mImageView.setLayoutParams(new ViewGroup.LayoutParams(v.getWidth(), v.getHeight()));
76 |
77 | return mImageView;
78 | }
79 |
80 | /**
81 | * This does nothing
82 | */
83 | @Override
84 | public void onDragFloatView(View floatView, Point position, Point touch) {
85 | // do nothing
86 | }
87 |
88 | /**
89 | * Removes the Bitmap from the ImageView created in
90 | * onCreateFloatView() and tells the system to recycle it.
91 | */
92 | @Override
93 | public void onDestroyFloatView(View floatView) {
94 | ((ImageView) floatView).setImageDrawable(null);
95 |
96 | mFloatBitmap.recycle();
97 | mFloatBitmap = null;
98 | }
99 |
100 | }
101 |
102 |
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/util/Tab.java:
--------------------------------------------------------------------------------
1 | package com.brewcrewfoo.performance.util;
2 |
3 | /**
4 | * Created by H0RN3T on 01.09.2014.
5 | */
6 | public class Tab {
7 | String name = null;
8 | boolean selected = false;
9 | long id=-1;
10 |
11 | public Tab(String name, boolean selected,int id) {
12 | super();
13 | this.name = name;
14 | this.selected = selected;
15 | this.id=id;
16 | }
17 |
18 | public String getName() {
19 | return name;
20 | }
21 | public void setName(String name) {
22 | this.name = name;
23 | }
24 | public boolean isSelected() {
25 | return selected;
26 | }
27 | public void setSelected(boolean selected) { this.selected = selected; }
28 | public long getId(){return id;}
29 | }
30 |
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/util/TabAdapter.java:
--------------------------------------------------------------------------------
1 | package com.brewcrewfoo.performance.util;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.ArrayAdapter;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | import com.brewcrewfoo.performance.R;
12 |
13 | import java.util.ArrayList;
14 |
15 | /**
16 | * Created by H0RN3T on 05.09.2014.
17 | */
18 | public class TabAdapter extends ArrayAdapter {
19 | private ArrayList TabList;
20 | private Context context;
21 |
22 | public TabAdapter(Context context, int textViewResourceId,ArrayList TabList) {
23 | super(context, textViewResourceId, TabList);
24 | this.context=context;
25 | this.TabList = new ArrayList();
26 | this.TabList.addAll(TabList);
27 | }
28 |
29 |
30 | public class ViewHolder {
31 | public TextView name;
32 | public ImageView status;
33 | }
34 |
35 | @Override
36 | public View getView(int position, View convertView, ViewGroup parent) {
37 | ViewHolder holder = null;
38 | if (convertView == null) {
39 | LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
40 | convertView = vi.inflate(R.layout.tab_item, parent,false);
41 |
42 | holder = new ViewHolder();
43 | holder.name = (TextView) convertView.findViewById(R.id.label);
44 | holder.status=(ImageView) convertView.findViewById(R.id.status);
45 |
46 | convertView.setTag(holder);
47 | }
48 | else {
49 | holder = (ViewHolder) convertView.getTag();
50 | }
51 |
52 | Tab t = getItem(position);
53 | holder.name.setText(t.getName());
54 | if(t.isSelected()){
55 | holder.status.setImageDrawable(context.getResources().getDrawable(android.R.drawable.checkbox_on_background));
56 | }
57 | else{
58 | holder.status.setImageDrawable(context.getResources().getDrawable(android.R.drawable.checkbox_off_background));
59 | }
60 |
61 | return convertView;
62 |
63 | }
64 |
65 | }
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/util/UnzipUtility.java:
--------------------------------------------------------------------------------
1 | package com.brewcrewfoo.performance.util;
2 |
3 | import android.util.Log;
4 |
5 | import java.io.BufferedOutputStream;
6 | import java.io.File;
7 | import java.io.FileInputStream;
8 | import java.io.FileOutputStream;
9 | import java.io.IOException;
10 | import java.util.zip.ZipEntry;
11 | import java.util.zip.ZipInputStream;
12 |
13 | /**
14 | * Created by h0rn3t on 27.08.2013.
15 | */
16 | public class UnzipUtility implements Constants {
17 | private static final int BUFFER_SIZE = 4096;
18 |
19 | public void unzipall(String zipFilePath, String destDirectory) throws IOException {
20 | File destDir = new File(destDirectory);
21 | if (!destDir.exists()) {destDir.mkdir();}
22 |
23 | ZipInputStream zipIn = new ZipInputStream(new FileInputStream(zipFilePath));
24 | ZipEntry entry = zipIn.getNextEntry();
25 | while (entry != null) {
26 | if (!entry.isDirectory()) {
27 | File dir=new File(destDirectory,entry.getName());
28 | if(!dir.getParentFile().exists())
29 | dir.getParentFile().mkdirs();
30 | extractFile(zipIn, destDirectory+"/"+entry.getName());
31 | }
32 |
33 | zipIn.closeEntry();
34 | entry = zipIn.getNextEntry();
35 | }
36 | zipIn.close();
37 | }
38 | public void unzipfile(String zipFilePath, String destDirectory,String[] f) throws IOException {
39 | File destDir = new File(destDirectory);
40 | if (!destDir.exists()) {destDir.mkdir();}
41 |
42 | ZipInputStream zipIn = new ZipInputStream(new FileInputStream(zipFilePath));
43 | ZipEntry entry = zipIn.getNextEntry();
44 | while (entry != null) {
45 | //if (!entry.isDirectory() && entry.getName().contains(f)) {
46 | if (!entry.isDirectory() && inlist(entry.getName(),f)) {
47 |
48 | File dir=new File(destDirectory,entry.getName());
49 | if(!dir.getParentFile().exists())
50 | dir.getParentFile().mkdirs();
51 | extractFile(zipIn, destDirectory+"/"+entry.getName());
52 | zipIn.closeEntry();
53 | //break;
54 | }
55 | zipIn.closeEntry();
56 | entry = zipIn.getNextEntry();
57 | }
58 | zipIn.close();
59 | }
60 | private boolean inlist(String e,String[] f){
61 | boolean flag=false;
62 | for (String a : f) {
63 | if (e.contains(a)) {
64 | flag= true;
65 | break;
66 | }
67 | }
68 | return flag;
69 | }
70 | private void extractFile(ZipInputStream zipIn, String filePath) throws IOException {
71 | BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(filePath));
72 | byte[] bytesIn = new byte[BUFFER_SIZE];
73 | int read = 0;
74 | while ((read = zipIn.read(bytesIn)) != -1) {
75 | bos.write(bytesIn, 0, read);
76 | }
77 | bos.close();
78 | }
79 |
80 | public Boolean testZip(String zipFilePath,String tip) throws IOException {
81 | ZipInputStream zipIn = new ZipInputStream(new FileInputStream(zipFilePath));
82 | ZipEntry entry = zipIn.getNextEntry();
83 | String f="recovery.img";
84 | if(tip.equalsIgnoreCase("kernel")){ f="boot.img";}
85 | boolean gasit=false;
86 | while (entry != null) {
87 | if (!entry.isDirectory()) {
88 | if(entry.getName().contains(f)){gasit=true;break;}
89 | }
90 | zipIn.closeEntry();
91 | entry = zipIn.getNextEntry();
92 | }
93 | zipIn.close();
94 | return gasit;
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/util/VibratorClass.java:
--------------------------------------------------------------------------------
1 | package com.brewcrewfoo.performance.util;
2 |
3 | import android.util.Log;
4 | import java.io.File;
5 |
6 | /**
7 | * Created by h0rn3t on 05.01.2014.
8 | * http://forum.xda-developers.com/member.php?u=4674443
9 | */
10 | public class VibratorClass implements Constants {
11 | private int max=0;
12 | private int min=0;
13 | private String path=null;
14 |
15 | public int get_min(){
16 | return min;
17 | }
18 | public int get_max(){
19 | return max;
20 | }
21 | public String get_val(String p){
22 | return getOnlyNumerics(Helpers.readOneLine(p));
23 | }
24 | public String get_path(){
25 | if (new File("/sys/class/vibetonz/immDuty/pwmvalue_intensity").exists()) {
26 | this.min=0;
27 | this.max=127;
28 | this.path= "/sys/class/vibetonz/immDuty/pwmvalue_intensity";
29 | Log.d(TAG, "vibe path detected: "+this.path);
30 | }
31 | else if (new File("/sys/vibrator/pwmvalue").exists()) {
32 | this.min=0;
33 | this.max=127;
34 | this.path= "/sys/vibrator/pwmvalue";
35 | Log.d(TAG, "vibe path detected: "+this.path);
36 | }
37 | else if (new File("/sys/class/misc/vibratorcontrol/vibrator_strength").exists()) {
38 | this.min=1000;
39 | this.max=1600;
40 | this.path= "/sys/class/misc/vibratorcontrol/vibrator_strength";
41 | Log.d(TAG, "vibe path detected: "+this.path);
42 | }
43 | else if (new File("/sys/vibe/pwmduty").exists()) {
44 | this.min=1000;
45 | this.max=1450;
46 | this.path= "/sys/vibe/pwmduty";
47 | Log.d(TAG, "vibe path detected: "+this.path);
48 | }
49 | else if (new File("/sys/class/timed_output/vibrator/amp").exists()) {
50 | this.min=0;
51 | this.max=100;
52 | this.path= "/sys/class/timed_output/vibrator/amp";
53 | Log.d(TAG, "vibe path detected: "+this.path);
54 | }
55 | else if (new File("/sys/class/misc/pwm_duty/pwm_duty").exists()) {
56 | this.min=0;
57 | this.max=100;
58 | this.path="/sys/class/misc/pwm_duty/pwm_duty";
59 | Log.d(TAG, "vibe path detected: "+this.path);
60 | }
61 | else if (new File("/sys/devices/virtual/timed_output/vibrator/voltage_level").exists()) {
62 | this.min=1200;
63 | this.max=3100;
64 | this.path="/sys/devices/virtual/timed_output/vibrator/voltage_level";
65 | Log.d(TAG, "vibe path detected: "+this.path);
66 | }
67 | else{
68 | this.path=null;
69 | Log.d(TAG, "vibe path not detected");
70 | }
71 | return this.path;
72 | }
73 | private String getOnlyNumerics(String str) {
74 | if (str == null) {
75 | Log.e(TAG, "vibe value read error");
76 | return "0";
77 | }
78 | StringBuffer strBuff = new StringBuffer();
79 | char c;
80 | for (int i = 0; i < str.length() ; i++) {
81 | c = str.charAt(i);
82 | if (Character.isDigit(c)) {
83 | strBuff.append(c);
84 | }
85 | }
86 | return strBuff.toString();
87 | }
88 |
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/util/Voltage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Performance Control - An Android CPU Control application Copyright (C) 2012
3 | * Jared Rummler Copyright (C) 2012 James Roberts
4 | *
5 | * This program is free software: you can redistribute it and/or modify it under
6 | * the terms of the GNU General Public License as published by the Free Software
7 | * Foundation, either version 3 of the License, or (at your option) any later
8 | * version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 | * details.
14 | *
15 | * You should have received a copy of the GNU General Public License along with
16 | * this program. If not, see .
17 | */
18 |
19 | package com.brewcrewfoo.performance.util;
20 |
21 | public class Voltage {
22 | private String mFreq;
23 | private String mCurrentMv;
24 | private String mSavedMv;
25 |
26 | public void setFreq(final String freq) {
27 | this.mFreq = freq;
28 | }
29 |
30 | public String getFreq() {
31 | return mFreq;
32 | }
33 |
34 | public void setCurrentMV(final String currentMv) {
35 | this.mCurrentMv = currentMv;
36 | }
37 |
38 | public String getCurrentMv() {
39 | return mCurrentMv;
40 | }
41 |
42 | public void setSavedMV(final String savedMv) {
43 | this.mSavedMv = savedMv;
44 | }
45 |
46 | public String getSavedMV() {
47 | return mSavedMv;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/com/brewcrewfoo/performance/widget/PCWidget.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Performance Control - An Android CPU Control application Copyright (C) 2012
3 | * James Roberts
4 | *
5 | * This program is free software: you can redistribute it and/or modify it under
6 | * the terms of the GNU General Public License as published by the Free Software
7 | * Foundation, either version 3 of the License, or (at your option) any later
8 | * version.
9 | *
10 | * This program is distributed in the hope that it will be useful, but WITHOUT
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 | * details.
14 | *
15 | * You should have received a copy of the GNU General Public License along with
16 | * this program. If not, see .
17 | */
18 |
19 | package com.brewcrewfoo.performance.widget;
20 |
21 | import android.app.PendingIntent;
22 | import android.appwidget.AppWidgetManager;
23 | import android.appwidget.AppWidgetProvider;
24 | import android.content.ComponentName;
25 | import android.content.Context;
26 | import android.content.Intent;
27 | import android.content.SharedPreferences;
28 | import android.os.Bundle;
29 | import android.preference.PreferenceManager;
30 | import android.widget.RemoteViews;
31 | import com.brewcrewfoo.performance.R;
32 | import com.brewcrewfoo.performance.activities.MainActivity;
33 | import com.brewcrewfoo.performance.util.Constants;
34 | import com.brewcrewfoo.performance.util.Helpers;
35 |
36 |
37 | public class PCWidget extends AppWidgetProvider implements Constants {
38 | SharedPreferences mPreferences;
39 |
40 | @Override
41 | public void onReceive(Context context, Intent intent) {
42 | super.onReceive(context, intent);
43 | Bundle extras = intent.getExtras();
44 | if (extras == null) return;
45 | final AppWidgetManager awm = AppWidgetManager.getInstance(context);
46 | final ComponentName nm = new ComponentName(context, PCWidget.class);
47 | final String action = intent.getAction();
48 | if (action!=null && action.equals("com.brewcrewfoo.performance.ACTION_FREQS_CHANGED")) {
49 | onUpdate(context, awm, awm.getAppWidgetIds(nm));
50 | }
51 | }
52 |
53 | @Override
54 | public void onUpdate(Context context, AppWidgetManager appWidgetManager,int[] appWidgetIds) {
55 | int nCpus=Helpers.getNumOfCpus();
56 | int i=0;
57 | for (int awi : appWidgetIds) {
58 | String r;
59 | if(MainActivity.mMinFreqSetting.isEmpty() || MainActivity.mMaxFreqSetting.isEmpty() || MainActivity.mCurGovernor.isEmpty() || MainActivity.mCurIO.isEmpty()){
60 | try {
61 | r = Helpers.readCPU(context, nCpus);
62 | }
63 | catch (Exception e){
64 | r=null;
65 | }
66 | if(r!=null)
67 | onUpdateWidget(context, appWidgetManager, awi, Helpers.toMHz(r.split(":")[i*5+1]), Helpers.toMHz(r.split(":")[i*5]), r.split(":")[i*5+2], r.split(":")[i*5+3],(i+1));
68 | else
69 | onUpdateWidget(context, appWidgetManager, awi, Helpers.toMHz("0"), Helpers.toMHz("0"), "-", "-",(i+1));
70 | }
71 | else{
72 | onUpdateWidget(context, appWidgetManager, awi, Helpers.toMHz(MainActivity.mMaxFreqSetting.get(i)), Helpers.toMHz(MainActivity.mMinFreqSetting.get(i)), MainActivity.mCurGovernor.get(i), MainActivity.mCurIO.get(i), (i+1));
73 | }
74 | if(++i==nCpus) i=0;
75 | }
76 | }
77 |
78 | public void onUpdateWidget(Context context,AppWidgetManager appWidgetManager, int appWidgetId, String max,String min, String gov, String io,int curcpu) {
79 | mPreferences = PreferenceManager.getDefaultSharedPreferences(context);
80 | RemoteViews views = new RemoteViews(context.getPackageName(),R.layout.widget);
81 |
82 | int bgColor = mPreferences.getInt(PREF_WIDGET_BG_COLOR, 0xff000000);
83 | int textColor = mPreferences.getInt(PREF_WIDGET_TEXT_COLOR, 0xff808080);
84 | views.setImageViewBitmap(R.id.widget_bg, Helpers.getBackground(bgColor));
85 | views.setTextViewText(R.id.curcpu, "CPU "+curcpu);
86 | views.setTextViewText(R.id.max, max);
87 | views.setTextViewText(R.id.min, min);
88 | views.setTextViewText(R.id.gov, gov);
89 | views.setTextViewText(R.id.io, io);
90 | views.setTextColor(R.id.curcpu, textColor);
91 | views.setTextColor(R.id.max, textColor);
92 | views.setTextColor(R.id.min, textColor);
93 | views.setTextColor(R.id.io, textColor);
94 | views.setTextColor(R.id.gov, textColor);
95 |
96 | Intent intent = new Intent(context, MainActivity.class);
97 | intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
98 | intent.putExtra("cpu",curcpu-1);
99 | intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
100 | PendingIntent pendingIntent = PendingIntent.getActivity(context, appWidgetId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
101 | views.setOnClickPendingIntent(R.id.widget_bg, pendingIntent);
102 |
103 | appWidgetManager.updateAppWidget(appWidgetId, views);
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/src/net/margaritov/preference/colorpicker/AlphaPatternDrawable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Daniel Nilsson
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package net.margaritov.preference.colorpicker;
18 |
19 | import android.graphics.*;
20 | import android.graphics.Bitmap.Config;
21 | import android.graphics.drawable.Drawable;
22 |
23 | /**
24 | * This drawable that draws a simple white and gray chessboard pattern. It's
25 | * pattern you will often see as a background behind a partly transparent image
26 | * in many applications.
27 | *
28 | * @author Daniel Nilsson
29 | */
30 | public class AlphaPatternDrawable extends Drawable {
31 |
32 | private int mRectangleSize = 10;
33 |
34 | private Paint mPaint = new Paint();
35 | private Paint mPaintWhite = new Paint();
36 | private Paint mPaintGray = new Paint();
37 |
38 | private int numRectanglesHorizontal;
39 | private int numRectanglesVertical;
40 |
41 | /**
42 | * Bitmap in which the pattern will be cahched.
43 | */
44 | private Bitmap mBitmap;
45 |
46 | public AlphaPatternDrawable(int rectangleSize) {
47 | mRectangleSize = rectangleSize;
48 | mPaintWhite.setColor(0xffffffff);
49 | mPaintGray.setColor(0xffcbcbcb);
50 | }
51 |
52 | @Override
53 | public void draw(Canvas canvas) {
54 | canvas.drawBitmap(mBitmap, null, getBounds(), mPaint);
55 | }
56 |
57 | @Override
58 | public int getOpacity() {
59 | return 0;
60 | }
61 |
62 | @Override
63 | public void setAlpha(int alpha) {
64 | throw new UnsupportedOperationException(
65 | "Alpha is not supported by this drawwable.");
66 | }
67 |
68 | @Override
69 | public void setColorFilter(ColorFilter cf) {
70 | throw new UnsupportedOperationException(
71 | "ColorFilter is not supported by this drawwable.");
72 | }
73 |
74 | @Override
75 | protected void onBoundsChange(Rect bounds) {
76 | super.onBoundsChange(bounds);
77 |
78 | int height = bounds.height();
79 | int width = bounds.width();
80 |
81 | numRectanglesHorizontal = (int) Math.ceil((width / mRectangleSize));
82 | numRectanglesVertical = (int) Math.ceil(height / mRectangleSize);
83 |
84 | generatePatternBitmap();
85 |
86 | }
87 |
88 | /**
89 | * This will generate a bitmap with the pattern as big as the rectangle we
90 | * were allow to draw on. We do this to chache the bitmap so we don't need
91 | * to recreate it each time draw() is called since it takes a few
92 | * milliseconds.
93 | */
94 | private void generatePatternBitmap() {
95 |
96 | if (getBounds().width() <= 0 || getBounds().height() <= 0) {
97 | return;
98 | }
99 |
100 | mBitmap = Bitmap.createBitmap(getBounds().width(),
101 | getBounds().height(), Config.ARGB_8888);
102 | Canvas canvas = new Canvas(mBitmap);
103 |
104 | Rect r = new Rect();
105 | boolean verticalStartWhite = true;
106 | for (int i = 0; i <= numRectanglesVertical; i++) {
107 |
108 | boolean isWhite = verticalStartWhite;
109 | for (int j = 0; j <= numRectanglesHorizontal; j++) {
110 |
111 | r.top = i * mRectangleSize;
112 | r.left = j * mRectangleSize;
113 | r.bottom = r.top + mRectangleSize;
114 | r.right = r.left + mRectangleSize;
115 |
116 | canvas.drawRect(r, isWhite ? mPaintWhite : mPaintGray);
117 |
118 | isWhite = !isWhite;
119 | }
120 |
121 | verticalStartWhite = !verticalStartWhite;
122 |
123 | }
124 |
125 | }
126 |
127 | }
128 |
--------------------------------------------------------------------------------
/src/net/margaritov/preference/colorpicker/ColorPickerPanelView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Daniel Nilsson
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package net.margaritov.preference.colorpicker;
18 |
19 | import android.content.Context;
20 | import android.graphics.Canvas;
21 | import android.graphics.Paint;
22 | import android.graphics.RectF;
23 | import android.util.AttributeSet;
24 | import android.view.View;
25 |
26 | /**
27 | * This class draws a panel which which will be filled with a color which can be
28 | * set. It can be used to show the currently selected color which you will get
29 | * from the {@link ColorPickerView}.
30 | *
31 | * @author Daniel Nilsson
32 | */
33 | public class ColorPickerPanelView extends View {
34 |
35 | /**
36 | * The width in pixels of the border surrounding the color panel.
37 | */
38 | private final static float BORDER_WIDTH_PX = 1;
39 |
40 | private float mDensity = 1f;
41 |
42 | private int mBorderColor = 0xff6E6E6E;
43 | private int mColor = 0xff000000;
44 |
45 | private Paint mBorderPaint;
46 | private Paint mColorPaint;
47 |
48 | private RectF mDrawingRect;
49 | private RectF mColorRect;
50 |
51 | private AlphaPatternDrawable mAlphaPattern;
52 |
53 | public ColorPickerPanelView(Context context) {
54 | this(context, null);
55 | }
56 |
57 | public ColorPickerPanelView(Context context, AttributeSet attrs) {
58 | this(context, attrs, 0);
59 | }
60 |
61 | public ColorPickerPanelView(Context context, AttributeSet attrs,
62 | int defStyle) {
63 | super(context, attrs, defStyle);
64 | init();
65 | }
66 |
67 | private void init() {
68 | mBorderPaint = new Paint();
69 | mColorPaint = new Paint();
70 | mDensity = getContext().getResources().getDisplayMetrics().density;
71 | }
72 |
73 | @Override
74 | protected void onDraw(Canvas canvas) {
75 |
76 | final RectF rect = mColorRect;
77 |
78 | if (BORDER_WIDTH_PX > 0) {
79 | mBorderPaint.setColor(mBorderColor);
80 | canvas.drawRect(mDrawingRect, mBorderPaint);
81 | }
82 |
83 | if (mAlphaPattern != null) {
84 | mAlphaPattern.draw(canvas);
85 | }
86 |
87 | mColorPaint.setColor(mColor);
88 |
89 | canvas.drawRect(rect, mColorPaint);
90 | }
91 |
92 | @Override
93 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
94 |
95 | int width = MeasureSpec.getSize(widthMeasureSpec);
96 | int height = MeasureSpec.getSize(heightMeasureSpec);
97 |
98 | setMeasuredDimension(width, height);
99 | }
100 |
101 | @Override
102 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
103 | super.onSizeChanged(w, h, oldw, oldh);
104 |
105 | mDrawingRect = new RectF();
106 | mDrawingRect.left = getPaddingLeft();
107 | mDrawingRect.right = w - getPaddingRight();
108 | mDrawingRect.top = getPaddingTop();
109 | mDrawingRect.bottom = h - getPaddingBottom();
110 |
111 | setUpColorRect();
112 |
113 | }
114 |
115 | private void setUpColorRect() {
116 | final RectF dRect = mDrawingRect;
117 |
118 | float left = dRect.left + BORDER_WIDTH_PX;
119 | float top = dRect.top + BORDER_WIDTH_PX;
120 | float bottom = dRect.bottom - BORDER_WIDTH_PX;
121 | float right = dRect.right - BORDER_WIDTH_PX;
122 |
123 | mColorRect = new RectF(left, top, right, bottom);
124 |
125 | mAlphaPattern = new AlphaPatternDrawable((int) (5 * mDensity));
126 |
127 | mAlphaPattern.setBounds(Math.round(mColorRect.left),
128 | Math.round(mColorRect.top), Math.round(mColorRect.right),
129 | Math.round(mColorRect.bottom));
130 |
131 | }
132 |
133 | /**
134 | * Set the color that should be shown by this view.
135 | *
136 | * @param color
137 | */
138 | public void setColor(int color) {
139 | mColor = color;
140 | invalidate();
141 | }
142 |
143 | /**
144 | * Get the color currently show by this view.
145 | *
146 | * @return
147 | */
148 | public int getColor() {
149 | return mColor;
150 | }
151 |
152 | /**
153 | * Set the color of the border surrounding the panel.
154 | *
155 | * @param color
156 | */
157 | public void setBorderColor(int color) {
158 | mBorderColor = color;
159 | invalidate();
160 | }
161 |
162 | /**
163 | * Get the color of the border surrounding the panel.
164 | */
165 | public int getBorderColor() {
166 | return mBorderColor;
167 | }
168 |
169 | }
170 |
--------------------------------------------------------------------------------