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 17 package com.android.dialer.logging; 18 19 import android.app.Activity; 20 import android.text.TextUtils; 21 import android.util.Log; 22 23 import com.android.contacts.commonbind.analytics.AnalyticsUtil; 24 import com.android.dialerbind.ObjectFactory; 25 import com.android.incallui.Call; 26 27 /** 28 * Single entry point for all logging/analytics-related work for all user interactions. 29 */ 30 public abstract class Logger { 31 public static final String TAG = "Logger"; 32 getInstance()33 public static Logger getInstance() { 34 return ObjectFactory.getLoggerInstance(); 35 } 36 37 /** 38 * Logs a call event. PII like the call's number or caller details should never be logged. 39 * 40 * @param call to log. 41 */ logCall(Call call)42 public static void logCall(Call call) { 43 final Logger logger = getInstance(); 44 if (logger != null) { 45 logger.logCallImpl(call); 46 } 47 } 48 49 /** 50 * Logs an event indicating that a screen was displayed. 51 * 52 * @param screenType integer identifier of the displayed screen 53 * @param activity Parent activity of the displayed screen. 54 */ logScreenView(int screenType, Activity activity)55 public static void logScreenView(int screenType, Activity activity) { 56 final Logger logger = getInstance(); 57 if (logger != null) { 58 logger.logScreenViewImpl(screenType); 59 } 60 61 final String screenName = ScreenEvent.getScreenName(screenType); 62 if (!TextUtils.isEmpty(screenName)) { 63 AnalyticsUtil.sendScreenView(screenName, activity, null); 64 } else { 65 Log.w(TAG, "Unknown screenType: " + screenType); 66 } 67 } 68 69 /** 70 * Logs an interaction that occurred 71 * 72 * @param interaction an integer representing what interaction occurred. 73 * {@see com.android.dialer.logging.InteractionEvent} 74 */ logInteraction(int interaction)75 public static void logInteraction(int interaction) { 76 final Logger logger = getInstance(); 77 if (logger != null) { 78 logger.logInteractionImpl(interaction); 79 } 80 } 81 logCallImpl(Call call)82 public abstract void logCallImpl(Call call); logScreenViewImpl(int screenType)83 public abstract void logScreenViewImpl(int screenType); logInteractionImpl(int dialerInteraction)84 public abstract void logInteractionImpl(int dialerInteraction); 85 } 86