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