Skip to content

Commit

Permalink
feat(inventory): retrieve more informations from camera
Browse files Browse the repository at this point in the history
Signed-off-by: Teclib <skita@teclib.com>
  • Loading branch information
stonebuzz committed Aug 13, 2021
1 parent 7f705de commit 58de937
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
3 changes: 0 additions & 3 deletions inventory/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ ext {
libraryName = 'inventory'
artifact = 'inventory'




task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public Cameras(Context xCtx) {
Category c = new Category("CAMERAS", "cameras");
CameraCharacteristics chars = getCharacteristics(xCtx, index);
if (chars != null) {
c.put("RESOLUTION", new CategoryValue(getResolution(chars), "RESOLUTION", "resolution"));
c.put("DESIGNATION", new CategoryValue(Integer.toString(index), "DESIGNATION", "designation"));
c.put("RESOLUTIONIMAGE", new CategoryValue(getResolution(chars), "RESOLUTIONIMAGE", "resolutionimage"));
c.put("LENSFACING", new CategoryValue(getFacingState(chars), "LENSFACING", "lensfacing"));
c.put("FLASHUNIT", new CategoryValue(getFlashUnit(chars), "FLASHUNIT", "flashunit"));
c.put("IMAGEFORMATS", new CategoryValue(getImageFormat(chars), "IMAGEFORMATS", "imageformats"));
Expand Down Expand Up @@ -159,7 +160,9 @@ public CameraCharacteristics getCharacteristics(Context xCtx, int index) {
* @param characteristics CameraCharacteristics
* @return String resolution camera
*/
public String getResolution(CameraCharacteristics characteristics) {
public ArrayList<String> getResolution(CameraCharacteristics characteristics) {
ArrayList<String> resolutions = new ArrayList<>();

String value = "N/A";
try {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
Expand All @@ -172,23 +175,28 @@ public String getResolution(CameraCharacteristics characteristics) {
if (rect != null) {
width = rect.width();
height = rect.height();
value = width + "x" + height;
resolutions.add(value);
}
} else {
Size size = outputSizes[outputSizes.length - 1];
width = size.getWidth();
height = size.getHeight();
for (int i = 0; i <outputSizes.length; i++ ) {
Size size = outputSizes[i];
width = size.getWidth();
height = size.getHeight();
value = width + "x" + height;
resolutions.add(value);
}
}
value = width + "x" + height;
} else {
return value;
return resolutions;
}
} else {
return value;
return resolutions;
}
} catch (Exception ex) {
InventoryLog.e(InventoryLog.getMessage(context, CommonErrorType.CAMERA_RESOLUTION, ex.getMessage()));
}
return value;
return resolutions;
}

/**
Expand Down

0 comments on commit 58de937

Please sign in to comment.