1 /* 2 * Copyright (C) 2008 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.voicedialer; 18 19 20 import android.content.Context; 21 import android.content.Intent; 22 import android.content.BroadcastReceiver; 23 import android.provider.Telephony.Intents; 24 import android.util.Config; 25 import android.util.Log; 26 import android.widget.Toast; 27 28 public class VoiceDialerReceiver extends BroadcastReceiver { 29 private static final String TAG = "VoiceDialerReceiver"; 30 31 @Override 32 public void onReceive(Context context, Intent intent) { 33 if (Config.LOGD) Log.d(TAG, "onReceive " + intent); 34 35 // fetch up useful stuff 36 String action = intent.getAction(); 37 String host = intent.getData() != null ? intent.getData().getHost() : null; 38 39 // force recompilation of g2g on boot 40 if (Intent.ACTION_BOOT_COMPLETED.equals(action)) { 41 CommandRecognizerEngine.deleteCachedGrammarFiles(context); 42 } 43 44 // force recompilation if apps change, for 'OPEN' command 45 else if (Intent.ACTION_PACKAGE_ADDED.equals(action) || 46 Intent.ACTION_PACKAGE_CHANGED.equals(action) || 47 Intent.ACTION_PACKAGE_REMOVED.equals(action) || 48 Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE.equals(action) || 49 Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE.equals(action)) { 50 CommandRecognizerEngine.deleteCachedGrammarFiles(context); 51 } 52 53 // Voice Dialer Logging Enabled, *#*#8351#*#* 54 else if (Intents.SECRET_CODE_ACTION.equals(action) && "8351".equals(host)) { 55 RecognizerLogger.enable(context); 56 Toast.makeText(context, R.string.logging_enabled, Toast.LENGTH_LONG).show(); 57 } 58 59 // Voice Dialer Logging Disabled, *#*#8350#*#* 60 else if (Intents.SECRET_CODE_ACTION.equals(action) && "8350".equals(host)) { 61 RecognizerLogger.disable(context); 62 Toast.makeText(context, R.string.logging_disabled, Toast.LENGTH_LONG).show(); 63 } 64 } 65 } 66