Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Commit

Permalink
Agora usando valores aproximados para status de corrente e tensão
Browse files Browse the repository at this point in the history
  • Loading branch information
cledsupper committed Oct 19, 2021
1 parent 9902fd3 commit f81d744
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
5 changes: 3 additions & 2 deletions batservice.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/system/bin/sh

# BatService v1.1 - battery conservation mode for Galaxy A20
# BatService v1.2 - battery conservation mode for Galaxy A20
#
# Copyright (C) 2021 Cledson Ferreira
#
Expand All @@ -21,7 +21,7 @@
NAME="BATSERVICE"
Name="BatService"
name="batservice"
VERSION="1.1.211017"
VERSION="1.2.211018"


if [ "$SERVICE_LIB" = "" ]; then
Expand Down Expand Up @@ -66,6 +66,7 @@ while [ ! -r "$EXIT_FILE" ]; do

battery_percent
battery_status
battery_current
battery_voltage
battery_temp

Expand Down
18 changes: 13 additions & 5 deletions lib/battery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ if [ "$BWD" = "" ]; then
fi

Bpercent="${BWD}/capacity"
Bvoltage="${BWD}/voltage_now"
Bvoltage="${BWD}/voltage_avg"
Bstatus="${BWD}/status"
Bcurrent="${BWD}/current_now"
Bcurrent="${BWD}/current_avg"
Bcurrentnow="${BWD}/current_now"
Btemp="${BWD}/temp"

# Controlador de carga do Galaxy A20 {
Expand Down Expand Up @@ -97,16 +98,23 @@ battery_status () {
status=$(cat "$Bstatus")

# corrige o status para "Not charging" quando a corrente varia abaixo de |10| mA
battery_current
if ( [ "$status" = "Charging" ] && [ $current -le $RATIONALE_MAMAX ] && [ $current -ge $RATIONALE_MAMIN ] ); then
battery_current_now
if ( [ "$status" = "Charging" ] && [ $current_now -le $RATIONALE_MAMAX ] && [ $current_now -ge $RATIONALE_MAMIN ] ); then
status="Not charging"
fi
}


battery_current_now () {
current_now=$(cat "$Bcurrentnow")
if [ $current_now -ge 10000 ]; then
current_now=$(expr $current_now / 1000)
fi
}

battery_current () {
current=$(cat "$Bcurrent")
if [ $current -ge 10000 ]; then
if [ $current -ge 10000 ]; then
current=$(expr $current / 1000)
fi
}
Expand Down
2 changes: 1 addition & 1 deletion lib/startup-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if [ "$TERMUX_PREFIX" = "$PREFIX" ]; then
TERMUX_HOME="$(cd $PREFIX/../home && pwd)"
TERMUX_HOME_CACHE="$TERMUX_HOME/.cache"
SERVICE_CACHE="$TERMUX_HOME_CACHE/$Name"
backup_perms "$TERMUX_HOME"
backup_owner "$TERMUX_HOME"

# Necessário para evitar que arquivos root prejudiquem a remoção do aplicativo
mkdir -p "$SERVICE_CACHE"
Expand Down

1 comment on commit f81d744

@cledsupper
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMPORTANTE:

  • Inclui correção para erro severo que impossibilitava recuperar a propriedade do Termux sobre seus arquivos.

Please sign in to comment.