diff options
author | Maryam Garrett <mkamvar@google.com> | 2010-01-26 10:41:51 -0500 |
---|---|---|
committer | Maryam Garrett <mkamvar@google.com> | 2010-01-29 13:27:56 -0500 |
commit | c36bd07eaec7817f27a1ea7913236d0090c00f5c (patch) | |
tree | 3e2d7ccde00723d0c2570b298dca18e434561c9b /common | |
parent | 0f5bcea6f579b195a5ae3f8a7e6463353eac9669 (diff) | |
download | frameworks_native-c36bd07eaec7817f27a1ea7913236d0090c00f5c.zip frameworks_native-c36bd07eaec7817f27a1ea7913236d0090c00f5c.tar.gz frameworks_native-c36bd07eaec7817f27a1ea7913236d0090c00f5c.tar.bz2 |
Move LoggingEvents.java to android-common & add UserHappiness
The LoggingEvents move will allow Gmail, Voice Search and other apps to
access the LoggingEvents needed. This file will replace
packages/inputmethods/LatinIMEsrc/com/android/inputmethod/voice/LoggingEvents.java
vendor/google/apps/VoiceSearch/apps/VoiceSearch/src/com/google/android/voicesearch/logging/LoggingEvents.java
In addition to moving the file, I have added 3 new fields:
TIMESTAMP, IME_TEXT_ACCEPTED, CALLING_APP_NAME. I needed to
create CALLING_APP_NAME b/c I can't re-use EXTRA_APP_NAME
because that is reserved for one of two values: voice
search or voice IME.
I added another file to android-common: UserHappinessSignals
This can be imported by different applications to broadcast
various user happiness metrics. It is currently used by Gmail's
CompseActivity.java to indicate that a user "accepted" the IME
text when they pressed the send button.
Change-Id: Ia859140facb7fb66a12706735d5132ba9eaa5ea0
Diffstat (limited to 'common')
-rw-r--r-- | common/java/com/android/common/speech/LoggingEvents.java | 133 | ||||
-rw-r--r-- | common/java/com/android/common/userhappiness/UserHappinessSignals.java | 45 |
2 files changed, 178 insertions, 0 deletions
diff --git a/common/java/com/android/common/speech/LoggingEvents.java b/common/java/com/android/common/speech/LoggingEvents.java new file mode 100644 index 0000000..eb9476f --- /dev/null +++ b/common/java/com/android/common/speech/LoggingEvents.java @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.android.common.speech; + +import android.content.Intent; +import android.content.Context; + +/** + * Logging event constants used for Voice Search and VoiceIME. These are the + * keys and values of extras to be specified in logging broadcast intents. + * This class is used by clients of the android.speech APIs to log how the + * user interacts with the IME settings and speech recognition result. + */ +public class LoggingEvents { + // The name of the broadcast intent for logging. + public static final String ACTION_LOG_EVENT = "com.android.common.speech.LOG_EVENT"; + + // The extra key used for the name of the app being logged. + public static final String EXTRA_APP_NAME = "app_name"; + + // The extra key used for the name of the app issuing the VoiceSearch + // or VoiceIME request + public static final String EXTRA_CALLING_APP_NAME = ""; + + // The extra key used for the event value. The possible event values depend + // on the app being logged for, and are defined in the subclasses below. + public static final String EXTRA_EVENT = "extra_event"; + + // The extra key used to log the time in milliseconds at which the EXTRA_EVENT + // occurred in the client. + public static final String EXTRA_TIMESTAMP = "timestamp"; + + // The extra key used (with a boolean value of 'true') as a way to trigger a + // flush of the log events to the server. + public static final String EXTRA_FLUSH = "flush"; + + /** + * Logging event constants for voice search. Below are the extra values for + * {@link LoggingEvents#EXTRA_EVENT}, clustered with keys to additional + * extras for some events that need to be included as additional fields in + * the event. Note that this is not representative of *all* voice search + * events - only the ones that need to be reported from outside the voice + * search app, such as from Browser. + */ + public class VoiceSearch { + // The app name to be used for logging VoiceSearch events. + public static final String APP_NAME = "googlemobile"; + + public static final int RETRY = 0; + + public static final int N_BEST_REVEAL = 1; + + public static final int N_BEST_CHOOSE = 2; + public static final String EXTRA_N_BEST_CHOOSE_INDEX = "index"; // value should be int + + public static final int QUERY_UPDATED = 3; + public static final String EXTRA_QUERY_UPDATED_VALUE = "value"; // value should be String + } + + /** + * Logging event constants for VoiceIME. Below are the extra values for + * {@link LoggingEvents#EXTRA_EVENT}, clustered with keys to additional + * extras for some events that need to be included as additional fields in + * the event. + */ + public class VoiceIme { + // The app name to be used for logging VoiceIME events. + public static final String APP_NAME = "voiceime"; + + public static final int KEYBOARD_WARNING_DIALOG_SHOWN = 0; + + public static final int KEYBOARD_WARNING_DIALOG_DISMISSED = 1; + + public static final int KEYBOARD_WARNING_DIALOG_OK = 2; + + public static final int KEYBOARD_WARNING_DIALOG_CANCEL = 3; + + public static final int SETTINGS_WARNING_DIALOG_SHOWN = 4; + + public static final int SETTINGS_WARNING_DIALOG_DISMISSED = 5; + + public static final int SETTINGS_WARNING_DIALOG_OK = 6; + + public static final int SETTINGS_WARNING_DIALOG_CANCEL = 7; + + public static final int SWIPE_HINT_DISPLAYED = 8; + + public static final int PUNCTUATION_HINT_DISPLAYED = 9; + + public static final int CANCEL_DURING_LISTENING = 10; + + public static final int CANCEL_DURING_WORKING = 11; + + public static final int CANCEL_DURING_ERROR = 12; + + public static final int ERROR = 13; + public static final String EXTRA_ERROR_CODE = "code"; // value should be int + + public static final int START = 14; + public static final String EXTRA_START_LOCALE = "locale"; // value should be String + public static final String EXTRA_START_SWIPE = "swipe"; // value should be boolean + + public static final int VOICE_INPUT_DELIVERED = 15; + + public static final int N_BEST_CHOOSE = 16; + public static final String EXTRA_N_BEST_CHOOSE_INDEX = "index"; // value should be int + + public static final int TEXT_MODIFIED = 17; + + public static final int INPUT_ENDED = 18; + + public static final int VOICE_INPUT_SETTING_ENABLED = 19; + + public static final int VOICE_INPUT_SETTING_DISABLED = 20; + + public static final int IME_TEXT_ACCEPTED = 21; + } + +} diff --git a/common/java/com/android/common/userhappiness/UserHappinessSignals.java b/common/java/com/android/common/userhappiness/UserHappinessSignals.java new file mode 100644 index 0000000..347bdaa --- /dev/null +++ b/common/java/com/android/common/userhappiness/UserHappinessSignals.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.android.common.userhappiness; + +import android.content.Intent; +import android.content.Context; +import com.android.common.speech.LoggingEvents; + +/** + * Metrics for User Happiness are recorded here. Each app can define when to + * call these User Happiness metrics. + */ +public class UserHappinessSignals { + + /** + * Log when a user "accepted" IME text. Each application can define what + * it means to "accept" text. In the case of Gmail, pressing the "Send" + * button indicates text acceptance. We broadcast this information to + * 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); + } + +} |