summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBrian Orr <brianorr@google.com>2021-05-13 20:42:01 -0700
committerBrian Orr <brianorr@google.com>2021-05-13 20:42:01 -0700
commit1b62159ffcebb2c102e129b2e778a8f65b7e5948 (patch)
treec28571796470b5c9e3d9e8c2dc8d49ddf819fd60 /tests
parent86a43bb54c1ed3c75d072a2c465bf0447b5188c1 (diff)
parent3a582255fbbf0840208ec8cee02f8401982f0e39 (diff)
Merge SP1A.210510.001
Change-Id: Ia86f3e18206beabe334e3081cedbaf5b3274f78e
Diffstat (limited to 'tests')
-rw-r--r--tests/ActivityViewTest/Android.bp15
-rw-r--r--tests/ActivityViewTest/AndroidManifest.xml67
-rw-r--r--tests/ActivityViewTest/res/layout/activity_view_activity.xml47
-rw-r--r--tests/ActivityViewTest/res/layout/activity_view_main_activity.xml50
-rw-r--r--tests/ActivityViewTest/res/layout/activity_view_resize_activity.xml51
-rw-r--r--tests/ActivityViewTest/res/layout/activity_view_scroll_activity.xml57
-rw-r--r--tests/ActivityViewTest/res/layout/activity_view_test_activity.xml70
-rw-r--r--tests/ActivityViewTest/res/layout/activity_view_visibility_activity.xml46
-rw-r--r--tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewActivity.java56
-rw-r--r--tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewMainActivity.java42
-rw-r--r--tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewResizeActivity.java79
-rw-r--r--tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewScrollActivity.java44
-rw-r--r--tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewTestActivity.java116
-rw-r--r--tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewVisibilityActivity.java75
-rw-r--r--tests/DynamicCodeLoggerIntegrationTests/Android.mk3
-rw-r--r--tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppTransition.kt4
-rw-r--r--tests/HwAccelerationTest/AndroidManifest.xml9
-rw-r--r--tests/HwAccelerationTest/res/layout/scrolling_stretch_surfaceview.xml76
-rw-r--r--tests/HwAccelerationTest/res/layout/stretch_layout.xml2
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/ColorFiltersMutateActivity.java2
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/PositionListenerActivity.java36
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/RippleActivity.java8
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/ScrollingStretchSurfaceViewActivity.java113
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/StretchShaderActivity.java6
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/StretchySurfaceViewActivity.java2
-rw-r--r--tests/Input/src/com/android/test/input/ViewFrameInfoTest.kt6
-rw-r--r--tests/RollbackTest/MultiUserRollbackTest/src/com/android/tests/rollback/host/MultiUserRollbackTest.java2
-rw-r--r--tests/TouchLatency/gradle/wrapper/gradle-wrapper.jarbin49896 -> 54417 bytes
-rw-r--r--tests/TouchLatency/gradle/wrapper/gradle-wrapper.properties3
-rwxr-xr-xtests/TouchLatency/gradlew78
-rw-r--r--tests/TouchLatency/gradlew.bat14
-rw-r--r--tests/UiBench/res/layout/recycler_view.xml1
-rw-r--r--tests/UpdatableSystemFontTest/Android.bp14
-rw-r--r--tests/UpdatableSystemFontTest/AndroidManifest.xml30
-rw-r--r--tests/UpdatableSystemFontTest/AndroidTest.xml5
-rw-r--r--tests/UpdatableSystemFontTest/src/com/android/updatablesystemfont/UpdatableSystemFontTest.java316
-rw-r--r--tests/net/common/java/android/net/NetworkCapabilitiesTest.java133
-rw-r--r--tests/net/common/java/android/net/UnderlyingNetworkInfoTest.kt12
-rw-r--r--tests/net/integration/src/com/android/server/net/integrationtests/TestNetworkStackService.kt3
-rw-r--r--tests/net/java/android/net/NetworkTemplateTest.kt124
-rw-r--r--tests/net/java/com/android/server/ConnectivityServiceTest.java25
-rw-r--r--tests/net/java/com/android/server/connectivity/DnsManagerTest.java19
-rw-r--r--tests/net/java/com/android/server/net/NetworkStatsServiceTest.java15
-rw-r--r--tests/vcn/java/android/net/vcn/VcnGatewayConnectionConfigTest.java12
-rw-r--r--tests/vcn/java/android/net/vcn/VcnTransportInfoTest.java41
-rw-r--r--tests/vcn/java/com/android/server/VcnManagementServiceTest.java25
-rw-r--r--tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionConnectedStateTest.java28
-rw-r--r--tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionRetryTimeoutStateTest.java2
-rw-r--r--tests/vcn/java/com/android/server/vcn/VcnTest.java6
49 files changed, 843 insertions, 1147 deletions
diff --git a/tests/ActivityViewTest/Android.bp b/tests/ActivityViewTest/Android.bp
deleted file mode 100644
index 95178a0fb9a5..000000000000
--- a/tests/ActivityViewTest/Android.bp
+++ /dev/null
@@ -1,15 +0,0 @@
-package {
- // See: http://go/android-license-faq
- // A large-scale-change added 'default_applicable_licenses' to import
- // all of the 'license_kinds' from "frameworks_base_license"
- // to get the below license kinds:
- // SPDX-license-identifier-Apache-2.0
- default_applicable_licenses: ["frameworks_base_license"],
-}
-
-android_test {
- name: "ActivityViewTest",
- srcs: ["src/**/*.java"],
- platform_apis: true,
- certificate: "platform",
-}
diff --git a/tests/ActivityViewTest/AndroidManifest.xml b/tests/ActivityViewTest/AndroidManifest.xml
deleted file mode 100644
index 7563a25424ad..000000000000
--- a/tests/ActivityViewTest/AndroidManifest.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.google.android.test.activityview">
- <uses-permission android:name="android.permission.INJECT_EVENTS"/>
- <uses-permission android:name="android.permission.MANAGE_ACTIVITY_TASKS"/>
- <uses-permission android:name="android.permission.ACTIVITY_EMBEDDING"/>
- <uses-permission android:name="android.permission.INTERNAL_SYSTEM_WINDOW"/>
-
- <uses-sdk android:targetSdkVersion="27"/>
- <application android:label="ActivityViewTest">
- <activity android:name=".ActivityViewMainActivity"
- android:label="AV Main"
- android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|colorMode|density"
- android:exported="true">
- <intent-filter>
- <action android:name="android.intent.action.MAIN"/>
- <category android:name="android.intent.category.LAUNCHER"/>
- <category android:name="android.intent.category.DEFAULT"/>
- </intent-filter>
- </activity>
-
- <activity android:name=".ActivityViewActivity"
- android:label="AV"
- android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|colorMode|density"
- android:windowSoftInputMode="stateHidden|adjustResize">
- </activity>
-
- <activity android:name=".ActivityViewResizeActivity"
- android:label="AV Resize"
- android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|colorMode|density"
- android:windowSoftInputMode="stateHidden|adjustResize">
- </activity>
-
- <activity android:name=".ActivityViewScrollActivity"
- android:label="AV Scroll"
- android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|colorMode|density"
- android:windowSoftInputMode="stateHidden">
- </activity>
-
- <activity android:name=".ActivityViewTestActivity"
- android:resizeableActivity="true"
- android:theme="@*android:style/Theme.NoTitleBar"
- android:exported="true"
- android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|colorMode|density">
- </activity>
-
- <activity android:name=".ActivityViewVisibilityActivity"
- android:label="AV Visibility"
- android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|colorMode|density">
- </activity>
- </application>
-</manifest>
diff --git a/tests/ActivityViewTest/res/layout/activity_view_activity.xml b/tests/ActivityViewTest/res/layout/activity_view_activity.xml
deleted file mode 100644
index 67c01f8c78fe..000000000000
--- a/tests/ActivityViewTest/res/layout/activity_view_activity.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="#cfd8dc">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal">
-
- <Button
- android:id="@+id/activity_launch_button"
- android:layout_width="200dp"
- android:layout_height="wrap_content"
- android:text="Launch test activity" />
-
- <Button
- android:id="@+id/activity_pick_launch_button"
- android:layout_width="200dp"
- android:layout_height="wrap_content"
- android:text="Launch from picker" />
-
- </LinearLayout>
-
- <ActivityView
- android:id="@+id/activity_view"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-
-</LinearLayout> \ No newline at end of file
diff --git a/tests/ActivityViewTest/res/layout/activity_view_main_activity.xml b/tests/ActivityViewTest/res/layout/activity_view_main_activity.xml
deleted file mode 100644
index efcaef679a9c..000000000000
--- a/tests/ActivityViewTest/res/layout/activity_view_main_activity.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <Button
- android:id="@+id/activity_view_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Test ActivityView"
- android:textAllCaps="false"/>
-
- <Button
- android:id="@+id/scroll_activity_view_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Test Scroll ActivityView"
- android:textAllCaps="false"/>
-
- <Button
- android:id="@+id/resize_activity_view_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Test Resize ActivityView"
- android:textAllCaps="false"/>
-
- <Button
- android:id="@+id/visibility_activity_view_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Test ActivityView Visibility"
- android:textAllCaps="false"/>
-</LinearLayout>
diff --git a/tests/ActivityViewTest/res/layout/activity_view_resize_activity.xml b/tests/ActivityViewTest/res/layout/activity_view_resize_activity.xml
deleted file mode 100644
index 18d86e3d5a6f..000000000000
--- a/tests/ActivityViewTest/res/layout/activity_view_resize_activity.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="#cfd8dc">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal">
-
- <Button
- android:id="@+id/activity_launch_button"
- android:layout_width="100dp"
- android:layout_height="wrap_content"
- android:text="Launch" />
-
- <Button
- android:id="@+id/activity_resize_button"
- android:layout_width="100dp"
- android:layout_height="wrap_content"
- android:text="Resize" />
- </LinearLayout>
-
- <SeekBar
- android:id="@+id/activity_view_seek_bar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- <ActivityView
- android:id="@+id/activity_view"
- android:layout_width="match_parent"
- android:layout_height="600dp" />
-
-</LinearLayout> \ No newline at end of file
diff --git a/tests/ActivityViewTest/res/layout/activity_view_scroll_activity.xml b/tests/ActivityViewTest/res/layout/activity_view_scroll_activity.xml
deleted file mode 100644
index 879c2c20a082..000000000000
--- a/tests/ActivityViewTest/res/layout/activity_view_scroll_activity.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <Button
- android:id="@+id/activity_launch_button"
- android:layout_width="100dp"
- android:layout_height="wrap_content"
- android:text="Launch" />
-
- <ScrollView
- android:id="@+id/activity_view_host_scroll_view"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:color="#cfd8dc">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
-
- <View
- android:layout_width="match_parent"
- android:layout_height="300dp"
- android:layout_gravity="center_horizontal"
- android:background="#eeeeee" />
-
- <ActivityView
- android:id="@+id/activity_view"
- android:layout_width="match_parent"
- android:layout_height="300dp"
- android:background="#fce4ec" />
-
- <View
- android:layout_width="match_parent"
- android:layout_height="300dp"
- android:layout_gravity="center_horizontal"
- android:background="#eeeeee" />
- </LinearLayout>
- </ScrollView>
-</LinearLayout> \ No newline at end of file
diff --git a/tests/ActivityViewTest/res/layout/activity_view_test_activity.xml b/tests/ActivityViewTest/res/layout/activity_view_test_activity.xml
deleted file mode 100644
index 338d68adfafb..000000000000
--- a/tests/ActivityViewTest/res/layout/activity_view_test_activity.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/test_activity_root"
- android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="#ffe0b2">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true"
- android:orientation="vertical"
- android:background="#00000000" >
- <TextView
- android:id="@+id/test_activity_title"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textColor="@android:color/black"
- android:background="#00000000"
- android:gravity="center" />
- <TextView
- android:id="@+id/test_activity_touch_state"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textColor="@android:color/black"
- android:background="#00000000"
- android:gravity="center" />
- </LinearLayout>
-
- <TextView
- android:id="@+id/test_activity_width_text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textColor="@android:color/black"
- android:background="#00000000"
- android:gravity="center" />
-
- <TextView
- android:id="@+id/test_activity_height_text"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_alignParentRight="true"
- android:layout_alignParentEnd="true"
- android:textColor="@android:color/black"
- android:background="#00000000"
- android:gravity="center" />
-
- <EditText
- android:id="@+id/test_activity_edittext"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:layout_margin="16dp" />
-</RelativeLayout> \ No newline at end of file
diff --git a/tests/ActivityViewTest/res/layout/activity_view_visibility_activity.xml b/tests/ActivityViewTest/res/layout/activity_view_visibility_activity.xml
deleted file mode 100644
index d29d4dfc0428..000000000000
--- a/tests/ActivityViewTest/res/layout/activity_view_visibility_activity.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2019 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="#cfd8dc">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal">
-
- <Button
- android:id="@+id/activity_launch_button"
- android:layout_width="200dp"
- android:layout_height="wrap_content"
- android:text="Launch test activity" />
-
- <Spinner
- android:id="@+id/visibility_spinner"
- android:layout_width="200dp"
- android:layout_height="match_parent"/>
-
- </LinearLayout>
-
- <ActivityView
- android:id="@+id/activity_view"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-
-</LinearLayout>
diff --git a/tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewActivity.java b/tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewActivity.java
deleted file mode 100644
index f7c60fc73cb3..000000000000
--- a/tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewActivity.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Copyright (c) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.test.activityview;
-
-import android.app.Activity;
-import android.app.ActivityView;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Parcelable;
-import android.widget.Button;
-
-public class ActivityViewActivity extends Activity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_view_activity);
-
- final ActivityView activityView = findViewById(R.id.activity_view);
- final Button launchButton = findViewById(R.id.activity_launch_button);
- launchButton.setOnClickListener(v -> {
- final Intent intent = new Intent(this, ActivityViewTestActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
- activityView.startActivity(intent);
- });
- final Button pickActivityLaunchButton = findViewById(R.id.activity_pick_launch_button);
- pickActivityLaunchButton.setOnClickListener(v -> {
- final Intent intent = Intent.makeMainActivity(null);
- final Intent chooser = Intent.createChooser(intent,
- "Pick an app to launch in ActivityView");
- chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Parcelable[] {
- new Intent(Intent.ACTION_MAIN)
- .addCategory("com.android.internal.category.PLATLOGO")
- });
- if (intent.resolveActivity(getPackageManager()) != null) {
- chooser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
- | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
- activityView.startActivity(chooser);
- }
- });
- }
-}
diff --git a/tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewMainActivity.java b/tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewMainActivity.java
deleted file mode 100644
index 4f09c28fe711..000000000000
--- a/tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewMainActivity.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright (c) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.test.activityview;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-
-public class ActivityViewMainActivity extends Activity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_view_main_activity);
-
- findViewById(R.id.activity_view_button).setOnClickListener(
- v -> startActivity(new Intent(this, ActivityViewActivity.class)));
-
- findViewById(R.id.scroll_activity_view_button).setOnClickListener(
- v -> startActivity(new Intent(this, ActivityViewScrollActivity.class)));
-
- findViewById(R.id.resize_activity_view_button).setOnClickListener(
- v -> startActivity(new Intent(this, ActivityViewResizeActivity.class)));
-
- findViewById(R.id.visibility_activity_view_button).setOnClickListener(
- v -> startActivity(new Intent(this, ActivityViewVisibilityActivity.class)));
- }
-}
diff --git a/tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewResizeActivity.java b/tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewResizeActivity.java
deleted file mode 100644
index 8860a771fd5a..000000000000
--- a/tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewResizeActivity.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * Copyright (c) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.test.activityview;
-
-import android.app.Activity;
-import android.app.ActivityView;
-import android.content.Intent;
-import android.os.Bundle;
-import android.widget.Button;
-import android.widget.LinearLayout;
-import android.widget.SeekBar;
-
-public class ActivityViewResizeActivity extends Activity {
- private static final int SMALL_SIZE = 600;
- private static final int LARGE_SIZE = 1200;
-
- private ActivityView mActivityView;
-
- private boolean mFlipSize;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_view_resize_activity);
-
- mActivityView = findViewById(R.id.activity_view);
-
- final Button launchButton = findViewById(R.id.activity_launch_button);
- launchButton.setOnClickListener(v -> {
- final Intent intent = new Intent(this, ActivityViewTestActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
- mActivityView.startActivity(intent);
- });
- final Button resizeButton = findViewById(R.id.activity_resize_button);
- if (resizeButton != null) {
- resizeButton.setOnClickListener(v -> {
- LinearLayout.LayoutParams params =
- (LinearLayout.LayoutParams) mActivityView.getLayoutParams();
- params.height = mFlipSize ? SMALL_SIZE : LARGE_SIZE;
- mFlipSize = !mFlipSize;
- mActivityView.setLayoutParams(params);
- });
- }
- final SeekBar seekBar = findViewById(R.id.activity_view_seek_bar);
- if (seekBar != null) {
- seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- final LinearLayout.LayoutParams params =
- (LinearLayout.LayoutParams) mActivityView.getLayoutParams();
- params.height = SMALL_SIZE + progress * 10;
- mActivityView.setLayoutParams(params);
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- }
- });
- }
- }
-}
diff --git a/tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewScrollActivity.java b/tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewScrollActivity.java
deleted file mode 100644
index 56543662675c..000000000000
--- a/tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewScrollActivity.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Copyright (c) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.test.activityview;
-
-import android.app.Activity;
-import android.app.ActivityView;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.Button;
-
-public class ActivityViewScrollActivity extends Activity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_view_scroll_activity);
-
- final ActivityView activityView = findViewById(R.id.activity_view);
- final Button launchButton = findViewById(R.id.activity_launch_button);
- launchButton.setOnClickListener(v -> {
- final Intent intent = new Intent(this, ActivityViewTestActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
- activityView.startActivity(intent);
- });
- findViewById(R.id.activity_view_host_scroll_view).setOnScrollChangeListener(
- (View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY)
- -> activityView.onLocationChanged());
- }
-}
diff --git a/tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewTestActivity.java b/tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewTestActivity.java
deleted file mode 100644
index 52aba2b13c42..000000000000
--- a/tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewTestActivity.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/**
- * Copyright (c) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.test.activityview;
-
-import static android.view.MotionEvent.ACTION_CANCEL;
-import static android.view.MotionEvent.ACTION_DOWN;
-import static android.view.MotionEvent.ACTION_MOVE;
-import static android.view.MotionEvent.ACTION_UP;
-
-import android.app.Activity;
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.ViewTreeObserver;
-import android.widget.TextView;
-
-public class ActivityViewTestActivity extends Activity {
- private static final String TAG = "ActivityViewTestActivity";
-
- private View mRoot;
- private TextView mTextView;
- private TextView mWidthTextView;
- private TextView mHeightTextView;
- private TextView mTouchStateTextView;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_view_test_activity);
- mRoot = findViewById(R.id.test_activity_root);
- mTextView = findViewById(R.id.test_activity_title);
- mWidthTextView = findViewById(R.id.test_activity_width_text);
- mHeightTextView = findViewById(R.id.test_activity_height_text);
- mTouchStateTextView = findViewById(R.id.test_activity_touch_state);
- ViewTreeObserver viewTreeObserver = mRoot.getViewTreeObserver();
- if (viewTreeObserver.isAlive()) {
- viewTreeObserver.addOnGlobalLayoutListener(this::updateDimensionTexts);
- }
- updateStateText("CREATED");
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- updateStateText("STARTED");
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- updateStateText("RESUMED");
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- updateStateText("PAUSED");
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- updateStateText("STOPPED");
- }
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- updateDimensionTexts();
- }
-
- private void updateStateText(String state) {
- Log.d(TAG, state);
- mTextView.setText(state);
- }
-
- private void updateDimensionTexts() {
- mWidthTextView.setText("" + mRoot.getWidth());
- mHeightTextView.setText("" + mRoot.getHeight());
- }
-
- private void updateTouchState(MotionEvent event) {
- switch (event.getAction()) {
- case ACTION_DOWN:
- case ACTION_MOVE:
- mTouchStateTextView.setText("[" + event.getX() + "," + event.getY() + "]");
- break;
- case ACTION_UP:
- case ACTION_CANCEL:
- mTouchStateTextView.setText("");
- break;
- }
- }
-
- @Override
- public boolean dispatchTouchEvent(MotionEvent event) {
- updateTouchState(event);
- return super.dispatchTouchEvent(event);
- }
-}
diff --git a/tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewVisibilityActivity.java b/tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewVisibilityActivity.java
deleted file mode 100644
index ecd2cf3c578e..000000000000
--- a/tests/ActivityViewTest/src/com/google/android/test/activityview/ActivityViewVisibilityActivity.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * Copyright (c) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.test.activityview;
-
-import static android.view.View.GONE;
-import static android.view.View.INVISIBLE;
-import static android.view.View.VISIBLE;
-
-import android.app.Activity;
-import android.app.ActivityView;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.Spinner;
-
-public class ActivityViewVisibilityActivity extends Activity {
- private static final String[] sVisibilityOptions = {"VISIBLE", "INVISIBLE", "GONE"};
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_view_visibility_activity);
-
- final ActivityView activityView = findViewById(R.id.activity_view);
- final Button launchButton = findViewById(R.id.activity_launch_button);
- launchButton.setOnClickListener(v -> {
- final Intent intent = new Intent(this, ActivityViewTestActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
- activityView.startActivity(intent);
- });
-
- final Spinner visibilitySpinner = findViewById(R.id.visibility_spinner);
- final ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
- android.R.layout.simple_spinner_item, sVisibilityOptions);
- adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- visibilitySpinner.setAdapter(adapter);
- visibilitySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
- @Override
- public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
- switch (position) {
- case 0:
- activityView.setVisibility(VISIBLE);
- break;
- case 1:
- activityView.setVisibility(INVISIBLE);
- break;
- case 2:
- activityView.setVisibility(GONE);
- break;
- }
- }
-
- @Override
- public void onNothingSelected(AdapterView<?> parent) {
- }
- });
- }
-}
diff --git a/tests/DynamicCodeLoggerIntegrationTests/Android.mk b/tests/DynamicCodeLoggerIntegrationTests/Android.mk
index bfb5b076237a..dab83046c28f 100644
--- a/tests/DynamicCodeLoggerIntegrationTests/Android.mk
+++ b/tests/DynamicCodeLoggerIntegrationTests/Android.mk
@@ -89,4 +89,7 @@ LOCAL_JAVA_RESOURCE_FILES := \
$(dynamiccodeloggertest_jar) \
$(dynamiccodeloggertest_executable) \
+LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
+LOCAL_LICENSE_CONDITIONS := notice
+LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../../NOTICE
include $(BUILD_PACKAGE)
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppTransition.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppTransition.kt
index 9ac504ba3e6f..96c7c0a4ae20 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppTransition.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppTransition.kt
@@ -116,7 +116,7 @@ abstract class CloseAppTransition(protected val testSpec: FlickerTestParameter)
}
}
- @Presubmit
+ @FlakyTest(bugId = 185400889)
@Test
open fun noUncoveredRegions() {
testSpec.noUncoveredRegions(testSpec.config.startRotation, Surface.ROTATION_0)
@@ -134,7 +134,7 @@ abstract class CloseAppTransition(protected val testSpec: FlickerTestParameter)
testSpec.launcherWindowBecomesVisible()
}
- @Presubmit
+ @FlakyTest(bugId = 185400889)
@Test
open fun launcherLayerReplacesApp() {
testSpec.launcherLayerReplacesApp(testApp)
diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml
index 6bf44920ee26..04a55d6038b0 100644
--- a/tests/HwAccelerationTest/AndroidManifest.xml
+++ b/tests/HwAccelerationTest/AndroidManifest.xml
@@ -409,6 +409,15 @@
</intent-filter>
</activity>
+ <activity android:name="ScrollingStretchSurfaceViewActivity"
+ android:label="SurfaceView/Scrolling Stretched SurfaceView"
+ android:exported="true">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="com.android.test.hwui.TEST"/>
+ </intent-filter>
+ </activity>
+
<activity android:name="GetBitmapSurfaceViewActivity"
android:label="SurfaceView/GetBitmap with Camera source"
android:exported="true">
diff --git a/tests/HwAccelerationTest/res/layout/scrolling_stretch_surfaceview.xml b/tests/HwAccelerationTest/res/layout/scrolling_stretch_surfaceview.xml
new file mode 100644
index 000000000000..77f5e60dc091
--- /dev/null
+++ b/tests/HwAccelerationTest/res/layout/scrolling_stretch_surfaceview.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2021 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:overScrollMode="always"
+ android:fillViewport="true"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ >
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:layout_marginTop="100dp"
+ android:orientation="horizontal"
+ >
+
+ <ImageView
+ android:id="@+id/vertical_imageview"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="match_parent"/>
+ <FrameLayout
+ android:id="@+id/vertical_surfaceview_container"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"/>
+ </LinearLayout>
+
+ <HorizontalScrollView
+ android:overScrollMode="always"
+ android:layout_width="400dp"
+ android:layout_height="0dp"
+ android:background="#FF0000"
+ android:layout_weight="1"
+ >
+ <LinearLayout
+ android:layout_width="400dp"
+ android:layout_height="400dp"
+ android:layout_marginLeft="100dp"
+ android:orientation="vertical">
+
+ <ImageView
+ android:id="@+id/horizontal_imageview"
+ android:layout_width="100dp"
+ android:layout_weight="1"
+ android:layout_height="0dp"/>
+
+ <FrameLayout
+ android:id="@+id/horizontal_surfaceview_container"
+ android:layout_width="100dp"
+ android:layout_height="0dp"
+ android:layout_weight="1"/>
+
+ </LinearLayout>
+ </HorizontalScrollView>
+ </LinearLayout>
+</ScrollView> \ No newline at end of file
diff --git a/tests/HwAccelerationTest/res/layout/stretch_layout.xml b/tests/HwAccelerationTest/res/layout/stretch_layout.xml
index df5f297da729..81e0c019490f 100644
--- a/tests/HwAccelerationTest/res/layout/stretch_layout.xml
+++ b/tests/HwAccelerationTest/res/layout/stretch_layout.xml
@@ -16,7 +16,6 @@
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroll_view"
- android:edgeEffectType="stretch"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
@@ -26,7 +25,6 @@
<HorizontalScrollView
android:id="@+id/horizontal_scroll_view"
- android:edgeEffectType="stretch"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ColorFiltersMutateActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ColorFiltersMutateActivity.java
index 8be3b7e35d42..c06f8fd44c03 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/ColorFiltersMutateActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ColorFiltersMutateActivity.java
@@ -60,7 +60,7 @@ public class ColorFiltersMutateActivity extends Activity {
private float mShaderParam1 = 0.0f;
static final String sSkSL =
- "in shader bitmapShader;\n"
+ "uniform shader bitmapShader;\n"
+ "uniform float param1;\n"
+ "half4 main(float2 xy) {\n"
+ " return half4(sample(bitmapShader, xy).rgb, param1);\n"
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/PositionListenerActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/PositionListenerActivity.java
index 6b6287da2711..2ad034cd143e 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/PositionListenerActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/PositionListenerActivity.java
@@ -74,12 +74,10 @@ public class PositionListenerActivity extends Activity {
float maxStretchAmount = 100f;
// Although we could do this in a single call, the real one won't be - so mimic that
if (dir.x != 0f) {
- node.stretch(0f, 0f, (float) getWidth(), (float) getHeight(),
- dir.x, 0f, maxStretchAmount, maxStretchAmount);
+ node.stretch(dir.x, 0f, maxStretchAmount, maxStretchAmount);
}
if (dir.y != 0f) {
- node.stretch(0f, 0f, (float) getWidth(), (float) getHeight(),
- 0f, dir.y, maxStretchAmount, maxStretchAmount);
+ node.stretch(0f, dir.y, maxStretchAmount, maxStretchAmount);
}
}
};
@@ -94,10 +92,13 @@ public class PositionListenerActivity extends Activity {
int mCurrentCount = 0;
int mTranslateY = 0;
Rect mPosition = new Rect();
- RectF mStretchArea = new RectF();
+ float mWidth = 0f;
+ float mHeight = 0f;
+ RectF mMappedBounds = new RectF();
float mStretchX = 0.0f;
float mStretchY = 0.0f;
- float mStretchMax = 0.0f;
+ float mStretchMaxX = 0.0f;
+ float mStretchMaxY = 0.0f;
MyPositionReporter(Context c) {
super(c);
@@ -128,9 +129,12 @@ public class PositionListenerActivity extends Activity {
}
void updateText() {
- setText(String.format("%d: Position %s, stretch area %s, vec %f,%f, amount %f",
- mCurrentCount, mPosition.toShortString(), mStretchArea.toShortString(),
- mStretchX, mStretchY, mStretchMax));
+ String posText =
+ "%d: Position %s, stretch width %f, height %f, vec %f,%f, amountX %f amountY %f mappedBounds %s";
+ setText(String.format(posText,
+ mCurrentCount, mPosition.toShortString(), mWidth, mHeight,
+ mStretchX, mStretchY, mStretchMaxX, mStretchMaxY,
+ mMappedBounds.toShortString()));
}
@Override
@@ -143,13 +147,19 @@ public class PositionListenerActivity extends Activity {
}
@Override
- public void applyStretch(long frameNumber, float left, float top, float right, float bottom,
- float vecX, float vecY, float maxStretch) {
+ public void applyStretch(long frameNumber, float width, float height,
+ float vecX, float vecY,
+ float maxStretchX, float maxStretchY, float childRelativeLeft,
+ float childRelativeTop, float childRelativeRight, float childRelativeBottom) {
getHandler().postAtFrontOfQueue(() -> {
- mStretchArea.set(left, top, right, bottom);
+ mWidth = width;
+ mHeight = height;
mStretchX = vecX;
mStretchY = vecY;
- mStretchMax = maxStretch;
+ mStretchMaxX = maxStretchX;
+ mStretchMaxY = maxStretchY;
+ mMappedBounds.set(childRelativeLeft, childRelativeTop, childRelativeRight,
+ childRelativeBottom);
updateText();
});
}
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/RippleActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/RippleActivity.java
index 487c8566ce37..d925541c76d6 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/RippleActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/RippleActivity.java
@@ -20,6 +20,7 @@ import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.CanvasProperty;
+import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RecordingCanvas;
import android.graphics.RuntimeShader;
@@ -48,6 +49,7 @@ public class RippleActivity extends Activity {
static class RippleView extends View {
static final int DURATION = 1000;
static final int MAX_RADIUS = 250;
+ private final int mColor = Color.RED;
private boolean mToggle = false;
ArrayList<RenderNodeAnimator> mRunningAnimations = new ArrayList<RenderNodeAnimator>();
@@ -89,7 +91,7 @@ public class RippleActivity extends Activity {
+ " d = rand(float2(x, y)) > density ? d : d * .2;\n"
+ " d = d * rand(float2(fraction, x * y));\n"
+ " float alpha = 1. - pow(fraction, 3.);\n"
- + " return float4(sample(in_paintColor).rgb, d * alpha);\n"
+ + " return float4(sample(in_paintColor, p).rgb, d * alpha);\n"
+ "}";
RippleView(Context c) {
@@ -104,7 +106,7 @@ public class RippleActivity extends Activity {
Paint p = new Paint();
p.setAntiAlias(true);
- p.setColor(0xFFFF0000);
+ p.setColor(mColor);
mPaint = CanvasProperty.createPaint(p);
mRuntimeShader = new RuntimeShader(sSkSL, false);
@@ -118,7 +120,7 @@ public class RippleActivity extends Activity {
if (canvas.isHardwareAccelerated()) {
RecordingCanvas recordingCanvas = (RecordingCanvas) canvas;
recordingCanvas.drawRipple(mX, mY, mRadius, mPaint, mProgress, mNoisePhase,
- mRuntimeShader);
+ mColor, mRuntimeShader);
}
}
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ScrollingStretchSurfaceViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ScrollingStretchSurfaceViewActivity.java
new file mode 100644
index 000000000000..040bff5d74d8
--- /dev/null
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ScrollingStretchSurfaceViewActivity.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.test.hwui;
+
+import android.app.Activity;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.ColorFilter;
+import android.graphics.Paint;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.view.SurfaceHolder;
+import android.view.SurfaceHolder.Callback;
+import android.view.SurfaceView;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+
+public class ScrollingStretchSurfaceViewActivity extends Activity implements Callback {
+
+ SurfaceView mVerticalSurfaceView;
+ SurfaceView mHorizontalSurfaceView;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.scrolling_stretch_surfaceview);
+
+ mVerticalSurfaceView = new SurfaceView(this);
+ mVerticalSurfaceView.getHolder().addCallback(this);
+
+ mHorizontalSurfaceView = new SurfaceView(this);
+ mHorizontalSurfaceView.getHolder().addCallback(this);
+
+ FrameLayout verticalContainer = findViewById(R.id.vertical_surfaceview_container);
+ verticalContainer.addView(mVerticalSurfaceView,
+ new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
+ FrameLayout.LayoutParams.MATCH_PARENT));
+
+ FrameLayout horizontalContainer = findViewById(R.id.horizontal_surfaceview_container);
+ horizontalContainer.addView(mHorizontalSurfaceView,
+ new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
+ FrameLayout.LayoutParams.MATCH_PARENT));
+
+ ImageView verticalImageView = findViewById(R.id.vertical_imageview);
+ verticalImageView.setImageDrawable(new LineDrawable());
+
+ ImageView horizontalImageView = findViewById(R.id.horizontal_imageview);
+ horizontalImageView.setImageDrawable(new LineDrawable());
+ }
+
+ @Override
+ public void surfaceCreated(SurfaceHolder holder) {
+ }
+
+ @Override
+ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+ Canvas canvas = holder.lockCanvas();
+
+ drawLine(canvas, width, height);
+ holder.unlockCanvasAndPost(canvas);
+ }
+
+ private static void drawLine(Canvas canvas, int width, int height) {
+ canvas.drawColor(Color.GRAY);
+
+ Paint paint = new Paint();
+ paint.setAntiAlias(true);
+ paint.setColor(Color.GREEN);
+ paint.setStyle(Paint.Style.STROKE);
+ paint.setStrokeWidth(10f);
+ canvas.drawLine(0, 0, width, height, paint);
+ }
+
+ private static class LineDrawable extends Drawable {
+ @Override
+ public void draw(Canvas canvas) {
+ drawLine(canvas, getBounds().width(), getBounds().height());
+ }
+
+ @Override
+ public void setAlpha(int alpha) {
+ // NO-OP
+ }
+
+ @Override
+ public void setColorFilter(ColorFilter colorFilter) {
+ // NO-OP
+ }
+
+ @Override
+ public int getOpacity() {
+ return 0;
+ }
+ }
+
+ @Override
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ }
+}
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/StretchShaderActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/StretchShaderActivity.java
index 912aee686924..3307c36d9d1a 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/StretchShaderActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/StretchShaderActivity.java
@@ -409,10 +409,6 @@ public class StretchShaderActivity extends Activity {
if (mStretchDistance > 0 && canvas instanceof RecordingCanvas) {
Rect bounds = getBounds();
((RecordingCanvas) canvas).mNode.stretch(
- 0,
- 0,
- bounds.width(),
- bounds.height(),
mOverScrollX,
mOverScrollY,
mStretchDistance,
@@ -440,7 +436,7 @@ public class StretchShaderActivity extends Activity {
}
}
- private static final String SKSL = "in shader uContentTexture;\n"
+ private static final String SKSL = "uniform shader uContentTexture;\n"
+ "uniform float uMaxStretchIntensity; // multiplier to apply to scale effect\n"
+ "uniform float uStretchAffectedDist; // Maximum percentage to stretch beyond bounds"
+ " of target\n"
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/StretchySurfaceViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/StretchySurfaceViewActivity.java
index 67b9be580ba6..acb872cd23b8 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/StretchySurfaceViewActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/StretchySurfaceViewActivity.java
@@ -99,7 +99,7 @@ public class StretchySurfaceViewActivity extends Activity implements Callback {
super.onDraw(canvas);
RenderNode node = ((RecordingCanvas) canvas).mNode;
- node.stretch(0f, 0f, getWidth(), getHeight() / 2f, 0f,
+ node.stretch(0f,
1f, 400f, 400f);
}
};
diff --git a/tests/Input/src/com/android/test/input/ViewFrameInfoTest.kt b/tests/Input/src/com/android/test/input/ViewFrameInfoTest.kt
index c01d32bf4cd2..6ef1ecdae59b 100644
--- a/tests/Input/src/com/android/test/input/ViewFrameInfoTest.kt
+++ b/tests/Input/src/com/android/test/input/ViewFrameInfoTest.kt
@@ -35,7 +35,7 @@ class ViewFrameInfoTest {
fun setUp() {
mViewFrameInfo.reset()
mViewFrameInfo.setInputEvent(139)
- mViewFrameInfo.flags = mViewFrameInfo.flags or FrameInfo.FLAG_WINDOW_LAYOUT_CHANGED
+ mViewFrameInfo.flags = mViewFrameInfo.flags or FrameInfo.FLAG_WINDOW_VISIBILITY_CHANGED
mTimeStarted = SystemClock.uptimeNanos()
mViewFrameInfo.markDrawStart()
}
@@ -43,7 +43,7 @@ class ViewFrameInfoTest {
@Test
fun testPopulateFields() {
assertThat(mViewFrameInfo.drawStart).isGreaterThan(mTimeStarted)
- assertThat(mViewFrameInfo.flags).isEqualTo(FrameInfo.FLAG_WINDOW_LAYOUT_CHANGED)
+ assertThat(mViewFrameInfo.flags).isEqualTo(FrameInfo.FLAG_WINDOW_VISIBILITY_CHANGED)
}
@Test
@@ -66,7 +66,7 @@ class ViewFrameInfoTest {
mViewFrameInfo.populateFrameInfo(frameInfo)
assertThat(frameInfo.frameInfo[FrameInfo.INPUT_EVENT_ID]).isEqualTo(139)
assertThat(frameInfo.frameInfo[FrameInfo.FLAGS]).isEqualTo(
- FrameInfo.FLAG_WINDOW_LAYOUT_CHANGED)
+ FrameInfo.FLAG_WINDOW_VISIBILITY_CHANGED)
assertThat(frameInfo.frameInfo[FrameInfo.DRAW_START]).isGreaterThan(mTimeStarted)
}
} \ No newline at end of file
diff --git a/tests/RollbackTest/MultiUserRollbackTest/src/com/android/tests/rollback/host/MultiUserRollbackTest.java b/tests/RollbackTest/MultiUserRollbackTest/src/com/android/tests/rollback/host/MultiUserRollbackTest.java
index 741745560c61..35859fe1472e 100644
--- a/tests/RollbackTest/MultiUserRollbackTest/src/com/android/tests/rollback/host/MultiUserRollbackTest.java
+++ b/tests/RollbackTest/MultiUserRollbackTest/src/com/android/tests/rollback/host/MultiUserRollbackTest.java
@@ -48,6 +48,8 @@ public class MultiUserRollbackTest extends BaseHostJUnit4Test {
public void tearDown() throws Exception {
removeSecondaryUserIfNecessary();
runPhaseForUsers("cleanUp", mOriginalUserId);
+ uninstallPackage("com.android.cts.install.lib.testapp.A");
+ uninstallPackage("com.android.cts.install.lib.testapp.B");
}
@Before
diff --git a/tests/TouchLatency/gradle/wrapper/gradle-wrapper.jar b/tests/TouchLatency/gradle/wrapper/gradle-wrapper.jar
index 8c0fb64a8698..758de960ec79 100644
--- a/tests/TouchLatency/gradle/wrapper/gradle-wrapper.jar
+++ b/tests/TouchLatency/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/tests/TouchLatency/gradle/wrapper/gradle-wrapper.properties b/tests/TouchLatency/gradle/wrapper/gradle-wrapper.properties
index 111992a460fa..2d80b69a7665 100644
--- a/tests/TouchLatency/gradle/wrapper/gradle-wrapper.properties
+++ b/tests/TouchLatency/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Tue Nov 27 13:37:59 PST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
diff --git a/tests/TouchLatency/gradlew b/tests/TouchLatency/gradlew
index 91a7e269e19d..cccdd3d517fc 100755
--- a/tests/TouchLatency/gradlew
+++ b/tests/TouchLatency/gradlew
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
##############################################################################
##
@@ -6,20 +6,38 @@
##
##############################################################################
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
-warn ( ) {
+warn () {
echo "$*"
}
-die ( ) {
+die () {
echo
echo "$*"
echo
@@ -30,6 +48,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
+nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
@@ -40,31 +59,11 @@ case "`uname`" in
MINGW* )
msys=true
;;
+ NONSTOP* )
+ nonstop=true
+ ;;
esac
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
-if $cygwin ; then
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >&-
-APP_HOME="`pwd -P`"
-cd "$SAVED" >&-
-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -90,7 +89,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -114,6 +113,7 @@ fi
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
@@ -154,11 +154,19 @@ if $cygwin ; then
esac
fi
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+exec "$JAVACMD" "$@"
diff --git a/tests/TouchLatency/gradlew.bat b/tests/TouchLatency/gradlew.bat
index aec99730b4e8..e95643d6a2ca 100644
--- a/tests/TouchLatency/gradlew.bat
+++ b/tests/TouchLatency/gradlew.bat
@@ -8,14 +8,14 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -46,10 +46,9 @@ echo location of your Java installation.
goto fail
:init
-@rem Get command-line arguments, handling Windowz variants
+@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@@ -60,11 +59,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
diff --git a/tests/UiBench/res/layout/recycler_view.xml b/tests/UiBench/res/layout/recycler_view.xml
index 53eab68f7866..c8a85de81710 100644
--- a/tests/UiBench/res/layout/recycler_view.xml
+++ b/tests/UiBench/res/layout/recycler_view.xml
@@ -17,5 +17,6 @@
<androidx.recyclerview.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recyclerView"
+ android:overScrollMode="never"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
diff --git a/tests/UpdatableSystemFontTest/Android.bp b/tests/UpdatableSystemFontTest/Android.bp
index 8b0ae5c37bae..ea5a43104bba 100644
--- a/tests/UpdatableSystemFontTest/Android.bp
+++ b/tests/UpdatableSystemFontTest/Android.bp
@@ -21,16 +21,15 @@ package {
default_applicable_licenses: ["frameworks_base_license"],
}
-java_test_host {
+android_test {
name: "UpdatableSystemFontTest",
srcs: ["src/**/*.java"],
- libs: [
- "tradefed",
- "compatibility-tradefed",
- "compatibility-host-util",
- ],
+ libs: ["android.test.runner"],
static_libs: [
- "frameworks-base-hostutils",
+ "androidx.test.ext.junit",
+ "compatibility-device-util-axt",
+ "platform-test-annotations",
+ "truth-prebuilt",
],
test_suites: [
"general-tests",
@@ -47,4 +46,5 @@ java_test_host {
":UpdatableSystemFontTestNotoColorEmojiVPlus2Ttf",
":UpdatableSystemFontTestNotoColorEmojiVPlus2TtfFsvSig",
],
+ sdk_version: "test_current",
}
diff --git a/tests/UpdatableSystemFontTest/AndroidManifest.xml b/tests/UpdatableSystemFontTest/AndroidManifest.xml
new file mode 100644
index 000000000000..531ee981a92c
--- /dev/null
+++ b/tests/UpdatableSystemFontTest/AndroidManifest.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2021 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.updatablesystemfont">
+
+ <application android:label="UpdatableSystemFontTest">
+ <uses-library android:name="android.test.runner"/>
+ </application>
+
+ <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
+ android:label="UpdatableSystemFontTest"
+ android:targetPackage="com.android.updatablesystemfont">
+ </instrumentation>
+
+</manifest>
diff --git a/tests/UpdatableSystemFontTest/AndroidTest.xml b/tests/UpdatableSystemFontTest/AndroidTest.xml
index 4f116698ba72..4f6487e7e953 100644
--- a/tests/UpdatableSystemFontTest/AndroidTest.xml
+++ b/tests/UpdatableSystemFontTest/AndroidTest.xml
@@ -21,6 +21,7 @@
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
+ <option name="test-file-name" value="UpdatableSystemFontTest.apk" />
<option name="test-file-name" value="EmojiRenderingTestApp.apk" />
</target_preparer>
@@ -37,7 +38,7 @@
<option name="push" value="UpdatableSystemFontTestNotoColorEmojiVPlus2.ttf.fsv_sig->/data/local/tmp/UpdatableSystemFontTestNotoColorEmojiVPlus2.ttf.fsv_sig" />
</target_preparer>
- <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
- <option name="jar" value="UpdatableSystemFontTest.jar" />
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest">
+ <option name="package" value="com.android.updatablesystemfont" />
</test>
</configuration>
diff --git a/tests/UpdatableSystemFontTest/src/com/android/updatablesystemfont/UpdatableSystemFontTest.java b/tests/UpdatableSystemFontTest/src/com/android/updatablesystemfont/UpdatableSystemFontTest.java
index 74f6bca4d7a0..898b8d4cbdc1 100644
--- a/tests/UpdatableSystemFontTest/src/com/android/updatablesystemfont/UpdatableSystemFontTest.java
+++ b/tests/UpdatableSystemFontTest/src/com/android/updatablesystemfont/UpdatableSystemFontTest.java
@@ -16,44 +16,59 @@
package com.android.updatablesystemfont;
+import static android.os.ParcelFileDescriptor.MODE_READ_ONLY;
+
import static com.google.common.truth.Truth.assertThat;
-import static com.google.common.truth.Truth.assertWithMessage;
+
+import static org.junit.Assume.assumeTrue;
import static java.util.concurrent.TimeUnit.SECONDS;
+import android.app.UiAutomation;
+import android.content.Context;
+import android.graphics.fonts.FontFamilyUpdateRequest;
+import android.graphics.fonts.FontFileUpdateRequest;
+import android.graphics.fonts.FontManager;
+import android.os.ParcelFileDescriptor;
import android.platform.test.annotations.RootPermissionTest;
+import android.security.FileIntegrityManager;
+import android.text.FontConfig;
+import android.util.Log;
+import android.util.Pair;
-import com.android.fsverity.AddFsVerityCertRule;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
-import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
-import com.android.tradefed.util.CommandResult;
-import com.android.tradefed.util.CommandStatus;
+import androidx.annotation.Nullable;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.platform.app.InstrumentationRegistry;
+
+import com.android.compatibility.common.util.StreamUtil;
+import com.android.compatibility.common.util.SystemUtil;
import org.junit.After;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
/**
- * Tests if fonts can be updated by 'cmd font'.
+ * Tests if fonts can be updated by {@link FontManager} API.
*/
@RootPermissionTest
-@RunWith(DeviceJUnit4ClassRunner.class)
-public class UpdatableSystemFontTest extends BaseHostJUnit4Test {
+@RunWith(AndroidJUnit4.class)
+public class UpdatableSystemFontTest {
+ private static final String TAG = "UpdatableSystemFontTest";
private static final String SYSTEM_FONTS_DIR = "/system/fonts/";
private static final String DATA_FONTS_DIR = "/data/fonts/files/";
-
private static final String CERT_PATH = "/data/local/tmp/UpdatableSystemFontTestCert.der";
-
- private static final Pattern PATTERN_FONT = Pattern.compile("path = ([^, \n]*)");
- private static final String NOTO_COLOR_EMOJI_TTF = "NotoColorEmoji.ttf";
+ private static final String NOTO_COLOR_EMOJI_POSTSCRIPT_NAME = "NotoColorEmoji";
private static final String ORIGINAL_NOTO_COLOR_EMOJI_TTF =
"/data/local/tmp/NotoColorEmoji.ttf";
@@ -80,64 +95,76 @@ public class UpdatableSystemFontTest extends BaseHostJUnit4Test {
EMOJI_RENDERING_TEST_APP_ID + "/.EmojiRenderingTestActivity";
private static final long ACTIVITY_TIMEOUT_MILLIS = SECONDS.toMillis(10);
- private interface ThrowingSupplier<T> {
- T get() throws Exception;
- }
-
- @Rule
- public final AddFsVerityCertRule mAddFsverityCertRule =
- new AddFsVerityCertRule(this, CERT_PATH);
+ private String mKeyId;
+ private FontManager mFontManager;
@Before
public void setUp() throws Exception {
- expectRemoteCommandToSucceed("cmd font clear");
+ Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ // Run tests only if updatable system font is enabled.
+ FileIntegrityManager fim = context.getSystemService(FileIntegrityManager.class);
+ assumeTrue(fim != null);
+ assumeTrue(fim.isApkVeritySupported());
+ mKeyId = insertCert(CERT_PATH);
+ mFontManager = context.getSystemService(FontManager.class);
+ expectCommandToSucceed("cmd font clear");
}
@After
public void tearDown() throws Exception {
- expectRemoteCommandToSucceed("cmd font clear");
+ // Ignore errors because this may fail if updatable system font is not enabled.
+ runShellCommand("cmd font clear", null);
+ if (mKeyId != null) {
+ expectCommandToSucceed("mini-keyctl unlink " + mKeyId + " .fs-verity");
+ }
}
@Test
public void updateFont() throws Exception {
- expectRemoteCommandToSucceed(String.format("cmd font update %s %s",
- TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF, TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF_FSV_SIG));
- String fontPath = getFontPath(NOTO_COLOR_EMOJI_TTF);
+ assertThat(updateFontFile(
+ TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF, TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF_FSV_SIG))
+ .isEqualTo(FontManager.RESULT_SUCCESS);
+ String fontPath = getFontPath(NOTO_COLOR_EMOJI_POSTSCRIPT_NAME);
assertThat(fontPath).startsWith(DATA_FONTS_DIR);
// The updated font should be readable and unmodifiable.
- expectRemoteCommandToSucceed("cat " + fontPath + " > /dev/null");
- expectRemoteCommandToFail("echo -n '' >> " + fontPath);
+ expectCommandToSucceed("dd status=none if=" + fontPath + " of=/dev/null");
+ expectCommandToFail("dd status=none if=" + CERT_PATH + " of=" + fontPath);
}
@Test
public void updateFont_twice() throws Exception {
- expectRemoteCommandToSucceed(String.format("cmd font update %s %s",
- TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF, TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF_FSV_SIG));
- String fontPath = getFontPath(NOTO_COLOR_EMOJI_TTF);
- expectRemoteCommandToSucceed(String.format("cmd font update %s %s",
- TEST_NOTO_COLOR_EMOJI_VPLUS2_TTF, TEST_NOTO_COLOR_EMOJI_VPLUS2_TTF_FSV_SIG));
- String fontPath2 = getFontPath(NOTO_COLOR_EMOJI_TTF);
+ assertThat(updateFontFile(
+ TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF, TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF_FSV_SIG))
+ .isEqualTo(FontManager.RESULT_SUCCESS);
+ String fontPath = getFontPath(NOTO_COLOR_EMOJI_POSTSCRIPT_NAME);
+ assertThat(updateFontFile(
+ TEST_NOTO_COLOR_EMOJI_VPLUS2_TTF, TEST_NOTO_COLOR_EMOJI_VPLUS2_TTF_FSV_SIG))
+ .isEqualTo(FontManager.RESULT_SUCCESS);
+ String fontPath2 = getFontPath(NOTO_COLOR_EMOJI_POSTSCRIPT_NAME);
assertThat(fontPath2).startsWith(DATA_FONTS_DIR);
assertThat(fontPath2).isNotEqualTo(fontPath);
// The new file should be readable.
- expectRemoteCommandToSucceed("cat " + fontPath2 + " > /dev/null");
+ expectCommandToSucceed("dd status=none if=" + fontPath2 + " of=/dev/null");
// The old file should be still readable.
- expectRemoteCommandToSucceed("cat " + fontPath + " > /dev/null");
+ expectCommandToSucceed("dd status=none if=" + fontPath + " of=/dev/null");
}
@Test
public void updateFont_allowSameVersion() throws Exception {
// Update original font to the same version
- expectRemoteCommandToSucceed(String.format("cmd font update %s %s",
- ORIGINAL_NOTO_COLOR_EMOJI_TTF, ORIGINAL_NOTO_COLOR_EMOJI_TTF_FSV_SIG));
- String fontPath = getFontPath(NOTO_COLOR_EMOJI_TTF);
- expectRemoteCommandToSucceed(String.format("cmd font update %s %s",
- TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF, TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF_FSV_SIG));
- String fontPath2 = getFontPath(NOTO_COLOR_EMOJI_TTF);
+ assertThat(updateFontFile(
+ ORIGINAL_NOTO_COLOR_EMOJI_TTF, ORIGINAL_NOTO_COLOR_EMOJI_TTF_FSV_SIG))
+ .isEqualTo(FontManager.RESULT_SUCCESS);
+ String fontPath = getFontPath(NOTO_COLOR_EMOJI_POSTSCRIPT_NAME);
+ assertThat(updateFontFile(
+ TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF, TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF_FSV_SIG))
+ .isEqualTo(FontManager.RESULT_SUCCESS);
+ String fontPath2 = getFontPath(NOTO_COLOR_EMOJI_POSTSCRIPT_NAME);
// Update updated font to the same version
- expectRemoteCommandToSucceed(String.format("cmd font update %s %s",
- TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF, TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF_FSV_SIG));
- String fontPath3 = getFontPath(NOTO_COLOR_EMOJI_TTF);
+ assertThat(updateFontFile(
+ TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF, TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF_FSV_SIG))
+ .isEqualTo(FontManager.RESULT_SUCCESS);
+ String fontPath3 = getFontPath(NOTO_COLOR_EMOJI_POSTSCRIPT_NAME);
assertThat(fontPath).startsWith(DATA_FONTS_DIR);
assertThat(fontPath2).isNotEqualTo(fontPath);
assertThat(fontPath2).startsWith(DATA_FONTS_DIR);
@@ -147,134 +174,171 @@ public class UpdatableSystemFontTest extends BaseHostJUnit4Test {
@Test
public void updateFont_invalidCert() throws Exception {
- expectRemoteCommandToFail(String.format("cmd font update %s %s",
- TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF, TEST_NOTO_COLOR_EMOJI_VPLUS2_TTF_FSV_SIG));
+ assertThat(updateFontFile(
+ TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF, TEST_NOTO_COLOR_EMOJI_VPLUS2_TTF_FSV_SIG))
+ .isEqualTo(FontManager.RESULT_ERROR_VERIFICATION_FAILURE);
}
@Test
public void updateFont_downgradeFromSystem() throws Exception {
- expectRemoteCommandToFail(String.format("cmd font update %s %s",
- TEST_NOTO_COLOR_EMOJI_V0_TTF, TEST_NOTO_COLOR_EMOJI_V0_TTF_FSV_SIG));
+ assertThat(updateFontFile(
+ TEST_NOTO_COLOR_EMOJI_V0_TTF, TEST_NOTO_COLOR_EMOJI_V0_TTF_FSV_SIG))
+ .isEqualTo(FontManager.RESULT_ERROR_DOWNGRADING);
}
@Test
public void updateFont_downgradeFromData() throws Exception {
- expectRemoteCommandToSucceed(String.format("cmd font update %s %s",
- TEST_NOTO_COLOR_EMOJI_VPLUS2_TTF, TEST_NOTO_COLOR_EMOJI_VPLUS2_TTF_FSV_SIG));
- expectRemoteCommandToFail(String.format("cmd font update %s %s",
- TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF, TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF_FSV_SIG));
+ assertThat(updateFontFile(
+ TEST_NOTO_COLOR_EMOJI_VPLUS2_TTF, TEST_NOTO_COLOR_EMOJI_VPLUS2_TTF_FSV_SIG))
+ .isEqualTo(FontManager.RESULT_SUCCESS);
+ assertThat(updateFontFile(
+ TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF, TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF_FSV_SIG))
+ .isEqualTo(FontManager.RESULT_ERROR_DOWNGRADING);
}
@Test
public void launchApp() throws Exception {
- String fontPath = getFontPath(NOTO_COLOR_EMOJI_TTF);
+ String fontPath = getFontPath(NOTO_COLOR_EMOJI_POSTSCRIPT_NAME);
assertThat(fontPath).startsWith(SYSTEM_FONTS_DIR);
startActivity(EMOJI_RENDERING_TEST_APP_ID, EMOJI_RENDERING_TEST_ACTIVITY);
- waitUntil(ACTIVITY_TIMEOUT_MILLIS, () ->
- isFileOpenedBy(fontPath, EMOJI_RENDERING_TEST_APP_ID));
+ SystemUtil.eventually(
+ () -> assertThat(isFileOpenedBy(fontPath, EMOJI_RENDERING_TEST_APP_ID)).isTrue(),
+ ACTIVITY_TIMEOUT_MILLIS);
}
@Test
public void launchApp_afterUpdateFont() throws Exception {
- String originalFontPath = getFontPath(NOTO_COLOR_EMOJI_TTF);
+ String originalFontPath = getFontPath(NOTO_COLOR_EMOJI_POSTSCRIPT_NAME);
assertThat(originalFontPath).startsWith(SYSTEM_FONTS_DIR);
- expectRemoteCommandToSucceed(String.format("cmd font update %s %s",
- TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF, TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF_FSV_SIG));
- String updatedFontPath = getFontPath(NOTO_COLOR_EMOJI_TTF);
+ assertThat(updateFontFile(
+ TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF, TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF_FSV_SIG))
+ .isEqualTo(FontManager.RESULT_SUCCESS);
+ String updatedFontPath = getFontPath(NOTO_COLOR_EMOJI_POSTSCRIPT_NAME);
assertThat(updatedFontPath).startsWith(DATA_FONTS_DIR);
startActivity(EMOJI_RENDERING_TEST_APP_ID, EMOJI_RENDERING_TEST_ACTIVITY);
// The original font should NOT be opened by the app.
- waitUntil(ACTIVITY_TIMEOUT_MILLIS, () ->
- isFileOpenedBy(updatedFontPath, EMOJI_RENDERING_TEST_APP_ID)
- && !isFileOpenedBy(originalFontPath, EMOJI_RENDERING_TEST_APP_ID));
+ SystemUtil.eventually(() -> {
+ assertThat(isFileOpenedBy(updatedFontPath, EMOJI_RENDERING_TEST_APP_ID)).isTrue();
+ assertThat(isFileOpenedBy(originalFontPath, EMOJI_RENDERING_TEST_APP_ID)).isFalse();
+ }, ACTIVITY_TIMEOUT_MILLIS);
}
@Test
public void reboot() throws Exception {
- expectRemoteCommandToSucceed(String.format("cmd font update %s %s",
+ expectCommandToSucceed(String.format("cmd font update %s %s",
TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF, TEST_NOTO_COLOR_EMOJI_VPLUS1_TTF_FSV_SIG));
- String fontPath = getFontPath(NOTO_COLOR_EMOJI_TTF);
+ String fontPath = getFontPath(NOTO_COLOR_EMOJI_POSTSCRIPT_NAME);
assertThat(fontPath).startsWith(DATA_FONTS_DIR);
// Emulate reboot by 'cmd font restart'.
- expectRemoteCommandToSucceed("cmd font restart");
- String fontPathAfterReboot = getFontPath(NOTO_COLOR_EMOJI_TTF);
+ expectCommandToSucceed("cmd font restart");
+ String fontPathAfterReboot = getFontPath(NOTO_COLOR_EMOJI_POSTSCRIPT_NAME);
assertThat(fontPathAfterReboot).isEqualTo(fontPath);
}
- private String getFontPath(String fontFileName) throws Exception {
- // TODO: add a dedicated command for testing.
- String lines = expectRemoteCommandToSucceed("cmd font dump");
- for (String line : lines.split("\n")) {
- Matcher m = PATTERN_FONT.matcher(line);
- if (m.find() && m.group(1).endsWith(fontFileName)) {
- return m.group(1);
- }
+ private static String insertCert(String certPath) throws Exception {
+ Pair<String, String> result;
+ try (InputStream is = new FileInputStream(certPath)) {
+ result = runShellCommand("mini-keyctl padd asymmetric fsv_test .fs-verity", is);
+ }
+ // Assert that there are no errors.
+ assertThat(result.second).isEmpty();
+ String keyId = result.first.trim();
+ assertThat(keyId).matches("^\\d+$");
+ return keyId;
+ }
+
+ private int updateFontFile(String fontPath, String signaturePath) throws IOException {
+ byte[] signature = Files.readAllBytes(Paths.get(signaturePath));
+ try (ParcelFileDescriptor fd =
+ ParcelFileDescriptor.open(new File(fontPath), MODE_READ_ONLY)) {
+ return SystemUtil.runWithShellPermissionIdentity(() -> {
+ FontConfig fontConfig = mFontManager.getFontConfig();
+ return mFontManager.updateFontFamily(
+ new FontFamilyUpdateRequest.Builder()
+ .addFontFileUpdateRequest(new FontFileUpdateRequest(fd, signature))
+ .build(),
+ fontConfig.getConfigVersion());
+ });
}
- CLog.e("Font not found: " + fontFileName);
- return null;
}
- private void startActivity(String appId, String activityId) throws Exception {
- // Make sure that the app is installed and enabled.
- waitUntil(ACTIVITY_TIMEOUT_MILLIS, () -> {
- String packageInfo = expectRemoteCommandToSucceed(
- "pm list packages -e " + EMOJI_RENDERING_TEST_APP_ID);
- return !packageInfo.isEmpty();
+ private String getFontPath(String psName) {
+ return SystemUtil.runWithShellPermissionIdentity(() -> {
+ FontConfig fontConfig = mFontManager.getFontConfig();
+ for (FontConfig.FontFamily family : fontConfig.getFontFamilies()) {
+ for (FontConfig.Font font : family.getFontList()) {
+ if (psName.equals(font.getPostScriptName())) {
+ return font.getFile().getAbsolutePath();
+ }
+ }
+ }
+ throw new AssertionError("Font not found: " + psName);
});
- expectRemoteCommandToSucceed("am force-stop " + EMOJI_RENDERING_TEST_APP_ID);
- expectRemoteCommandToSucceed("am start-activity -n " + EMOJI_RENDERING_TEST_ACTIVITY);
}
- private String expectRemoteCommandToSucceed(String cmd) throws Exception {
- CommandResult result = getDevice().executeShellV2Command(cmd);
- assertWithMessage("`" + cmd + "` failed: " + result.getStderr())
- .that(result.getStatus())
- .isEqualTo(CommandStatus.SUCCESS);
- return result.getStdout();
+ private static void startActivity(String appId, String activityId) throws Exception {
+ expectCommandToSucceed("am force-stop " + appId);
+ expectCommandToSucceed("am start-activity -n " + activityId);
+ }
+
+ private static String expectCommandToSucceed(String cmd) throws IOException {
+ Pair<String, String> result = runShellCommand(cmd, null);
+ // UiAutomation.runShellCommand() does not return exit code.
+ // Assume that the command fails if stderr is not empty.
+ assertThat(result.second.trim()).isEmpty();
+ return result.first;
}
- private void expectRemoteCommandToFail(String cmd) throws Exception {
- CommandResult result = getDevice().executeShellV2Command(cmd);
- assertWithMessage("Unexpected success from `" + cmd + "`: " + result.getStderr())
- .that(result.getStatus())
- .isNotEqualTo(CommandStatus.SUCCESS);
+ private static void expectCommandToFail(String cmd) throws IOException {
+ Pair<String, String> result = runShellCommand(cmd, null);
+ // UiAutomation.runShellCommand() does not return exit code.
+ // Assume that the command fails if stderr is not empty.
+ assertThat(result.second.trim()).isNotEmpty();
}
- private void waitUntil(long timeoutMillis, ThrowingSupplier<Boolean> func) {
- long untilMillis = System.currentTimeMillis() + timeoutMillis;
- do {
- try {
- if (func.get()) return;
- Thread.sleep(100);
- } catch (InterruptedException e) {
- throw new AssertionError("Interrupted", e);
- } catch (Exception e) {
- throw new AssertionError("Unexpected exception", e);
+ /** Runs a command and returns (stdout, stderr). */
+ private static Pair<String, String> runShellCommand(String cmd, @Nullable InputStream input)
+ throws IOException {
+ Log.i(TAG, "runShellCommand: " + cmd);
+ UiAutomation automation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
+ ParcelFileDescriptor[] rwe = automation.executeShellCommandRwe(cmd);
+ // executeShellCommandRwe returns [stdout, stdin, stderr].
+ try (ParcelFileDescriptor outFd = rwe[0];
+ ParcelFileDescriptor inFd = rwe[1];
+ ParcelFileDescriptor errFd = rwe[2]) {
+ if (input != null) {
+ try (OutputStream os = new FileOutputStream(inFd.getFileDescriptor())) {
+ StreamUtil.copyStreams(input, os);
+ }
}
- } while (System.currentTimeMillis() < untilMillis);
- throw new AssertionError("Timed out");
+ // We have to close stdin before reading stdout and stderr.
+ // It's safe to close ParcelFileDescriptor multiple times.
+ inFd.close();
+ String stdout;
+ try (InputStream is = new FileInputStream(outFd.getFileDescriptor())) {
+ stdout = StreamUtil.readInputStream(is);
+ }
+ Log.i(TAG, "stdout = " + stdout);
+ String stderr;
+ try (InputStream is = new FileInputStream(errFd.getFileDescriptor())) {
+ stderr = StreamUtil.readInputStream(is);
+ }
+ Log.i(TAG, "stderr = " + stderr);
+ return new Pair<>(stdout, stderr);
+ }
}
- private boolean isFileOpenedBy(String path, String appId) throws DeviceNotAvailableException {
+ private static boolean isFileOpenedBy(String path, String appId) throws Exception {
String pid = pidOf(appId);
if (pid.isEmpty()) {
return false;
}
- CommandResult result = getDevice().executeShellV2Command(
- String.format("lsof -t -p %s '%s'", pid, path));
- if (result.getStatus() != CommandStatus.SUCCESS) {
- return false;
- }
- // The file is open if the output of lsof is non-empty.
- return !result.getStdout().trim().isEmpty();
+ String cmd = String.format("lsof -t -p %s %s", pid, path);
+ return !expectCommandToSucceed(cmd).trim().isEmpty();
}
- private String pidOf(String appId) throws DeviceNotAvailableException {
- CommandResult result = getDevice().executeShellV2Command("pidof " + appId);
- if (result.getStatus() != CommandStatus.SUCCESS) {
- return "";
- }
- return result.getStdout().trim();
+ private static String pidOf(String appId) throws Exception {
+ return expectCommandToSucceed("pidof " + appId).trim();
}
}
diff --git a/tests/net/common/java/android/net/NetworkCapabilitiesTest.java b/tests/net/common/java/android/net/NetworkCapabilitiesTest.java
index 9b7458397cf5..1c8a1bfeb417 100644
--- a/tests/net/common/java/android/net/NetworkCapabilitiesTest.java
+++ b/tests/net/common/java/android/net/NetworkCapabilitiesTest.java
@@ -391,9 +391,11 @@ public class NetworkCapabilitiesTest {
@Test
public void testOemPaid() {
NetworkCapabilities nc = new NetworkCapabilities();
- // By default OEM_PAID is neither in the unwanted or required lists and the network is not
+ // By default OEM_PAID is neither in the required or forbidden lists and the network is not
// restricted.
- assertFalse(nc.hasUnwantedCapability(NET_CAPABILITY_OEM_PAID));
+ if (isAtLeastS()) {
+ assertFalse(nc.hasForbiddenCapability(NET_CAPABILITY_OEM_PAID));
+ }
assertFalse(nc.hasCapability(NET_CAPABILITY_OEM_PAID));
nc.maybeMarkCapabilitiesRestricted();
assertTrue(nc.hasCapability(NET_CAPABILITY_NOT_RESTRICTED));
@@ -418,9 +420,9 @@ public class NetworkCapabilitiesTest {
@Test @IgnoreUpTo(Build.VERSION_CODES.R)
public void testOemPrivate() {
NetworkCapabilities nc = new NetworkCapabilities();
- // By default OEM_PRIVATE is neither in the unwanted or required lists and the network is
+ // By default OEM_PRIVATE is neither in the required or forbidden lists and the network is
// not restricted.
- assertFalse(nc.hasUnwantedCapability(NET_CAPABILITY_OEM_PRIVATE));
+ assertFalse(nc.hasForbiddenCapability(NET_CAPABILITY_OEM_PRIVATE));
assertFalse(nc.hasCapability(NET_CAPABILITY_OEM_PRIVATE));
nc.maybeMarkCapabilitiesRestricted();
assertTrue(nc.hasCapability(NET_CAPABILITY_NOT_RESTRICTED));
@@ -442,8 +444,8 @@ public class NetworkCapabilitiesTest {
assertFalse(nr.satisfiedByNetworkCapabilities(new NetworkCapabilities()));
}
- @Test
- public void testUnwantedCapabilities() {
+ @Test @IgnoreUpTo(Build.VERSION_CODES.R)
+ public void testForbiddenCapabilities() {
NetworkCapabilities network = new NetworkCapabilities();
NetworkCapabilities request = new NetworkCapabilities();
@@ -451,19 +453,19 @@ public class NetworkCapabilitiesTest {
request.satisfiedByNetworkCapabilities(network));
// Requesting absence of capabilities that network doesn't have. Request should satisfy.
- request.addUnwantedCapability(NET_CAPABILITY_WIFI_P2P);
- request.addUnwantedCapability(NET_CAPABILITY_NOT_METERED);
+ request.addForbiddenCapability(NET_CAPABILITY_WIFI_P2P);
+ request.addForbiddenCapability(NET_CAPABILITY_NOT_METERED);
assertTrue(request.satisfiedByNetworkCapabilities(network));
- assertArrayEquals(new int[] {NET_CAPABILITY_WIFI_P2P,
+ assertArrayEquals(new int[]{NET_CAPABILITY_WIFI_P2P,
NET_CAPABILITY_NOT_METERED},
- request.getUnwantedCapabilities());
+ request.getForbiddenCapabilities());
// This is a default capability, just want to make sure its there because we use it below.
assertTrue(network.hasCapability(NET_CAPABILITY_NOT_RESTRICTED));
- // Verify that adding unwanted capability will effectively remove it from capability list.
- request.addUnwantedCapability(NET_CAPABILITY_NOT_RESTRICTED);
- assertTrue(request.hasUnwantedCapability(NET_CAPABILITY_NOT_RESTRICTED));
+ // Verify that adding forbidden capability will effectively remove it from capability list.
+ request.addForbiddenCapability(NET_CAPABILITY_NOT_RESTRICTED);
+ assertTrue(request.hasForbiddenCapability(NET_CAPABILITY_NOT_RESTRICTED));
assertFalse(request.hasCapability(NET_CAPABILITY_NOT_RESTRICTED));
// Now this request won't be satisfied because network contains NOT_RESTRICTED.
@@ -471,10 +473,10 @@ public class NetworkCapabilitiesTest {
network.removeCapability(NET_CAPABILITY_NOT_RESTRICTED);
assertTrue(request.satisfiedByNetworkCapabilities(network));
- // Verify that adding capability will effectively remove it from unwanted list
+ // Verify that adding capability will effectively remove it from forbidden list
request.addCapability(NET_CAPABILITY_NOT_RESTRICTED);
assertTrue(request.hasCapability(NET_CAPABILITY_NOT_RESTRICTED));
- assertFalse(request.hasUnwantedCapability(NET_CAPABILITY_NOT_RESTRICTED));
+ assertFalse(request.hasForbiddenCapability(NET_CAPABILITY_NOT_RESTRICTED));
assertFalse(request.satisfiedByNetworkCapabilities(network));
network.addCapability(NET_CAPABILITY_NOT_RESTRICTED);
@@ -513,24 +515,20 @@ public class NetworkCapabilitiesTest {
assertTrue(nc1.equalsNetCapabilities(nc2));
assertEquals(nc1, nc2);
- nc1.addUnwantedCapability(NET_CAPABILITY_INTERNET);
- assertFalse(nc1.equalsNetCapabilities(nc2));
- nc2.addUnwantedCapability(NET_CAPABILITY_INTERNET);
- assertTrue(nc1.equalsNetCapabilities(nc2));
if (isAtLeastS()) {
- // Remove a required capability doesn't affect unwanted capabilities.
- // This is a behaviour change from S.
- nc1.removeCapability(NET_CAPABILITY_INTERNET);
- assertTrue(nc1.equalsNetCapabilities(nc2));
-
- nc1.removeUnwantedCapability(NET_CAPABILITY_INTERNET);
+ nc1.addForbiddenCapability(NET_CAPABILITY_INTERNET);
assertFalse(nc1.equalsNetCapabilities(nc2));
- nc2.removeUnwantedCapability(NET_CAPABILITY_INTERNET);
+ nc2.addForbiddenCapability(NET_CAPABILITY_INTERNET);
assertTrue(nc1.equalsNetCapabilities(nc2));
- } else {
+
+ // Remove a required capability doesn't affect forbidden capabilities.
+ // This is a behaviour change from R to S.
nc1.removeCapability(NET_CAPABILITY_INTERNET);
+ assertTrue(nc1.equalsNetCapabilities(nc2));
+
+ nc1.removeForbiddenCapability(NET_CAPABILITY_INTERNET);
assertFalse(nc1.equalsNetCapabilities(nc2));
- nc2.removeCapability(NET_CAPABILITY_INTERNET);
+ nc2.removeForbiddenCapability(NET_CAPABILITY_INTERNET);
assertTrue(nc1.equalsNetCapabilities(nc2));
}
}
@@ -582,31 +580,25 @@ public class NetworkCapabilitiesTest {
NetworkCapabilities nc1 = new NetworkCapabilities();
NetworkCapabilities nc2 = new NetworkCapabilities();
- nc1.addUnwantedCapability(NET_CAPABILITY_CAPTIVE_PORTAL);
+ if (isAtLeastS()) {
+ nc1.addForbiddenCapability(NET_CAPABILITY_CAPTIVE_PORTAL);
+ }
nc1.addCapability(NET_CAPABILITY_NOT_ROAMING);
assertNotEquals(nc1, nc2);
nc2.combineCapabilities(nc1);
assertEquals(nc1, nc2);
assertTrue(nc2.hasCapability(NET_CAPABILITY_NOT_ROAMING));
- assertTrue(nc2.hasUnwantedCapability(NET_CAPABILITY_CAPTIVE_PORTAL));
-
- // This will effectively move NOT_ROAMING capability from required to unwanted for nc1.
- nc1.addUnwantedCapability(NET_CAPABILITY_NOT_ROAMING);
+ if (isAtLeastS()) {
+ assertTrue(nc2.hasForbiddenCapability(NET_CAPABILITY_CAPTIVE_PORTAL));
+ }
if (isAtLeastS()) {
- // From S, it is not allowed to have the same capability in both wanted and
- // unwanted list.
+ // This will effectively move NOT_ROAMING capability from required to forbidden for nc1.
+ nc1.addForbiddenCapability(NET_CAPABILITY_NOT_ROAMING);
+ // It is not allowed to have the same capability in both wanted and forbidden list.
assertThrows(IllegalArgumentException.class, () -> nc2.combineCapabilities(nc1));
- // Remove unwanted capability to continue other tests.
- nc1.removeUnwantedCapability(NET_CAPABILITY_NOT_ROAMING);
- } else {
- nc2.combineCapabilities(nc1);
- // We will get this capability in both requested and unwanted lists thus this request
- // will never be satisfied.
- assertTrue(nc2.hasCapability(NET_CAPABILITY_NOT_ROAMING));
- assertTrue(nc2.hasUnwantedCapability(NET_CAPABILITY_NOT_ROAMING));
- // For R or below, remove unwanted capability via removeCapability.
- nc1.removeCapability(NET_CAPABILITY_NOT_ROAMING);
+ // Remove forbidden capability to continue other tests.
+ nc1.removeForbiddenCapability(NET_CAPABILITY_NOT_ROAMING);
}
nc1.setSSID(TEST_SSID);
@@ -684,14 +676,11 @@ public class NetworkCapabilitiesTest {
public void testSetCapabilities() {
final int[] REQUIRED_CAPABILITIES = new int[] {
NET_CAPABILITY_INTERNET, NET_CAPABILITY_NOT_VPN };
- final int[] UNWANTED_CAPABILITIES = new int[] {
- NET_CAPABILITY_NOT_RESTRICTED, NET_CAPABILITY_NOT_METERED
- };
NetworkCapabilities nc1 = new NetworkCapabilities();
NetworkCapabilities nc2 = new NetworkCapabilities();
- nc1.setCapabilities(REQUIRED_CAPABILITIES, UNWANTED_CAPABILITIES);
+ nc1.setCapabilities(REQUIRED_CAPABILITIES);
assertArrayEquals(REQUIRED_CAPABILITIES, nc1.getCapabilities());
// Verify that setting and adding capabilities leads to the same object state.
@@ -699,10 +688,25 @@ public class NetworkCapabilitiesTest {
for (int cap : REQUIRED_CAPABILITIES) {
nc2.addCapability(cap);
}
- for (int cap : UNWANTED_CAPABILITIES) {
- nc2.addUnwantedCapability(cap);
- }
assertEquals(nc1, nc2);
+
+ if (isAtLeastS()) {
+ final int[] forbiddenCapabilities = new int[]{
+ NET_CAPABILITY_NOT_METERED, NET_CAPABILITY_NOT_RESTRICTED };
+
+ nc1.setCapabilities(REQUIRED_CAPABILITIES, forbiddenCapabilities);
+ assertArrayEquals(REQUIRED_CAPABILITIES, nc1.getCapabilities());
+ assertArrayEquals(forbiddenCapabilities, nc1.getForbiddenCapabilities());
+
+ nc2.clearAll();
+ for (int cap : REQUIRED_CAPABILITIES) {
+ nc2.addCapability(cap);
+ }
+ for (int cap : forbiddenCapabilities) {
+ nc2.addForbiddenCapability(cap);
+ }
+ assertEquals(nc1, nc2);
+ }
}
@Test
@@ -770,23 +774,32 @@ public class NetworkCapabilitiesTest {
NetworkCapabilities nc1 = new NetworkCapabilities();
NetworkCapabilities nc2 = new NetworkCapabilities();
- nc1.addUnwantedCapability(NET_CAPABILITY_CAPTIVE_PORTAL);
+ if (isAtLeastS()) {
+ nc1.addForbiddenCapability(NET_CAPABILITY_CAPTIVE_PORTAL);
+ }
nc1.addCapability(NET_CAPABILITY_NOT_ROAMING);
assertNotEquals(nc1, nc2);
nc2.set(nc1);
assertEquals(nc1, nc2);
assertTrue(nc2.hasCapability(NET_CAPABILITY_NOT_ROAMING));
- assertTrue(nc2.hasUnwantedCapability(NET_CAPABILITY_CAPTIVE_PORTAL));
+ if (isAtLeastS()) {
+ assertTrue(nc2.hasForbiddenCapability(NET_CAPABILITY_CAPTIVE_PORTAL));
+ }
- // This will effectively move NOT_ROAMING capability from required to unwanted for nc1.
- nc1.addUnwantedCapability(NET_CAPABILITY_NOT_ROAMING);
+ if (isAtLeastS()) {
+ // This will effectively move NOT_ROAMING capability from required to forbidden for nc1.
+ nc1.addForbiddenCapability(NET_CAPABILITY_NOT_ROAMING);
+ }
nc1.setSSID(TEST_SSID);
nc2.set(nc1);
assertEquals(nc1, nc2);
- // Contrary to combineCapabilities, set() will have removed the NOT_ROAMING capability
- // from nc2.
- assertFalse(nc2.hasCapability(NET_CAPABILITY_NOT_ROAMING));
- assertTrue(nc2.hasUnwantedCapability(NET_CAPABILITY_NOT_ROAMING));
+ if (isAtLeastS()) {
+ // Contrary to combineCapabilities, set() will have removed the NOT_ROAMING capability
+ // from nc2.
+ assertFalse(nc2.hasCapability(NET_CAPABILITY_NOT_ROAMING));
+ assertTrue(nc2.hasForbiddenCapability(NET_CAPABILITY_NOT_ROAMING));
+ }
+
if (isAtLeastR()) {
assertTrue(TEST_SSID.equals(nc2.getSsid()));
}
diff --git a/tests/net/common/java/android/net/UnderlyingNetworkInfoTest.kt b/tests/net/common/java/android/net/UnderlyingNetworkInfoTest.kt
index 87cfb345e5e0..f23ba26d0039 100644
--- a/tests/net/common/java/android/net/UnderlyingNetworkInfoTest.kt
+++ b/tests/net/common/java/android/net/UnderlyingNetworkInfoTest.kt
@@ -36,15 +36,15 @@ class UnderlyingNetworkInfoTest {
@Test
fun testParcelUnparcel() {
val testInfo = UnderlyingNetworkInfo(TEST_OWNER_UID, TEST_IFACE, TEST_IFACE_LIST)
- assertEquals(TEST_OWNER_UID, testInfo.ownerUid)
- assertEquals(TEST_IFACE, testInfo.iface)
- assertEquals(TEST_IFACE_LIST, testInfo.underlyingIfaces)
+ assertEquals(TEST_OWNER_UID, testInfo.getOwnerUid())
+ assertEquals(TEST_IFACE, testInfo.getInterface())
+ assertEquals(TEST_IFACE_LIST, testInfo.getUnderlyingInterfaces())
assertParcelSane(testInfo, 3)
val emptyInfo = UnderlyingNetworkInfo(0, String(), listOf())
- assertEquals(0, emptyInfo.ownerUid)
- assertEquals(String(), emptyInfo.iface)
- assertEquals(listOf(), emptyInfo.underlyingIfaces)
+ assertEquals(0, emptyInfo.getOwnerUid())
+ assertEquals(String(), emptyInfo.getInterface())
+ assertEquals(listOf(), emptyInfo.getUnderlyingInterfaces())
assertParcelSane(emptyInfo, 3)
}
} \ No newline at end of file
diff --git a/tests/net/integration/src/com/android/server/net/integrationtests/TestNetworkStackService.kt b/tests/net/integration/src/com/android/server/net/integrationtests/TestNetworkStackService.kt
index a44ad1e05259..eff66584d6c1 100644
--- a/tests/net/integration/src/com/android/server/net/integrationtests/TestNetworkStackService.kt
+++ b/tests/net/integration/src/com/android/server/net/integrationtests/TestNetworkStackService.kt
@@ -61,7 +61,6 @@ class TestNetworkStackService : Service() {
private class NetworkMonitorDeps(private val privateDnsBypassNetwork: Network) :
NetworkMonitor.Dependencies() {
override fun getPrivateDnsBypassNetwork(network: Network?) = privateDnsBypassNetwork
- override fun sendNetworkConditionsBroadcast(context: Context, broadcast: Intent) = Unit
}
private inner class TestNetworkStackConnector(context: Context) : NetworkStackConnector(
@@ -98,4 +97,4 @@ class TestNetworkStackService : Service() {
cb.onNetworkMonitorCreated(NetworkMonitorConnector(nm, TestPermissionChecker()))
}
}
-} \ No newline at end of file
+}
diff --git a/tests/net/java/android/net/NetworkTemplateTest.kt b/tests/net/java/android/net/NetworkTemplateTest.kt
index 64b774cc4340..ab6b2f409867 100644
--- a/tests/net/java/android/net/NetworkTemplateTest.kt
+++ b/tests/net/java/android/net/NetworkTemplateTest.kt
@@ -31,11 +31,16 @@ import android.net.NetworkTemplate.MATCH_MOBILE
import android.net.NetworkTemplate.MATCH_MOBILE_WILDCARD
import android.net.NetworkTemplate.MATCH_WIFI
import android.net.NetworkTemplate.MATCH_WIFI_WILDCARD
+import android.net.NetworkTemplate.WIFI_NETWORKID_ALL
import android.net.NetworkTemplate.NETWORK_TYPE_5G_NSA
import android.net.NetworkTemplate.NETWORK_TYPE_ALL
import android.net.NetworkTemplate.OEM_MANAGED_ALL
import android.net.NetworkTemplate.OEM_MANAGED_NO
import android.net.NetworkTemplate.OEM_MANAGED_YES
+import android.net.NetworkTemplate.SUBSCRIBER_ID_MATCH_RULE_EXACT
+import android.net.NetworkTemplate.buildTemplateWifi
+import android.net.NetworkTemplate.buildTemplateWifiWildcard
+import android.net.NetworkTemplate.buildTemplateCarrier
import android.net.NetworkTemplate.buildTemplateMobileWithRatType
import android.telephony.TelephonyManager
import com.android.testutils.assertParcelSane
@@ -53,6 +58,7 @@ import kotlin.test.assertTrue
private const val TEST_IMSI1 = "imsi1"
private const val TEST_IMSI2 = "imsi2"
private const val TEST_SSID1 = "ssid1"
+private const val TEST_SSID2 = "ssid2"
@RunWith(JUnit4::class)
class NetworkTemplateTest {
@@ -60,8 +66,8 @@ class NetworkTemplateTest {
private fun buildMobileNetworkState(subscriberId: String): NetworkStateSnapshot =
buildNetworkState(TYPE_MOBILE, subscriberId = subscriberId)
- private fun buildWifiNetworkState(ssid: String): NetworkStateSnapshot =
- buildNetworkState(TYPE_WIFI, ssid = ssid)
+ private fun buildWifiNetworkState(subscriberId: String?, ssid: String?): NetworkStateSnapshot =
+ buildNetworkState(TYPE_WIFI, subscriberId = subscriberId, ssid = ssid)
private fun buildNetworkState(
type: Int,
@@ -94,6 +100,95 @@ class NetworkTemplateTest {
}
@Test
+ fun testWifiWildcardMatches() {
+ val templateWifiWildcard = buildTemplateWifiWildcard()
+
+ val identMobileImsi1 = buildNetworkIdentity(mockContext,
+ buildMobileNetworkState(TEST_IMSI1),
+ false, TelephonyManager.NETWORK_TYPE_UMTS)
+ val identWifiImsiNullSsid1 = buildNetworkIdentity(
+ mockContext, buildWifiNetworkState(null, TEST_SSID1), true, 0)
+ val identWifiImsi1Ssid1 = buildNetworkIdentity(
+ mockContext, buildWifiNetworkState(TEST_IMSI1, TEST_SSID1), true, 0)
+
+ templateWifiWildcard.assertDoesNotMatch(identMobileImsi1)
+ templateWifiWildcard.assertMatches(identWifiImsiNullSsid1)
+ templateWifiWildcard.assertMatches(identWifiImsi1Ssid1)
+ }
+
+ @Test
+ fun testWifiMatches() {
+ val templateWifiSsid1 = buildTemplateWifi(TEST_SSID1)
+ val templateWifiSsid1ImsiNull = buildTemplateWifi(TEST_SSID1, null)
+ val templateWifiSsid1Imsi1 = buildTemplateWifi(TEST_SSID1, TEST_IMSI1)
+ val templateWifiSsidAllImsi1 = buildTemplateWifi(WIFI_NETWORKID_ALL, TEST_IMSI1)
+
+ val identMobile1 = buildNetworkIdentity(mockContext, buildMobileNetworkState(TEST_IMSI1),
+ false, TelephonyManager.NETWORK_TYPE_UMTS)
+ val identWifiImsiNullSsid1 = buildNetworkIdentity(
+ mockContext, buildWifiNetworkState(null, TEST_SSID1), true, 0)
+ val identWifiImsi1Ssid1 = buildNetworkIdentity(
+ mockContext, buildWifiNetworkState(TEST_IMSI1, TEST_SSID1), true, 0)
+ val identWifiImsi2Ssid1 = buildNetworkIdentity(
+ mockContext, buildWifiNetworkState(TEST_IMSI2, TEST_SSID1), true, 0)
+ val identWifiImsi1Ssid2 = buildNetworkIdentity(
+ mockContext, buildWifiNetworkState(TEST_IMSI1, TEST_SSID2), true, 0)
+
+ // Verify that template with SSID only matches any subscriberId and specific SSID.
+ templateWifiSsid1.assertDoesNotMatch(identMobile1)
+ templateWifiSsid1.assertMatches(identWifiImsiNullSsid1)
+ templateWifiSsid1.assertMatches(identWifiImsi1Ssid1)
+ templateWifiSsid1.assertMatches(identWifiImsi2Ssid1)
+ templateWifiSsid1.assertDoesNotMatch(identWifiImsi1Ssid2)
+
+ // Verify that template with SSID1 and null imsi matches any network with
+ // SSID1 and null imsi.
+ templateWifiSsid1ImsiNull.assertDoesNotMatch(identMobile1)
+ templateWifiSsid1ImsiNull.assertMatches(identWifiImsiNullSsid1)
+ templateWifiSsid1ImsiNull.assertDoesNotMatch(identWifiImsi1Ssid1)
+ templateWifiSsid1ImsiNull.assertDoesNotMatch(identWifiImsi2Ssid1)
+ templateWifiSsid1ImsiNull.assertDoesNotMatch(identWifiImsi1Ssid2)
+
+ // Verify that template with SSID1 and imsi1 matches any network with
+ // SSID1 and imsi1.
+ templateWifiSsid1Imsi1.assertDoesNotMatch(identMobile1)
+ templateWifiSsid1Imsi1.assertDoesNotMatch(identWifiImsiNullSsid1)
+ templateWifiSsid1Imsi1.assertMatches(identWifiImsi1Ssid1)
+ templateWifiSsid1Imsi1.assertDoesNotMatch(identWifiImsi2Ssid1)
+ templateWifiSsid1Imsi1.assertDoesNotMatch(identWifiImsi1Ssid2)
+
+ // Verify that template with SSID all and imsi1 matches any network with
+ // any SSID and imsi1.
+ templateWifiSsidAllImsi1.assertDoesNotMatch(identMobile1)
+ templateWifiSsidAllImsi1.assertDoesNotMatch(identWifiImsiNullSsid1)
+ templateWifiSsidAllImsi1.assertMatches(identWifiImsi1Ssid1)
+ templateWifiSsidAllImsi1.assertDoesNotMatch(identWifiImsi2Ssid1)
+ templateWifiSsidAllImsi1.assertMatches(identWifiImsi1Ssid2)
+ }
+
+ @Test
+ fun testCarrierMatches() {
+ val templateCarrierImsi1 = buildTemplateCarrier(TEST_IMSI1)
+
+ val identMobile1 = buildNetworkIdentity(mockContext, buildMobileNetworkState(TEST_IMSI1),
+ false, TelephonyManager.NETWORK_TYPE_UMTS)
+ val identMobile2 = buildNetworkIdentity(mockContext, buildMobileNetworkState(TEST_IMSI2),
+ false, TelephonyManager.NETWORK_TYPE_UMTS)
+ val identWifiSsid1 = buildNetworkIdentity(
+ mockContext, buildWifiNetworkState(null, TEST_SSID1), true, 0)
+ val identCarrierWifiImsi1 = buildNetworkIdentity(
+ mockContext, buildWifiNetworkState(TEST_IMSI1, TEST_SSID1), true, 0)
+ val identCarrierWifiImsi2 = buildNetworkIdentity(
+ mockContext, buildWifiNetworkState(TEST_IMSI2, TEST_SSID1), true, 0)
+
+ templateCarrierImsi1.assertMatches(identCarrierWifiImsi1)
+ templateCarrierImsi1.assertDoesNotMatch(identCarrierWifiImsi2)
+ templateCarrierImsi1.assertDoesNotMatch(identWifiSsid1)
+ templateCarrierImsi1.assertMatches(identMobile1)
+ templateCarrierImsi1.assertDoesNotMatch(identMobile2)
+ }
+
+ @Test
fun testRatTypeGroupMatches() {
val stateMobile = buildMobileNetworkState(TEST_IMSI1)
// Build UMTS template that matches mobile identities with RAT in the same
@@ -117,7 +212,7 @@ class NetworkTemplateTest {
val identImsi2 = buildNetworkIdentity(mockContext, buildMobileNetworkState(TEST_IMSI2),
false, TelephonyManager.NETWORK_TYPE_UMTS)
val identWifi = buildNetworkIdentity(
- mockContext, buildWifiNetworkState(TEST_SSID1), true, 0)
+ mockContext, buildWifiNetworkState(null, TEST_SSID1), true, 0)
// Assert that identity with the same RAT matches.
templateUmts.assertMatches(identUmts)
@@ -151,14 +246,16 @@ class NetworkTemplateTest {
fun testParcelUnparcel() {
val templateMobile = NetworkTemplate(MATCH_MOBILE, TEST_IMSI1, null, null, METERED_ALL,
ROAMING_ALL, DEFAULT_NETWORK_ALL, TelephonyManager.NETWORK_TYPE_LTE,
- OEM_MANAGED_ALL)
+ OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_EXACT)
val templateWifi = NetworkTemplate(MATCH_WIFI, null, null, TEST_SSID1, METERED_ALL,
- ROAMING_ALL, DEFAULT_NETWORK_ALL, 0, OEM_MANAGED_ALL)
+ ROAMING_ALL, DEFAULT_NETWORK_ALL, 0, OEM_MANAGED_ALL,
+ SUBSCRIBER_ID_MATCH_RULE_EXACT)
val templateOem = NetworkTemplate(MATCH_MOBILE, null, null, null, METERED_ALL,
- ROAMING_ALL, DEFAULT_NETWORK_ALL, 0, OEM_MANAGED_YES)
- assertParcelSane(templateMobile, 9)
- assertParcelSane(templateWifi, 9)
- assertParcelSane(templateOem, 9)
+ ROAMING_ALL, DEFAULT_NETWORK_ALL, 0, OEM_MANAGED_YES,
+ SUBSCRIBER_ID_MATCH_RULE_EXACT)
+ assertParcelSane(templateMobile, 10)
+ assertParcelSane(templateWifi, 10)
+ assertParcelSane(templateOem, 10)
}
// Verify NETWORK_TYPE_* constants in NetworkTemplate do not conflict with
@@ -207,15 +304,14 @@ class NetworkTemplateTest {
identSsid: String? = null
) {
val oemManagedStates = arrayOf(OEM_NONE, OEM_PAID, OEM_PRIVATE, OEM_PAID or OEM_PRIVATE)
- // A null subscriberId needs a null matchSubscriberIds argument as well.
- val matchSubscriberIds = if (subscriberId == null) null else arrayOf(subscriberId)
+ val matchSubscriberIds = arrayOf(subscriberId)
val templateOemYes = NetworkTemplate(matchType, subscriberId, matchSubscriberIds,
templateSsid, METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
- OEM_MANAGED_YES)
+ OEM_MANAGED_YES, SUBSCRIBER_ID_MATCH_RULE_EXACT)
val templateOemAll = NetworkTemplate(matchType, subscriberId, matchSubscriberIds,
templateSsid, METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
- OEM_MANAGED_ALL)
+ OEM_MANAGED_ALL, SUBSCRIBER_ID_MATCH_RULE_EXACT)
for (identityOemManagedState in oemManagedStates) {
val ident = buildNetworkIdentity(mockContext, buildNetworkState(networkType,
@@ -226,7 +322,7 @@ class NetworkTemplateTest {
for (templateOemManagedState in oemManagedStates) {
val template = NetworkTemplate(matchType, subscriberId, matchSubscriberIds,
templateSsid, METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL,
- NETWORK_TYPE_ALL, templateOemManagedState)
+ NETWORK_TYPE_ALL, templateOemManagedState, SUBSCRIBER_ID_MATCH_RULE_EXACT)
if (identityOemManagedState == templateOemManagedState) {
template.assertMatches(ident)
} else {
diff --git a/tests/net/java/com/android/server/ConnectivityServiceTest.java b/tests/net/java/com/android/server/ConnectivityServiceTest.java
index dcbfb933f867..f277e94a7bd3 100644
--- a/tests/net/java/com/android/server/ConnectivityServiceTest.java
+++ b/tests/net/java/com/android/server/ConnectivityServiceTest.java
@@ -44,9 +44,6 @@ import static android.net.ConnectivityManager.BLOCKED_REASON_NONE;
import static android.net.ConnectivityManager.CONNECTIVITY_ACTION;
import static android.net.ConnectivityManager.EXTRA_NETWORK_INFO;
import static android.net.ConnectivityManager.EXTRA_NETWORK_TYPE;
-import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OFF;
-import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OPPORTUNISTIC;
-import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
import static android.net.ConnectivityManager.PROFILE_NETWORK_PREFERENCE_DEFAULT;
import static android.net.ConnectivityManager.PROFILE_NETWORK_PREFERENCE_ENTERPRISE;
import static android.net.ConnectivityManager.TYPE_ETHERNET;
@@ -57,6 +54,9 @@ import static android.net.ConnectivityManager.TYPE_MOBILE_SUPL;
import static android.net.ConnectivityManager.TYPE_PROXY;
import static android.net.ConnectivityManager.TYPE_VPN;
import static android.net.ConnectivityManager.TYPE_WIFI;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_OFF;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_OPPORTUNISTIC;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
import static android.net.INetworkMonitor.NETWORK_VALIDATION_PROBE_DNS;
import static android.net.INetworkMonitor.NETWORK_VALIDATION_PROBE_FALLBACK;
import static android.net.INetworkMonitor.NETWORK_VALIDATION_PROBE_HTTP;
@@ -4273,10 +4273,9 @@ public class ConnectivityServiceTest {
waitForIdle();
}
- private void setPrivateDnsSettings(String mode, String specifier) {
- final ContentResolver cr = mServiceContext.getContentResolver();
- Settings.Global.putString(cr, ConnectivitySettingsManager.PRIVATE_DNS_MODE, mode);
- Settings.Global.putString(cr, ConnectivitySettingsManager.PRIVATE_DNS_SPECIFIER, specifier);
+ private void setPrivateDnsSettings(int mode, String specifier) {
+ ConnectivitySettingsManager.setPrivateDnsMode(mServiceContext, mode);
+ ConnectivitySettingsManager.setPrivateDnsHostname(mServiceContext, specifier);
mService.updatePrivateDnsSettings();
waitForIdle();
}
@@ -5899,9 +5898,9 @@ public class ConnectivityServiceTest {
assertEquals("Should have exactly one VPN:", 1, infos.length);
UnderlyingNetworkInfo info = infos[0];
assertEquals("Unexpected VPN owner:", (int) vpnUid, info.getOwnerUid());
- assertEquals("Unexpected VPN interface:", vpnIfname, info.getIface());
+ assertEquals("Unexpected VPN interface:", vpnIfname, info.getInterface());
assertSameElementsNoDuplicates(underlyingIfaces,
- info.getUnderlyingIfaces().toArray(new String[0]));
+ info.getUnderlyingInterfaces().toArray(new String[0]));
} else {
assertEquals(0, infos.length);
return;
@@ -6045,8 +6044,8 @@ public class ConnectivityServiceTest {
// network for the VPN...
verify(mStatsManager, never()).notifyNetworkStatus(any(List.class),
any(List.class), any() /* anyString() doesn't match null */,
- argThat(infos -> infos.get(0).getUnderlyingIfaces().size() == 1
- && WIFI_IFNAME.equals(infos.get(0).getUnderlyingIfaces().get(0))));
+ argThat(infos -> infos.get(0).getUnderlyingInterfaces().size() == 1
+ && WIFI_IFNAME.equals(infos.get(0).getUnderlyingInterfaces().get(0))));
verifyNoMoreInteractions(mStatsManager);
reset(mStatsManager);
@@ -6060,8 +6059,8 @@ public class ConnectivityServiceTest {
waitForIdle();
verify(mStatsManager).notifyNetworkStatus(any(List.class),
any(List.class), any() /* anyString() doesn't match null */,
- argThat(vpnInfos -> vpnInfos.get(0).getUnderlyingIfaces().size() == 1
- && WIFI_IFNAME.equals(vpnInfos.get(0).getUnderlyingIfaces().get(0))));
+ argThat(vpnInfos -> vpnInfos.get(0).getUnderlyingInterfaces().size() == 1
+ && WIFI_IFNAME.equals(vpnInfos.get(0).getUnderlyingInterfaces().get(0))));
mEthernetNetworkAgent.disconnect();
waitForIdle();
reset(mStatsManager);
diff --git a/tests/net/java/com/android/server/connectivity/DnsManagerTest.java b/tests/net/java/com/android/server/connectivity/DnsManagerTest.java
index 692c50fbef86..0ffeec98cf90 100644
--- a/tests/net/java/com/android/server/connectivity/DnsManagerTest.java
+++ b/tests/net/java/com/android/server/connectivity/DnsManagerTest.java
@@ -16,10 +16,10 @@
package com.android.server.connectivity;
-import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OFF;
-import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_DEFAULT_MODE;
import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_OFF;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_SPECIFIER;
import static android.net.NetworkCapabilities.MAX_TRANSPORT;
import static android.net.NetworkCapabilities.MIN_TRANSPORT;
@@ -44,6 +44,7 @@ import static org.mockito.Mockito.when;
import android.annotation.NonNull;
import android.content.Context;
+import android.net.ConnectivitySettingsManager;
import android.net.IDnsResolver;
import android.net.IpPrefix;
import android.net.LinkAddress;
@@ -187,9 +188,8 @@ public class DnsManagerTest {
lp.addRoute(new RouteInfo((IpPrefix) null, InetAddress.getByName("2001:db8:1::1"),
TEST_IFACENAME));
- Settings.Global.putString(mContentResolver,
- PRIVATE_DNS_MODE, PRIVATE_DNS_MODE_PROVIDER_HOSTNAME);
- Settings.Global.putString(mContentResolver, PRIVATE_DNS_SPECIFIER, "strictmode.com");
+ ConnectivitySettingsManager.setPrivateDnsMode(mCtx, PRIVATE_DNS_MODE_PROVIDER_HOSTNAME);
+ ConnectivitySettingsManager.setPrivateDnsHostname(mCtx, "strictmode.com");
mDnsManager.updatePrivateDns(new Network(TEST_NETID),
new PrivateDnsConfig("strictmode.com", new InetAddress[] {
InetAddress.parseNumericAddress("6.6.6.6"),
@@ -294,7 +294,7 @@ public class DnsManagerTest {
assertNull(lp.getPrivateDnsServerName());
// Turn private DNS mode off
- Settings.Global.putString(mContentResolver, PRIVATE_DNS_MODE, PRIVATE_DNS_MODE_OFF);
+ ConnectivitySettingsManager.setPrivateDnsMode(mCtx, PRIVATE_DNS_MODE_OFF);
mDnsManager.updatePrivateDns(new Network(TEST_NETID),
mDnsManager.getPrivateDnsConfig());
mDnsManager.updateTransportsForNetwork(TEST_NETID, TEST_TRANSPORT_TYPES);
@@ -318,16 +318,15 @@ public class DnsManagerTest {
assertEquals(new InetAddress[0], cfgAuto.ips);
// Pretend a gservices push sets the default to "off".
- Settings.Global.putString(mContentResolver, PRIVATE_DNS_DEFAULT_MODE, "off");
+ ConnectivitySettingsManager.setPrivateDnsDefaultMode(mCtx, PRIVATE_DNS_MODE_OFF);
final PrivateDnsConfig cfgOff = DnsManager.getPrivateDnsConfig(mCtx);
assertFalse(cfgOff.useTls);
assertEquals("", cfgOff.hostname);
assertEquals(new InetAddress[0], cfgOff.ips);
// Strict mode still works.
- Settings.Global.putString(
- mContentResolver, PRIVATE_DNS_MODE, PRIVATE_DNS_MODE_PROVIDER_HOSTNAME);
- Settings.Global.putString(mContentResolver, PRIVATE_DNS_SPECIFIER, "strictmode.com");
+ ConnectivitySettingsManager.setPrivateDnsMode(mCtx, PRIVATE_DNS_MODE_PROVIDER_HOSTNAME);
+ ConnectivitySettingsManager.setPrivateDnsHostname(mCtx, "strictmode.com");
final PrivateDnsConfig cfgStrict = DnsManager.getPrivateDnsConfig(mCtx);
assertTrue(cfgStrict.useTls);
assertEquals("strictmode.com", cfgStrict.hostname);
diff --git a/tests/net/java/com/android/server/net/NetworkStatsServiceTest.java b/tests/net/java/com/android/server/net/NetworkStatsServiceTest.java
index 42441c214575..fd374bc9e68f 100644
--- a/tests/net/java/com/android/server/net/NetworkStatsServiceTest.java
+++ b/tests/net/java/com/android/server/net/NetworkStatsServiceTest.java
@@ -45,6 +45,7 @@ import static android.net.NetworkTemplate.MATCH_MOBILE_WILDCARD;
import static android.net.NetworkTemplate.NETWORK_TYPE_ALL;
import static android.net.NetworkTemplate.OEM_MANAGED_NO;
import static android.net.NetworkTemplate.OEM_MANAGED_YES;
+import static android.net.NetworkTemplate.SUBSCRIBER_ID_MATCH_RULE_EXACT;
import static android.net.NetworkTemplate.buildTemplateMobileAll;
import static android.net.NetworkTemplate.buildTemplateMobileWithRatType;
import static android.net.NetworkTemplate.buildTemplateWifi;
@@ -669,24 +670,28 @@ public class NetworkStatsServiceTest extends NetworkStatsBaseTest {
public void testMobileStatsOemManaged() throws Exception {
final NetworkTemplate templateOemPaid = new NetworkTemplate(MATCH_MOBILE_WILDCARD,
/*subscriberId=*/null, /*matchSubscriberIds=*/null, /*networkId=*/null,
- METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_PAID);
+ METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_PAID,
+ SUBSCRIBER_ID_MATCH_RULE_EXACT);
final NetworkTemplate templateOemPrivate = new NetworkTemplate(MATCH_MOBILE_WILDCARD,
/*subscriberId=*/null, /*matchSubscriberIds=*/null, /*networkId=*/null,
- METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_PRIVATE);
+ METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_PRIVATE,
+ SUBSCRIBER_ID_MATCH_RULE_EXACT);
final NetworkTemplate templateOemAll = new NetworkTemplate(MATCH_MOBILE_WILDCARD,
/*subscriberId=*/null, /*matchSubscriberIds=*/null, /*networkId=*/null,
METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
- OEM_PAID | OEM_PRIVATE);
+ OEM_PAID | OEM_PRIVATE, SUBSCRIBER_ID_MATCH_RULE_EXACT);
final NetworkTemplate templateOemYes = new NetworkTemplate(MATCH_MOBILE_WILDCARD,
/*subscriberId=*/null, /*matchSubscriberIds=*/null, /*networkId=*/null,
- METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_YES);
+ METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_YES,
+ SUBSCRIBER_ID_MATCH_RULE_EXACT);
final NetworkTemplate templateOemNone = new NetworkTemplate(MATCH_MOBILE_WILDCARD,
/*subscriberId=*/null, /*matchSubscriberIds=*/null, /*networkId=*/null,
- METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_NO);
+ METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, OEM_MANAGED_NO,
+ SUBSCRIBER_ID_MATCH_RULE_EXACT);
// OEM_PAID network comes online.
NetworkStateSnapshot[] states = new NetworkStateSnapshot[]{
diff --git a/tests/vcn/java/android/net/vcn/VcnGatewayConnectionConfigTest.java b/tests/vcn/java/android/net/vcn/VcnGatewayConnectionConfigTest.java
index 0d3fd3fef49c..9410886c3549 100644
--- a/tests/vcn/java/android/net/vcn/VcnGatewayConnectionConfigTest.java
+++ b/tests/vcn/java/android/net/vcn/VcnGatewayConnectionConfigTest.java
@@ -22,7 +22,7 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import android.net.NetworkCapabilities;
-import android.net.TunnelConnectionParams;
+import android.net.ipsec.ike.IkeTunnelConnectionParams;
import android.net.vcn.persistablebundleutils.TunnelConnectionParamsUtilsTest;
import androidx.test.filters.SmallTest;
@@ -60,7 +60,7 @@ public class VcnGatewayConnectionConfigTest {
};
public static final int MAX_MTU = 1360;
- public static final TunnelConnectionParams TUNNEL_CONNECTION_PARAMS =
+ public static final IkeTunnelConnectionParams TUNNEL_CONNECTION_PARAMS =
TunnelConnectionParamsUtilsTest.buildTestParams();
public static final String GATEWAY_CONNECTION_NAME_PREFIX = "gatewayConnectionName-";
@@ -82,7 +82,7 @@ public class VcnGatewayConnectionConfigTest {
// Public for use in VcnGatewayConnectionTest
public static VcnGatewayConnectionConfig buildTestConfigWithExposedCaps(int... exposedCaps) {
final VcnGatewayConnectionConfig.Builder builder =
- newBuilder().setRetryIntervalsMs(RETRY_INTERVALS_MS).setMaxMtu(MAX_MTU);
+ newBuilder().setRetryIntervalsMillis(RETRY_INTERVALS_MS).setMaxMtu(MAX_MTU);
for (int caps : exposedCaps) {
builder.addExposedCapability(caps);
@@ -134,7 +134,7 @@ public class VcnGatewayConnectionConfigTest {
@Test
public void testBuilderRequiresNonNullRetryInterval() {
try {
- newBuilder().setRetryIntervalsMs(null);
+ newBuilder().setRetryIntervalsMillis(null);
fail("Expected exception due to invalid retryIntervalMs");
} catch (IllegalArgumentException e) {
}
@@ -143,7 +143,7 @@ public class VcnGatewayConnectionConfigTest {
@Test
public void testBuilderRequiresNonEmptyRetryInterval() {
try {
- newBuilder().setRetryIntervalsMs(new long[0]);
+ newBuilder().setRetryIntervalsMillis(new long[0]);
fail("Expected exception due to invalid retryIntervalMs");
} catch (IllegalArgumentException e) {
}
@@ -174,7 +174,7 @@ public class VcnGatewayConnectionConfigTest {
assertEquals(TUNNEL_CONNECTION_PARAMS, config.getTunnelConnectionParams());
- assertArrayEquals(RETRY_INTERVALS_MS, config.getRetryIntervalsMs());
+ assertArrayEquals(RETRY_INTERVALS_MS, config.getRetryIntervalsMillis());
assertEquals(MAX_MTU, config.getMaxMtu());
}
diff --git a/tests/vcn/java/android/net/vcn/VcnTransportInfoTest.java b/tests/vcn/java/android/net/vcn/VcnTransportInfoTest.java
index 31561901be9e..582275d0547d 100644
--- a/tests/vcn/java/android/net/vcn/VcnTransportInfoTest.java
+++ b/tests/vcn/java/android/net/vcn/VcnTransportInfoTest.java
@@ -16,6 +16,8 @@
package android.net.vcn;
+import static android.net.NetworkCapabilities.REDACT_ALL;
+import static android.net.NetworkCapabilities.REDACT_FOR_NETWORK_SETTINGS;
import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
import static org.junit.Assert.assertEquals;
@@ -37,6 +39,12 @@ public class VcnTransportInfoTest {
private static final VcnTransportInfo WIFI_UNDERLYING_INFO = new VcnTransportInfo(WIFI_INFO);
@Test
+ public void testRedactionDefaults() {
+ assertEquals(REDACT_ALL, CELL_UNDERLYING_INFO.getRedaction());
+ assertEquals(REDACT_ALL, WIFI_UNDERLYING_INFO.getRedaction());
+ }
+
+ @Test
public void testGetWifiInfo() {
assertEquals(WIFI_INFO, WIFI_UNDERLYING_INFO.getWifiInfo());
@@ -51,6 +59,18 @@ public class VcnTransportInfoTest {
}
@Test
+ public void testMakeCopySetsRedactions() {
+ assertEquals(
+ REDACT_FOR_NETWORK_SETTINGS,
+ ((VcnTransportInfo) CELL_UNDERLYING_INFO.makeCopy(REDACT_FOR_NETWORK_SETTINGS))
+ .getRedaction());
+ assertEquals(
+ REDACT_FOR_NETWORK_SETTINGS,
+ ((VcnTransportInfo) WIFI_UNDERLYING_INFO.makeCopy(REDACT_FOR_NETWORK_SETTINGS))
+ .getRedaction());
+ }
+
+ @Test
public void testEquals() {
assertEquals(CELL_UNDERLYING_INFO, CELL_UNDERLYING_INFO);
assertEquals(WIFI_UNDERLYING_INFO, WIFI_UNDERLYING_INFO);
@@ -64,8 +84,29 @@ public class VcnTransportInfoTest {
}
private void verifyParcelingIsNull(VcnTransportInfo vcnTransportInfo) {
+ // Verify redacted by default
Parcel parcel = Parcel.obtain();
vcnTransportInfo.writeToParcel(parcel, 0 /* flags */);
+ parcel.setDataPosition(0);
+
assertNull(VcnTransportInfo.CREATOR.createFromParcel(parcel));
}
+
+ @Test
+ public void testParcelUnparcelNotRedactedForSysUi() {
+ verifyParcelingForSysUi(CELL_UNDERLYING_INFO);
+ verifyParcelingForSysUi(WIFI_UNDERLYING_INFO);
+ }
+
+ private void verifyParcelingForSysUi(VcnTransportInfo vcnTransportInfo) {
+ // Allow fully unredacted; SysUI will have all the relevant permissions.
+ final VcnTransportInfo unRedacted = (VcnTransportInfo) vcnTransportInfo.makeCopy(0);
+ final Parcel parcel = Parcel.obtain();
+ unRedacted.writeToParcel(parcel, 0 /* flags */);
+ parcel.setDataPosition(0);
+
+ final VcnTransportInfo unparceled = VcnTransportInfo.CREATOR.createFromParcel(parcel);
+ assertEquals(vcnTransportInfo, unparceled);
+ assertEquals(REDACT_ALL, unparceled.getRedaction());
+ }
}
diff --git a/tests/vcn/java/com/android/server/VcnManagementServiceTest.java b/tests/vcn/java/com/android/server/VcnManagementServiceTest.java
index aa4b5f8e208f..9ecd82ff6bcb 100644
--- a/tests/vcn/java/com/android/server/VcnManagementServiceTest.java
+++ b/tests/vcn/java/com/android/server/VcnManagementServiceTest.java
@@ -77,6 +77,7 @@ import android.os.test.TestLooper;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
+import android.util.ArraySet;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
@@ -98,6 +99,7 @@ import java.io.FileNotFoundException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
@@ -326,6 +328,17 @@ public class VcnManagementServiceTest {
return subIdToGroupMap.get(invocation.getArgument(0));
}).when(snapshot).getGroupForSubId(anyInt());
+ doAnswer(invocation -> {
+ final ParcelUuid subGrp = invocation.getArgument(0);
+ final Set<Integer> subIds = new ArraySet<>();
+ for (Entry<Integer, ParcelUuid> entry : subIdToGroupMap.entrySet()) {
+ if (entry.getValue().equals(subGrp)) {
+ subIds.add(entry.getKey());
+ }
+ }
+ return subIds;
+ }).when(snapshot).getAllSubIdsInGroup(any());
+
final TelephonySubscriptionTrackerCallback cb = getTelephonySubscriptionTrackerCallback();
cb.onNewSnapshot(snapshot);
@@ -914,6 +927,18 @@ public class VcnManagementServiceTest {
verify(mMockPolicyListener).onPolicyChanged();
}
+ @Test
+ public void testVcnSubIdChangeUpdatesPolicyListener() throws Exception {
+ startAndGetVcnInstance(TEST_UUID_2);
+ mVcnMgmtSvc.addVcnUnderlyingNetworkPolicyListener(mMockPolicyListener);
+
+ triggerSubscriptionTrackerCbAndGetSnapshot(
+ Collections.singleton(TEST_UUID_2),
+ Collections.singletonMap(TEST_SUBSCRIPTION_ID, TEST_UUID_2));
+
+ verify(mMockPolicyListener).onPolicyChanged();
+ }
+
private void triggerVcnSafeMode(
@NonNull ParcelUuid subGroup,
@NonNull TelephonySubscriptionSnapshot snapshot,
diff --git a/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionConnectedStateTest.java b/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionConnectedStateTest.java
index 530e63699e9f..eedaac48293c 100644
--- a/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionConnectedStateTest.java
+++ b/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionConnectedStateTest.java
@@ -51,7 +51,6 @@ import android.net.LinkProperties;
import android.net.NetworkAgent;
import android.net.NetworkCapabilities;
import android.net.ipsec.ike.ChildSaProposal;
-import android.net.ipsec.ike.IkeTunnelConnectionParams;
import android.net.ipsec.ike.exceptions.IkeException;
import android.net.ipsec.ike.exceptions.IkeInternalException;
import android.net.ipsec.ike.exceptions.IkeProtocolException;
@@ -181,7 +180,7 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection
assertEquals(mGatewayConnection.mConnectedState, mGatewayConnection.getCurrentState());
final List<ChildSaProposal> saProposals =
- ((IkeTunnelConnectionParams) mConfig.getTunnelConnectionParams())
+ mConfig.getTunnelConnectionParams()
.getTunnelModeChildSessionParams()
.getSaProposals();
final int expectedMtu =
@@ -344,6 +343,31 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection
assertFalse(mGatewayConnection.isInSafeMode());
}
+ @Test
+ public void testSubsequentFailedValidationTriggersSafeMode() throws Exception {
+ triggerChildOpened();
+ mTestLooper.dispatchAll();
+
+ triggerValidation(NetworkAgent.VALIDATION_STATUS_VALID);
+ assertFalse(mGatewayConnection.isInSafeMode());
+
+ // Trigger a failed validation, and the subsequent safemode timeout.
+ triggerValidation(NetworkAgent.VALIDATION_STATUS_NOT_VALID);
+ mTestLooper.dispatchAll();
+
+ final ArgumentCaptor<Runnable> runnableCaptor = ArgumentCaptor.forClass(Runnable.class);
+ verify(mDeps, times(2))
+ .newWakeupMessage(
+ eq(mVcnContext),
+ any(),
+ eq(VcnGatewayConnection.SAFEMODE_TIMEOUT_ALARM),
+ runnableCaptor.capture());
+ runnableCaptor.getValue().run();
+ mTestLooper.dispatchAll();
+
+ assertTrue(mGatewayConnection.isInSafeMode());
+ }
+
private Consumer<VcnNetworkAgent> setupNetworkAndGetUnwantedCallback() {
triggerChildOpened();
mTestLooper.dispatchAll();
diff --git a/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionRetryTimeoutStateTest.java b/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionRetryTimeoutStateTest.java
index 044bef5b002f..a88f112f4502 100644
--- a/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionRetryTimeoutStateTest.java
+++ b/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionRetryTimeoutStateTest.java
@@ -38,7 +38,7 @@ public class VcnGatewayConnectionRetryTimeoutStateTest extends VcnGatewayConnect
public void setUp() throws Exception {
super.setUp();
- mFirstRetryInterval = mConfig.getRetryIntervalsMs()[0];
+ mFirstRetryInterval = mConfig.getRetryIntervalsMillis()[0];
mGatewayConnection.setUnderlyingNetwork(TEST_UNDERLYING_NETWORK_RECORD_1);
mGatewayConnection.transitionTo(mGatewayConnection.mRetryTimeoutState);
diff --git a/tests/vcn/java/com/android/server/vcn/VcnTest.java b/tests/vcn/java/com/android/server/vcn/VcnTest.java
index 736fabdb1ac5..f681ee19ab12 100644
--- a/tests/vcn/java/com/android/server/vcn/VcnTest.java
+++ b/tests/vcn/java/com/android/server/vcn/VcnTest.java
@@ -388,8 +388,9 @@ public class VcnTest {
final ContentObserver contentObserver = captor.getValue();
// Start VcnGatewayConnections
+ final NetworkRequestListener requestListener = verifyAndGetRequestListener();
mVcn.setMobileDataEnabled(startingToggleState);
- triggerVcnRequestListeners(verifyAndGetRequestListener());
+ triggerVcnRequestListeners(requestListener);
final Map<VcnGatewayConnectionConfig, VcnGatewayConnection> gateways =
mVcn.getVcnGatewayConnectionConfigMap();
@@ -411,6 +412,9 @@ public class VcnTest {
}
}
+ if (startingToggleState != endingToggleState) {
+ verify(mVcnNetworkProvider).resendAllRequests(requestListener);
+ }
assertEquals(endingToggleState, mVcn.isMobileDataEnabled());
}