diff options
author | Ryan Mitchell <rtmitchell@google.com> | 2019-06-03 16:11:24 -0700 |
---|---|---|
committer | Ryan Mitchell <rtmitchell@google.com> | 2019-09-26 14:15:26 -0700 |
commit | 4043ca78ea8b877aece33b5daf334096683dec0b (patch) | |
tree | 2da71a444d320d8c5396d42dd936152205c6a1fe | |
parent | 68e6b3af8876997126d741788fd64531a8f3c6fb (diff) |
Add Resources Perf Tests
This changes adds benchamrks for Resources, ResourcesManager,
OverlayManager, and Resources.Theme.
Bug: 136085555
Test: atest OverlayManagerPerfTest
Test: atest ResourcesManagerPerfTest
Test: atest ResourcesPerfTest
Test: atest ResourcesThemePerfTest
Change-Id: I6a3b3275399c161e55ff6ce34e7bc2ae5556edf1
24 files changed, 2041 insertions, 66 deletions
diff --git a/apct-tests/perftests/core/Android.mk b/apct-tests/perftests/core/Android.mk index 3f87a1c8b598..968478c3f338 100644 --- a/apct-tests/perftests/core/Android.mk +++ b/apct-tests/perftests/core/Android.mk @@ -9,8 +9,11 @@ LOCAL_SRC_FILES := \ src/android/os/ISomeService.aidl LOCAL_STATIC_JAVA_LIBRARIES := \ + androidx.appcompat_appcompat \ androidx.test.rules \ androidx.annotation_annotation \ + apct-perftests-overlay-apps \ + apct-perftests-resources-manager-apps \ apct-perftests-utils \ guava @@ -25,5 +28,6 @@ LOCAL_JNI_SHARED_LIBRARIES := libperftestscore_jni LOCAL_ASSET_DIR := $(TOP)/external/google-fonts/dancing-script LOCAL_COMPATIBILITY_SUITE += device-tests +LOCAL_CERTIFICATE := platform -include $(BUILD_PACKAGE) +include $(BUILD_PACKAGE)
\ No newline at end of file diff --git a/apct-tests/perftests/core/AndroidManifest.xml b/apct-tests/perftests/core/AndroidManifest.xml index a564a4d27fb3..525975d36772 100644 --- a/apct-tests/perftests/core/AndroidManifest.xml +++ b/apct-tests/perftests/core/AndroidManifest.xml @@ -5,8 +5,11 @@ <permission android:name="com.android.perftests.core.TestPermission" /> <uses-permission android:name="com.android.perftests.core.TestPermission" /> - <uses-permission - android:name="android.permission.GET_ACCOUNTS" /> + <uses-permission android:name="android.permission.CHANGE_OVERLAY_PACKAGES" /> + <uses-permission android:name="android.permission.DELETE_PACKAGES" /> + <uses-permission android:name="android.permission.GET_ACCOUNTS" /> + <uses-permission android:name="android.permission.INSTALL_PACKAGES"/> + <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" /> <application> <uses-library android:name="android.test.runner" /> diff --git a/apct-tests/perftests/core/apps/overlay/Android.bp b/apct-tests/perftests/core/apps/overlay/Android.bp new file mode 100644 index 000000000000..7bee30ee9cb4 --- /dev/null +++ b/apct-tests/perftests/core/apps/overlay/Android.bp @@ -0,0 +1,188 @@ +// 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. + +android_test_helper_app { + name: "Overlay0", + aaptflags: [ + "--rename-manifest-package com.android.perftests.overlay0", + ] +} + +android_test_helper_app { + name: "Overlay1", + aaptflags: [ + "--rename-manifest-package com.android.perftests.overlay1", + ] +} + +android_test_helper_app { + name: "Overlay2", + aaptflags: [ + "--rename-manifest-package com.android.perftests.overlay2", + ] +} + +android_test_helper_app { + name: "Overlay3", + aaptflags: [ + "--rename-manifest-package com.android.perftests.overlay3", + ] +} + +android_test_helper_app { + name: "Overlay4", + aaptflags: [ + "--rename-manifest-package com.android.perftests.overlay4", + ] +} + +android_test_helper_app { + name: "Overlay5", + aaptflags: [ + "--rename-manifest-package com.android.perftests.overlay5", + ] +} + +android_test_helper_app { + name: "Overlay6", + aaptflags: [ + "--rename-manifest-package com.android.perftests.overlay6", + ] +} + +android_test_helper_app { + name: "Overlay7", + aaptflags: [ + "--rename-manifest-package com.android.perftests.overlay7", + ] +} +android_test_helper_app { + name: "Overlay8", + aaptflags: [ + "--rename-manifest-package com.android.perftests.overlay8", + ] +} + +android_test_helper_app { + name: "Overlay9", + aaptflags: [ + "--rename-manifest-package com.android.perftests.overlay9", + ] +} + +android_test_helper_app { + name: "LargeOverlay0", + resource_dirs : [ "res_large" ], + aaptflags: [ + "--rename-manifest-package com.android.perftests.overlay.large0", + ] +} + +android_test_helper_app { + name: "LargeOverlay1", + resource_dirs : [ "res_large" ], + aaptflags: [ + "--rename-manifest-package com.android.perftests.overlay.large1", + ] +} + +android_test_helper_app { + name: "LargeOverlay2", + resource_dirs : [ "res_large" ], + aaptflags: [ + "--rename-manifest-package com.android.perftests.overlay.large2", + ] +} + +android_test_helper_app { + name: "LargeOverlay3", + resource_dirs : [ "res_large" ], + aaptflags: [ + "--rename-manifest-package com.android.perftests.overlay.large3", + ] +} + +android_test_helper_app { + name: "LargeOverlay4", + resource_dirs : [ "res_large" ], + aaptflags: [ + "--rename-manifest-package com.android.perftests.overlay.large4", + ] +} + +android_test_helper_app { + name: "LargeOverlay5", + resource_dirs : [ "res_large" ], + aaptflags: [ + "--rename-manifest-package com.android.perftests.overlay.large5", + ] +} + +android_test_helper_app { + name: "LargeOverlay6", + resource_dirs : [ "res_large" ], + aaptflags: [ + "--rename-manifest-package com.android.perftests.overlay.large6", + ] +} + +android_test_helper_app { + name: "LargeOverlay7", + resource_dirs : [ "res_large" ], + aaptflags: [ + "--rename-manifest-package com.android.perftests.overlay.large7", + ] +} + +android_test_helper_app { + name: "LargeOverlay8", + resource_dirs : [ "res_large" ], + aaptflags: [ + "--rename-manifest-package com.android.perftests.overlay.large8", + ] +} + +android_test_helper_app { + name: "LargeOverlay9", + resource_dirs : [ "res_large" ], + aaptflags: [ + "--rename-manifest-package com.android.perftests.overlay.large9", + ] +} + +java_library { + name: "apct-perftests-overlay-apps", + java_resources: [ + ":Overlay0", + ":Overlay1", + ":Overlay2", + ":Overlay3", + ":Overlay4", + ":Overlay5", + ":Overlay6", + ":Overlay7", + ":Overlay8", + ":Overlay9", + ":LargeOverlay0", + ":LargeOverlay1", + ":LargeOverlay2", + ":LargeOverlay3", + ":LargeOverlay4", + ":LargeOverlay5", + ":LargeOverlay6", + ":LargeOverlay7", + ":LargeOverlay8", + ":LargeOverlay9", + ], +}
\ No newline at end of file diff --git a/apct-tests/perftests/core/apps/overlay/AndroidManifest.xml b/apct-tests/perftests/core/apps/overlay/AndroidManifest.xml new file mode 100644 index 000000000000..52f5a89bc9e4 --- /dev/null +++ b/apct-tests/perftests/core/apps/overlay/AndroidManifest.xml @@ -0,0 +1,21 @@ +<?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. +--> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.perftests.overlay"> + <application android:hasCode="false" /> + <uses-sdk android:targetSdkVersion="29" /> + <overlay android:targetPackage="com.android.perftests.core" android:targetName="TestResources"/> +</manifest>
\ No newline at end of file diff --git a/apct-tests/perftests/core/apps/overlay/res/values/values.xml b/apct-tests/perftests/core/apps/overlay/res/values/values.xml new file mode 100644 index 000000000000..a1a8d83eb193 --- /dev/null +++ b/apct-tests/perftests/core/apps/overlay/res/values/values.xml @@ -0,0 +1,19 @@ +<?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. +--> + +<resources> + <string name="short_text">B</string> +</resources> diff --git a/apct-tests/perftests/core/apps/overlay/res_large/values/values.xml b/apct-tests/perftests/core/apps/overlay/res_large/values/values.xml new file mode 100644 index 000000000000..e74144648e32 --- /dev/null +++ b/apct-tests/perftests/core/apps/overlay/res_large/values/values.xml @@ -0,0 +1,274 @@ +<?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. +--> + +<resources> + <string name="short_text000">B</string> + <string name="short_text001">B</string> + <string name="short_text002">B</string> + <string name="short_text003">B</string> + <string name="short_text004">B</string> + <string name="short_text005">B</string> + <string name="short_text006">B</string> + <string name="short_text007">B</string> + <string name="short_text008">B</string> + <string name="short_text009">B</string> + <string name="short_text010">B</string> + <string name="short_text011">B</string> + <string name="short_text012">B</string> + <string name="short_text013">B</string> + <string name="short_text014">B</string> + <string name="short_text015">B</string> + <string name="short_text016">B</string> + <string name="short_text017">B</string> + <string name="short_text018">B</string> + <string name="short_text019">B</string> + <string name="short_text020">B</string> + <string name="short_text021">B</string> + <string name="short_text022">B</string> + <string name="short_text023">B</string> + <string name="short_text024">B</string> + <string name="short_text025">B</string> + <string name="short_text026">B</string> + <string name="short_text027">B</string> + <string name="short_text028">B</string> + <string name="short_text029">B</string> + <string name="short_text030">B</string> + <string name="short_text031">B</string> + <string name="short_text032">B</string> + <string name="short_text033">B</string> + <string name="short_text034">B</string> + <string name="short_text035">B</string> + <string name="short_text036">B</string> + <string name="short_text037">B</string> + <string name="short_text038">B</string> + <string name="short_text039">B</string> + <string name="short_text040">B</string> + <string name="short_text041">B</string> + <string name="short_text042">B</string> + <string name="short_text043">B</string> + <string name="short_text044">B</string> + <string name="short_text045">B</string> + <string name="short_text046">B</string> + <string name="short_text047">B</string> + <string name="short_text048">B</string> + <string name="short_text049">B</string> + <string name="short_text050">B</string> + <string name="short_text051">B</string> + <string name="short_text052">B</string> + <string name="short_text053">B</string> + <string name="short_text054">B</string> + <string name="short_text055">B</string> + <string name="short_text056">B</string> + <string name="short_text057">B</string> + <string name="short_text058">B</string> + <string name="short_text059">B</string> + <string name="short_text060">B</string> + <string name="short_text061">B</string> + <string name="short_text062">B</string> + <string name="short_text063">B</string> + <string name="short_text064">B</string> + <string name="short_text065">B</string> + <string name="short_text066">B</string> + <string name="short_text067">B</string> + <string name="short_text068">B</string> + <string name="short_text069">B</string> + <string name="short_text070">B</string> + <string name="short_text071">B</string> + <string name="short_text072">B</string> + <string name="short_text073">B</string> + <string name="short_text074">B</string> + <string name="short_text075">B</string> + <string name="short_text076">B</string> + <string name="short_text077">B</string> + <string name="short_text078">B</string> + <string name="short_text079">B</string> + <string name="short_text080">B</string> + <string name="short_text081">B</string> + <string name="short_text082">B</string> + <string name="short_text083">B</string> + <string name="short_text084">B</string> + <string name="short_text085">B</string> + <string name="short_text086">B</string> + <string name="short_text087">B</string> + <string name="short_text088">B</string> + <string name="short_text089">B</string> + <string name="short_text090">B</string> + <string name="short_text091">B</string> + <string name="short_text092">B</string> + <string name="short_text093">B</string> + <string name="short_text094">B</string> + <string name="short_text095">B</string> + <string name="short_text096">B</string> + <string name="short_text097">B</string> + <string name="short_text098">B</string> + <string name="short_text099">B</string> + <string name="short_text100">B</string> + <string name="short_text101">B</string> + <string name="short_text102">B</string> + <string name="short_text103">B</string> + <string name="short_text104">B</string> + <string name="short_text105">B</string> + <string name="short_text106">B</string> + <string name="short_text107">B</string> + <string name="short_text108">B</string> + <string name="short_text109">B</string> + <string name="short_text110">B</string> + <string name="short_text111">B</string> + <string name="short_text112">B</string> + <string name="short_text113">B</string> + <string name="short_text114">B</string> + <string name="short_text115">B</string> + <string name="short_text116">B</string> + <string name="short_text117">B</string> + <string name="short_text118">B</string> + <string name="short_text119">B</string> + <string name="short_text120">B</string> + <string name="short_text121">B</string> + <string name="short_text122">B</string> + <string name="short_text123">B</string> + <string name="short_text124">B</string> + <string name="short_text125">B</string> + <string name="short_text126">B</string> + <string name="short_text127">B</string> + <string name="short_text128">B</string> + <string name="short_text129">B</string> + <string name="short_text130">B</string> + <string name="short_text131">B</string> + <string name="short_text132">B</string> + <string name="short_text133">B</string> + <string name="short_text134">B</string> + <string name="short_text135">B</string> + <string name="short_text136">B</string> + <string name="short_text137">B</string> + <string name="short_text138">B</string> + <string name="short_text139">B</string> + <string name="short_text140">B</string> + <string name="short_text141">B</string> + <string name="short_text142">B</string> + <string name="short_text143">B</string> + <string name="short_text144">B</string> + <string name="short_text145">B</string> + <string name="short_text146">B</string> + <string name="short_text147">B</string> + <string name="short_text148">B</string> + <string name="short_text149">B</string> + <string name="short_text150">B</string> + <string name="short_text151">B</string> + <string name="short_text152">B</string> + <string name="short_text153">B</string> + <string name="short_text154">B</string> + <string name="short_text155">B</string> + <string name="short_text156">B</string> + <string name="short_text157">B</string> + <string name="short_text158">B</string> + <string name="short_text159">B</string> + <string name="short_text160">B</string> + <string name="short_text161">B</string> + <string name="short_text162">B</string> + <string name="short_text163">B</string> + <string name="short_text164">B</string> + <string name="short_text165">B</string> + <string name="short_text166">B</string> + <string name="short_text167">B</string> + <string name="short_text168">B</string> + <string name="short_text169">B</string> + <string name="short_text170">B</string> + <string name="short_text171">B</string> + <string name="short_text172">B</string> + <string name="short_text173">B</string> + <string name="short_text174">B</string> + <string name="short_text175">B</string> + <string name="short_text176">B</string> + <string name="short_text177">B</string> + <string name="short_text178">B</string> + <string name="short_text179">B</string> + <string name="short_text180">B</string> + <string name="short_text181">B</string> + <string name="short_text182">B</string> + <string name="short_text183">B</string> + <string name="short_text184">B</string> + <string name="short_text185">B</string> + <string name="short_text186">B</string> + <string name="short_text187">B</string> + <string name="short_text188">B</string> + <string name="short_text189">B</string> + <string name="short_text190">B</string> + <string name="short_text191">B</string> + <string name="short_text192">B</string> + <string name="short_text193">B</string> + <string name="short_text194">B</string> + <string name="short_text195">B</string> + <string name="short_text196">B</string> + <string name="short_text197">B</string> + <string name="short_text198">B</string> + <string name="short_text199">B</string> + <string name="short_text200">B</string> + <string name="short_text201">B</string> + <string name="short_text202">B</string> + <string name="short_text203">B</string> + <string name="short_text204">B</string> + <string name="short_text205">B</string> + <string name="short_text206">B</string> + <string name="short_text207">B</string> + <string name="short_text208">B</string> + <string name="short_text209">B</string> + <string name="short_text210">B</string> + <string name="short_text211">B</string> + <string name="short_text212">B</string> + <string name="short_text213">B</string> + <string name="short_text214">B</string> + <string name="short_text215">B</string> + <string name="short_text216">B</string> + <string name="short_text217">B</string> + <string name="short_text218">B</string> + <string name="short_text219">B</string> + <string name="short_text220">B</string> + <string name="short_text221">B</string> + <string name="short_text222">B</string> + <string name="short_text223">B</string> + <string name="short_text224">B</string> + <string name="short_text225">B</string> + <string name="short_text226">B</string> + <string name="short_text227">B</string> + <string name="short_text228">B</string> + <string name="short_text229">B</string> + <string name="short_text230">B</string> + <string name="short_text231">B</string> + <string name="short_text232">B</string> + <string name="short_text233">B</string> + <string name="short_text234">B</string> + <string name="short_text235">B</string> + <string name="short_text236">B</string> + <string name="short_text237">B</string> + <string name="short_text238">B</string> + <string name="short_text239">B</string> + <string name="short_text240">B</string> + <string name="short_text241">B</string> + <string name="short_text242">B</string> + <string name="short_text243">B</string> + <string name="short_text244">B</string> + <string name="short_text245">B</string> + <string name="short_text246">B</string> + <string name="short_text247">B</string> + <string name="short_text248">B</string> + <string name="short_text249">B</string> + <string name="short_text250">B</string> + <string name="short_text251">B</string> + <string name="short_text252">B</string> + <string name="short_text253">B</string> + <string name="short_text254">B</string> + <string name="short_text255">B</string> +</resources> diff --git a/apct-tests/perftests/core/apps/reources_manager/Android.bp b/apct-tests/perftests/core/apps/reources_manager/Android.bp new file mode 100644 index 000000000000..451613236140 --- /dev/null +++ b/apct-tests/perftests/core/apps/reources_manager/Android.bp @@ -0,0 +1,34 @@ +// 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. + +android_test_helper_app { + name: "LargeResourcesCompressed", + static_libs: [ "androidx.appcompat_appcompat" ], +} + +genrule { + name: "LargeResourcesUncompressed", + srcs: [ ":LargeResourcesCompressed" ], + out: ["LargeResourcesUncompressed.apk"], + cmd: "cp $(in) $(out) && unzip -o $(out) resources.arsc" + + " && zip $(out) resources.arsc" +} + +java_library { + name: "apct-perftests-resources-manager-apps", + java_resources: [ + ":LargeResourcesCompressed", + ":LargeResourcesUncompressed", + ], +}
\ No newline at end of file diff --git a/apct-tests/perftests/core/apps/reources_manager/AndroidManifest.xml b/apct-tests/perftests/core/apps/reources_manager/AndroidManifest.xml new file mode 100644 index 000000000000..adb4e406c608 --- /dev/null +++ b/apct-tests/perftests/core/apps/reources_manager/AndroidManifest.xml @@ -0,0 +1,20 @@ +<?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. +--> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="fake.android"> + <application android:hasCode="false" /> + <uses-sdk android:targetSdkVersion="29" /> +</manifest>
\ No newline at end of file diff --git a/apct-tests/perftests/core/res/color/color_state_list.xml b/apct-tests/perftests/core/res/color/color_state_list.xml new file mode 100644 index 000000000000..142e47ae2738 --- /dev/null +++ b/apct-tests/perftests/core/res/color/color_state_list.xml @@ -0,0 +1,25 @@ +<?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. +--> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_focused="true" + android:color="#000000" /> + <item android:state_pressed="true" + android:state_enabled="false" + android:color="#212121" /> + <item android:state_enabled="false" + android:color="#414141" /> + <item android:color="#616161" /> +</selector>
\ No newline at end of file diff --git a/apct-tests/perftests/core/res/values/overlayable.xml b/apct-tests/perftests/core/res/values/overlayable.xml new file mode 100644 index 000000000000..70cedd7b0b75 --- /dev/null +++ b/apct-tests/perftests/core/res/values/overlayable.xml @@ -0,0 +1,280 @@ +<?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 + --> + +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <overlayable name="TestResources"> + <policy type="public"> + <item type="string" name="short_text" /> + <item type="string" name="short_text000" /> + <item type="string" name="short_text001" /> + <item type="string" name="short_text002" /> + <item type="string" name="short_text003" /> + <item type="string" name="short_text004" /> + <item type="string" name="short_text005" /> + <item type="string" name="short_text006" /> + <item type="string" name="short_text007" /> + <item type="string" name="short_text008" /> + <item type="string" name="short_text009" /> + <item type="string" name="short_text010" /> + <item type="string" name="short_text011" /> + <item type="string" name="short_text012" /> + <item type="string" name="short_text013" /> + <item type="string" name="short_text014" /> + <item type="string" name="short_text015" /> + <item type="string" name="short_text016" /> + <item type="string" name="short_text017" /> + <item type="string" name="short_text018" /> + <item type="string" name="short_text019" /> + <item type="string" name="short_text020" /> + <item type="string" name="short_text021" /> + <item type="string" name="short_text022" /> + <item type="string" name="short_text023" /> + <item type="string" name="short_text024" /> + <item type="string" name="short_text025" /> + <item type="string" name="short_text026" /> + <item type="string" name="short_text027" /> + <item type="string" name="short_text028" /> + <item type="string" name="short_text029" /> + <item type="string" name="short_text030" /> + <item type="string" name="short_text031" /> + <item type="string" name="short_text032" /> + <item type="string" name="short_text033" /> + <item type="string" name="short_text034" /> + <item type="string" name="short_text035" /> + <item type="string" name="short_text036" /> + <item type="string" name="short_text037" /> + <item type="string" name="short_text038" /> + <item type="string" name="short_text039" /> + <item type="string" name="short_text040" /> + <item type="string" name="short_text041" /> + <item type="string" name="short_text042" /> + <item type="string" name="short_text043" /> + <item type="string" name="short_text044" /> + <item type="string" name="short_text045" /> + <item type="string" name="short_text046" /> + <item type="string" name="short_text047" /> + <item type="string" name="short_text048" /> + <item type="string" name="short_text049" /> + <item type="string" name="short_text050" /> + <item type="string" name="short_text051" /> + <item type="string" name="short_text052" /> + <item type="string" name="short_text053" /> + <item type="string" name="short_text054" /> + <item type="string" name="short_text055" /> + <item type="string" name="short_text056" /> + <item type="string" name="short_text057" /> + <item type="string" name="short_text058" /> + <item type="string" name="short_text059" /> + <item type="string" name="short_text060" /> + <item type="string" name="short_text061" /> + <item type="string" name="short_text062" /> + <item type="string" name="short_text063" /> + <item type="string" name="short_text064" /> + <item type="string" name="short_text065" /> + <item type="string" name="short_text066" /> + <item type="string" name="short_text067" /> + <item type="string" name="short_text068" /> + <item type="string" name="short_text069" /> + <item type="string" name="short_text070" /> + <item type="string" name="short_text071" /> + <item type="string" name="short_text072" /> + <item type="string" name="short_text073" /> + <item type="string" name="short_text074" /> + <item type="string" name="short_text075" /> + <item type="string" name="short_text076" /> + <item type="string" name="short_text077" /> + <item type="string" name="short_text078" /> + <item type="string" name="short_text079" /> + <item type="string" name="short_text080" /> + <item type="string" name="short_text081" /> + <item type="string" name="short_text082" /> + <item type="string" name="short_text083" /> + <item type="string" name="short_text084" /> + <item type="string" name="short_text085" /> + <item type="string" name="short_text086" /> + <item type="string" name="short_text087" /> + <item type="string" name="short_text088" /> + <item type="string" name="short_text089" /> + <item type="string" name="short_text090" /> + <item type="string" name="short_text091" /> + <item type="string" name="short_text092" /> + <item type="string" name="short_text093" /> + <item type="string" name="short_text094" /> + <item type="string" name="short_text095" /> + <item type="string" name="short_text096" /> + <item type="string" name="short_text097" /> + <item type="string" name="short_text098" /> + <item type="string" name="short_text099" /> + <item type="string" name="short_text100" /> + <item type="string" name="short_text101" /> + <item type="string" name="short_text102" /> + <item type="string" name="short_text103" /> + <item type="string" name="short_text104" /> + <item type="string" name="short_text105" /> + <item type="string" name="short_text106" /> + <item type="string" name="short_text107" /> + <item type="string" name="short_text108" /> + <item type="string" name="short_text109" /> + <item type="string" name="short_text110" /> + <item type="string" name="short_text111" /> + <item type="string" name="short_text112" /> + <item type="string" name="short_text113" /> + <item type="string" name="short_text114" /> + <item type="string" name="short_text115" /> + <item type="string" name="short_text116" /> + <item type="string" name="short_text117" /> + <item type="string" name="short_text118" /> + <item type="string" name="short_text119" /> + <item type="string" name="short_text120" /> + <item type="string" name="short_text121" /> + <item type="string" name="short_text122" /> + <item type="string" name="short_text123" /> + <item type="string" name="short_text124" /> + <item type="string" name="short_text125" /> + <item type="string" name="short_text126" /> + <item type="string" name="short_text127" /> + <item type="string" name="short_text128" /> + <item type="string" name="short_text129" /> + <item type="string" name="short_text130" /> + <item type="string" name="short_text131" /> + <item type="string" name="short_text132" /> + <item type="string" name="short_text133" /> + <item type="string" name="short_text134" /> + <item type="string" name="short_text135" /> + <item type="string" name="short_text136" /> + <item type="string" name="short_text137" /> + <item type="string" name="short_text138" /> + <item type="string" name="short_text139" /> + <item type="string" name="short_text140" /> + <item type="string" name="short_text141" /> + <item type="string" name="short_text142" /> + <item type="string" name="short_text143" /> + <item type="string" name="short_text144" /> + <item type="string" name="short_text145" /> + <item type="string" name="short_text146" /> + <item type="string" name="short_text147" /> + <item type="string" name="short_text148" /> + <item type="string" name="short_text149" /> + <item type="string" name="short_text150" /> + <item type="string" name="short_text151" /> + <item type="string" name="short_text152" /> + <item type="string" name="short_text153" /> + <item type="string" name="short_text154" /> + <item type="string" name="short_text155" /> + <item type="string" name="short_text156" /> + <item type="string" name="short_text157" /> + <item type="string" name="short_text158" /> + <item type="string" name="short_text159" /> + <item type="string" name="short_text160" /> + <item type="string" name="short_text161" /> + <item type="string" name="short_text162" /> + <item type="string" name="short_text163" /> + <item type="string" name="short_text164" /> + <item type="string" name="short_text165" /> + <item type="string" name="short_text166" /> + <item type="string" name="short_text167" /> + <item type="string" name="short_text168" /> + <item type="string" name="short_text169" /> + <item type="string" name="short_text170" /> + <item type="string" name="short_text171" /> + <item type="string" name="short_text172" /> + <item type="string" name="short_text173" /> + <item type="string" name="short_text174" /> + <item type="string" name="short_text175" /> + <item type="string" name="short_text176" /> + <item type="string" name="short_text177" /> + <item type="string" name="short_text178" /> + <item type="string" name="short_text179" /> + <item type="string" name="short_text180" /> + <item type="string" name="short_text181" /> + <item type="string" name="short_text182" /> + <item type="string" name="short_text183" /> + <item type="string" name="short_text184" /> + <item type="string" name="short_text185" /> + <item type="string" name="short_text186" /> + <item type="string" name="short_text187" /> + <item type="string" name="short_text188" /> + <item type="string" name="short_text189" /> + <item type="string" name="short_text190" /> + <item type="string" name="short_text191" /> + <item type="string" name="short_text192" /> + <item type="string" name="short_text193" /> + <item type="string" name="short_text194" /> + <item type="string" name="short_text195" /> + <item type="string" name="short_text196" /> + <item type="string" name="short_text197" /> + <item type="string" name="short_text198" /> + <item type="string" name="short_text199" /> + <item type="string" name="short_text200" /> + <item type="string" name="short_text201" /> + <item type="string" name="short_text202" /> + <item type="string" name="short_text203" /> + <item type="string" name="short_text204" /> + <item type="string" name="short_text205" /> + <item type="string" name="short_text206" /> + <item type="string" name="short_text207" /> + <item type="string" name="short_text208" /> + <item type="string" name="short_text209" /> + <item type="string" name="short_text210" /> + <item type="string" name="short_text211" /> + <item type="string" name="short_text212" /> + <item type="string" name="short_text213" /> + <item type="string" name="short_text214" /> + <item type="string" name="short_text215" /> + <item type="string" name="short_text216" /> + <item type="string" name="short_text217" /> + <item type="string" name="short_text218" /> + <item type="string" name="short_text219" /> + <item type="string" name="short_text220" /> + <item type="string" name="short_text221" /> + <item type="string" name="short_text222" /> + <item type="string" name="short_text223" /> + <item type="string" name="short_text224" /> + <item type="string" name="short_text225" /> + <item type="string" name="short_text226" /> + <item type="string" name="short_text227" /> + <item type="string" name="short_text228" /> + <item type="string" name="short_text229" /> + <item type="string" name="short_text230" /> + <item type="string" name="short_text231" /> + <item type="string" name="short_text232" /> + <item type="string" name="short_text233" /> + <item type="string" name="short_text234" /> + <item type="string" name="short_text235" /> + <item type="string" name="short_text236" /> + <item type="string" name="short_text237" /> + <item type="string" name="short_text238" /> + <item type="string" name="short_text239" /> + <item type="string" name="short_text240" /> + <item type="string" name="short_text241" /> + <item type="string" name="short_text242" /> + <item type="string" name="short_text243" /> + <item type="string" name="short_text244" /> + <item type="string" name="short_text245" /> + <item type="string" name="short_text246" /> + <item type="string" name="short_text247" /> + <item type="string" name="short_text248" /> + <item type="string" name="short_text249" /> + <item type="string" name="short_text250" /> + <item type="string" name="short_text251" /> + <item type="string" name="short_text252" /> + <item type="string" name="short_text253" /> + <item type="string" name="short_text254" /> + <item type="string" name="short_text255" /> + </policy> + </overlayable> +</resources> diff --git a/apct-tests/perftests/core/res/values/strings.xml b/apct-tests/perftests/core/res/values/strings.xml deleted file mode 100644 index 7ab325f79dc7..000000000000 --- a/apct-tests/perftests/core/res/values/strings.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - ~ Copyright (C) 2016 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 - --> - -<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="long_text">text text text text text text text text text text text text - text text text text text text text text text text text text text text text text - text text text text text text text text text text text text text text text text - text text text text text text text text text text text text text text text text - text text text text text text text text text text text text text text text text - text text text text text text text text text text text text text text text text - text text text text text text text typo text text text text text text text text - text text text text text text text text text text text text text text text text - text text text text text text text text text text text text text text text text - text text text text text text text text text text text text text text text text - text text text text text text text text text text text text text text text text - text text text text text text text text text text text text </string> - <string name="short_text">text text</string> -</resources> diff --git a/apct-tests/perftests/core/res/values/values.xml b/apct-tests/perftests/core/res/values/values.xml new file mode 100644 index 000000000000..aad42ba04e11 --- /dev/null +++ b/apct-tests/perftests/core/res/values/values.xml @@ -0,0 +1,368 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2016 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 + --> + +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="long_text">text text text text text text text text text text text text + text text text text text text text text text text text text text text text text + text text text text text text text text text text text text text text text text + text text text text text text text text text text text text text text text text + text text text text text text text text text text text text text text text text + text text text text text text text text text text text text text text text text + text text text text text text text typo text text text text text text text text + text text text text text text text text text text text text text text text text + text text text text text text text text text text text text text text text text + text text text text text text text text text text text text text text text text + text text text text text text text text text text text text text text text text + text text text text text text text text text text text text </string> + + <plurals name="plurals_text"> + <item quantity="one">1 text</item> + <item quantity="other"><xliff:g id="count" example="3">%d</xliff:g> texts</item> + </plurals> + + <string-array name="strings"> + <item>Run</item> + <item>the</item> + <item>performance</item> + <item>tests!</item> + <item>Run</item> + <item>the</item> + <item>performance</item> + <item>tests!</item> + <item>Run</item> + <item>the</item> + <item>performance</item> + <item>tests!</item> + <item>Run</item> + <item>the</item> + <item>performance</item> + <item>tests!</item> + <item>Run</item> + <item>the</item> + <item>performance</item> + <item>tests!</item> + <item>Run</item> + <item>the</item> + <item>performance</item> + <item>tests!</item> + <item>Run</item> + <item>the</item> + <item>performance</item> + <item>tests!</item> + <item>Run</item> + <item>the</item> + <item>performance</item> + <item>tests!</item> + </string-array> + + <integer-array name="ints"> + <item>0</item> + <item>1</item> + <item>2</item> + <item>3</item> + <item>0</item> + <item>1</item> + <item>2</item> + <item>3</item> + <item>0</item> + <item>1</item> + <item>2</item> + <item>3</item> + <item>0</item> + <item>1</item> + <item>2</item> + <item>3</item> + <item>0</item> + <item>1</item> + <item>2</item> + <item>3</item> + <item>0</item> + <item>1</item> + <item>2</item> + <item>3</item> + <item>0</item> + <item>1</item> + <item>2</item> + <item>3</item> + <item>0</item> + <item>1</item> + <item>2</item> + <item>3</item> + </integer-array> + + <color name="white">#ffffff</color> + + <integer name="forty_two">42</integer> + + <string name="short_text">text text</string> + <string name="short_text000">B</string> + <string name="short_text001">B</string> + <string name="short_text002">B</string> + <string name="short_text003">B</string> + <string name="short_text004">B</string> + <string name="short_text005">B</string> + <string name="short_text006">B</string> + <string name="short_text007">B</string> + <string name="short_text008">B</string> + <string name="short_text009">B</string> + <string name="short_text010">B</string> + <string name="short_text011">B</string> + <string name="short_text012">B</string> + <string name="short_text013">B</string> + <string name="short_text014">B</string> + <string name="short_text015">B</string> + <string name="short_text016">B</string> + <string name="short_text017">B</string> + <string name="short_text018">B</string> + <string name="short_text019">B</string> + <string name="short_text020">B</string> + <string name="short_text021">B</string> + <string name="short_text022">B</string> + <string name="short_text023">B</string> + <string name="short_text024">B</string> + <string name="short_text025">B</string> + <string name="short_text026">B</string> + <string name="short_text027">B</string> + <string name="short_text028">B</string> + <string name="short_text029">B</string> + <string name="short_text030">B</string> + <string name="short_text031">B</string> + <string name="short_text032">B</string> + <string name="short_text033">B</string> + <string name="short_text034">B</string> + <string name="short_text035">B</string> + <string name="short_text036">B</string> + <string name="short_text037">B</string> + <string name="short_text038">B</string> + <string name="short_text039">B</string> + <string name="short_text040">B</string> + <string name="short_text041">B</string> + <string name="short_text042">B</string> + <string name="short_text043">B</string> + <string name="short_text044">B</string> + <string name="short_text045">B</string> + <string name="short_text046">B</string> + <string name="short_text047">B</string> + <string name="short_text048">B</string> + <string name="short_text049">B</string> + <string name="short_text050">B</string> + <string name="short_text051">B</string> + <string name="short_text052">B</string> + <string name="short_text053">B</string> + <string name="short_text054">B</string> + <string name="short_text055">B</string> + <string name="short_text056">B</string> + <string name="short_text057">B</string> + <string name="short_text058">B</string> + <string name="short_text059">B</string> + <string name="short_text060">B</string> + <string name="short_text061">B</string> + <string name="short_text062">B</string> + <string name="short_text063">B</string> + <string name="short_text064">B</string> + <string name="short_text065">B</string> + <string name="short_text066">B</string> + <string name="short_text067">B</string> + <string name="short_text068">B</string> + <string name="short_text069">B</string> + <string name="short_text070">B</string> + <string name="short_text071">B</string> + <string name="short_text072">B</string> + <string name="short_text073">B</string> + <string name="short_text074">B</string> + <string name="short_text075">B</string> + <string name="short_text076">B</string> + <string name="short_text077">B</string> + <string name="short_text078">B</string> + <string name="short_text079">B</string> + <string name="short_text080">B</string> + <string name="short_text081">B</string> + <string name="short_text082">B</string> + <string name="short_text083">B</string> + <string name="short_text084">B</string> + <string name="short_text085">B</string> + <string name="short_text086">B</string> + <string name="short_text087">B</string> + <string name="short_text088">B</string> + <string name="short_text089">B</string> + <string name="short_text090">B</string> + <string name="short_text091">B</string> + <string name="short_text092">B</string> + <string name="short_text093">B</string> + <string name="short_text094">B</string> + <string name="short_text095">B</string> + <string name="short_text096">B</string> + <string name="short_text097">B</string> + <string name="short_text098">B</string> + <string name="short_text099">B</string> + <string name="short_text100">B</string> + <string name="short_text101">B</string> + <string name="short_text102">B</string> + <string name="short_text103">B</string> + <string name="short_text104">B</string> + <string name="short_text105">B</string> + <string name="short_text106">B</string> + <string name="short_text107">B</string> + <string name="short_text108">B</string> + <string name="short_text109">B</string> + <string name="short_text110">B</string> + <string name="short_text111">B</string> + <string name="short_text112">B</string> + <string name="short_text113">B</string> + <string name="short_text114">B</string> + <string name="short_text115">B</string> + <string name="short_text116">B</string> + <string name="short_text117">B</string> + <string name="short_text118">B</string> + <string name="short_text119">B</string> + <string name="short_text120">B</string> + <string name="short_text121">B</string> + <string name="short_text122">B</string> + <string name="short_text123">B</string> + <string name="short_text124">B</string> + <string name="short_text125">B</string> + <string name="short_text126">B</string> + <string name="short_text127">B</string> + <string name="short_text128">B</string> + <string name="short_text129">B</string> + <string name="short_text130">B</string> + <string name="short_text131">B</string> + <string name="short_text132">B</string> + <string name="short_text133">B</string> + <string name="short_text134">B</string> + <string name="short_text135">B</string> + <string name="short_text136">B</string> + <string name="short_text137">B</string> + <string name="short_text138">B</string> + <string name="short_text139">B</string> + <string name="short_text140">B</string> + <string name="short_text141">B</string> + <string name="short_text142">B</string> + <string name="short_text143">B</string> + <string name="short_text144">B</string> + <string name="short_text145">B</string> + <string name="short_text146">B</string> + <string name="short_text147">B</string> + <string name="short_text148">B</string> + <string name="short_text149">B</string> + <string name="short_text150">B</string> + <string name="short_text151">B</string> + <string name="short_text152">B</string> + <string name="short_text153">B</string> + <string name="short_text154">B</string> + <string name="short_text155">B</string> + <string name="short_text156">B</string> + <string name="short_text157">B</string> + <string name="short_text158">B</string> + <string name="short_text159">B</string> + <string name="short_text160">B</string> + <string name="short_text161">B</string> + <string name="short_text162">B</string> + <string name="short_text163">B</string> + <string name="short_text164">B</string> + <string name="short_text165">B</string> + <string name="short_text166">B</string> + <string name="short_text167">B</string> + <string name="short_text168">B</string> + <string name="short_text169">B</string> + <string name="short_text170">B</string> + <string name="short_text171">B</string> + <string name="short_text172">B</string> + <string name="short_text173">B</string> + <string name="short_text174">B</string> + <string name="short_text175">B</string> + <string name="short_text176">B</string> + <string name="short_text177">B</string> + <string name="short_text178">B</string> + <string name="short_text179">B</string> + <string name="short_text180">B</string> + <string name="short_text181">B</string> + <string name="short_text182">B</string> + <string name="short_text183">B</string> + <string name="short_text184">B</string> + <string name="short_text185">B</string> + <string name="short_text186">B</string> + <string name="short_text187">B</string> + <string name="short_text188">B</string> + <string name="short_text189">B</string> + <string name="short_text190">B</string> + <string name="short_text191">B</string> + <string name="short_text192">B</string> + <string name="short_text193">B</string> + <string name="short_text194">B</string> + <string name="short_text195">B</string> + <string name="short_text196">B</string> + <string name="short_text197">B</string> + <string name="short_text198">B</string> + <string name="short_text199">B</string> + <string name="short_text200">B</string> + <string name="short_text201">B</string> + <string name="short_text202">B</string> + <string name="short_text203">B</string> + <string name="short_text204">B</string> + <string name="short_text205">B</string> + <string name="short_text206">B</string> + <string name="short_text207">B</string> + <string name="short_text208">B</string> + <string name="short_text209">B</string> + <string name="short_text210">B</string> + <string name="short_text211">B</string> + <string name="short_text212">B</string> + <string name="short_text213">B</string> + <string name="short_text214">B</string> + <string name="short_text215">B</string> + <string name="short_text216">B</string> + <string name="short_text217">B</string> + <string name="short_text218">B</string> + <string name="short_text219">B</string> + <string name="short_text220">B</string> + <string name="short_text221">B</string> + <string name="short_text222">B</string> + <string name="short_text223">B</string> + <string name="short_text224">B</string> + <string name="short_text225">B</string> + <string name="short_text226">B</string> + <string name="short_text227">B</string> + <string name="short_text228">B</string> + <string name="short_text229">B</string> + <string name="short_text230">B</string> + <string name="short_text231">B</string> + <string name="short_text232">B</string> + <string name="short_text233">B</string> + <string name="short_text234">B</string> + <string name="short_text235">B</string> + <string name="short_text236">B</string> + <string name="short_text237">B</string> + <string name="short_text238">B</string> + <string name="short_text239">B</string> + <string name="short_text240">B</string> + <string name="short_text241">B</string> + <string name="short_text242">B</string> + <string name="short_text243">B</string> + <string name="short_text244">B</string> + <string name="short_text245">B</string> + <string name="short_text246">B</string> + <string name="short_text247">B</string> + <string name="short_text248">B</string> + <string name="short_text249">B</string> + <string name="short_text250">B</string> + <string name="short_text251">B</string> + <string name="short_text252">B</string> + <string name="short_text253">B</string> + <string name="short_text254">B</string> + <string name="short_text255">B</string> +</resources> diff --git a/apct-tests/perftests/core/src/android/app/OverlayManagerPerfTest.java b/apct-tests/perftests/core/src/android/app/OverlayManagerPerfTest.java new file mode 100644 index 000000000000..fcb13a8d51f1 --- /dev/null +++ b/apct-tests/perftests/core/src/android/app/OverlayManagerPerfTest.java @@ -0,0 +1,234 @@ +/* + * 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 android.app; + +import static org.junit.Assert.assertTrue; + +import android.content.Context; +import android.content.om.OverlayManager; +import android.os.UserHandle; +import android.perftests.utils.BenchmarkState; +import android.perftests.utils.PerfStatusReporter; +import android.perftests.utils.TestPackageInstaller; + +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.LargeTest; + +import com.android.perftests.core.R; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.concurrent.Executor; +import java.util.concurrent.FutureTask; +import java.util.concurrent.TimeUnit; + +/** + * Benchmarks for {@link android.content.om.OverlayManager}. + */ +@LargeTest +public class OverlayManagerPerfTest { + private static final int OVERLAY_PKG_COUNT = 10; + private static Context sContext; + private static OverlayManager sOverlayManager; + private static Executor sExecutor; + private static ArrayList<TestPackageInstaller.InstalledPackage> sSmallOverlays = + new ArrayList<>(); + private static ArrayList<TestPackageInstaller.InstalledPackage> sLargeOverlays = + new ArrayList<>(); + + @Rule + public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + + @BeforeClass + public static void classSetUp() throws Exception { + sContext = InstrumentationRegistry.getTargetContext(); + sOverlayManager = new OverlayManager(sContext); + sExecutor = (command) -> new Thread(command).start(); + + // Install all of the test overlays. + TestPackageInstaller installer = new TestPackageInstaller(sContext); + for (int i = 0; i < OVERLAY_PKG_COUNT; i++) { + sSmallOverlays.add(installer.installPackage("Overlay" + i +".apk")); + sLargeOverlays.add(installer.installPackage("LargeOverlay" + i +".apk")); + } + } + + @AfterClass + public static void classTearDown() throws Exception { + for (TestPackageInstaller.InstalledPackage overlay : sSmallOverlays) { + overlay.uninstall(); + } + + for (TestPackageInstaller.InstalledPackage overlay : sLargeOverlays) { + overlay.uninstall(); + } + } + + @After + public void tearDown() throws Exception { + // Disable all test overlays after each test. + for (TestPackageInstaller.InstalledPackage overlay : sSmallOverlays) { + assertSetEnabled(sContext, overlay.getPackageName(), false); + } + + for (TestPackageInstaller.InstalledPackage overlay : sLargeOverlays) { + assertSetEnabled(sContext, overlay.getPackageName(), false); + } + } + + /** + * Enables the overlay and waits for the APK path change sto be propagated to the context + * AssetManager. + */ + private void assertSetEnabled(Context context, String overlayPackage, boolean eanabled) + throws Exception { + sOverlayManager.setEnabled(overlayPackage, true, UserHandle.SYSTEM); + + // Wait for the overlay changes to propagate + FutureTask<Boolean> task = new FutureTask<>(() -> { + while (true) { + for (String path : context.getAssets().getApkPaths()) { + if (eanabled == path.contains(overlayPackage)) { + return true; + } + } + } + }); + + sExecutor.execute(task); + assertTrue("Failed to load overlay " + overlayPackage, + task.get(20, TimeUnit.SECONDS)); + } + + @Test + public void setEnabledWarmCache() throws Exception { + String packageName = sSmallOverlays.get(0).getPackageName(); + BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + assertSetEnabled(sContext, packageName, true); + + // Disable the overlay for the next iteration of the test + state.pauseTiming(); + assertSetEnabled(sContext, packageName, false); + state.resumeTiming(); + } + } + + @Test + public void setEnabledColdCacheSmallOverlay() throws Exception { + String packageName = sSmallOverlays.get(0).getPackageName(); + BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + assertSetEnabled(sContext, packageName, true); + + // Disable the overlay and remove the idmap for the next iteration of the test + state.pauseTiming(); + assertSetEnabled(sContext, packageName, false); + sOverlayManager.invalidateCachesForOverlay(packageName, UserHandle.SYSTEM); + state.resumeTiming(); + } + } + + @Test + public void setEnabledColdCacheLargeOverlay() throws Exception { + String packageName = sLargeOverlays.get(0).getPackageName(); + BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + assertSetEnabled(sContext, packageName, true); + + // Disable the overlay and remove the idmap for the next iteration of the test + state.pauseTiming(); + assertSetEnabled(sContext, packageName, false); + sOverlayManager.invalidateCachesForOverlay(packageName, UserHandle.SYSTEM); + state.resumeTiming(); + } + } + + @Test + public void setEnabledDisable() throws Exception { + String packageName = sSmallOverlays.get(0).getPackageName(); + BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + state.pauseTiming(); + assertSetEnabled(sContext, packageName, true); + state.resumeTiming(); + + assertSetEnabled(sContext, packageName, false); + } + } + + @Test + public void getStringOneSmallOverlay() throws Exception { + String packageName = sSmallOverlays.get(0).getPackageName(); + assertSetEnabled(sContext, packageName, true); + + BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + sContext.getString(R.string.short_text); + } + + assertSetEnabled(sContext, packageName, false); + } + + @Test + public void getStringOneLargeOverlay() throws Exception { + String packageName = sLargeOverlays.get(0).getPackageName(); + assertSetEnabled(sContext, packageName, true); + + BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + for (int resId = R.string.short_text000; resId < R.string.short_text255; resId++) { + sContext.getString(resId); + } + } + + assertSetEnabled(sContext, packageName, false); + } + + @Test + public void getStringTenOverlays() throws Exception { + // Enable all test overlays + for (TestPackageInstaller.InstalledPackage overlay : sSmallOverlays) { + assertSetEnabled(sContext, overlay.getPackageName(), true); + } + + BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + sContext.getString(R.string.short_text); + } + } + + @Test + public void getStringLargeTenOverlays() throws Exception { + // Enable all test overlays + for (TestPackageInstaller.InstalledPackage overlay : sLargeOverlays) { + assertSetEnabled(sContext, overlay.getPackageName(), true); + } + + BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + for (int resId = R.string.short_text000; resId < R.string.short_text255; resId++) { + sContext.getString(resId); + } + } + } +} diff --git a/apct-tests/perftests/core/src/android/app/ResourcesManagerPerfTest.java b/apct-tests/perftests/core/src/android/app/ResourcesManagerPerfTest.java new file mode 100644 index 000000000000..2955d2ca7d0e --- /dev/null +++ b/apct-tests/perftests/core/src/android/app/ResourcesManagerPerfTest.java @@ -0,0 +1,139 @@ +/* + * 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 android.app; + +import android.content.Context; +import android.content.res.Configuration; +import android.content.res.Resources; +import android.perftests.utils.BenchmarkState; +import android.perftests.utils.PerfStatusReporter; +import android.view.Display; + +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.LargeTest; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; + +/** + * Benchmarks for {@link android.app.ResourcesManager}. + */ +@LargeTest +public class ResourcesManagerPerfTest { + private static Context sContext; + private static File sResourcesCompressed; + private static File sResourcesUncompressed; + + @Rule + public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + + @BeforeClass + public static void setUp() throws Exception { + sContext = InstrumentationRegistry.getTargetContext(); + sResourcesCompressed = copyApkToTemp("LargeResourcesCompressed.apk", + "LargeResourcesCompressed.apk"); + sResourcesUncompressed = copyApkToTemp("LargeResourcesUncompressed.apk", + "LargeResourcesUncompressed.apk"); + } + + @AfterClass + public static void tearDown() { + Assert.assertTrue(sResourcesCompressed.delete()); + Assert.assertTrue(sResourcesUncompressed.delete()); + } + + private static File copyApkToTemp(String inputFileName, String fileName) throws Exception { + File file = File.createTempFile(fileName, null, sContext.getCacheDir()); + try (OutputStream tempOutputStream = new FileOutputStream(file); + InputStream is = sContext.getResources().getAssets().openNonAsset(inputFileName)) { + byte[] buffer = new byte[4096]; + int n; + while ((n = is.read(buffer)) >= 0) { + tempOutputStream.write(buffer, 0, n); + } + tempOutputStream.flush(); + } + return file; + } + + private void getResourcesForPath(String path) { + ResourcesManager.getInstance().getResources(null, path, null, null, null, + Display.DEFAULT_DISPLAY, null, sContext.getResources().getCompatibilityInfo(), + null); + } + + @Test + public void getResourcesCached() { + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + getResourcesForPath(sResourcesCompressed.getPath()); + while (state.keepRunning()) { + getResourcesForPath(sResourcesCompressed.getPath()); + } + } + + @Test + public void getResourcesCompressedUncached() { + ResourcesManager resourcesManager = ResourcesManager.getInstance(); + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + state.pauseTiming(); + resourcesManager.invalidatePath(sResourcesCompressed.getPath()); + state.resumeTiming(); + + getResourcesForPath(sResourcesCompressed.getPath()); + } + } + + @Test + public void getResourcesUncompressedUncached() { + ResourcesManager resourcesManager = ResourcesManager.getInstance(); + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + state.pauseTiming(); + resourcesManager.invalidatePath(sResourcesUncompressed.getPath()); + state.resumeTiming(); + + getResourcesForPath(sResourcesUncompressed.getPath()); + } + } + + @Test + public void applyConfigurationToResourcesLocked() { + ResourcesManager resourcesManager = ResourcesManager.getInstance(); + Configuration c = new Configuration(resourcesManager.getConfiguration()); + c.uiMode = Configuration.UI_MODE_TYPE_WATCH; + + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + resourcesManager.applyConfigurationToResources(c, null); + + // Alternate configurations to ensure the set configuration is different each iteration + if (c.uiMode == Configuration.UI_MODE_TYPE_WATCH) { + c.uiMode = Configuration.UI_MODE_TYPE_TELEVISION; + } else { + c.uiMode = Configuration.UI_MODE_TYPE_WATCH; + } + } + } +} diff --git a/apct-tests/perftests/core/src/android/app/ResourcesPerfTest.java b/apct-tests/perftests/core/src/android/app/ResourcesPerfTest.java index c3e43ee07453..72162448a2e0 100644 --- a/apct-tests/perftests/core/src/android/app/ResourcesPerfTest.java +++ b/apct-tests/perftests/core/src/android/app/ResourcesPerfTest.java @@ -18,15 +18,18 @@ package android.app; import static org.junit.Assert.fail; -import android.content.res.AssetManager; +import android.content.Context; import android.content.res.Resources; import android.content.res.XmlResourceParser; import android.perftests.utils.BenchmarkState; import android.perftests.utils.PerfStatusReporter; +import android.util.TypedValue; +import androidx.test.InstrumentationRegistry; import androidx.test.filters.LargeTest; -import org.junit.After; +import com.android.perftests.core.R; + import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -43,36 +46,123 @@ public class ResourcesPerfTest { @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); - private AssetManager mAsset; private Resources mRes; - private int mTextId; - private int mColorId; - private int mIntegerId; - private int mLayoutId; - @Before public void setUp() { - mAsset = new AssetManager(); - mAsset.addAssetPath("/system/framework/framework-res.apk"); - mRes = new Resources(mAsset, null, null); + Context context = InstrumentationRegistry.getTargetContext(); + mRes = context.getResources(); + } + + @Test + public void getValue() { + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + TypedValue value = new TypedValue(); + while (state.keepRunning()) { + mRes.getValue(R.integer.forty_two, value, false /* resolve_refs */); + } + } - mTextId = mRes.getIdentifier("cancel", "string", "android"); - mColorId = mRes.getIdentifier("transparent", "color", "android"); - mIntegerId = mRes.getIdentifier("config_shortAnimTime", "integer", "android"); - mLayoutId = mRes.getIdentifier("two_line_list_item", "layout", "android"); + @Test + public void getFrameworkValue() { + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + TypedValue value = new TypedValue(); + while (state.keepRunning()) { + mRes.getValue(com.android.internal.R.integer.autofill_max_visible_datasets, value, + false /* resolve_refs */); + } + } + + @Test + public void getValueString() { + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + TypedValue value = new TypedValue(); + while (state.keepRunning()) { + mRes.getValue(R.string.long_text, value, false /* resolve_refs */); + } + } + + @Test + public void getFrameworkStringValue() { + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + TypedValue value = new TypedValue(); + while (state.keepRunning()) { + mRes.getValue(com.android.internal.R.string.cancel, value, false /* resolve_refs */); + } } - @After - public void tearDown() { - mAsset.close(); + @Test + public void getValueManyConfigurations() { + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + TypedValue value = new TypedValue(); + while (state.keepRunning()) { + mRes.getValue(com.android.internal.R.string.mmcc_illegal_me, value, + false /* resolve_refs */); + } } @Test public void getText() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { - mRes.getText(mTextId); + mRes.getText(R.string.long_text); + } + } + + + @Test + public void getFont() { + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + mRes.getFont(R.font.samplefont); + } + } + + @Test + public void getString() { + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + mRes.getString(R.string.long_text); + } + } + + @Test + public void getQuantityString() { + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + mRes.getQuantityString(R.plurals.plurals_text, 5); + } + } + + @Test + public void getQuantityText() { + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + mRes.getQuantityText(R.plurals.plurals_text, 5); + } + } + + @Test + public void getTextArray() { + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + mRes.getTextArray(R.array.strings); + } + } + + @Test + public void getStringArray() { + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + mRes.getStringArray(R.array.strings); + } + } + + @Test + public void getIntegerArray() { + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + mRes.getIntArray(R.array.ints); } } @@ -80,15 +170,23 @@ public class ResourcesPerfTest { public void getColor() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { - mRes.getColor(mColorId, null); + mRes.getColor(R.color.white, null); } } @Test - public void getInteger() { + public void getColorStateList() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { - mRes.getInteger(mIntegerId); + mRes.getColorStateList(R.color.color_state_list, null); + } + } + + @Test + public void getVectorDrawable() { + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + mRes.getDrawable(R.drawable.vector_drawable01, null); } } @@ -96,13 +194,32 @@ public class ResourcesPerfTest { public void getLayoutAndTravese() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { - try (XmlResourceParser parser = mRes.getLayout(mLayoutId)) { + try (XmlResourceParser parser = mRes.getLayout(R.layout.test_relative_layout)) { + while (parser.next() != XmlPullParser.END_DOCUMENT) { + // Walk the entire tree + } + } catch (IOException | XmlPullParserException exception) { + fail("Parsing of the layout failed. Something is really broken"); + } + } + } + + @Test + public void getLayoutAndTraverseInvalidateCaches() { + mRes.flushLayoutCache(); + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + try (XmlResourceParser parser = mRes.getLayout(R.layout.test_relative_layout)) { while (parser.next() != XmlPullParser.END_DOCUMENT) { // Walk the entire tree } } catch (IOException | XmlPullParserException exception) { fail("Parsing of the layout failed. Something is really broken"); } + + state.pauseTiming(); + mRes.flushLayoutCache(); + state.resumeTiming(); } } -} +}
\ No newline at end of file diff --git a/apct-tests/perftests/core/src/android/app/ResourcesThemePerfTest.java b/apct-tests/perftests/core/src/android/app/ResourcesThemePerfTest.java index 1b07572fd3f8..6123e69b584e 100644 --- a/apct-tests/perftests/core/src/android/app/ResourcesThemePerfTest.java +++ b/apct-tests/perftests/core/src/android/app/ResourcesThemePerfTest.java @@ -16,13 +16,19 @@ package android.app; import android.content.Context; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.content.res.Configuration; import android.content.res.Resources; +import android.os.UserHandle; import android.perftests.utils.BenchmarkState; import android.perftests.utils.PerfStatusReporter; +import android.view.Display; import androidx.test.InstrumentationRegistry; import androidx.test.filters.LargeTest; +import org.junit.Assert; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -35,13 +41,69 @@ public class ResourcesThemePerfTest { @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); + private Context mContext; + private int mThemeResId; private Resources.Theme mTheme; @Before - public void setUp() { - Context context = InstrumentationRegistry.getTargetContext(); - mTheme = context.getTheme(); + public void setUp() throws Exception { + mContext = InstrumentationRegistry.getTargetContext(); + mThemeResId = com.android.perftests.core.R.style.Base_V7_Theme_AppCompat; + mTheme = mContext.getResources().newTheme(); + mTheme.applyStyle(mThemeResId, true /* force */); + } + + @Test + public void applyStyle() { + Resources.Theme destTheme = mContext.getResources().newTheme(); + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + destTheme.applyStyle(mThemeResId, true /* force */); + } + } + @Test + public void rebase() { + Resources.Theme destTheme = mContext.getResources().newTheme(); + destTheme.applyStyle(mThemeResId, true /* force */); + destTheme.applyStyle(android.R.style.Theme_Material, true /* force */); + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + destTheme.rebase(); + } + } + + @Test + public void setToSameAssetManager() { + Resources.Theme destTheme = mContext.getResources().newTheme(); + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + destTheme.setTo(mTheme); + } + } + + @Test + public void setToDifferentAssetManager() throws Exception { + // Create a new Resources object with the same asset paths but a different AssetManager + PackageManager packageManager = mContext.getApplicationContext().getPackageManager(); + ApplicationInfo ai = packageManager.getApplicationInfo(mContext.getPackageName(), + UserHandle.myUserId()); + + ResourcesManager resourcesManager = ResourcesManager.getInstance(); + Configuration c = resourcesManager.getConfiguration(); + c.orientation = (c.orientation == Configuration.ORIENTATION_PORTRAIT) + ? Configuration.ORIENTATION_LANDSCAPE : Configuration.ORIENTATION_PORTRAIT; + + Resources destResources = resourcesManager.getResources(null, ai.sourceDir, + ai.splitSourceDirs, ai.resourceDirs, ai.sharedLibraryFiles, Display.DEFAULT_DISPLAY, + c, mContext.getResources().getCompatibilityInfo(), null); + Assert.assertNotEquals(destResources.getAssets(), mContext.getAssets()); + + Resources.Theme destTheme = destResources.newTheme(); + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + while (state.keepRunning()) { + destTheme.setTo(mTheme); + } } @Test @@ -51,5 +113,4 @@ public class ResourcesThemePerfTest { mTheme.obtainStyledAttributes(android.R.style.Theme_Material, android.R.styleable.View); } } - -} +}
\ No newline at end of file diff --git a/apct-tests/perftests/utils/src/android/perftests/utils/TestPackageInstaller.java b/apct-tests/perftests/utils/src/android/perftests/utils/TestPackageInstaller.java new file mode 100644 index 000000000000..a433d801acaf --- /dev/null +++ b/apct-tests/perftests/utils/src/android/perftests/utils/TestPackageInstaller.java @@ -0,0 +1,145 @@ +/* + * 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 android.perftests.utils; + +import android.app.PendingIntent; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.IntentSender; +import android.content.pm.PackageInstaller; +import android.content.res.Resources; +import android.util.Log; + +import org.junit.Assert; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; + +/** + * Installs packages included within the assets directory. + */ +public class TestPackageInstaller { + private static final String LOG_TAG = "TestPackageInstaller"; + private static final String BROADCAST_ACTION = + "com.android.perftests.core.ACTION_INSTALL_COMMIT"; + + private final Context mContext; + public TestPackageInstaller(Context context) { + mContext = context; + } + + + + /** + * Installs an APK located at the specified path in the assets directory. + **/ + public InstalledPackage installPackage(String resourceName) throws IOException, + InterruptedException { + Log.d(LOG_TAG, "Installing resource APK '" + resourceName + "'"); + LocalBroadcastReceiver intentSender = new LocalBroadcastReceiver(mContext); + + // Initialize the package install session. + PackageInstaller packageInstaller = mContext.getPackageManager().getPackageInstaller(); + PackageInstaller.SessionParams params = new PackageInstaller.SessionParams( + PackageInstaller.SessionParams.MODE_FULL_INSTALL); + params.setInstallAsInstantApp(false); + int sessionId = packageInstaller.createSession(params); + PackageInstaller.Session session = packageInstaller.openSession(sessionId); + + // Copy the apk to the install session. + try (OutputStream os = session.openWrite("TestPackageInstaller", 0, -1); + InputStream is = mContext.getResources().getAssets().openNonAsset(resourceName)) { + if (is == null) { + throw new IOException("Resource " + resourceName + " not found"); + } + byte[] buffer = new byte[4096]; + int n; + while ((n = is.read(buffer)) >= 0) { + os.write(buffer, 0, n); + } + } + + session.commit(intentSender.getIntentSender(sessionId)); + session.close(); + + // Retrieve the results of the installation. + Intent intent = intentSender.getIntentSenderResult(); + int status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, + PackageInstaller.STATUS_FAILURE); + Assert.assertEquals(PackageInstaller.STATUS_SUCCESS, status); + String packageName = intent.getStringExtra(PackageInstaller.EXTRA_PACKAGE_NAME); + return new InstalledPackage(sessionId, packageName); + } + + public class InstalledPackage { + private int mSessionId; + private String mPackageName; + + private InstalledPackage(int sessionId, String packageName) { + mSessionId = sessionId; + mPackageName = packageName; + } + + public String getPackageName() { + return mPackageName; + } + + public void uninstall() throws Exception { + Log.d(LOG_TAG, "Uninstalling package '" + mPackageName + "'"); + LocalBroadcastReceiver intentSender = new LocalBroadcastReceiver(mContext); + PackageInstaller packageInstaller = mContext.getPackageManager().getPackageInstaller(); + packageInstaller.uninstall(mPackageName, intentSender.getIntentSender(mSessionId)); + int status = intentSender.getIntentSenderResult() + .getIntExtra(PackageInstaller.EXTRA_STATUS, PackageInstaller.STATUS_FAILURE); + Assert.assertEquals(PackageInstaller.STATUS_SUCCESS, status); + } + } + + private class LocalBroadcastReceiver extends BroadcastReceiver { + private final BlockingQueue<Intent> mIntentSenderResults = new LinkedBlockingQueue<>(); + private final Context mContext; + + private LocalBroadcastReceiver(Context context) { + mContext = context; + } + + @Override + public void onReceive(Context context, Intent intent) { + mIntentSenderResults.add(intent); + } + + IntentSender getIntentSender(int sessionId) { + String action = BROADCAST_ACTION + "." + sessionId; + IntentFilter filter = new IntentFilter(action); + mContext.registerReceiver(this, filter); + + Intent intent = new Intent(action); + PendingIntent pending = PendingIntent.getBroadcast(mContext, sessionId, intent, + PendingIntent.FLAG_UPDATE_CURRENT); + return pending.getIntentSender(); + } + + Intent getIntentSenderResult() throws InterruptedException { + return mIntentSenderResults.take(); + } + } +} diff --git a/core/java/android/app/ResourcesManager.java b/core/java/android/app/ResourcesManager.java index 40cb29fc80ab..cb9ebac728ec 100644 --- a/core/java/android/app/ResourcesManager.java +++ b/core/java/android/app/ResourcesManager.java @@ -20,6 +20,7 @@ import static android.app.ActivityThread.DEBUG_CONFIGURATION; import android.annotation.NonNull; import android.annotation.Nullable; +import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; @@ -191,6 +192,17 @@ public class ResourcesManager { } } Log.i(TAG, "Invalidated " + count + " asset managers that referenced " + path); + + for (int i = mCachedApkAssets.size() - 1; i >= 0; i--) { + final ApkKey key = mCachedApkAssets.keyAt(i); + if (key.path.equals(path)) { + WeakReference<ApkAssets> apkAssetsRef = mCachedApkAssets.remove(key); + if (apkAssetsRef != null && apkAssetsRef.get() != null) { + apkAssetsRef.get().close(); + } + mCachedApkAssets.remove(key); + } + } } } @@ -1000,6 +1012,14 @@ public class ResourcesManager { } } + @TestApi + public final boolean applyConfigurationToResources(@NonNull Configuration config, + @Nullable CompatibilityInfo compat) { + synchronized(this) { + return applyConfigurationToResourcesLocked(config, compat); + } + } + public final boolean applyConfigurationToResourcesLocked(@NonNull Configuration config, @Nullable CompatibilityInfo compat) { try { diff --git a/core/java/android/content/om/IOverlayManager.aidl b/core/java/android/content/om/IOverlayManager.aidl index 43a4fe5bc414..3d7e3befd9f1 100644 --- a/core/java/android/content/om/IOverlayManager.aidl +++ b/core/java/android/content/om/IOverlayManager.aidl @@ -157,4 +157,10 @@ interface IOverlayManager { * Returns the list of default overlay packages, or an empty array if there are none. */ String[] getDefaultOverlayPackages(); + + /** + * Invalidates and removes the idmap for an overlay, + * @param packageName The name of the overlay package whose idmap should be deleted. + */ + void invalidateCachesForOverlay(in String packageName, in int userIs); } diff --git a/core/java/android/content/om/OverlayManager.java b/core/java/android/content/om/OverlayManager.java index f2716fedc186..853e8189ea8a 100644 --- a/core/java/android/content/om/OverlayManager.java +++ b/core/java/android/content/om/OverlayManager.java @@ -21,6 +21,7 @@ import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.SystemApi; import android.annotation.SystemService; +import android.annotation.TestApi; import android.content.Context; import android.os.RemoteException; import android.os.ServiceManager; @@ -163,4 +164,28 @@ public class OverlayManager { throw e.rethrowFromSystemServer(); } } + + /** + * Returns information about all overlays for the given target package for + * the specified user. The returned list is ordered according to the + * overlay priority with the highest priority at the end of the list. + * + * @param targetPackageName The name of the target package. + * @param user The user to get the OverlayInfos for. + * + * @hide + */ + @TestApi + @RequiresPermission(anyOf = { + "android.permission.INTERACT_ACROSS_USERS", + }) + @NonNull + public void invalidateCachesForOverlay(@NonNull final String targetPackageName, + @NonNull UserHandle user) { + try { + mService.invalidateCachesForOverlay(targetPackageName, user.getIdentifier()); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } } diff --git a/core/java/android/content/res/ApkAssets.java b/core/java/android/content/res/ApkAssets.java index 69462ab99483..a35ad567ed81 100644 --- a/core/java/android/content/res/ApkAssets.java +++ b/core/java/android/content/res/ApkAssets.java @@ -188,7 +188,7 @@ public final class ApkAssets { /** * Closes this class and the contained {@link #mStringBlock}. */ - public void close() throws Throwable { + public void close() { synchronized (this) { if (mOpen) { mOpen = false; diff --git a/core/java/android/content/res/StringBlock.java b/core/java/android/content/res/StringBlock.java index b7bc8229fa45..2ae1932c3437 100644 --- a/core/java/android/content/res/StringBlock.java +++ b/core/java/android/content/res/StringBlock.java @@ -175,7 +175,7 @@ final class StringBlock { } } - public void close() throws Throwable { + public void close() { synchronized (this) { if (mOpen) { mOpen = false; diff --git a/services/core/java/com/android/server/om/OverlayManagerService.java b/services/core/java/com/android/server/om/OverlayManagerService.java index f8b3fb259089..17192b2fded6 100644 --- a/services/core/java/com/android/server/om/OverlayManagerService.java +++ b/services/core/java/com/android/server/om/OverlayManagerService.java @@ -740,6 +740,25 @@ public final class OverlayManagerService extends SystemService { } @Override + public void invalidateCachesForOverlay(@Nullable String packageName, int userId) + throws RemoteException { + if (packageName == null) { + return; + } + + enforceChangeOverlayPackagesPermission("invalidateCachesForOverlay"); + userId = handleIncomingUser(userId, "invalidateCachesForOverlay"); + final long ident = Binder.clearCallingIdentity(); + try { + synchronized (mLock) { + mImpl.removeIdmapForOverlay(packageName, userId); + } + } finally { + Binder.restoreCallingIdentity(ident); + } + } + + @Override public void onShellCommand(@NonNull final FileDescriptor in, @NonNull final FileDescriptor out, @NonNull final FileDescriptor err, @NonNull final String[] args, @NonNull final ShellCallback callback, diff --git a/services/core/java/com/android/server/om/OverlayManagerServiceImpl.java b/services/core/java/com/android/server/om/OverlayManagerServiceImpl.java index 934511bf88d1..019c9528f8ab 100644 --- a/services/core/java/com/android/server/om/OverlayManagerServiceImpl.java +++ b/services/core/java/com/android/server/om/OverlayManagerServiceImpl.java @@ -651,6 +651,11 @@ final class OverlayManagerServiceImpl { return mDefaultOverlays; } + void removeIdmapForOverlay(String packageName, int userId) { + final OverlayInfo oi = mSettings.getOverlayInfo(packageName, userId); + removeIdmapIfPossible(oi); + } + List<String> getEnabledOverlayPackageNames(@NonNull final String targetPackageName, final int userId) { final List<OverlayInfo> overlays = mSettings.getOverlaysForTarget(targetPackageName, |