Skip to content

Commit

Permalink
Revert "Temp fix: call /dev/acc/modPath/acc instead of acc"
Browse files Browse the repository at this point in the history
This reverts commit f88526f.
  • Loading branch information
MatteCarra committed May 12, 2019
1 parent 3a2ab53 commit 01bf5fa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
22 changes: 11 additions & 11 deletions app/src/main/java/mattecarra/accapp/utils/AccUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ object AccUtils {
}

fun listVoltageSupportedControlFiles(): List<String> {
val res = Shell.su("/dev/acc/modPath/acc -v :").exec()
val res = Shell.su("acc -v :").exec()
return if(res.isSuccess) res.out.filter { it.isNotEmpty() } else emptyList()
}

fun resetBatteryStats(): Boolean {
return Shell.su("/dev/acc/modPath/acc -R").exec().isSuccess
return Shell.su("acc -R").exec().isSuccess
}

/**
Expand Down Expand Up @@ -152,7 +152,7 @@ object AccUtils {
private val CYCLE_COUNT_REGEXP = """^\s*CYCLE_COUNT=(\d+)""".toRegex(RegexOption.MULTILINE)

fun getBatteryInfo(): BatteryInfo {
val info = Shell.su("/dev/acc/modPath/acc -i").exec().out.joinToString(separator = "\n")
val info = Shell.su("acc -i").exec().out.joinToString(separator = "\n")

return BatteryInfo(
NAME_REGEXP.find(info)?.destructured?.component1() ?: STRING_UNKNOWN,
Expand Down Expand Up @@ -213,23 +213,23 @@ object AccUtils {
}

fun isBatteryCharging(): Boolean {
return Shell.su("/dev/acc/modPath/acc -i").exec().out.find { it.matches(STATUS_REGEXP) } == "STATUS=Charging"
return Shell.su("acc -i").exec().out.find { it.matches(STATUS_REGEXP) } == "STATUS=Charging"
}

fun isAccdRunning(): Boolean {
return Shell.su("/dev/acc/modPath/acc -D").exec().out.find { it.contains("accd is running") } != null
return Shell.su("acc -D").exec().out.find { it.contains("accd is running") } != null
}

fun abcStartDaemon(): Boolean {
return Shell.su("/dev/acc/modPath/acc -D start").exec().isSuccess
return Shell.su("acc -D start").exec().isSuccess
}

fun abcRestartDaemon(): Boolean {
return Shell.su("/dev/acc/modPath/acc -D restart").exec().isSuccess
return Shell.su("acc -D restart").exec().isSuccess
}

fun abcStopDaemon(): Boolean {
return Shell.su("/dev/acc/modPath/acc -D stop").exec().isSuccess
return Shell.su("acc -D stop").exec().isSuccess
}

fun deleteSchedule(once: Boolean, name: String): Boolean {
Expand Down Expand Up @@ -261,12 +261,12 @@ object AccUtils {

//Charging switches
fun listChargingSwitches(): List<String> {
val res = Shell.su("/dev/acc/modPath/acc --set switch:").exec()
val res = Shell.su("acc --set switch:").exec()
return if(res.isSuccess) res.out.map { it.trim() }.filter { it.isNotEmpty() } else emptyList()
}

fun testChargingSwitch(chargingSwitch: String? = null): Int {
return Shell.su("/dev/acc/modPath/acc -t${chargingSwitch?.let{" $it"} ?: ""}").exec().code
return Shell.su("acc -t${chargingSwitch?.let{" $it"} ?: ""}").exec().code
}

fun getCurrentChargingSwitch(): String? {
Expand All @@ -275,7 +275,7 @@ object AccUtils {
}

fun setChargingLimitForOneCharge(limit: Int): Boolean {
return Shell.su("/dev/acc/modPath/acc -f $limit").exec().isSuccess
return Shell.su("acc -f $limit").exec().isSuccess
}

fun isAccInstalled(): Boolean {
Expand Down
24 changes: 12 additions & 12 deletions app/src/main/java/mattecarra/accapp/utils/ConfigUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ object ConfigUtils {

//reset unplugged command
fun updateResetUnplugged(resetUnplugged: Boolean): Boolean {
return Shell.su("/dev/acc/modPath/acc -s resetBsOnUnplug $resetUnplugged").exec().isSuccess
return Shell.su("acc -s resetBsOnUnplug $resetUnplugged").exec().isSuccess
}

/**
Expand All @@ -76,7 +76,7 @@ fun updateResetUnplugged(resetUnplugged: Boolean): Boolean {
fun updateAccCoolDown(charge: Int?, pause: Int?) : Boolean {
return charge?.let { charge ->
pause?.let { pause ->
Shell.su("/dev/acc/modPath/acc -s coolDownRatio $charge/$pause").exec().isSuccess
Shell.su("acc -s coolDownRatio $charge/$pause").exec().isSuccess
}
} ?: true
}
Expand All @@ -90,7 +90,7 @@ fun updateAccCoolDown(charge: Int?, pause: Int?) : Boolean {
* @return boolean if the command was successful.
*/
fun updateAccCapacity(shutdown: Int, coolDown: Int, resume: Int, pause: Int) : Boolean {
return Shell.su("/dev/acc/modPath/acc -s capacity $shutdown,$coolDown,$resume-$pause").exec().isSuccess
return Shell.su("acc -s capacity $shutdown,$coolDown,$resume-$pause").exec().isSuccess
}

/**
Expand All @@ -101,7 +101,7 @@ fun updateAccCapacity(shutdown: Int, coolDown: Int, resume: Int, pause: Int) : B
* @return the boolean result of the command's execution.
*/
fun updateAccTemperature(coolDownTemperature: Int, pauseTemperature: Int, wait: Int) : Boolean {
return Shell.su("/dev/acc/modPath/acc -s temperature ${coolDownTemperature*10}-${pauseTemperature*10}_$wait").exec().isSuccess
return Shell.su("acc -s temperature ${coolDownTemperature*10}-${pauseTemperature*10}_$wait").exec().isSuccess
}

/**
Expand All @@ -113,11 +113,11 @@ fun updateAccTemperature(coolDownTemperature: Int, pauseTemperature: Int, wait:
fun updateAccVoltControl(voltFile: String?, voltMax: Int?) : Boolean {
return Shell.su(
if(voltFile != null && voltMax != null)
"/dev/acc/modPath/acc --set chargingVoltageLimit $voltFile:$voltMax"
"acc --set chargingVoltageLimit $voltFile:$voltMax"
else if(voltMax != null)
"/dev/acc/modPath/acc --set chargingVoltageLimit $voltMax"
"acc --set chargingVoltageLimit $voltMax"
else
"/dev/acc/modPath/acc --set chargingVoltageLimit"
"acc --set chargingVoltageLimit"
).exec().isSuccess
}

Expand All @@ -127,7 +127,7 @@ fun updateAccVoltControl(voltFile: String?, voltMax: Int?) : Boolean {
* @return the boolean result of the command's execution.
*/
fun updateAccOnBootExit(enabled: Boolean) : Boolean {
return Shell.su("/dev/acc/modPath/acc -s onBootExit $enabled").exec().isSuccess
return Shell.su("acc -s onBootExit $enabled").exec().isSuccess
}

/**
Expand All @@ -136,7 +136,7 @@ fun updateAccOnBootExit(enabled: Boolean) : Boolean {
* @return the boolean result of the command's execution.
*/
fun updateAccOnBoot(command: String?) : Boolean {
return Shell.su("/dev/acc/modPath/acc -s applyOnBoot${command?.let{ " $it" } ?: ""}").exec().isSuccess
return Shell.su("acc -s applyOnBoot${command?.let{ " $it" } ?: ""}").exec().isSuccess
}

/**
Expand All @@ -145,13 +145,13 @@ fun updateAccOnBoot(command: String?) : Boolean {
* @return the boolean result of the command's execution.
*/
fun updateAccOnPlugged(command: String?) : Boolean {
return Shell.su("/dev/acc/modPath/acc -s applyOnPlug${command?.let{ " $it" } ?: ""}").exec().isSuccess
return Shell.su("acc -s applyOnPlug${command?.let{ " $it" } ?: ""}").exec().isSuccess
}

fun updateAccChargingSwitch(switch: String?) : Boolean {
if (switch.isNullOrBlank()) {
return Shell.su("/dev/acc/modPath/acc -s s-").exec().isSuccess
return Shell.su("acc -s s-").exec().isSuccess
}

return Shell.su("/dev/acc/modPath/acc --set switch $switch").exec().isSuccess
return Shell.su("acc --set switch $switch").exec().isSuccess
}

0 comments on commit 01bf5fa

Please sign in to comment.