summaryrefslogtreecommitdiffstats
path: root/common/java/com
diff options
context:
space:
mode:
authorMaryam Garrett <mkamvar@google.com>2010-09-30 22:59:09 -0400
committerMaryam Garrett <mkamvar@google.com>2010-10-01 00:50:52 -0400
commit66189d6156b4aa76f25bb1465d9e0e6f39668b9e (patch)
tree262ad9b530bef2b819aa68d47c819d42f68801fb /common/java/com
parentb4f5e0e5755938f2be9a2f1a1a6609b018c530ad (diff)
downloadandroid_frameworks_ex-66189d6156b4aa76f25bb1465d9e0e6f39668b9e.tar.gz
android_frameworks_ex-66189d6156b4aa76f25bb1465d9e0e6f39668b9e.tar.bz2
android_frameworks_ex-66189d6156b4aa76f25bb1465d9e0e6f39668b9e.zip
Only call VoiceSearch if there are IME logging actions
LatinIME/VoiceInput will set a boolean value if there are actions which need to be logged. This value will be checked before sending the intent to VS. This way applications which use IME can call this function without worrying about sending "empty" logging intents. Change-Id: If02971c1cada70aaac954a8a4dcf94794677fab9
Diffstat (limited to 'common/java/com')
-rw-r--r--common/java/com/android/common/userhappiness/UserHappinessSignals.java31
1 files changed, 24 insertions, 7 deletions
diff --git a/common/java/com/android/common/userhappiness/UserHappinessSignals.java b/common/java/com/android/common/userhappiness/UserHappinessSignals.java
index 347bdaa..0bc3e45 100644
--- a/common/java/com/android/common/userhappiness/UserHappinessSignals.java
+++ b/common/java/com/android/common/userhappiness/UserHappinessSignals.java
@@ -25,6 +25,20 @@ import com.android.common.speech.LoggingEvents;
* call these User Happiness metrics.
*/
public class UserHappinessSignals {
+ // So that we don't send logging events to VoiceSearch when there is nothing to
+ // log, IME will setHasVoiceLoggingInfo if there has been any voice activity,
+ // such as recognition results returned.
+ private static boolean mHasVoiceLoggingInfo = false;
+
+ /**
+ * Record whether or not there has been Voice-Input activity which
+ * needs to be logged. This is called with a value of true by the IME,
+ * when logging events (such as VoiceInputDelivered) occur, and is should
+ * be set to false after the logging broadcast is sent.
+ */
+ public static void setHasVoiceLoggingInfo(boolean hasVoiceLogging) {
+ mHasVoiceLoggingInfo = hasVoiceLogging;
+ }
/**
* Log when a user "accepted" IME text. Each application can define what
@@ -33,13 +47,16 @@ public class UserHappinessSignals {
* VoiceSearch LoggingEvents and use it to aggregate VoiceIME Happiness Metrics
*/
public static void userAcceptedImeText(Context context) {
- // Create a Voice IME Logging intent.
- Intent i = new Intent(LoggingEvents.ACTION_LOG_EVENT);
- i.putExtra(LoggingEvents.EXTRA_APP_NAME, LoggingEvents.VoiceIme.APP_NAME);
- i.putExtra(LoggingEvents.EXTRA_EVENT, LoggingEvents.VoiceIme.IME_TEXT_ACCEPTED);
- i.putExtra(LoggingEvents.EXTRA_CALLING_APP_NAME, context.getPackageName());
- i.putExtra(LoggingEvents.EXTRA_TIMESTAMP, System.currentTimeMillis());
- context.sendBroadcast(i);
+ // Create a Voice IME Logging intent only if there are logging actions
+ if (mHasVoiceLoggingInfo) {
+ Intent i = new Intent(LoggingEvents.ACTION_LOG_EVENT);
+ i.putExtra(LoggingEvents.EXTRA_APP_NAME, LoggingEvents.VoiceIme.APP_NAME);
+ i.putExtra(LoggingEvents.EXTRA_EVENT, LoggingEvents.VoiceIme.IME_TEXT_ACCEPTED);
+ i.putExtra(LoggingEvents.EXTRA_CALLING_APP_NAME, context.getPackageName());
+ i.putExtra(LoggingEvents.EXTRA_TIMESTAMP, System.currentTimeMillis());
+ context.sendBroadcast(i);
+ setHasVoiceLoggingInfo(false);
+ }
}
}