Skip to content

Commit

Permalink
Merge pull request #15 from Manabu-GT/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Manabu-GT authored Sep 2, 2017
2 parents 5fc44f8 + 3b7b2aa commit 94f524d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## Version 1.1.1 *(2017-09-02)*

* Fix to close filereaders in CpuFreqDataModule after reading data

## Version 1.1.0 *(2017-09-01)*

* Android O support (Note: CpuUsageModule/CpuFreqModule will not work on Android O and above)
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ so you just need to add the followings to your ***build.gradle*** file:

```groovy
dependencies {
debugCompile 'com.ms-square:debugoverlay:1.1.0'
releaseCompile 'com.ms-square:debugoverlay-no-op:1.1.0'
testCompile 'com.ms-square:debugoverlay-no-op:1.1.0'
debugCompile 'com.ms-square:debugoverlay:1.1.1'
releaseCompile 'com.ms-square:debugoverlay-no-op:1.1.1'
testCompile 'com.ms-square:debugoverlay-no-op:1.1.1'
}
```

Please note that `com.ms-square:debugoverlay:1.1.0` will add `android.permission.SYSTEM_ALERT_WINDOW` to your app.
Please note that `com.ms-square:debugoverlay:1.1.1` will add `android.permission.SYSTEM_ALERT_WINDOW` to your app.
Threfore, you should avoid to use that dependency for your release build.

FYI, the following table describes the total number of method/field references in this library's release aar.
This data is acquired by using [Dexcount Gradle Plugin](https://github.com/KeepSafe/dexcount-gradle-plugin).

| library | methods | fields |
|:------------- |:-------------|:-------------|
|com.ms-square:debugoverlay:1.1.0|565|249|
|com.ms-square:debugoverlay-no-op:1.1.0|142|37|
|com.ms-square:debugoverlay:1.1.1|565|249|
|com.ms-square:debugoverlay-no-op:1.1.1|142|37|

Due to the extensibility of this library, no-op version unfortunately has more than a few methods.
If you want to eliminate such method count in your release build, consider having separate `Application` class only for your debug build which uses this library and just specify `debugCompile 'com.ms-square:debugoverlay:1.1.0'` in the dependencies section of build.gradle.
If you want to eliminate such method count in your release build, consider having separate `Application` class only for your debug build which uses this library and just specify `debugCompile 'com.ms-square:debugoverlay:1.1.1'` in the dependencies section of build.gradle.

Usage
------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ public void run() {
for (File cpuFile : cpuFiles) {
double minFreq = -1f;
double maxFreq = -1f;
BufferedReader minFreqReader = null;
BufferedReader maxFreqReader = null;
try {
BufferedReader minFreqReader =
new BufferedReader(new FileReader(cpuFile.getAbsolutePath() + "/cpufreq/cpuinfo_min_freq"));
BufferedReader maxFreqReader =
new BufferedReader(new FileReader(cpuFile.getAbsolutePath() + "/cpufreq/cpuinfo_max_freq"));
minFreqReader = new BufferedReader(new FileReader(cpuFile.getAbsolutePath() + "/cpufreq/cpuinfo_min_freq"));
maxFreqReader = new BufferedReader(new FileReader(cpuFile.getAbsolutePath() + "/cpufreq/cpuinfo_max_freq"));
minFreq = parseDouble(minFreqReader.readLine());
maxFreq = parseDouble(maxFreqReader.readLine());

Expand All @@ -70,6 +70,17 @@ public void run() {
}
} catch (IOException ie) {
Log.w(TAG, "Error reading the min/max cpufreq", ie);
} finally {
if (minFreqReader != null) {
try {
minFreqReader.close();
} catch (IOException ignore) {}
}
if (maxFreqReader != null) {
try {
maxFreqReader.close();
} catch (IOException ignore) {}
}
}
cachedFrequencies.put(cpuFile, new CpuFreq(cpuFile.getName(), minFreq, -1f, maxFreq));
}
Expand All @@ -81,8 +92,9 @@ public void run() {
for (File cpuFile : cachedFrequencies.keySet()) {
CpuFreq cached = cachedFrequencies.get(cpuFile);
double curFreq = -1f;
BufferedReader curFreqReader = null;
try {
BufferedReader curFreqReader = new BufferedReader(new FileReader(cpuFile.getAbsolutePath() + "/cpufreq/scaling_cur_freq"));
curFreqReader = new BufferedReader(new FileReader(cpuFile.getAbsolutePath() + "/cpufreq/scaling_cur_freq"));
curFreq = parseDouble(curFreqReader.readLine());

if (DebugOverlay.isDebugLoggingEnabled()) {
Expand All @@ -91,6 +103,12 @@ public void run() {

} catch (IOException ie) {
Log.w(TAG, "Error reading the current cpufreq", ie);
} finally {
if (curFreqReader != null) {
try {
curFreqReader.close();
} catch (IOException ignore) {}
}
}

newCpuFreqList.add(new CpuFreq(cached.getCpuName(), cached.getMinFreq(), curFreq, cached.getMaxFreq()));
Expand Down Expand Up @@ -144,15 +162,11 @@ protected List<CpuFreq> getLatestData() {

private static File[] getCpuFiles() {
File dir = new File("/sys/devices/system/cpu/");
File[] files = dir.listFiles(new FileFilter() {
return dir.listFiles(new FileFilter() {
@Override
public boolean accept(File file) {
if(Pattern.matches("cpu[0-9]+", file.getName())) {
return true;
}
return false;
return Pattern.matches("cpu[0-9]+", file.getName());
}
});
return files;
}
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ android.enableBuildCache=true

# For maven central
GROUP=com.ms-square
VERSION_NAME=1.1.0
VERSION_CODE=3
VERSION_NAME=1.1.1
VERSION_CODE=4
POM_PACKAGING=aar
POM_DESCRIPTION=Android library to display various debugging information in an overlay window

Expand Down

0 comments on commit 94f524d

Please sign in to comment.