Skip to content

Commit

Permalink
feat(cpu): cpu name changes (#219)
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Grosz <lalogrosz@gmail.com>
  • Loading branch information
lalogrosz authored and Alexander Salas Bastidas committed Jun 20, 2019
1 parent c8376ed commit 7f996ca
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 18 deletions.
9 changes: 9 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,17 @@ reference:
name: Validate running
command: source ci/scripts/validate_running.sh

update_licenses: &update_licenses
run:
name: Update licenses
command: source ci/scripts/ci_licenses.sh

jobs:
build:
<<: *android_config
steps:
- checkout
- *update_licenses
- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "example_java/build.gradle" }}
- run:
Expand All @@ -65,6 +71,7 @@ jobs:
<<: *android_config
steps:
- checkout
- *update_licenses
- *validate_running
- *restore_gradle_cache
- *ruby_dependencies
Expand All @@ -81,6 +88,7 @@ jobs:
<<: *android_config
steps:
- checkout
- *update_licenses
- *restore_gradle_cache
- run:
name: Setup environment
Expand All @@ -97,6 +105,7 @@ jobs:
<<: *android_config
steps:
- checkout
- *update_licenses
- *restore_gradle_cache
- run:
name: Setup environment
Expand Down
29 changes: 29 additions & 0 deletions ci/scripts/ci_licenses.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
#
# LICENSE
#
# This file is part of Flyve MDM Inventory Library for Android.
#
# Inventory Library for Android is a subproject of Flyve MDM.
# Flyve MDM is a mobile device management software.
#
# Flyve MDM is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# Flyve MDM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# ---------------------------------------------------------------------
# @copyright Copyright © 2018 Teclib. All rights reserved.
# @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
# @link https://github.com/flyve-mdm/android-inventory-library/
# @link http://flyve.org/android-inventory-library/
# @link https://flyve-mdm.com/
# ---------------------------------------------------------------------
#

# Manage sdk licenses
yes | sdkmanager --licenses || if [ $? -ne '141' ]; then exit $?; fi;
9 changes: 9 additions & 0 deletions inventory/src/main/java/org/flyve/inventory/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,15 @@ public static String getValueMapInfo(Map<String, String> mapInfo, String name) {
return "";
}

public static String getValueMapCase(Map<String, String> mapInfo, String name) {
for (String s : mapInfo.keySet()) {
if (s.equals(name)) {
return mapInfo.get(s);
}
}
return "";
}

public static String getCatInfoMultiple(String path) {
StringBuilder concatInfo = new StringBuilder();
try {
Expand Down
28 changes: 10 additions & 18 deletions inventory/src/main/java/org/flyve/inventory/categories/Cpus.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,30 +230,22 @@ public String getModel() {
*/

public String getCpuName() {
String cpuName = "N/A";
String value = "N/A";
try {
FileReader fr = null;
BufferedReader br = null;
try {
File f = new File(CPUINFO);
fr = new FileReader(f);
br = new BufferedReader(fr, 8 * 1024);
String info = br.readLine();
cpuName = info.replaceAll("(.*):\\ (.*)", "$2");
} catch (IOException e) {
FlyveLog.e(e.getMessage());
} finally {
if (fr != null) {
fr.close();
}
if (br != null) {
br.close();
Map<String, String> cpuInfo = Utils.getCatMapInfo("/proc/cpuinfo");
String cpuName = Utils.getValueMapCase(cpuInfo, "Processor").trim();
if (!"".equals(cpuName)){
value = cpuName;
} else {
cpuName = Utils.getValueMapCase(cpuInfo, "model name").trim();
if (!"".equals(cpuName)){
value = cpuName;
}
}
} catch (Exception ex) {
FlyveLog.e(FlyveLog.getMessage(context, CommonErrorType.CPU_NAME, ex.getMessage()));
}
return cpuName;
return value;
}

/**
Expand Down

0 comments on commit 7f996ca

Please sign in to comment.