Skip to content

Commit

Permalink
feat(hardware): changed name hardware
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Del Pino <idelpino@teclib.com>
  • Loading branch information
Ivan Del Pino authored and ajsb85 committed Oct 11, 2018
1 parent 024b154 commit 22ff2c7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion inventory/src/main/java/org/flyve/inventory/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ public static String getCatInfo(String path) {
return "";
}

public static BufferedReader getBufferedRootPermission(String[] values) throws IOException, InterruptedException {
public static BufferedReader getBufferedSequentialCatInfo(String[] values) throws IOException, InterruptedException {
Process p = Runtime.getRuntime().exec(values[0]);
DataOutputStream dos = new DataOutputStream(p.getOutputStream());
for (int i = 1; i < values.length; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
Expand Down Expand Up @@ -172,7 +169,7 @@ public String getDateLastLoggedUser() {
public String getLastLoggedUser() {
String value = "N/A";
try {
if (userInfo.size() > 0) {
if (userInfo.get(2) != null) {
DocumentBuilder newDocumentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
String info = userInfo.get(2).trim();
Document parse = newDocumentBuilder.parse(new ByteArrayInputStream(info.getBytes()));
Expand All @@ -184,11 +181,15 @@ public String getLastLoggedUser() {
return value;
}

/**
* Get the user tag of the last logged user
* @return string the user tag
*/
private String getUserTagValue(String tagName) {
String evaluate = "";
String value = "N/A";
try {
if (userInfo.size() > 0) {
if (userInfo.get(1) != null) {
String removeChar = userInfo.get(1).replaceAll("[\"><]", "");
if (removeChar.contains("user ")) {
evaluate = removeChar.replaceAll(" ", ",").trim();
Expand All @@ -213,12 +214,16 @@ private String getUserTagValue(String tagName) {
return value;
}

/**
* Get user info of the last logged user from an XML
*/
private void getUserInfo() {
userInfo = new ArrayList<>();
try {
String temp;
String[] values = {"su", "cat /data/system/users/0.xml\n", "exit\n"};
while ((temp = Utils.getBufferedRootPermission(values).readLine()) != null) {
BufferedReader catInfo = Utils.getBufferedSequentialCatInfo(values);
while ((temp = catInfo.readLine()) != null) {
userInfo.add(temp);
}
} catch (Exception ex) {
Expand All @@ -233,11 +238,11 @@ private void getUserInfo() {
public String getName() {
String value = "N/A";
try {
value = Build.MODEL;
value = Utils.getSystemProperty("net.hostname");
} catch (Exception ex) {
FlyveLog.e(FlyveLog.getMessage(context, CommonErrorType.HARDWARE_NAME, ex.getMessage()));
}
return value;
return value.trim();
}

/**
Expand Down

0 comments on commit 22ff2c7

Please sign in to comment.