Home | History | Annotate | Download | only in telecom
      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.server.telecom;
     18 
     19 import android.content.BroadcastReceiver;
     20 import android.content.Context;
     21 import android.content.Intent;
     22 import android.telecom.Log;
     23 import android.telecom.TelecomManager;
     24 
     25 /**
     26  * Receiver for "secret codes" broadcast by Dialer.
     27  */
     28 public 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();
     63                 Log.addEvent(currentCall, LogUtils.Events.USER_LOG_MARK);
     64             }
     65         }
     66     }
     67 }
     68