am 516c25b3: Merge "Fix 6414061: Add new ACTION_ASSIST intent." into jb-dev
* commit '516c25b38a03decc8f9cbd41f4d9baa4f52f438f': Fix 6414061: Add new ACTION_ASSIST intent.
This commit is contained in:
@@ -5661,6 +5661,7 @@ package android.content {
|
|||||||
field public static final java.lang.String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
|
field public static final java.lang.String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
|
||||||
field public static final java.lang.String ACTION_ANSWER = "android.intent.action.ANSWER";
|
field public static final java.lang.String ACTION_ANSWER = "android.intent.action.ANSWER";
|
||||||
field public static final java.lang.String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
|
field public static final java.lang.String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
|
||||||
|
field public static final java.lang.String ACTION_ASSIST = "android.intent.action.ASSIST";
|
||||||
field public static final java.lang.String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
|
field public static final java.lang.String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
|
||||||
field public static final java.lang.String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
|
field public static final java.lang.String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
|
||||||
field public static final java.lang.String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
|
field public static final java.lang.String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
|
||||||
|
|||||||
@@ -1098,6 +1098,14 @@ public class Intent implements Parcelable, Cloneable {
|
|||||||
*/
|
*/
|
||||||
@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
|
@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
|
||||||
public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
|
public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
|
||||||
|
/**
|
||||||
|
* Activity Action: Perform assist action.
|
||||||
|
* <p>
|
||||||
|
* Input: nothing
|
||||||
|
* Output: nothing.
|
||||||
|
*/
|
||||||
|
@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
|
||||||
|
public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
|
||||||
/**
|
/**
|
||||||
* Activity Action: List all available applications
|
* Activity Action: List all available applications
|
||||||
* <p>Input: Nothing.
|
* <p>Input: Nothing.
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ public class SearchPanelView extends FrameLayout implements
|
|||||||
private boolean mShowing;
|
private boolean mShowing;
|
||||||
private View mSearchTargetsContainer;
|
private View mSearchTargetsContainer;
|
||||||
private MultiWaveView mMultiWaveView;
|
private MultiWaveView mMultiWaveView;
|
||||||
private SearchManager mSearchManager;
|
|
||||||
|
|
||||||
public SearchPanelView(Context context, AttributeSet attrs) {
|
public SearchPanelView(Context context, AttributeSet attrs) {
|
||||||
this(context, attrs, 0);
|
this(context, attrs, 0);
|
||||||
@@ -67,10 +66,30 @@ public class SearchPanelView extends FrameLayout implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSearchAvailable() {
|
private SearchManager mSearchManager;
|
||||||
|
|
||||||
|
public boolean isAssistantAvailable() {
|
||||||
return mSearchManager != null && mSearchManager.getGlobalSearchActivity() != null;
|
return mSearchManager != null && mSearchManager.getGlobalSearchActivity() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startAssistActivity() {
|
||||||
|
if (mSearchManager != null) {
|
||||||
|
ComponentName globalSearchActivity = mSearchManager.getGlobalSearchActivity();
|
||||||
|
if (globalSearchActivity != null) {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_ASSIST);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
intent.setPackage(globalSearchActivity.getPackageName());
|
||||||
|
try {
|
||||||
|
mContext.startActivity(intent);
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
Slog.w(TAG, "Activity not found for " + intent.getAction());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Slog.w(TAG, "No global search activity");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final MultiWaveView.OnTriggerListener mMultiWaveViewListener
|
final MultiWaveView.OnTriggerListener mMultiWaveViewListener
|
||||||
= new MultiWaveView.OnTriggerListener() {
|
= new MultiWaveView.OnTriggerListener() {
|
||||||
|
|
||||||
@@ -90,29 +109,11 @@ public class SearchPanelView extends FrameLayout implements
|
|||||||
final int resId = mMultiWaveView.getResourceIdForTarget(target);
|
final int resId = mMultiWaveView.getResourceIdForTarget(target);
|
||||||
switch (resId) {
|
switch (resId) {
|
||||||
case com.android.internal.R.drawable.ic_lockscreen_search:
|
case com.android.internal.R.drawable.ic_lockscreen_search:
|
||||||
startGlobalSearch();
|
startAssistActivity();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mBar.hideSearchPanel();
|
mBar.hideSearchPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startGlobalSearch() {
|
|
||||||
if (mSearchManager != null) {
|
|
||||||
ComponentName globalSearchActivity = mSearchManager.getGlobalSearchActivity();
|
|
||||||
if (globalSearchActivity != null) {
|
|
||||||
Intent intent = new Intent(SearchManager.INTENT_ACTION_GLOBAL_SEARCH);
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
intent.setComponent(globalSearchActivity);
|
|
||||||
try {
|
|
||||||
mContext.startActivity(intent);
|
|
||||||
} catch (ActivityNotFoundException e) {
|
|
||||||
Slog.w(TAG, "Application not found for action " + intent.getAction());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Slog.w(TAG, "No global search activity");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -397,7 +397,7 @@ public abstract class BaseStatusBar extends SystemUI implements
|
|||||||
break;
|
break;
|
||||||
case MSG_OPEN_SEARCH_PANEL:
|
case MSG_OPEN_SEARCH_PANEL:
|
||||||
if (DEBUG) Slog.d(TAG, "opening search panel");
|
if (DEBUG) Slog.d(TAG, "opening search panel");
|
||||||
if (mSearchPanelView != null && mSearchPanelView.isSearchAvailable()) {
|
if (mSearchPanelView != null && mSearchPanelView.isAssistantAvailable()) {
|
||||||
mSearchPanelView.show(true, true);
|
mSearchPanelView.show(true, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import android.app.ActivityManager;
|
|||||||
import android.app.ActivityManagerNative;
|
import android.app.ActivityManagerNative;
|
||||||
import android.app.SearchManager;
|
import android.app.SearchManager;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
@@ -38,8 +39,8 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
import android.speech.RecognizerIntent;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.util.Slog;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
@@ -80,6 +81,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
|
|||||||
private View mUnlockWidget;
|
private View mUnlockWidget;
|
||||||
private boolean mCameraDisabled;
|
private boolean mCameraDisabled;
|
||||||
private boolean mSearchDisabled;
|
private boolean mSearchDisabled;
|
||||||
|
private SearchManager mSearchManager;
|
||||||
|
|
||||||
InfoCallbackImpl mInfoCallback = new InfoCallbackImpl() {
|
InfoCallbackImpl mInfoCallback = new InfoCallbackImpl() {
|
||||||
|
|
||||||
@@ -237,6 +239,25 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Intent getAssistIntent() {
|
||||||
|
Intent intent = null;
|
||||||
|
if (mSearchManager == null) {
|
||||||
|
mSearchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
|
||||||
|
}
|
||||||
|
if (mSearchManager != null) {
|
||||||
|
ComponentName globalSearchActivity = mSearchManager.getGlobalSearchActivity();
|
||||||
|
if (globalSearchActivity != null) {
|
||||||
|
intent = new Intent(Intent.ACTION_ASSIST);
|
||||||
|
intent.setPackage(globalSearchActivity.getPackageName());
|
||||||
|
} else {
|
||||||
|
Slog.w(TAG, "No global search activity");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Slog.w(TAG, "No SearchManager");
|
||||||
|
}
|
||||||
|
return intent;
|
||||||
|
}
|
||||||
|
|
||||||
class MultiWaveViewMethods implements MultiWaveView.OnTriggerListener,
|
class MultiWaveViewMethods implements MultiWaveView.OnTriggerListener,
|
||||||
UnlockWidgetCommonMethods {
|
UnlockWidgetCommonMethods {
|
||||||
private final MultiWaveView mMultiWaveView;
|
private final MultiWaveView mMultiWaveView;
|
||||||
@@ -279,7 +300,12 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
|
|||||||
final int resId = mMultiWaveView.getResourceIdForTarget(target);
|
final int resId = mMultiWaveView.getResourceIdForTarget(target);
|
||||||
switch (resId) {
|
switch (resId) {
|
||||||
case com.android.internal.R.drawable.ic_lockscreen_search:
|
case com.android.internal.R.drawable.ic_lockscreen_search:
|
||||||
launchActivity(new Intent(RecognizerIntent.ACTION_WEB_SEARCH));
|
Intent assistIntent = getAssistIntent();
|
||||||
|
if (assistIntent != null) {
|
||||||
|
launchActivity(assistIntent);
|
||||||
|
} else {
|
||||||
|
Log.w(TAG, "Failed to get intent for assist activity");
|
||||||
|
}
|
||||||
mCallback.pokeWakelock();
|
mCallback.pokeWakelock();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user