summaryrefslogtreecommitdiffstats
path: root/policy/src
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2012-02-27 13:07:58 -0800
committerMichael Jurka <mikejurka@google.com>2012-02-28 14:37:35 -0800
commit7a3489552ca92776c5e2a57c80026216b44005eb (patch)
treee5fef38dfd06be095cd8377d8f0579e0cfbc4271 /policy/src
parent69db4df48713d695e40144833c7008020e0720f0 (diff)
downloadframeworks_base-7a3489552ca92776c5e2a57c80026216b44005eb.zip
frameworks_base-7a3489552ca92776c5e2a57c80026216b44005eb.tar.gz
frameworks_base-7a3489552ca92776c5e2a57c80026216b44005eb.tar.bz2
Add shortcut for voice search
On phones with soft nav bar, make long press on home launch a voice search intent Change-Id: I69840a96a08524a76e33a306b799222c879db095
Diffstat (limited to 'policy/src')
-rwxr-xr-xpolicy/src/com/android/internal/policy/impl/PhoneWindowManager.java21
1 files changed, 19 insertions, 2 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 8f35afb..1763674 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -39,6 +39,8 @@ import android.database.ContentObserver;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.RectF;
+import android.media.AudioManager;
+import android.media.IAudioService;
import android.os.BatteryManager;
import android.os.Bundle;
import android.os.Handler;
@@ -64,6 +66,7 @@ import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.telephony.ITelephony;
import com.android.internal.widget.PointerLocationView;
+import android.speech.RecognizerIntent;
import android.util.DisplayMetrics;
import android.util.EventLog;
import android.util.Log;
@@ -133,8 +136,6 @@ import android.view.KeyCharacterMap.FallbackAction;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
-import android.media.IAudioService;
-import android.media.AudioManager;
import java.io.File;
import java.io.FileDescriptor;
@@ -176,6 +177,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
static final int LONG_PRESS_HOME_NOTHING = 0;
static final int LONG_PRESS_HOME_RECENT_DIALOG = 1;
static final int LONG_PRESS_HOME_RECENT_SYSTEM_UI = 2;
+ static final int LONG_PRESS_HOME_VOICE_SEARCH = 3;
// wallpaper is at the bottom, though the window manager may move it.
static final int WALLPAPER_LAYER = 2;
@@ -710,6 +712,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mLongPressOnHomeBehavior > LONG_PRESS_HOME_RECENT_SYSTEM_UI) {
mLongPressOnHomeBehavior = LONG_PRESS_HOME_NOTHING;
}
+ if (hasNavigationBar()) {
+ mLongPressOnHomeBehavior = LONG_PRESS_HOME_VOICE_SEARCH;
+ }
}
if (mLongPressOnHomeBehavior != LONG_PRESS_HOME_NOTHING) {
@@ -729,6 +734,18 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException when showing recent apps", e);
}
+ } else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_VOICE_SEARCH) {
+ Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
+ try {
+ intent.setFlags(
+ Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
+ mContext.startActivity(intent);
+ } catch (ActivityNotFoundException e) {
+ Log.e(TAG, "Unable to launch. tag=" + TAG + " intent=" + intent, e);
+ } catch (SecurityException e) {
+ Log.e(TAG, "PhoneWindowManager does not have the permission to launch " +
+ "tag=" + TAG + " intent=" + intent, e);
+ }
}
}