blob: 57f84a0efc3c22e1a21f4515191956fe1644bcc2 [file] [log] [blame]
Tyler Gunnb5e7d802015-10-21 08:17:38 -07001/*
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
17package com.android.server.telecom;
18
19import android.content.BroadcastReceiver;
20import android.content.Context;
21import android.content.Intent;
Brad Ebingera3eccfe2016-10-05 15:45:22 -070022import android.telecom.Log;
Tyler Gunnb5e7d802015-10-21 08:17:38 -070023import android.telecom.TelecomManager;
24
25/**
26 * Receiver for "secret codes" broadcast by Dialer.
27 */
28public class DialerCodeReceiver extends BroadcastReceiver {
29 // Copied from TelephonyIntents.java.
30 public static final String SECRET_CODE_ACTION = "android.provider.Telephony.SECRET_CODE";
31
32 // Enables extended logging for a period of time.
33 public static final String TELECOM_SECRET_CODE_DEBUG_ON = "823241";
34
35 // Disables extended logging.
36 public static final String TELECOM_SECRET_CODE_DEBUG_OFF = "823240";
37
38 // Writes a MARK to the Telecom log.
39 public static final String TELECOM_SECRET_CODE_MARK = "826275";
40
41 private final CallsManager mCallsManager;
42
43 DialerCodeReceiver(CallsManager callsManager) {
44 mCallsManager = callsManager;
45 }
46
47 @Override
48 public void onReceive(Context context, Intent intent) {
49 if (SECRET_CODE_ACTION.equals(intent.getAction()) && intent.getData() != null &&
50 intent.getData().getHost() != null) {
51 if (intent.getData().getHost().equals(TELECOM_SECRET_CODE_DEBUG_ON)) {
52 Log.i("DialerCodeReceiver", "Secret code used to enable extended logging mode");
53 Log.setIsExtendedLoggingEnabled(true);
54 } else if (intent.getData().getHost().equals(TELECOM_SECRET_CODE_DEBUG_OFF)) {
55 Log.i("DialerCodeReceiver", "Secret code used to disable extended logging mode");
56 Log.setIsExtendedLoggingEnabled(false);
57 } else if (intent.getData().getHost().equals(TELECOM_SECRET_CODE_MARK)) {
58 Log.i("DialerCodeReceiver", "Secret code used to mark logs.");
59
60 // If there is an active call, add the "log mark" for that call; otherwise we will
61 // add a non-call event.
62 Call currentCall = mCallsManager.getActiveCall();
Brad Ebingera3eccfe2016-10-05 15:45:22 -070063 Log.addEvent(currentCall, LogUtils.Events.USER_LOG_MARK);
Tyler Gunnb5e7d802015-10-21 08:17:38 -070064 }
65 }
66 }
67}