diff options
| author | Leon Scroggins <scroggo@google.com> | 2010-02-09 15:31:26 -0500 |
|---|---|---|
| committer | Leon Scroggins <scroggo@google.com> | 2010-02-09 16:29:17 -0500 |
| commit | 1fe13a5230e319df42b21939a14d127bd9bf3856 (patch) | |
| tree | 39dd639b6d5a97577f9b5c2e8f403b837ff18ad8 /src/com/android | |
| parent | 3b18ce37c13fce7212948df90a012d7011924a6e (diff) | |
| download | packages_apps_Browser-1fe13a5230e319df42b21939a14d127bd9bf3856.tar.gz packages_apps_Browser-1fe13a5230e319df42b21939a14d127bd9bf3856.tar.bz2 packages_apps_Browser-1fe13a5230e319df42b21939a14d127bd9bf3856.zip | |
send broadcast intents to voice search for logging purposes
Fix for http://b/issue?id=2390720
Diffstat (limited to 'src/com/android')
| -rw-r--r-- | src/com/android/browser/BrowserActivity.java | 15 | ||||
| -rw-r--r-- | src/com/android/browser/Tab.java | 36 | ||||
| -rw-r--r-- | src/com/android/browser/TitleBar.java | 18 |
3 files changed, 69 insertions, 0 deletions
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java index ebb52461a..864d68867 100644 --- a/src/com/android/browser/BrowserActivity.java +++ b/src/com/android/browser/BrowserActivity.java @@ -111,6 +111,7 @@ import android.accounts.OperationCanceledException; import android.accounts.AccountManagerCallback; import com.android.common.Patterns; +import com.android.common.speech.LoggingEvents; import com.google.android.gsf.GoogleLoginServiceConstants; @@ -487,6 +488,20 @@ public class BrowserActivity extends Activity // search, so do nothing. return; } + if (Intent.ACTION_SEARCH.equals(action) + && current.voiceSearchSourceIsGoogle()) { + Intent logIntent = new Intent( + LoggingEvents.ACTION_LOG_EVENT); + logIntent.putExtra(LoggingEvents.EXTRA_EVENT, + LoggingEvents.VoiceSearch.QUERY_UPDATED); + logIntent.putExtra( + LoggingEvents.VoiceSearch.EXTRA_QUERY_UPDATED_VALUE, + intent.getDataString()); + sendBroadcast(logIntent); + // Note, onPageStarted will revert the voice title bar + // When http://b/issue?id=2379215 is fixed, we should update + // the title bar here. + } } // If this was a search request (e.g. search query directly typed into the address bar), // pass it on to the default web search provider. diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java index 3c8f5bac1..afd9b0972 100644 --- a/src/com/android/browser/Tab.java +++ b/src/com/android/browser/Tab.java @@ -65,6 +65,8 @@ import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.TextView; +import com.android.common.speech.LoggingEvents; + /** * Class for maintaining Tabs with a main WebView and a subwindow. */ @@ -158,6 +160,13 @@ class Tab { return mVoiceSearchData != null; } /** + * Return true if the voice search Intent came with a String identifying + * that Google provided the Intent. + */ + public boolean voiceSearchSourceIsGoogle() { + return mVoiceSearchData != null && mVoiceSearchData.mSourceIsGoogle; + } + /** * Get the title to display for the current voice search page. If the Tab * is not in voice search mode, return null. */ @@ -205,6 +214,8 @@ class Tab { } mVoiceSearchData = new VoiceSearchData(results, urls, htmls, baseUrls); + mVoiceSearchData.mSourceIsGoogle = intent.getBooleanExtra( + VoiceSearchData.SOURCE_IS_GOOGLE, false); } else { String extraData = intent.getStringExtra( SearchManager.EXTRA_DATA_KEY); @@ -214,6 +225,16 @@ class Tab { throw new AssertionError("index must be less than " + " size of mVoiceSearchResults"); } + if (mVoiceSearchData.mSourceIsGoogle) { + Intent logIntent = new Intent( + LoggingEvents.ACTION_LOG_EVENT); + logIntent.putExtra(LoggingEvents.EXTRA_EVENT, + LoggingEvents.VoiceSearch.N_BEST_CHOOSE); + logIntent.putExtra( + LoggingEvents.VoiceSearch.EXTRA_N_BEST_CHOOSE_INDEX, + index); + mActivity.sendBroadcast(logIntent); + } } } mVoiceSearchData.mLastVoiceSearchTitle @@ -292,6 +313,16 @@ class Tab { * when switching tabs. */ public String mLastVoiceSearchTitle; + /** + * Whether the Intent which turned on voice search mode contained the + * String signifying that Google was the source. + */ + public boolean mSourceIsGoogle; + /** + * String used to identify Google as the source of voice search. + */ + public static String SOURCE_IS_GOOGLE + = "android.speech.extras.SOURCE_IS_GOOGLE"; } // Container class for the next error dialog that needs to be displayed @@ -373,6 +404,11 @@ class Tab { mLoadStartTime = SystemClock.uptimeMillis(); if (mVoiceSearchData != null && !url.equals(mVoiceSearchData.mLastVoiceSearchUrl)) { + if (mVoiceSearchData.mSourceIsGoogle) { + Intent i = new Intent(LoggingEvents.ACTION_LOG_EVENT); + i.putExtra(LoggingEvents.EXTRA_FLUSH, true); + mActivity.sendBroadcast(i); + } mVoiceSearchData = null; if (mInForeground) { mActivity.revertVoiceTitleBar(); diff --git a/src/com/android/browser/TitleBar.java b/src/com/android/browser/TitleBar.java index 14ac2aeb9..844d5a1ec 100644 --- a/src/com/android/browser/TitleBar.java +++ b/src/com/android/browser/TitleBar.java @@ -48,6 +48,8 @@ import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; +import com.android.common.speech.LoggingEvents; + /** * This class represents a title bar for a particular "tab" or "window" in the * browser. @@ -189,6 +191,14 @@ public class TitleBar extends LinearLayout { case MotionEvent.ACTION_UP: if (mRtButton.isPressed()) { if (mInVoiceMode) { + if (mBrowserActivity.getTabControl().getCurrentTab() + .voiceSearchSourceIsGoogle()) { + Intent i = new Intent( + LoggingEvents.ACTION_LOG_EVENT); + i.putExtra(LoggingEvents.EXTRA_EVENT, + LoggingEvents.VoiceSearch.RETRY); + mBrowserActivity.sendBroadcast(i); + } mBrowserActivity.startActivity(mVoiceSearchIntent); } else if (mInLoad) { mBrowserActivity.stopLoading(); @@ -199,6 +209,14 @@ public class TitleBar extends LinearLayout { } else if (mTitleBg.isPressed()) { mHandler.removeMessages(LONG_PRESS); if (mInVoiceMode) { + if (mBrowserActivity.getTabControl().getCurrentTab() + .voiceSearchSourceIsGoogle()) { + Intent i = new Intent( + LoggingEvents.ACTION_LOG_EVENT); + i.putExtra(LoggingEvents.EXTRA_EVENT, + LoggingEvents.VoiceSearch.N_BEST_REVEAL); + mBrowserActivity.sendBroadcast(i); + } mBrowserActivity.showVoiceSearchResults( mTitle.getText().toString().trim()); } else { |
