1 /* 2 * Copyright (C) 2018 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 package com.android.tv.perf; 17 18 import android.app.Activity; 19 import android.app.Application; 20 21 /** 22 * Measures App startup. 23 * 24 * <p>This interface is lightweight to help measure both cold and warm startup latency. 25 * Implementations must not throw any Exception. 26 * 27 * <p>Because this class needs to be used in static initialization blocks, it can not be injected 28 * via dagger. 29 * 30 * <p>Creating implementations of this interface must be idempotent and lightweight. It does not 31 * need to be cached. 32 */ 33 public interface StartupMeasure { 34 35 /** To be be placed as the first static block in the app's Application class. */ onAppClassLoaded()36 void onAppClassLoaded(); 37 38 /** 39 * To be placed in your {@link Application#onCreate} to let Performance Monitoring know when 40 * this happen. 41 */ onAppCreate(Application application)42 void onAppCreate(Application application); 43 44 /** 45 * To be placed in an initialization block of your {@link Activity} to let Performance 46 * Monitoring know when this activity is instantiated. Please note that this initialization 47 * block should be before other initialization blocks (if any) in your activity class. 48 */ onActivityInit()49 void onActivityInit(); 50 } 51