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