Before

…lines 1–8 unchanged (8 lines)
9import android.hardware.camera2.CameraManager;
10import android.hardware.camera2.params.StreamConfigurationMap;
11import android.media.MediaCodec;
12import android.util.Range;
13
14import java.util.List;
15import java.util.TreeSet;
16
17public final class LogUtils {
18
19 private LogUtils() {
20 // not instantiable
21 }
…lines 22–99 unchanged (78 lines)
100
101 Rect activeSize = characteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
102 builder.append(activeSize.width()).append("x").append(activeSize.height()).append(", ");
103
104 // Capture frame rates for low-FPS mode are the same for every resolution
105 Range<Integer>[] lowFpsRanges = characteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES);
106 TreeSet<Integer> uniqueLowFps = new TreeSet<>();
107 for (Range<Integer> range : lowFpsRanges) {
108 uniqueLowFps.add(range.getUpper());
109 }
110 builder.append("fps=").append(uniqueLowFps).append(')');
111
112 if (includeSizes) {
113 StreamConfigurationMap configs = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
114 android.util.Size[] sizes = configs.getOutputSizes(MediaCodec.class);
115 for (android.util.Size size : sizes) {
116 builder.append("\n - ").append(size.getWidth()).append('x').append(size.getHeight());
117 }
118 }
119 }
120 }
121 } catch (CameraAccessException e) {
122 builder.append("\n (access denied)");
123 }
124 return builder.toString();
125 }
126}
127

After

…lines 1–8 unchanged (8 lines)
9import android.hardware.camera2.CameraManager;
10import android.hardware.camera2.params.StreamConfigurationMap;
11import android.media.MediaCodec;
12import android.util.Range;
13
14import java.util.List;
15import java.util.SortedSet;
16import java.util.TreeSet;
17
18public final class LogUtils {
19
20 private LogUtils() {
21 // not instantiable
…lines 22–100 unchanged (79 lines)
101
102 Rect activeSize = characteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
103 builder.append(activeSize.width()).append("x").append(activeSize.height()).append(", ");
104
105 // Capture frame rates for low-FPS mode are the same for every resolution
106 Range<Integer>[] lowFpsRanges = characteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES);
107 SortedSet<Integer> uniqueLowFps = getUniqueSet(lowFpsRanges);
108 builder.append("fps=").append(uniqueLowFps).append(')');
109
110 if (includeSizes) {
111 StreamConfigurationMap configs = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
112
113 android.util.Size[] sizes = configs.getOutputSizes(MediaCodec.class);
114 for (android.util.Size size : sizes) {
115 builder.append("\n - ").append(size.getWidth()).append('x').append(size.getHeight());
116 }
117
118 android.util.Size[] highSpeedSizes = configs.getHighSpeedVideoSizes();
119 if (highSpeedSizes.length > 0) {
120 builder.append("\n High speed capture (--camera-high-speed):");
121 for (android.util.Size size : highSpeedSizes) {
122 Range<Integer>[] highFpsRanges = configs.getHighSpeedVideoFpsRanges();
123 SortedSet<Integer> uniqueHighFps = getUniqueSet(highFpsRanges);
124 builder.append("\n - ").append(size.getWidth()).append("x").append(size.getHeight());
125 builder.append(" (fps=").append(uniqueHighFps).append(')');
126 }
127 }
128 }
129 }
130 }
131 } catch (CameraAccessException e) {
132 builder.append("\n (access denied)");
133 }
134 return builder.toString();
135 }
136
137 private static SortedSet<Integer> getUniqueSet(Range<Integer>[] ranges) {
138 SortedSet<Integer> set = new TreeSet<>();
139 for (Range<Integer> range : ranges) {
140 set.add(range.getUpper());
141 }
142 return set;
143 }
144}
145

Before

program
package_declaration
package "package"
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "genymobile"
. "."
identifier "scrcpy"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "genymobile"
. "."
identifier "scrcpy"
. "."
identifier "wrappers"
. "."
identifier "DisplayManager"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "genymobile"
. "."
identifier "scrcpy"
. "."
identifier "wrappers"
. "."
identifier "ServiceManager"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "android"
. "."
identifier "graphics"
. "."
identifier "Rect"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "android"
. "."
identifier "hardware"
. "."
identifier "camera2"
. "."
identifier "CameraAccessException"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "android"
. "."
identifier "hardware"
. "."
identifier "camera2"
. "."
identifier "CameraCharacteristics"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "android"
. "."
identifier "hardware"
. "."
identifier "camera2"
. "."
identifier "CameraManager"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "android"
. "."
identifier "hardware"
. "."
identifier "camera2"
. "."
identifier "params"
. "."
identifier "StreamConfigurationMap"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "android"
. "."
identifier "media"
. "."
identifier "MediaCodec"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "android"
. "."
identifier "util"
. "."
identifier "Range"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "List"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "TreeSet"
; ";"
class_declaration
modifiers
public "public"
final "final"
class "class"
identifier "LogUtils"
class_body
{ "{"
constructor_declaration
modifiers
private "private"
identifier "LogUtils"
formal_parameters
( "("
) ")"
constructor_body
{ "{"
line_comment "// not instantiable"
} "}"
method_declaration (+181 nodes collapsed)
method_declaration (+181 nodes collapsed)
method_declaration (+259 nodes collapsed)
method_declaration (+81 nodes collapsed)
method_declaration
modifiers
public "public"
static "static"
type_identifier "String"
identifier "buildCameraListMessage"
formal_parameters
( "("
formal_parameter
boolean_type "boolean"
identifier "includeSizes"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "StringBuilder"
variable_declarator
identifier "builder"
= "="
object_creation_expression
new "new"
type_identifier "StringBuilder"
argument_list
( "("
string_literal
" "\""
string_fragment "List of cameras:"
" "\""
) ")"
; ";"
local_variable_declaration
type_identifier "CameraManager"
variable_declarator
identifier "cameraManager"
= "="
method_invocation
identifier "ServiceManager"
. "."
identifier "getCameraManager"
argument_list
( "("
) ")"
; ";"
try_statement
try "try"
block
{ "{"
local_variable_declaration
array_type
type_identifier "String"
dimensions
[ "["
] "]"
variable_declarator
identifier "cameraIds"
= "="
method_invocation
identifier "cameraManager"
. "."
identifier "getCameraIdList"
argument_list
( "("
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
identifier "cameraIds"
== "=="
null_literal "null"
|| "||"
binary_expression
field_access
identifier "cameraIds"
. "."
identifier "length"
== "=="
decimal_integer_literal "0"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "builder"
. "."
identifier "append"
argument_list
( "("
string_literal
" "\""
escape_sequence "\\n"
string_fragment " (none)"
" "\""
) ")"
; ";"
} "}"
else "else"
block
{ "{"
enhanced_for_statement
for "for"
( "("
type_identifier "String"
identifier "id"
: ":"
identifier "cameraIds"
) ")"
block
{ "{"
expression_statement (+21 nodes collapsed)
local_variable_declaration
type_identifier "CameraCharacteristics"
variable_declarator
identifier "characteristics"
= "="
method_invocation
identifier "cameraManager"
. "."
identifier "getCameraCharacteristics"
argument_list
( "("
identifier "id"
) ")"
; ";"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "facing"
= "="
method_invocation
identifier "characteristics"
. "."
identifier "get"
argument_list
( "("
field_access
identifier "CameraCharacteristics"
. "."
identifier "LENS_FACING"
) ")"
; ";"
expression_statement (+35 nodes collapsed)
local_variable_declaration
type_identifier "Rect"
variable_declarator
identifier "activeSize"
= "="
method_invocation
identifier "characteristics"
. "."
identifier "get"
argument_list
( "("
field_access
identifier "CameraCharacteristics"
. "."
identifier "SENSOR_INFO_ACTIVE_ARRAY_SIZE"
) ")"
; ";"
expression_statement (+49 nodes collapsed)
line_comment "// Capture frame rates for low-FPS mode are the same for eve"...
local_variable_declaration (+26 nodes collapsed)
local_variable_declaration
generic_type
type_identifier "TreeSet"
type_arguments
< "<"
type_identifier "Integer"
> ">"
variable_declarator
identifier "uniqueLowFps"
= "="
object_creation_expression
new "new"
generic_type
type_identifier "TreeSet"
type_arguments
< "<"
> ">"
argument_list
( "("
) ")"
; ";"
enhanced_for_statement
for "for"
( "("
generic_type
type_identifier "Range"
type_arguments
< "<"
type_identifier "Integer"
> ">"
identifier "range"
: ":"
identifier "lowFpsRanges"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "uniqueLowFps"
. "."
identifier "add"
argument_list
( "("
method_invocation
identifier "range"
. "."
identifier "getUpper"
argument_list
( "("
) ")"
) ")"
; ";"
} "}"
expression_statement (+27 nodes collapsed)
if_statement
if "if"
parenthesized_expression
( "("
identifier "includeSizes"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "StreamConfigurationMap"
variable_declarator
identifier "configs"
= "="
method_invocation
identifier "characteristics"
. "."
identifier "get"
argument_list
( "("
field_access
identifier "CameraCharacteristics"
. "."
identifier "SCALER_STREAM_CONFIGURATION_MAP"
) ")"
; ";"
local_variable_declaration (+27 nodes collapsed)
enhanced_for_statement (+64 nodes collapsed)
} "}"
} "}"
} "}"
} "}"
catch_clause (+25 nodes collapsed)
return_statement
return "return"
method_invocation
identifier "builder"
. "."
identifier "toString"
argument_list
( "("
) ")"
; ";"
} "}"
} "}"

After

program
package_declaration
package "package"
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "genymobile"
. "."
identifier "scrcpy"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "genymobile"
. "."
identifier "scrcpy"
. "."
identifier "wrappers"
. "."
identifier "DisplayManager"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "genymobile"
. "."
identifier "scrcpy"
. "."
identifier "wrappers"
. "."
identifier "ServiceManager"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "android"
. "."
identifier "graphics"
. "."
identifier "Rect"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "android"
. "."
identifier "hardware"
. "."
identifier "camera2"
. "."
identifier "CameraAccessException"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "android"
. "."
identifier "hardware"
. "."
identifier "camera2"
. "."
identifier "CameraCharacteristics"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "android"
. "."
identifier "hardware"
. "."
identifier "camera2"
. "."
identifier "CameraManager"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "android"
. "."
identifier "hardware"
. "."
identifier "camera2"
. "."
identifier "params"
. "."
identifier "StreamConfigurationMap"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "android"
. "."
identifier "media"
. "."
identifier "MediaCodec"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "android"
. "."
identifier "util"
. "."
identifier "Range"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "List"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "SortedSet"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "TreeSet"
; ";"
class_declaration
modifiers
public "public"
final "final"
class "class"
identifier "LogUtils"
class_body
{ "{"
constructor_declaration
modifiers
private "private"
identifier "LogUtils"
formal_parameters
( "("
) ")"
constructor_body
{ "{"
line_comment "// not instantiable"
} "}"
method_declaration (+181 nodes collapsed)
method_declaration (+181 nodes collapsed)
method_declaration (+259 nodes collapsed)
method_declaration (+81 nodes collapsed)
method_declaration
modifiers
public "public"
static "static"
type_identifier "String"
identifier "buildCameraListMessage"
formal_parameters
( "("
formal_parameter
boolean_type "boolean"
identifier "includeSizes"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "StringBuilder"
variable_declarator
identifier "builder"
= "="
object_creation_expression
new "new"
type_identifier "StringBuilder"
argument_list
( "("
string_literal
" "\""
string_fragment "List of cameras:"
" "\""
) ")"
; ";"
local_variable_declaration
type_identifier "CameraManager"
variable_declarator
identifier "cameraManager"
= "="
method_invocation
identifier "ServiceManager"
. "."
identifier "getCameraManager"
argument_list
( "("
) ")"
; ";"
try_statement
try "try"
block
{ "{"
local_variable_declaration
array_type
type_identifier "String"
dimensions
[ "["
] "]"
variable_declarator
identifier "cameraIds"
= "="
method_invocation
identifier "cameraManager"
. "."
identifier "getCameraIdList"
argument_list
( "("
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
identifier "cameraIds"
== "=="
null_literal "null"
|| "||"
binary_expression
field_access
identifier "cameraIds"
. "."
identifier "length"
== "=="
decimal_integer_literal "0"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "builder"
. "."
identifier "append"
argument_list
( "("
string_literal
" "\""
escape_sequence "\\n"
string_fragment " (none)"
" "\""
) ")"
; ";"
} "}"
else "else"
block
{ "{"
enhanced_for_statement
for "for"
( "("
type_identifier "String"
identifier "id"
: ":"
identifier "cameraIds"
) ")"
block
{ "{"
expression_statement (+21 nodes collapsed)
local_variable_declaration
type_identifier "CameraCharacteristics"
variable_declarator
identifier "characteristics"
= "="
method_invocation
identifier "cameraManager"
. "."
identifier "getCameraCharacteristics"
argument_list
( "("
identifier "id"
) ")"
; ";"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "facing"
= "="
method_invocation
identifier "characteristics"
. "."
identifier "get"
argument_list
( "("
field_access
identifier "CameraCharacteristics"
. "."
identifier "LENS_FACING"
) ")"
; ";"
expression_statement (+35 nodes collapsed)
local_variable_declaration
type_identifier "Rect"
variable_declarator
identifier "activeSize"
= "="
method_invocation
identifier "characteristics"
. "."
identifier "get"
argument_list
( "("
field_access
identifier "CameraCharacteristics"
. "."
identifier "SENSOR_INFO_ACTIVE_ARRAY_SIZE"
) ")"
; ";"
expression_statement (+49 nodes collapsed)
line_comment "// Capture frame rates for low-FPS mode are the same for eve"...
local_variable_declaration (+26 nodes collapsed)
local_variable_declaration
generic_type
type_identifier "SortedSet"
type_arguments
< "<"
type_identifier "Integer"
> ">"
variable_declarator
identifier "uniqueLowFps"
= "="
method_invocation
identifier "getUniqueSet"
argument_list
( "("
identifier "lowFpsRanges"
) ")"
; ";"
expression_statement (+27 nodes collapsed)
if_statement
if "if"
parenthesized_expression
( "("
identifier "includeSizes"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "StreamConfigurationMap"
variable_declarator
identifier "configs"
= "="
method_invocation
identifier "characteristics"
. "."
identifier "get"
argument_list
( "("
field_access
identifier "CameraCharacteristics"
. "."
identifier "SCALER_STREAM_CONFIGURATION_MAP"
) ")"
; ";"
local_variable_declaration (+27 nodes collapsed)
enhanced_for_statement (+64 nodes collapsed)
local_variable_declaration
array_type
scoped_type_identifier
scoped_type_identifier
type_identifier "android"
. "."
type_identifier "util"
. "."
type_identifier "Size"
dimensions
[ "["
] "]"
variable_declarator
identifier "highSpeedSizes"
= "="
method_invocation
identifier "configs"
. "."
identifier "getHighSpeedVideoSizes"
argument_list
( "("
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
field_access
identifier "highSpeedSizes"
. "."
identifier "length"
> ">"
decimal_integer_literal "0"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "builder"
. "."
identifier "append"
argument_list
( "("
string_literal
" "\""
escape_sequence "\\n"
string_fragment " High speed capture (--camera-high-speed):"
" "\""
) ")"
; ";"
enhanced_for_statement
for "for"
( "("
scoped_type_identifier
scoped_type_identifier
type_identifier "android"
. "."
type_identifier "util"
. "."
type_identifier "Size"
identifier "size"
: ":"
identifier "highSpeedSizes"
) ")"
block
{ "{"
local_variable_declaration
array_type
generic_type
type_identifier "Range"
type_arguments
< "<"
type_identifier "Integer"
> ">"
dimensions
[ "["
] "]"
variable_declarator
identifier "highFpsRanges"
= "="
method_invocation
identifier "configs"
. "."
identifier "getHighSpeedVideoFpsRanges"
argument_list
( "("
) ")"
; ";"
local_variable_declaration
generic_type
type_identifier "SortedSet"
type_arguments
< "<"
type_identifier "Integer"
> ">"
variable_declarator
identifier "uniqueHighFps"
= "="
method_invocation
identifier "getUniqueSet"
argument_list
( "("
identifier "highFpsRanges"
) ")"
; ";"
expression_statement
method_invocation
method_invocation
method_invocation
method_invocation
identifier "builder"
. "."
identifier "append"
argument_list
( "("
string_literal
" "\""
escape_sequence "\\n"
string_fragment " - "
" "\""
) ")"
. "."
identifier "append"
argument_list
( "("
method_invocation
identifier "size"
. "."
identifier "getWidth"
argument_list
( "("
) ")"
) ")"
. "."
identifier "append"
argument_list
( "("
string_literal
" "\""
string_fragment "x"
" "\""
) ")"
. "."
identifier "append"
argument_list
( "("
method_invocation
identifier "size"
. "."
identifier "getHeight"
argument_list
( "("
) ")"
) ")"
; ";"
expression_statement
method_invocation
method_invocation
method_invocation
identifier "builder"
. "."
identifier "append"
argument_list
( "("
string_literal
" "\""
string_fragment " (fps="
" "\""
) ")"
. "."
identifier "append"
argument_list
( "("
identifier "uniqueHighFps"
) ")"
. "."
identifier "append"
argument_list
( "("
character_literal "')'"
) ")"
; ";"
} "}"
} "}"
} "}"
} "}"
} "}"
} "}"
catch_clause (+25 nodes collapsed)
return_statement
return "return"
method_invocation
identifier "builder"
. "."
identifier "toString"
argument_list
( "("
) ")"
; ";"
} "}"
method_declaration
modifiers
private "private"
static "static"
generic_type
type_identifier "SortedSet"
type_arguments
< "<"
type_identifier "Integer"
> ">"
identifier "getUniqueSet"
formal_parameters
( "("
formal_parameter
array_type
generic_type
type_identifier "Range"
type_arguments
< "<"
type_identifier "Integer"
> ">"
dimensions
[ "["
] "]"
identifier "ranges"
) ")"
block
{ "{"
local_variable_declaration
generic_type
type_identifier "SortedSet"
type_arguments
< "<"
type_identifier "Integer"
> ">"
variable_declarator
identifier "set"
= "="
object_creation_expression
new "new"
generic_type
type_identifier "TreeSet"
type_arguments
< "<"
> ">"
argument_list
( "("
) ")"
; ";"
enhanced_for_statement
for "for"
( "("
generic_type
type_identifier "Range"
type_arguments
< "<"
type_identifier "Integer"
> ">"
identifier "range"
: ":"
identifier "ranges"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "set"
. "."
identifier "add"
argument_list
( "("
method_invocation
identifier "range"
. "."
identifier "getUpper"
argument_list
( "("
) ")"
) ")"
; ";"
} "}"
return_statement
return "return"
identifier "set"
; ";"
} "}"
} "}"