1 /* 2 * Copyright (C) 2016 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 com.android.tv.util; 18 19 import java.util.HashMap; 20 import java.util.Map; 21 import java.util.concurrent.TimeUnit; 22 23 /** 24 * A class only for help developers. 25 */ 26 public class Debug { 27 /** 28 * A threshold of start up time, when the start up time of Live TV is more than it, 29 * a warning will show to the developer. 30 */ 31 public static final long TIME_START_UP_DURATION_THRESHOLD = TimeUnit.SECONDS.toMillis(6); 32 /** 33 * Tag for measuring start up time of Live TV. 34 */ 35 public static final String TAG_START_UP_TIMER = "start_up_timer"; 36 37 /** 38 * A global map for duration timers. 39 */ 40 private final static Map<String, DurationTimer> sTimerMap = new HashMap<>(); 41 42 /** 43 * Returns the global duration timer by tag. 44 */ getTimer(String tag)45 public static DurationTimer getTimer(String tag) { 46 if (sTimerMap.get(tag) != null) { 47 return sTimerMap.get(tag); 48 } 49 DurationTimer timer = new DurationTimer(tag, true); 50 sTimerMap.put(tag, timer); 51 return timer; 52 } 53 54 /** 55 * Removes the global duration timer by tag. 56 */ removeTimer(String tag)57 public static DurationTimer removeTimer(String tag) { 58 return sTimerMap.remove(tag); 59 } 60 } 61