send broadcast intents to voice search for logging purposes
Fix for http://b/issue?id=2390720
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index ebb5246..864d688 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -111,6 +111,7 @@
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 @@
// 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 3c8f5ba..afd9b09 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -65,6 +65,8 @@
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 @@
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 @@
}
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 @@
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 @@
* 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 @@
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 14ac2ae..844d5a1 100644
--- a/src/com/android/browser/TitleBar.java
+++ b/src/com/android/browser/TitleBar.java
@@ -48,6 +48,8 @@
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 @@
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 @@
} 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 {