summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-12-12 02:00:50 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-12-12 02:00:50 +0000
commit51fe4878627ba1780f493f2289beb74b5ae78476 (patch)
tree4b9022b444e085576fbdd022008a90313124ead8
parent0be993646e2f3e4487eb4f633b372ebe526f4b4f (diff)
parent992cdee7c4994161d5768f0265b2c00f17dfbb2d (diff)
downloaddevelopment-51fe4878627ba1780f493f2289beb74b5ae78476.tar.gz
Snap for 11206181 from 992cdee7c4994161d5768f0265b2c00f17dfbb2d to 24Q1-release
Change-Id: Icbfa3ed31d1a52980c97aef2423b43e27835d627
-rw-r--r--samples/VirtualDeviceManager/client/res/layout/display_fragment.xml45
-rw-r--r--samples/VirtualDeviceManager/client/src/com/example/android/vdmdemo/client/DisplayAdapter.java32
-rw-r--r--samples/VirtualDeviceManager/common/src/com/example/android/vdmdemo/common/ConnectivityFragment.java24
-rw-r--r--tools/compare_cts_reports/README.md12
-rwxr-xr-xtools/compare_cts_reports/aggregate_cts_reports.py13
-rwxr-xr-xtools/compare_cts_reports/compare_cts_reports.py5
-rwxr-xr-xtools/compare_cts_reports/constant.py2
-rw-r--r--tools/compare_cts_reports/generate_spread_sheet.py5
-rwxr-xr-xtools/compare_cts_reports/parse_cts_report.py8
9 files changed, 84 insertions, 62 deletions
diff --git a/samples/VirtualDeviceManager/client/res/layout/display_fragment.xml b/samples/VirtualDeviceManager/client/res/layout/display_fragment.xml
index 29a4e25c9..190739899 100644
--- a/samples/VirtualDeviceManager/client/res/layout/display_fragment.xml
+++ b/samples/VirtualDeviceManager/client/res/layout/display_fragment.xml
@@ -1,16 +1,21 @@
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/display_focus"
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="match_parent"
- android:gravity="center"
+ android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="5dp">
<LinearLayout
+ android:id="@+id/display_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:gravity="center"
- android:orientation="vertical">
+ android:orientation="vertical"
+ app:layout_constraintBottom_toTopOf="@id/remote_display_view"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintVertical_chainStyle="packed">
<TextView
android:id="@+id/display_title"
@@ -64,17 +69,23 @@
</LinearLayout>
</LinearLayout>
- <FrameLayout
- android:id="@+id/frame"
- android:layout_width="250dp"
- android:layout_height="440dp"
- android:layout_gravity="center">
+ <View
+ android:id="@+id/strut"
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ app:layout_constraintBottom_toTopOf="@id/remote_display_view"
+ app:layout_constraintEnd_toEndOf="@id/display_header"
+ app:layout_constraintStart_toStartOf="@id/display_header"
+ app:layout_constraintTop_toBottomOf="@id/display_header" />
- <TextureView
- android:id="@+id/remote_display_view"
- android:layout_width="250dp"
- android:layout_height="440dp"
- android:layout_gravity="center" />
- </FrameLayout>
+ <TextureView
+ android:id="@+id/remote_display_view"
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintDimensionRatio="9:16"
+ app:layout_constraintEnd_toEndOf="@id/display_header"
+ app:layout_constraintStart_toStartOf="@id/display_header"
+ app:layout_constraintTop_toBottomOf="@id/display_header" />
-</LinearLayout> \ No newline at end of file
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/samples/VirtualDeviceManager/client/src/com/example/android/vdmdemo/client/DisplayAdapter.java b/samples/VirtualDeviceManager/client/src/com/example/android/vdmdemo/client/DisplayAdapter.java
index 3a0498fc8..00fdac386 100644
--- a/samples/VirtualDeviceManager/client/src/com/example/android/vdmdemo/client/DisplayAdapter.java
+++ b/samples/VirtualDeviceManager/client/src/com/example/android/vdmdemo/client/DisplayAdapter.java
@@ -27,7 +27,6 @@ import android.view.Surface;
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -149,7 +148,6 @@ final class DisplayAdapter extends RecyclerView.Adapter<DisplayHolder> {
private InputManager.FocusListener mFocusListener = null;
private Surface mSurface = null;
private TextureView mTextureView = null;
- private FrameLayout mTextureFrame = null;
private TextView mDisplayTitle = null;
private View mRotateButton = null;
private int mDisplayId = 0;
@@ -163,10 +161,12 @@ final class DisplayAdapter extends RecyclerView.Adapter<DisplayHolder> {
mRotateButton.setEnabled(rotationDegrees == 0 || resize);
// Make sure the rotation is visible.
- ViewGroup.LayoutParams frameLayoutParams = mTextureFrame.getLayoutParams();
- frameLayoutParams.width = Math.max(mTextureView.getWidth(), mTextureView.getHeight());
- frameLayoutParams.height = frameLayoutParams.width;
- mTextureFrame.setLayoutParams(frameLayoutParams);
+ View strut = itemView.findViewById(R.id.strut);
+ ViewGroup.LayoutParams layoutParams = strut.getLayoutParams();
+ layoutParams.width = Math.max(mTextureView.getWidth(), mTextureView.getHeight());
+ strut.setLayoutParams(layoutParams);
+ final int postRotationWidth = (resize || rotationDegrees % 180 != 0)
+ ? mTextureView.getHeight() : mTextureView.getWidth();
mTextureView
.animate()
@@ -181,17 +181,9 @@ final class DisplayAdapter extends RecyclerView.Adapter<DisplayHolder> {
0,
mTextureView.getHeight(),
mTextureView.getWidth()));
- } else {
- frameLayoutParams.width =
- (rotationDegrees % 180 == 0)
- ? mTextureView.getWidth()
- : mTextureView.getHeight();
- frameLayoutParams.height =
- (rotationDegrees % 180 == 0)
- ? mTextureView.getHeight()
- : mTextureView.getWidth();
- mTextureFrame.setLayoutParams(frameLayoutParams);
}
+ layoutParams.width = postRotationWidth;
+ strut.setLayoutParams(layoutParams);
})
.start();
}
@@ -204,11 +196,6 @@ final class DisplayAdapter extends RecyclerView.Adapter<DisplayHolder> {
layoutParams.width = newBounds.width();
layoutParams.height = newBounds.height();
mTextureView.setLayoutParams(layoutParams);
-
- ViewGroup.LayoutParams frameLayoutParams = mTextureFrame.getLayoutParams();
- frameLayoutParams.width = newBounds.width();
- frameLayoutParams.height = newBounds.height();
- mTextureFrame.setLayoutParams(frameLayoutParams);
}
private void setDisplayTitle(String title) {
@@ -235,11 +222,10 @@ final class DisplayAdapter extends RecyclerView.Adapter<DisplayHolder> {
mDisplayTitle = itemView.findViewById(R.id.display_title);
mTextureView = itemView.findViewById(R.id.remote_display_view);
- mTextureFrame = itemView.findViewById(R.id.frame);
mFocusListener =
focusedDisplayId -> {
- View displayFocusIndicator = itemView.findViewById(R.id.display_focus);
+ View displayFocusIndicator = itemView.findViewById(R.id.display_header);
if (focusedDisplayId == mDisplayId) {
displayFocusIndicator.setBackgroundResource(R.drawable.focus_frame);
} else {
diff --git a/samples/VirtualDeviceManager/common/src/com/example/android/vdmdemo/common/ConnectivityFragment.java b/samples/VirtualDeviceManager/common/src/com/example/android/vdmdemo/common/ConnectivityFragment.java
index cdbea98f4..a28abfb43 100644
--- a/samples/VirtualDeviceManager/common/src/com/example/android/vdmdemo/common/ConnectivityFragment.java
+++ b/samples/VirtualDeviceManager/common/src/com/example/android/vdmdemo/common/ConnectivityFragment.java
@@ -41,26 +41,27 @@ public final class ConnectivityFragment extends Hilt_ConnectivityFragment {
new ConnectionManager.ConnectionCallback() {
@Override
public void onConnecting(String remoteDeviceName) {
- mStatus.setText(getContext().getString(R.string.connecting, remoteDeviceName));
- mStatus.setBackgroundColor(mDefaultBackgroundColor);
+ updateStatus(
+ getContext().getString(R.string.connecting, remoteDeviceName),
+ mDefaultBackgroundColor);
}
@Override
public void onConnected(String remoteDeviceName) {
- mStatus.setText(getContext().getString(R.string.connected, remoteDeviceName));
- mStatus.setBackgroundColor(Color.GREEN);
+ updateStatus(
+ getContext().getString(R.string.connected, remoteDeviceName),
+ Color.GREEN);
}
@Override
public void onDisconnected() {
- mStatus.setText(getContext().getString(R.string.disconnected));
- mStatus.setBackgroundColor(mDefaultBackgroundColor);
+ updateStatus(
+ getContext().getString(R.string.disconnected), mDefaultBackgroundColor);
}
@Override
public void onError(String message) {
- mStatus.setText(message);
- mStatus.setBackgroundColor(Color.RED);
+ updateStatus(message, Color.RED);
}
};
@@ -103,4 +104,11 @@ public final class ConnectivityFragment extends Hilt_ConnectivityFragment {
super.onDestroyView();
mConnectionManager.removeConnectionCallback(mConnectionCallback);
}
+
+ private void updateStatus(String message, int backgroundColor) {
+ getActivity().runOnUiThread(() -> {
+ mStatus.setText(message);
+ mStatus.setBackgroundColor(backgroundColor);
+ });
+ }
}
diff --git a/tools/compare_cts_reports/README.md b/tools/compare_cts_reports/README.md
index 99cd3a1ad..f7c5cd2f9 100644
--- a/tools/compare_cts_reports/README.md
+++ b/tools/compare_cts_reports/README.md
@@ -20,17 +20,19 @@ The `-d` flag specifies the directory in which the information files will be sto
## aggregate_cts_reports.py
### usage
```
-./aggregate_cts_reports.py -r REPORT [REPORT ...] -d OUTPUT_DIR
+./aggregate_cts_reports.py -r REPORT [REPORT ...] -d OUTPUT_DIR [--ignore-abi]
```
The `-r` flag can be followed by one or more reports.
The `-d` flag has the same behavior as `parse_cts_report.py`.
+`--ignore-abi` is a boolean flag. If users specify this flag, tests ABI would be ignored while doing the aggregation. It means that two tests would be considered as the same one as long as they have the same module_name#class_name.test_name.
+
## compare_cts_reports.py
### usage
```
-./compare_cts_reports.py [-h] [-r CTS_REPORTS [CTS_REPORTS ...]] [-f CTS_REPORTS] --mode {1,2,n} --output-dir OUTPUT_DIR [--csv CSV] [--output-files]
+./compare_cts_reports.py [-h] [-r CTS_REPORTS [CTS_REPORTS ...]] [-f CTS_REPORTS] --mode {1,2,n} --output-dir OUTPUT_DIR [--csv CSV] [--output-files] [--ignore-abi]
```
One `-r` flag is followed by a group of report files that you want to aggregate.
@@ -41,9 +43,11 @@ The `-m` flag has to be specified: `1` for one-way mode, `2` for two-way mode, a
The `-d` flag has to be specified. Behavior same as `parse_cts_report.py`.
+`--csv` allows users to specify the file name of the comparison result. The default value is `diff.csv`.
+
`--output-files/-o` is a boolean flag. If users specify this flag, the parsed results of reports after flags `-r` will be outputed into the information files.
-`--csv` allows users to specify the file name of the comparison result. The default value is `diff.csv`.
+`--ignore-abi` is a boolean flag, which has the same behavior as `aggregate_cts_reports.py`.
### modes
#### One-way Comparison
@@ -64,4 +68,4 @@ N-way comparison mode is used to show a summary of several test reports.
./test_parse_cts_report.py
./test_aggregate_cts_reports.py
./test_compare_cts_reports.py
-``` \ No newline at end of file
+```
diff --git a/tools/compare_cts_reports/aggregate_cts_reports.py b/tools/compare_cts_reports/aggregate_cts_reports.py
index 82d754e06..f2db373e2 100755
--- a/tools/compare_cts_reports/aggregate_cts_reports.py
+++ b/tools/compare_cts_reports/aggregate_cts_reports.py
@@ -29,7 +29,7 @@ import zipfile
import parse_cts_report
-def aggregate_cts_reports(report_files):
+def aggregate_cts_reports(report_files, ignore_abi=False):
"""Aggregate all report files and produce information files to output_dir.
If the results of the same test are different in two reports, choose the one
@@ -38,6 +38,9 @@ def aggregate_cts_reports(report_files):
Args:
report_files: A list of paths to cts reports.
+ ignore_abi: Ignore the tests ABI when doing the aggregation, which means
+ that tests would be considered as the same one as long as they
+ have the same module_name#class_name.test_name.
Raises:
UserWarning: Report files not compatible.
@@ -48,7 +51,7 @@ def aggregate_cts_reports(report_files):
first_report_file = report_files[0]
- report = parse_cts_report.parse_report_file(first_report_file)
+ report = parse_cts_report.parse_report_file(first_report_file, ignore_abi)
with tempfile.TemporaryDirectory() as temp_dir:
@@ -64,7 +67,7 @@ def aggregate_cts_reports(report_files):
msg = (f'{report_file} is incompatible to {first_report_file}.')
raise UserWarning(msg)
- report.read_test_result_xml(xml_path)
+ report.read_test_result_xml(xml_path, ignore_abi)
return report
@@ -77,6 +80,8 @@ def main():
'be a zip archive or a xml file.'))
parser.add_argument('-d', '--output-dir', required=True,
help=('Path to the directory to store output files.'))
+ parser.add_argument('--ignore-abi', action='store_true',
+ help='Ignore the tests ABI while aggregating reports.')
args = parser.parse_args()
@@ -86,7 +91,7 @@ def main():
if not os.path.exists(output_dir):
raise FileNotFoundError(f'Output directory {output_dir} does not exist.')
- report = aggregate_cts_reports(report_files)
+ report = aggregate_cts_reports(report_files, args.ignore_abi)
report.output_files(output_dir)
diff --git a/tools/compare_cts_reports/compare_cts_reports.py b/tools/compare_cts_reports/compare_cts_reports.py
index 006f63638..168af2058 100755
--- a/tools/compare_cts_reports/compare_cts_reports.py
+++ b/tools/compare_cts_reports/compare_cts_reports.py
@@ -270,6 +270,8 @@ def main():
parser.add_argument('--csv', default='diff.csv', help='Path to csv output.')
parser.add_argument('--output-files', '-o', action='store_true',
help='Output parsed csv files.')
+ parser.add_argument('--ignore-abi', action='store_true',
+ help='Ignore the tests ABI while comparing.')
args = parser.parse_args()
@@ -287,10 +289,11 @@ def main():
diff_csv = os.path.join(output_dir, args.csv)
ctsreports = []
+ ignore_abi = args.ignore_abi
for i, report_path in enumerate(reports):
is_report_files = isinstance(report_path, list)
report = (
- aggregate_cts_reports.aggregate_cts_reports(report_path)
+ aggregate_cts_reports.aggregate_cts_reports(report_path, ignore_abi)
if is_report_files # path(s) come from --report flag
else load_parsed_report(report_path)
)
diff --git a/tools/compare_cts_reports/constant.py b/tools/compare_cts_reports/constant.py
index c409e909a..8c5dc72fa 100755
--- a/tools/compare_cts_reports/constant.py
+++ b/tools/compare_cts_reports/constant.py
@@ -22,3 +22,5 @@ VERSION = '1.0'
NO_DATA = 'null'
TESTED_ITEMS = 'tested_items'
PASS_RATE = 'pass_rate'
+
+ABI_IGNORED = 'abi-ignored'
diff --git a/tools/compare_cts_reports/generate_spread_sheet.py b/tools/compare_cts_reports/generate_spread_sheet.py
index 7d64f39bc..438ce1f10 100644
--- a/tools/compare_cts_reports/generate_spread_sheet.py
+++ b/tools/compare_cts_reports/generate_spread_sheet.py
@@ -27,6 +27,7 @@ python3 generate_spread_sheet.py \
"""
import argparse
+import constant
import csv
import gspread
import os
@@ -183,7 +184,9 @@ def _write_compare_details(
# Module changes, need a new header row.
if module_name != curr_module:
- rows_content.append([f'{module_name} [{abi}]', ''] + [''] * num_reports)
+ module_with_abi = (module_name if abi == constant.ABI_IGNORED
+ else f'{module_name} [{abi}]')
+ rows_content.append([module_with_abi, ''] + [''] * num_reports)
module_header_row = len(rows_content)
header_cell = _get_range_cell(
begin_row=curr_row, begin_column='A',
diff --git a/tools/compare_cts_reports/parse_cts_report.py b/tools/compare_cts_reports/parse_cts_report.py
index f6a082de4..8ed7111e3 100755
--- a/tools/compare_cts_reports/parse_cts_report.py
+++ b/tools/compare_cts_reports/parse_cts_report.py
@@ -126,7 +126,7 @@ class CtsReport:
summary.counter[previous] -= 1
summary.counter[test_status] += 1
- def read_test_result_xml(self, test_result_path):
+ def read_test_result_xml(self, test_result_path, ignore_abi=False):
"""Read the result from test_result.xml into a CtsReport object."""
tree = ET.parse(test_result_path)
@@ -134,7 +134,7 @@ class CtsReport:
for module in root.iter('Module'):
module_name = module.attrib['name']
- abi = module.attrib['abi']
+ abi = constant.ABI_IGNORED if ignore_abi else module.attrib['abi']
for testcase in module.iter('TestCase'):
class_name = testcase.attrib['name']
@@ -341,7 +341,7 @@ def extract_test_result_from_zip(zip_file_path, dest_dir):
return extracted
-def parse_report_file(report_file):
+def parse_report_file(report_file, ignore_abi=False):
"""Turn one cts report into a CtsReport object."""
with tempfile.TemporaryDirectory() as temp_dir:
@@ -355,7 +355,7 @@ def parse_report_file(report_file):
print_test_info(test_info)
report = CtsReport(test_info)
- report.read_test_result_xml(xml_path)
+ report.read_test_result_xml(xml_path, ignore_abi)
return report