This repository has been archived by the owner on Feb 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
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 #1 from kacpak/develop
Moved database to DBFlow with EventBus and introduced looking for mul…
- Loading branch information
Showing
27 changed files
with
549 additions
and
869 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
92 changes: 92 additions & 0 deletions
92
app/src/main/java/net/kacpak/batterychargingmonitor/data/BatteryDataPaths.java
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 |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package net.kacpak.batterychargingmonitor.data; | ||
|
||
import android.util.Log; | ||
|
||
import java.io.File; | ||
|
||
public class BatteryDataPaths { | ||
|
||
/** | ||
* Znane ścieżki do folderu systemowego zawierającego dane o stanie baterii | ||
*/ | ||
private static final String[] mBatteryDataPaths = new String[] { | ||
"/sys/class/power_supply/battery/" | ||
}; | ||
|
||
/** | ||
* | ||
*/ | ||
private static final String[] mCurrentNowFilenames = new String[] { | ||
"batt_current_ua_now", | ||
"current_now" | ||
}; | ||
|
||
/** | ||
* | ||
*/ | ||
private static final String[] mCurrentAvgFilenames = new String[] { | ||
"batt_current_ua_avg", | ||
"current_avg" | ||
}; | ||
|
||
public static final String CurrentNow; | ||
|
||
public static final String CurrentAvg; | ||
|
||
private static final String mBatteryDataPath; | ||
|
||
static { | ||
mBatteryDataPath = getBatteryDataPath(); | ||
CurrentNow = getCurrentNowPath(); | ||
CurrentAvg = getCurrentAvgPath(); | ||
} | ||
|
||
/** | ||
* | ||
* @return | ||
*/ | ||
private static String getBatteryDataPath() { | ||
File dir; | ||
for (String path : mBatteryDataPaths) { | ||
Log.d("BatteryStatus", "PATH checked: " + path); | ||
dir = new File(path); | ||
if (dir.isDirectory()) { | ||
return path; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
/** | ||
* | ||
* @return | ||
*/ | ||
private static String getCurrentNowPath() { | ||
File dir; | ||
for (String path : mCurrentNowFilenames) { | ||
dir = new File(mBatteryDataPath + path); | ||
if (dir.isFile()) { | ||
return dir.getPath(); | ||
} | ||
} | ||
return ""; | ||
} | ||
|
||
/** | ||
* | ||
* @return | ||
*/ | ||
private static String getCurrentAvgPath() { | ||
File dir; | ||
for (String path : mCurrentAvgFilenames) { | ||
dir = new File(mBatteryDataPath + path); | ||
if (dir.isFile()) { | ||
return dir.getPath(); | ||
} | ||
} | ||
return ""; | ||
} | ||
|
||
private BatteryDataPaths() { | ||
} | ||
} |
Oops, something went wrong.