Skip to content

Commit

Permalink
fix(inventory): improve imei inventory
Browse files Browse the repository at this point in the history
Signed-off-by: Teclib <skita@teclib.com>
  • Loading branch information
stonebuzz committed Dec 18, 2019
1 parent 2247525 commit 0f8a851
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions inventory/src/main/java/org/flyve/inventory/categories/Modems.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
import org.flyve.inventory.InventoryLog;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
* This class get all the information of the Controllers
Expand All @@ -62,15 +64,20 @@ public class Modems extends Categories {
*/
public Modems(Context xCtx) {
super(xCtx);

context = xCtx;

try {
Category c = new Category("MODEMS", "modems");
for (String imei : getIMEI()) {
c.put("IMEI", new CategoryValue(imei, "IMEI", "imei"));
ArrayList<String> imeiList;
imeiList = getIMEI();

for (String imei :imeiList) {
if(imei != null && !imei.equalsIgnoreCase("N/A")){
Category c = new Category("MODEMS", "modems");
c.put("IMEI", new CategoryValue(imei, "IMEI", "imei"));
this.add(c);
}
}
this.add(c);

} catch (Exception ex) {
InventoryLog.e(InventoryLog.getMessage(context, CommonErrorType.MODEMS, ex.getMessage()));
}
Expand All @@ -91,7 +98,10 @@ public ArrayList<String> getIMEI() {
if (multipleSim != null && multipleSim.size() > 0) {
for (int i = 0; i < multipleSim.size(); i++) {
if (telephonyManager != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
imeiList.add(telephonyManager.getDeviceId(i));
if(telephonyManager.getDeviceId(i) != null){
imeiList.add(telephonyManager.getDeviceId(i));
}

}
}
} else {
Expand Down

0 comments on commit 0f8a851

Please sign in to comment.