1 /*
2  * Copyright 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package androidx.benchmark.integration.macrobenchmark.target
18 
19 import android.os.Build
20 import android.os.Bundle
21 import android.util.Log
22 import android.widget.TextView
23 import androidx.appcompat.app.AppCompatActivity
24 import androidx.tracing.trace
25 import kotlin.concurrent.thread
26 
27 class TrivialStartupActivity : AppCompatActivity() {
onCreatenull28     override fun onCreate(savedInstanceState: Bundle?) {
29         super.onCreate(savedInstanceState)
30         setContentView(R.layout.activity_main)
31 
32         val notice = findViewById<TextView>(R.id.txtNotice)
33         notice.setText(R.string.app_notice)
34     }
35 
onResumenull36     override fun onResume() {
37         super.onResume()
38 
39         if (Build.VERSION.SDK_INT <= 23) {
40             // temporary logging/tracing to debug b/204572406
41             Log.d("Benchmark", "onResume")
42             trace("onResume") {}
43         }
44     }
45 
46     init {
47         if (Build.VERSION.SDK_INT <= 23) {
48             // temporary tracing to debug b/204572406
<lambda>null49             thread {
50                 while (true) {
51                     trace("tracing") { Thread.sleep(50) }
52                 }
53             }
54         }
55     }
56 }
57