1 /*
2  * Copyright (C) 2019 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 android.net.ipsec.ike;
17 
18 import com.android.internal.annotations.VisibleForTesting;
19 import com.android.internal.net.ipsec.ike.utils.IkeMetrics;
20 import com.android.internal.net.utils.Log;
21 
22 /**
23  * This class provides global logging methods.
24  *
25  * @hide
26  */
27 public final class IkeManager {
28     private static final String IKE_TAG = "IKE";
29     private static final boolean LOG_SENSITIVE = false;
30 
31     private static Log sIkeLog = new Log(IKE_TAG, LOG_SENSITIVE);
32     private static IkeMetrics sIkeMetrics = new IkeMetrics();
33 
34     /**
35      * Returns IKE logger.
36      *
37      * @hide
38      */
getIkeLog()39     public static Log getIkeLog() {
40         return sIkeLog;
41     }
42 
43     /**
44      * Injects IKE logger for testing.
45      *
46      * @hide
47      */
48     @VisibleForTesting
setIkeLog(Log log)49     public static void setIkeLog(Log log) {
50         sIkeLog = log;
51     }
52 
53     /**
54      * Resets IKE logger.
55      *
56      * @hide
57      */
58     @VisibleForTesting
resetIkeLog()59     public static void resetIkeLog() {
60         sIkeLog = new Log(IKE_TAG, LOG_SENSITIVE);
61     }
62 
63     /**
64      * Returns IKE metrics tool.
65      *
66      * @hide
67      */
getIkeMetrics()68     public static IkeMetrics getIkeMetrics() {
69         return sIkeMetrics;
70     }
71 
72     /**
73      * Injects IKE metrics tool for testing.
74      *
75      * @hide
76      */
77     @VisibleForTesting
setIkeMetrics(IkeMetrics ikeMetrics)78     public static void setIkeMetrics(IkeMetrics ikeMetrics) {
79         sIkeMetrics = ikeMetrics;
80     }
81 }
82