1823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang/* 2823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang * Copyright (C) 2010 The Android Open Source Project 3823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang * 4823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang * use this file except in compliance with the License. You may obtain a copy of 6823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang * the License at 7823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang * 8823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang * http://www.apache.org/licenses/LICENSE-2.0 9823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang * 10823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang * Unless required by applicable law or agreed to in writing, software 11823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang * License for the specific language governing permissions and limitations under 14823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang * the License. 15823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang */ 16823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang 17823b6f3516076b92f78c3fc27037d24bb514e653Ying Wangpackage com.android.common.userhappiness; 18823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang 19823b6f3516076b92f78c3fc27037d24bb514e653Ying Wangimport android.content.Intent; 20823b6f3516076b92f78c3fc27037d24bb514e653Ying Wangimport android.content.Context; 21823b6f3516076b92f78c3fc27037d24bb514e653Ying Wangimport com.android.common.speech.LoggingEvents; 22823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang 23823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang/** 24823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang * Metrics for User Happiness are recorded here. Each app can define when to 25823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang * call these User Happiness metrics. 26823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang */ 27823b6f3516076b92f78c3fc27037d24bb514e653Ying Wangpublic class UserHappinessSignals { 2866189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett // So that we don't send logging events to VoiceSearch when there is nothing to 2966189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett // log, IME will setHasVoiceLoggingInfo if there has been any voice activity, 3066189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett // such as recognition results returned. 3166189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett private static boolean mHasVoiceLoggingInfo = false; 3266189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett 3366189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett /** 3466189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett * Record whether or not there has been Voice-Input activity which 3566189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett * needs to be logged. This is called with a value of true by the IME, 3666189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett * when logging events (such as VoiceInputDelivered) occur, and is should 3766189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett * be set to false after the logging broadcast is sent. 3866189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett */ 3966189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett public static void setHasVoiceLoggingInfo(boolean hasVoiceLogging) { 4066189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett mHasVoiceLoggingInfo = hasVoiceLogging; 4166189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett } 42823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang 43823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang /** 44823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang * Log when a user "accepted" IME text. Each application can define what 45823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang * it means to "accept" text. In the case of Gmail, pressing the "Send" 46823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang * button indicates text acceptance. We broadcast this information to 47823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang * VoiceSearch LoggingEvents and use it to aggregate VoiceIME Happiness Metrics 48823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang */ 49823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang public static void userAcceptedImeText(Context context) { 5066189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett // Create a Voice IME Logging intent only if there are logging actions 5166189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett if (mHasVoiceLoggingInfo) { 5266189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett Intent i = new Intent(LoggingEvents.ACTION_LOG_EVENT); 5366189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett i.putExtra(LoggingEvents.EXTRA_APP_NAME, LoggingEvents.VoiceIme.APP_NAME); 5466189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett i.putExtra(LoggingEvents.EXTRA_EVENT, LoggingEvents.VoiceIme.IME_TEXT_ACCEPTED); 5566189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett i.putExtra(LoggingEvents.EXTRA_CALLING_APP_NAME, context.getPackageName()); 5666189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett i.putExtra(LoggingEvents.EXTRA_TIMESTAMP, System.currentTimeMillis()); 5766189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett context.sendBroadcast(i); 5866189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett setHasVoiceLoggingInfo(false); 5966189d6156b4aa76f25bb1465d9e0e6f39668b9eMaryam Garrett } 60823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang } 61823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang 62823b6f3516076b92f78c3fc27037d24bb514e653Ying Wang} 63