From 13ae1a1b5ac4bccfb77315fb354aaf08f4cf1a00 Mon Sep 17 00:00:00 2001 From: Rafa Hernandez Date: Tue, 7 Nov 2017 15:12:32 -0400 Subject: [PATCH] feat(software): add install date --- .../flyve/inventory/categories/Software.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/inventory/src/main/java/org/flyve/inventory/categories/Software.java b/inventory/src/main/java/org/flyve/inventory/categories/Software.java index bec3ce105..990e72e10 100644 --- a/inventory/src/main/java/org/flyve/inventory/categories/Software.java +++ b/inventory/src/main/java/org/flyve/inventory/categories/Software.java @@ -102,9 +102,10 @@ public Software(Context xCtx) { Category c = new Category("SOFTWARES", "softwares"); c.put("NAME", new CategoryValue(getName(p), "NAME", "name")); - c.put("VERSION", new CategoryValue(getVersion(p), "NAME", "name")); + c.put("VERSION", new CategoryValue(getVersion(p), "VERSION", "VERSION")); c.put("FILESIZE", new CategoryValue(getFilesize(p), "FILESIZE", "fileSize")); c.put("FROM", new CategoryValue(FROM, "FROM", "from")); + c.put("INSTALLDATE", new CategoryValue(getInstallDate(p), "INSTALLDATE", "installDate")); this.add(c); } @@ -129,6 +130,24 @@ public String getName(ApplicationInfo p) { return mName; } + /** + * Get the version of the application + * @param ApplicationInfo p + * @return string the application version + */ + public String getInstallDate(ApplicationInfo p) { + String mInstalled = ""; + + try { + PackageInfo pi = packageManager.getPackageInfo(p.packageName, PackageManager.GET_META_DATA); + mInstalled = String.valueOf(pi.firstInstallTime); + } catch (NameNotFoundException e) { + FILog.e(e.getMessage()); + } + + return mInstalled; + } + /** * Get the version of the application * @param ApplicationInfo p