1 /* 2 * Copyright (C) 2023 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.settings.wifi.factory; 18 19 import android.content.Context; 20 import android.net.wifi.WifiManager; 21 import android.util.Log; 22 23 import androidx.annotation.NonNull; 24 import androidx.annotation.Nullable; 25 26 /** 27 * Wi-Fi Verbose Logging 28 */ 29 public class WifiVerboseLogging { 30 private static final String TAG = "WifiVerboseLogging"; 31 32 protected final Context mAppContext; 33 protected final WifiManager mWifiManager; 34 protected final boolean mIsVerboseLoggingEnabled; 35 WifiVerboseLogging(@onNull Context appContext, @NonNull WifiManager wifiManager)36 public WifiVerboseLogging(@NonNull Context appContext, @NonNull WifiManager wifiManager) { 37 mAppContext = appContext; 38 mWifiManager = wifiManager; 39 mIsVerboseLoggingEnabled = wifiManager.isVerboseLoggingEnabled(); 40 Log.v(TAG, "isVerboseLoggingEnabled:" + mIsVerboseLoggingEnabled); 41 } 42 43 /** 44 * Send a {@link Log#VERBOSE} log message. 45 * 46 * @param tag Used to identify the source of a log message. It usually identifies 47 * the class or activity where the log call occurs. 48 * @param msg The message you would like logged. 49 */ log(@ullable String tag, @NonNull String msg)50 public void log(@Nullable String tag, @NonNull String msg) { 51 if (mIsVerboseLoggingEnabled) { 52 Log.v(tag, msg); 53 } 54 } 55 } 56