From 8be08e5679982afe6bfd01d7c1a976a7251fb94a Mon Sep 17 00:00:00 2001 From: Carmen Jackson Date: Wed, 26 Jun 2019 16:52:06 -0700 Subject: [PATCH] Add textview and framelayout inflation cases, refactor. This change adds a base activity to inflate views, and then adds two more views to inflate: one with 1000 TextViews and the other with 1000 FrameLayouts in a LinearLayout nested inside a ScrollView. This change also adds launcher icons for each of the new cases for ease in testing a launcher-based start. Bug: 132721345 Test: Verified that the layout segments appear in traces as expected. Change-Id: Id8c3e867a1ad5df5c3322ce5d69c9b4255042b69 --- startop/apps/test/Android.bp | 5 +- startop/apps/test/AndroidManifest.xml | 43 +- startop/apps/test/README.md | 2 +- .../apps/test/res/layout/framelayout_list.xml | 5013 ++++++++++++++++ .../apps/test/res/layout/textview_list.xml | 5014 +++++++++++++++++ .../src/ComplexLayoutInflationActivity.java | 34 + startop/apps/test/src/EmptyActivity.java | 30 +- .../src/FrameLayoutInflationActivity.java | 29 + startop/apps/test/src/LayoutInflation.java | 39 - .../test/src/LayoutInflationActivity.java | 39 + .../test/src/TextViewInflationActivity.java | 29 + 11 files changed, 10219 insertions(+), 58 deletions(-) create mode 100644 startop/apps/test/res/layout/framelayout_list.xml create mode 100644 startop/apps/test/res/layout/textview_list.xml create mode 100644 startop/apps/test/src/ComplexLayoutInflationActivity.java create mode 100644 startop/apps/test/src/FrameLayoutInflationActivity.java delete mode 100644 startop/apps/test/src/LayoutInflation.java create mode 100644 startop/apps/test/src/LayoutInflationActivity.java create mode 100644 startop/apps/test/src/TextViewInflationActivity.java diff --git a/startop/apps/test/Android.bp b/startop/apps/test/Android.bp index 3adc05e2cab94..7a1678ac9a5a9 100644 --- a/startop/apps/test/Android.bp +++ b/startop/apps/test/Android.bp @@ -18,6 +18,9 @@ android_app { name: "startop_test_app", srcs: [ "src/EmptyActivity.java", - "src/LayoutInflation.java", + "src/LayoutInflationActivity.java", + "src/ComplexLayoutInflationActivity.java", + "src/FrameLayoutInflationActivity.java", + "src/TextViewInflationActivity.java", ], } diff --git a/startop/apps/test/AndroidManifest.xml b/startop/apps/test/AndroidManifest.xml index 6b08118b73b70..467d8f72e4689 100644 --- a/startop/apps/test/AndroidManifest.xml +++ b/startop/apps/test/AndroidManifest.xml @@ -23,7 +23,12 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true"> - + + + @@ -31,7 +36,41 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/startop/apps/test/README.md b/startop/apps/test/README.md index 53c184bdd1c8c..dadc66af33068 100644 --- a/startop/apps/test/README.md +++ b/startop/apps/test/README.md @@ -23,4 +23,4 @@ The activity adds an `inflate#activity_main` slice to atrace around the time spent in view inflation to make it easier to focus on the time spent in view inflation. - adb shell am start -n com.android.startop.test/.LayoutInflation + adb shell am start -n com.android.startop.test/.ComplexLayoutInflationActivity diff --git a/startop/apps/test/res/layout/framelayout_list.xml b/startop/apps/test/res/layout/framelayout_list.xml new file mode 100644 index 0000000000000..2dd821913cb8d --- /dev/null +++ b/startop/apps/test/res/layout/framelayout_list.xml @@ -0,0 +1,5013 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/startop/apps/test/res/layout/textview_list.xml b/startop/apps/test/res/layout/textview_list.xml new file mode 100644 index 0000000000000..1cff5b2e769a2 --- /dev/null +++ b/startop/apps/test/res/layout/textview_list.xml @@ -0,0 +1,5014 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/startop/apps/test/src/ComplexLayoutInflationActivity.java b/startop/apps/test/src/ComplexLayoutInflationActivity.java new file mode 100644 index 0000000000000..a357073261f52 --- /dev/null +++ b/startop/apps/test/src/ComplexLayoutInflationActivity.java @@ -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. + */ + +package com.android.startop.test; + +import android.os.Bundle; + +/** + * This activity inflates a reasonably complex layout to see the impact of + * layout inflation. The layout is supported by the viewcompiler, so this can be + * used for testing precompiled layout performance. + */ +public class ComplexLayoutInflationActivity extends LayoutInflationActivity { + protected void onCreate(Bundle savedInstanceState) { + Bundle newState = savedInstanceState == null + ? new Bundle() : new Bundle(savedInstanceState); + newState.putInt(LAYOUT_ID, R.layout.activity_main); + + super.onCreate(newState); + } +} diff --git a/startop/apps/test/src/EmptyActivity.java b/startop/apps/test/src/EmptyActivity.java index 5202938686c03..bcb2e707016b1 100644 --- a/startop/apps/test/src/EmptyActivity.java +++ b/startop/apps/test/src/EmptyActivity.java @@ -1,18 +1,18 @@ -// -// 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. -// +/* + * 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.android.startop.test; diff --git a/startop/apps/test/src/FrameLayoutInflationActivity.java b/startop/apps/test/src/FrameLayoutInflationActivity.java new file mode 100644 index 0000000000000..b995e799e22b7 --- /dev/null +++ b/startop/apps/test/src/FrameLayoutInflationActivity.java @@ -0,0 +1,29 @@ +/* + * 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.android.startop.test; + +import android.os.Bundle; + +public class FrameLayoutInflationActivity extends LayoutInflationActivity { + protected void onCreate(Bundle savedInstanceState) { + Bundle newState = savedInstanceState == null + ? new Bundle() : new Bundle(savedInstanceState); + newState.putInt(LAYOUT_ID, R.layout.framelayout_list); + + super.onCreate(newState); + } +} diff --git a/startop/apps/test/src/LayoutInflation.java b/startop/apps/test/src/LayoutInflation.java deleted file mode 100644 index daa4e4556f8ed..0000000000000 --- a/startop/apps/test/src/LayoutInflation.java +++ /dev/null @@ -1,39 +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.android.startop.test; - -import android.app.Activity; -import android.os.Bundle; -import android.os.Trace; -import android.view.LayoutInflater; -import android.view.View; - -/** - * This activity inflates a reasonably complex layout to see the impact of - * layout inflation. The layout is supported by the viewcompiler, so this can be - * used for testing precompiled layout performance. - */ -public class LayoutInflation extends Activity { - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - LayoutInflater inflater = LayoutInflater.from(this); - Trace.beginSection("inflate layout:activity_main"); - View view = inflater.inflate(R.layout.activity_main, /*root=*/null); - Trace.endSection(); - setContentView(view); - } -} diff --git a/startop/apps/test/src/LayoutInflationActivity.java b/startop/apps/test/src/LayoutInflationActivity.java new file mode 100644 index 0000000000000..06a05701f831c --- /dev/null +++ b/startop/apps/test/src/LayoutInflationActivity.java @@ -0,0 +1,39 @@ +/* + * 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.android.startop.test; + +import android.app.Activity; +import android.os.Bundle; +import android.os.Trace; +import android.view.LayoutInflater; +import android.view.View; + +public class LayoutInflationActivity extends Activity { + public static String LAYOUT_ID = "layout-id"; + + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + int layoutId = savedInstanceState.getInt(LAYOUT_ID); + String layoutName = getResources().getResourceEntryName(layoutId); + + LayoutInflater inflater = LayoutInflater.from(this); + Trace.beginSection("inflate layout: " + layoutName); + View view = inflater.inflate(layoutId, /*root=*/null); + Trace.endSection(); + setContentView(view); + } +} diff --git a/startop/apps/test/src/TextViewInflationActivity.java b/startop/apps/test/src/TextViewInflationActivity.java new file mode 100644 index 0000000000000..30e308ef7e6d7 --- /dev/null +++ b/startop/apps/test/src/TextViewInflationActivity.java @@ -0,0 +1,29 @@ +/* + * 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.android.startop.test; + +import android.os.Bundle; + +public class TextViewInflationActivity extends LayoutInflationActivity { + protected void onCreate(Bundle savedInstanceState) { + Bundle newState = savedInstanceState == null + ? new Bundle() : new Bundle(savedInstanceState); + newState.putInt(LAYOUT_ID, R.layout.textview_list); + + super.onCreate(newState); + } +}