forked from langerhans/OdinTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request langerhans#22 from langerhans/bugfix/rp4crash
Fix crash on devices without vibration setting
- Loading branch information
Showing
7 changed files
with
55 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 16 additions & 2 deletions
18
app/src/main/java/de/langerhans/odintools/tools/DeviceUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,29 @@ | ||
package de.langerhans.odintools.tools | ||
|
||
import de.langerhans.odintools.tools.DeviceType.* | ||
import javax.inject.Inject | ||
|
||
class DeviceUtils @Inject constructor( | ||
private val shellExecutor: ShellExecutor | ||
) { | ||
fun isOdin2() = shellExecutor.executeAsRoot("getprop ro.vendor.retro.name").map { it == "Q9" } | ||
.getOrDefault(false) | ||
|
||
fun getDeviceType(): DeviceType { | ||
val deviceName = shellExecutor.executeAsRoot("getprop ro.vendor.retro.name").getOrNull() | ||
return when (deviceName) { | ||
"Q9" -> ODIN2 | ||
"4.0", "4.0P" -> RP4 | ||
else -> OTHER | ||
} | ||
} | ||
|
||
fun isPServerAvailable() = shellExecutor.pServerAvailable | ||
|
||
fun getDeviceVersion() = shellExecutor.executeAsRoot("getprop ro.build.odin2.ota.version").map { it ?: "" } | ||
.getOrDefault("") | ||
} | ||
|
||
enum class DeviceType { | ||
ODIN2, | ||
RP4, | ||
OTHER | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters