summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2012-08-14 09:32:02 -0700
committerAmith Yamasani <yamasani@google.com>2012-08-14 12:39:29 -0700
commitc1d07a4bd26c0ecf87bfa151ae43cb92c0c73791 (patch)
tree620e4b1cf4e7534b41ea94f9ac3732fa622e4670 /policy
parentb26295b7a0bc23deb2987c4ff10810c3ce2f1869 (diff)
downloadframeworks_base-c1d07a4bd26c0ecf87bfa151ae43cb92c0c73791.zip
frameworks_base-c1d07a4bd26c0ecf87bfa151ae43cb92c0c73791.tar.gz
frameworks_base-c1d07a4bd26c0ecf87bfa151ae43cb92c0c73791.tar.bz2
Launch ASSIST intent on the current user
Lockscreen and statusbar now launch the intent on the current user. Make sure that the intent resolution is made to the package manager for the specific user, as the app could have been disabled for that user or may have an alternative app installed. Change-Id: I93b0f972d6c7e8880b146da83dc3d08a68fe7e51
Diffstat (limited to 'policy')
-rw-r--r--policy/src/com/android/internal/policy/impl/LockScreen.java18
-rwxr-xr-xpolicy/src/com/android/internal/policy/impl/PhoneWindowManager.java8
2 files changed, 19 insertions, 7 deletions
diff --git a/policy/src/com/android/internal/policy/impl/LockScreen.java b/policy/src/com/android/internal/policy/impl/LockScreen.java
index 82181d3..8645172 100644
--- a/policy/src/com/android/internal/policy/impl/LockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/LockScreen.java
@@ -32,6 +32,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.os.UserId;
import android.os.Vibrator;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -275,7 +276,8 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
// Update the search icon with drawable from the search .apk
if (!mSearchDisabled) {
- Intent intent = SearchManager.getAssistIntent(mContext);
+ Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE))
+ .getAssistIntent(mContext, UserId.USER_CURRENT);
if (intent != null) {
// XXX Hack. We need to substitute the icon here but haven't formalized
// the public API. The "_google" metadata will be going away, so
@@ -309,7 +311,9 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
final int resId = mGlowPadView.getResourceIdForTarget(target);
switch (resId) {
case com.android.internal.R.drawable.ic_action_assist_generic:
- Intent assistIntent = SearchManager.getAssistIntent(mContext);
+ Intent assistIntent =
+ ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE))
+ .getAssistIntent(mContext, UserId.USER_CURRENT);
if (assistIntent != null) {
launchActivity(assistIntent);
} else {
@@ -335,6 +339,10 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
}
}
+ /**
+ * Launches the said intent for the current foreground user.
+ * @param intent
+ */
private void launchActivity(Intent intent) {
intent.setFlags(
Intent.FLAG_ACTIVITY_NEW_TASK
@@ -346,7 +354,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
Log.w(TAG, "can't dismiss keyguard on launch");
}
try {
- mContext.startActivity(intent);
+ mContext.startActivityAsUser(intent, UserId.USER_CURRENT);
} catch (ActivityNotFoundException e) {
Log.w(TAG, "Activity not found for intent + " + intent.getAction());
}
@@ -522,7 +530,9 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
} else if (disabledBySimState) {
Log.v(TAG, "Camera disabled by Sim State");
}
- boolean searchActionAvailable = SearchManager.getAssistIntent(mContext) != null;
+ boolean searchActionAvailable =
+ ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE))
+ .getAssistIntent(mContext, UserId.USER_CURRENT) != null;
mCameraDisabled = disabledByAdmin || disabledBySimState || !cameraTargetPresent;
mSearchDisabled = disabledBySimState || !searchActionAvailable || !searchTargetPresent;
mUnlockWidgetMethods.updateResources();
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 8c627a3..769b513 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -55,6 +55,7 @@ import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UEventObserver;
+import android.os.UserId;
import android.os.Vibrator;
import android.provider.Settings;
@@ -2110,7 +2111,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (searchManager != null) {
searchManager.stopSearch();
}
- mContext.startActivity(intent);
+ mContext.startActivityAsUser(intent, UserId.USER_CURRENT);
} catch (ActivityNotFoundException e) {
Slog.w(TAG, "No activity to handle assist long press action.", e);
}
@@ -2118,13 +2119,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
private void launchAssistAction() {
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST);
- Intent intent = SearchManager.getAssistIntent(mContext);
+ Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE))
+ .getAssistIntent(mContext, UserId.USER_CURRENT);
if (intent != null) {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_SINGLE_TOP
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
- mContext.startActivity(intent);
+ mContext.startActivityAsUser(intent, UserId.USER_CURRENT);
} catch (ActivityNotFoundException e) {
Slog.w(TAG, "No activity to handle assist action.", e);
}