@@ -446,38 +446,45 @@ yuan_shen_opt_run() {
446446 fi
447447}
448448
449- # watch_app [time] [ on_tick] [on_change]
449+ # watch_app [on_tick] [on_change]
450450watch_app () {
451- local interval=" $1 "
452- local on_tick=" $2 "
453- local on_change=" $3 "
451+ local interval=120
452+ local on_tick=" $1 "
453+ local on_change=" $2 "
454454 local app=$( getprop vtools.powercfg_app)
455455
456456 if [[ " $on_tick " == " " ]]; then
457457 return
458458 fi
459459
460- local prop=' vtools.perf.watch'
461-
462- local current_watch=$( getprop $prop )
463- if [[ " $current_watch " != " " ]]; then
464- kill -9 $current_watch 2> /dev/null
465- setprop $prop " "
466- fi
467-
468460 if [[ " $app " == " " ]]; then
469461 return
470462 fi
471463
472- setprop $prop " $$ "
464+ procs=$( pgrep -f com.omarea.* powercfg.sh)
465+ last_proc=$( echo " $procs " | tail -n 1)
466+ if [[ " $last_proc " != " " ]]; then
467+ echo " $procs " | grep -v " $last_proc " | while read pid; do
468+ kill -9 $pid 2> /dev/null
469+ done
470+ fi
471+
472+ ticks=0
473473 while true
474474 do
475- sleep $interval
475+ if [[ $ticks -gt 3 ]]; then
476+ sleep $interval
477+ elif [[ $ticks -gt 0 ]]; then
478+ sleep 30
479+ else
480+ sleep 10
481+ fi
482+ ticks=$(( ticks + 1 ))
483+
476484 current=$( getprop vtools.powercfg_app)
477485 if [[ " $current " == " $app " ]]; then
478486 $on_tick $current
479487 else
480- setprop $prop " "
481488 if [[ " $on_change " ]]; then
482489 $on_change $current
483490 fi
@@ -486,19 +493,6 @@ watch_app() {
486493 done
487494}
488495
489- yuan_shen_opt () {
490- sleep 10
491- yuan_shen_opt_run
492- sleep 30
493- yuan_shen_opt_run
494- sleep 30
495- yuan_shen_opt_run
496- sleep 30
497- yuan_shen_opt_run
498-
499- watch_app 120 yuan_shen_opt_run
500- }
501-
502496adjustment_by_top_app () {
503497 case " $top_app " in
504498 # YuanShen
@@ -518,7 +512,6 @@ adjustment_by_top_app() {
518512 set_cpu_freq 1036800 1708800 710400 1670400 844800 1670400
519513 # set_gpu_max_freq 540000000
520514 set_gpu_max_freq 491000000
521- yuan_shen_opt &
522515 elif [[ " $action " = " balance" ]]; then
523516 if [[ " $manufacturer " == " Xiaomi" ]]; then
524517 conservative_mode 55 67 70 89 71 89
@@ -531,7 +524,6 @@ adjustment_by_top_app() {
531524 set_cpu_freq 1036800 1708800 960000 1996800 844800 2035200
532525 set_hispeed_freq 1708800 1440000 1075200
533526 set_gpu_max_freq 676000000
534- yuan_shen_opt &
535527 elif [[ " $action " = " performance" ]]; then
536528 # bw_max_always
537529 if [[ " $manufacturer " == " Xiaomi" ]]; then
@@ -542,7 +534,6 @@ adjustment_by_top_app() {
542534 stune_top_app 0 0
543535 set_cpu_freq 806400 1708800 710400 2419200 844800 2841600
544536 set_gpu_max_freq 738000000
545- yuan_shen_opt &
546537 elif [[ " $action " = " fast" ]]; then
547538 bw_max_always
548539 if [[ " $manufacturer " == " Xiaomi" ]]; then
@@ -552,9 +543,9 @@ adjustment_by_top_app() {
552543 stune_top_app 1 55
553544 # sched_config "40 60" "50 75" "120" "150"
554545 set_gpu_max_freq 778000000
555- yuan_shen_opt &
556546 fi
557547 cpuset ' 0-1' ' 0-1' ' 0-7' ' 0-7'
548+ watch_app yuan_shen_opt_run &
558549 ;;
559550
560551 # Wang Zhe Rong Yao
0 commit comments