1 /* 2 * Copyright (C) 2015 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.settingslib; 17 18 import android.content.Context; 19 import android.net.NetworkBadging; 20 21 import com.android.internal.logging.MetricsLogger; 22 23 /** Utilites for Tron Logging. */ 24 public final class TronUtils { 25 26 private TronUtils() {}; 27 28 public static void logWifiSettingsBadge(Context context, int badgeEnum) { 29 logNetworkBadgeMetric(context, "settings_wifibadging", badgeEnum); 30 } 31 32 /** 33 * Logs an occurrence of the given network badge to a Histogram. 34 * 35 * @param context Context 36 * @param histogram the Tron histogram name to write to 37 * @param badgeEnum the {@link NetworkBadging.Badging} badge value 38 * @throws IllegalArgumentException if the given badge enum is not supported 39 */ 40 private static void logNetworkBadgeMetric( 41 Context context, String histogram, int badgeEnum) 42 throws IllegalArgumentException { 43 int bucket; 44 switch (badgeEnum) { 45 case NetworkBadging.BADGING_NONE: 46 bucket = 0; 47 break; 48 case NetworkBadging.BADGING_SD: 49 bucket = 1; 50 break; 51 case NetworkBadging.BADGING_HD: 52 bucket = 2; 53 break; 54 case NetworkBadging.BADGING_4K: 55 bucket = 3; 56 break; 57 default: 58 throw new IllegalArgumentException("Unsupported badge enum: " + badgeEnum); 59 } 60 61 MetricsLogger.histogram(context, histogram, bucket); 62 } 63 } 64