LogUtils.java revision ad4ebc022bf8a28958606121a1a2a0c4130dc821
1/* 2 * Copyright (C) 2016 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 17package com.android.server.telecom; 18 19import android.content.Context; 20import android.telecom.Logging.EventManager; 21import android.telecom.Logging.EventManager.TimedEventPair; 22 23/** 24 * Temporary location of new Logging class 25 */ 26 27public class LogUtils { 28 29 private static final String TAG = "Telecom"; 30 private static final String LOGUTILS_TAG = "LogUtils"; 31 32 public static final boolean SYSTRACE_DEBUG = false; /* STOP SHIP if true */ 33 34 public static final class Sessions { 35 public static final String ICA_ANSWER_CALL = "ICA.aC"; 36 public static final String ICA_DEFLECT_CALL = "ICA.defC"; 37 public static final String ICA_REJECT_CALL = "ICA.rC"; 38 public static final String ICA_DISCONNECT_CALL = "ICA.dC"; 39 public static final String ICA_HOLD_CALL = "ICA.hC"; 40 public static final String ICA_UNHOLD_CALL = "ICA.uC"; 41 public static final String ICA_MUTE = "ICA.m"; 42 public static final String ICA_SET_AUDIO_ROUTE = "ICA.sAR"; 43 public static final String ICA_CONFERENCE = "ICA.c"; 44 public static final String CSW_HANDLE_CREATE_CONNECTION_COMPLETE = "CSW.hCCC"; 45 public static final String CSW_SET_ACTIVE = "CSW.sA"; 46 public static final String CSW_SET_RINGING = "CSW.sR"; 47 public static final String CSW_SET_DIALING = "CSW.sD"; 48 public static final String CSW_SET_PULLING = "CSW.sP"; 49 public static final String CSW_SET_DISCONNECTED = "CSW.sDc"; 50 public static final String CSW_SET_ON_HOLD = "CSW.sOH"; 51 public static final String CSW_REMOVE_CALL = "CSW.rC"; 52 public static final String CSW_SET_IS_CONFERENCED = "CSW.sIC"; 53 public static final String CSW_ADD_CONFERENCE_CALL = "CSW.aCC"; 54 } 55 56 public final static class Events { 57 public static final String CREATED = "CREATED"; 58 public static final String USER_CONFIRMATION = "USER_CONFIRMATION"; 59 public static final String USER_CONFIRMED = "USER_CONFIRMED"; 60 public static final String USER_CANCELLED = "USER_CANCELLED"; 61 public static final String DESTROYED = "DESTROYED"; 62 public static final String SET_CONNECTING = "SET_CONNECTING"; 63 public static final String SET_DIALING = "SET_DIALING"; 64 public static final String SET_PULLING = "SET_PULLING"; 65 public static final String SET_ACTIVE = "SET_ACTIVE"; 66 public static final String SET_HOLD = "SET_HOLD"; 67 public static final String SET_RINGING = "SET_RINGING"; 68 public static final String SET_DISCONNECTED = "SET_DISCONNECTED"; 69 public static final String SET_DISCONNECTING = "SET_DISCONNECTING"; 70 public static final String SET_SELECT_PHONE_ACCOUNT = "SET_SELECT_PHONE_ACCOUNT"; 71 public static final String REQUEST_HOLD = "REQUEST_HOLD"; 72 public static final String REQUEST_UNHOLD = "REQUEST_UNHOLD"; 73 public static final String REQUEST_DISCONNECT = "REQUEST_DISCONNECT"; 74 public static final String REQUEST_ACCEPT = "REQUEST_ACCEPT"; 75 public static final String REQUEST_DEFLECT = "REQUEST_DEFLECT"; 76 public static final String REQUEST_REJECT = "REQUEST_REJECT"; 77 public static final String START_DTMF = "START_DTMF"; 78 public static final String STOP_DTMF = "STOP_DTMF"; 79 public static final String START_RINGER = "START_RINGER"; 80 public static final String STOP_RINGER = "STOP_RINGER"; 81 public static final String START_VIBRATOR = "START_VIBRATOR"; 82 public static final String STOP_VIBRATOR = "STOP_VIBRATOR"; 83 public static final String SKIP_VIBRATION = "SKIP_VIBRATION"; 84 public static final String SKIP_RINGING = "SKIP_RINGING"; 85 public static final String START_CALL_WAITING_TONE = "START_CALL_WAITING_TONE"; 86 public static final String STOP_CALL_WAITING_TONE = "STOP_CALL_WAITING_TONE"; 87 public static final String START_CONNECTION = "START_CONNECTION"; 88 public static final String CREATE_CONNECTION_FAILED = "CREATE_CONNECTION_FAILED"; 89 public static final String BIND_CS = "BIND_CS"; 90 public static final String CS_BOUND = "CS_BOUND"; 91 public static final String CONFERENCE_WITH = "CONF_WITH"; 92 public static final String SPLIT_FROM_CONFERENCE = "CONF_SPLIT"; 93 public static final String SWAP = "SWAP"; 94 public static final String ADD_CHILD = "ADD_CHILD"; 95 public static final String REMOVE_CHILD = "REMOVE_CHILD"; 96 public static final String SET_PARENT = "SET_PARENT"; 97 public static final String MUTE = "MUTE"; 98 public static final String UNMUTE = "UNMUTE"; 99 public static final String AUDIO_ROUTE = "AUDIO_ROUTE"; 100 public static final String AUDIO_ROUTE_EARPIECE = "AUDIO_ROUTE_EARPIECE"; 101 public static final String AUDIO_ROUTE_HEADSET = "AUDIO_ROUTE_HEADSET"; 102 public static final String AUDIO_ROUTE_BT = "AUDIO_ROUTE_BT"; 103 public static final String AUDIO_ROUTE_SPEAKER = "AUDIO_ROUTE_SPEAKER"; 104 public static final String ERROR_LOG = "ERROR"; 105 public static final String USER_LOG_MARK = "USER_LOG_MARK"; 106 public static final String SILENCE = "SILENCE"; 107 public static final String BIND_SCREENING = "BIND_SCREENING"; 108 public static final String SCREENING_BOUND = "SCREENING_BOUND"; 109 public static final String SCREENING_SENT = "SCREENING_SENT"; 110 public static final String SCREENING_COMPLETED = "SCREENING_COMPLETED"; 111 public static final String BLOCK_CHECK_INITIATED = "BLOCK_CHECK_INITIATED"; 112 public static final String BLOCK_CHECK_FINISHED = "BLOCK_CHECK_FINISHED"; 113 public static final String DIRECT_TO_VM_INITIATED = "DIRECT_TO_VM_INITIATED"; 114 public static final String DIRECT_TO_VM_FINISHED = "DIRECT_TO_VM_FINISHED"; 115 public static final String FILTERING_INITIATED = "FILTERING_INITIATED"; 116 public static final String FILTERING_COMPLETED = "FILTERING_COMPLETED"; 117 public static final String FILTERING_TIMED_OUT = "FILTERING_TIMED_OUT"; 118 public static final String REMOTELY_HELD = "REMOTELY_HELD"; 119 public static final String REMOTELY_UNHELD = "REMOTELY_UNHELD"; 120 public static final String REQUEST_PULL = "PULL"; 121 public static final String INFO = "INFO"; 122 public static final String VIDEO_STATE_CHANGED = "VIDEO_STATE_CHANGED"; 123 public static final String RECEIVE_VIDEO_REQUEST = "RECEIVE_VIDEO_REQUEST"; 124 public static final String RECEIVE_VIDEO_RESPONSE = "RECEIVE_VIDEO_RESPONSE"; 125 public static final String SEND_VIDEO_REQUEST = "SEND_VIDEO_REQUEST"; 126 public static final String SEND_VIDEO_RESPONSE = "SEND_VIDEO_RESPONSE"; 127 public static final String IS_EXTERNAL = "IS_EXTERNAL"; 128 public static final String PROPERTY_CHANGE = "PROPERTY_CHANGE"; 129 public static final String CAPABILITY_CHANGE = "CAPABILITY_CHANGE"; 130 public static final String CONNECTION_EVENT = "CONNECTION_EVENT"; 131 public static final String CALL_EVENT = "CALL_EVENT"; 132 public static final String HANDOVER_REQUEST = "HANDOVER_REQUEST"; 133 public static final String START_HANDOVER = "START_HANDOVER"; 134 public static final String ACCEPT_HANDOVER = "ACCEPT_HANDOVER"; 135 public static final String HANDOVER_COMPLETE = "HANDOVER_COMPLETE"; 136 public static final String HANDOVER_FAILED = "HANDOVER_FAILED"; 137 138 public static class Timings { 139 public static final String ACCEPT_TIMING = "accept"; 140 public static final String REJECT_TIMING = "reject"; 141 public static final String DISCONNECT_TIMING = "disconnect"; 142 public static final String HOLD_TIMING = "hold"; 143 public static final String UNHOLD_TIMING = "unhold"; 144 public static final String OUTGOING_TIME_TO_DIALING_TIMING = "outgoing_time_to_dialing"; 145 public static final String BIND_CS_TIMING = "bind_cs"; 146 public static final String SCREENING_COMPLETED_TIMING = "screening_completed"; 147 public static final String DIRECT_TO_VM_FINISHED_TIMING = "direct_to_vm_finished"; 148 public static final String BLOCK_CHECK_FINISHED_TIMING = "block_check_finished"; 149 public static final String FILTERING_COMPLETED_TIMING = "filtering_completed"; 150 public static final String FILTERING_TIMED_OUT_TIMING = "filtering_timed_out"; 151 152 private static final TimedEventPair[] sTimedEvents = { 153 new TimedEventPair(REQUEST_ACCEPT, SET_ACTIVE, ACCEPT_TIMING), 154 new TimedEventPair(REQUEST_REJECT, SET_DISCONNECTED, REJECT_TIMING), 155 new TimedEventPair(REQUEST_DISCONNECT, SET_DISCONNECTED, DISCONNECT_TIMING), 156 new TimedEventPair(REQUEST_HOLD, SET_HOLD, HOLD_TIMING), 157 new TimedEventPair(REQUEST_UNHOLD, SET_ACTIVE, UNHOLD_TIMING), 158 new TimedEventPair(START_CONNECTION, SET_DIALING, 159 OUTGOING_TIME_TO_DIALING_TIMING), 160 new TimedEventPair(BIND_CS, CS_BOUND, BIND_CS_TIMING), 161 new TimedEventPair(SCREENING_SENT, SCREENING_COMPLETED, 162 SCREENING_COMPLETED_TIMING), 163 new TimedEventPair(DIRECT_TO_VM_INITIATED, DIRECT_TO_VM_FINISHED, 164 DIRECT_TO_VM_FINISHED_TIMING), 165 new TimedEventPair(BLOCK_CHECK_INITIATED, BLOCK_CHECK_FINISHED, 166 BLOCK_CHECK_FINISHED_TIMING), 167 new TimedEventPair(FILTERING_INITIATED, FILTERING_COMPLETED, 168 FILTERING_COMPLETED_TIMING), 169 new TimedEventPair(FILTERING_INITIATED, FILTERING_TIMED_OUT, 170 FILTERING_TIMED_OUT_TIMING, 6000L), 171 }; 172 } 173 } 174 175 private static void eventRecordAdded(EventManager.EventRecord eventRecord) { 176 // Only Calls will be added as event records in this case 177 EventManager.Loggable recordEntry = eventRecord.getRecordEntry(); 178 if (recordEntry instanceof Call) { 179 Call callRecordEntry = (Call) recordEntry; 180 android.telecom.Log.i(LOGUTILS_TAG, "EventRecord added as Call: " + callRecordEntry); 181 Analytics.CallInfo callInfo = callRecordEntry.getAnalytics(); 182 if(callInfo != null) { 183 callInfo.setCallEvents(eventRecord); 184 } else { 185 android.telecom.Log.w(LOGUTILS_TAG, "Could not get Analytics CallInfo."); 186 } 187 } else { 188 android.telecom.Log.w(LOGUTILS_TAG, "Non-Call EventRecord Added."); 189 } 190 } 191 192 public static void initLogging(Context context) { 193 android.telecom.Log.setTag(TAG); 194 android.telecom.Log.setSessionContext(context); 195 for (EventManager.TimedEventPair p : Events.Timings.sTimedEvents) { 196 android.telecom.Log.addRequestResponsePair(p); 197 } 198 android.telecom.Log.registerEventListener(LogUtils::eventRecordAdded); 199 // Store analytics about recently completed Sessions. 200 android.telecom.Log.registerSessionListener(Analytics::addSessionTiming); 201 } 202} 203