• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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.libraries.entitlement.utils;
18 
19 import android.os.Build;
20 import android.os.SystemProperties;
21 import android.util.Log;
22 
23 /** Provides API for debugging and not allow to debug on user build. */
24 public final class DebugUtils {
25     private static final String TAG = "ServiceEntitlement";
26 
27     private static final String PROP_PII_LOGGABLE = "dbg.se.pii_loggable";
28     private static final String BUILD_TYPE_USER = "user";
29 
DebugUtils()30     private DebugUtils() {}
31 
32     /** Logs PII data if allowed. */
logPii(String message)33     public static void logPii(String message) {
34         if (isPiiLoggable()) {
35             Log.d(TAG, message);
36         }
37     }
38 
isDebugBuild()39     private static boolean isDebugBuild() {
40         return !BUILD_TYPE_USER.equals(Build.TYPE);
41     }
42 
isPiiLoggable()43     private static boolean isPiiLoggable() {
44         if (!isDebugBuild()) {
45             return false;
46         }
47 
48         return SystemProperties.getBoolean(PROP_PII_LOGGABLE, false);
49     }
50 }
51