Merge "Call a search activity when using KEYCODE_SEARCH"
This commit is contained in:
@@ -1104,6 +1104,17 @@
|
|||||||
<integer name="config_shortPressOnStemPrimaryBehavior">0</integer>
|
<integer name="config_shortPressOnStemPrimaryBehavior">0</integer>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Control the behavior of the search key.
|
||||||
|
0 - Launch default search activity
|
||||||
|
1 - Launch target activity defined by config_searchKeyTargetActivity
|
||||||
|
-->
|
||||||
|
<integer name="config_searchKeyBehavior">0</integer>
|
||||||
|
|
||||||
|
<!-- Component name for the default target activity to be launched when user
|
||||||
|
presses the global search key. [DO NOT TRANSLATE]
|
||||||
|
-->
|
||||||
|
<string name="config_searchKeyTargetActivity" translatable="false"></string>
|
||||||
|
|
||||||
<!-- Time to wait while a button is pressed before triggering a very long press. -->
|
<!-- Time to wait while a button is pressed before triggering a very long press. -->
|
||||||
<integer name="config_veryLongPressTimeout">3500</integer>
|
<integer name="config_veryLongPressTimeout">3500</integer>
|
||||||
|
|
||||||
|
|||||||
@@ -451,6 +451,8 @@
|
|||||||
<java-symbol type="integer" name="config_doublePressOnStemPrimaryBehavior" />
|
<java-symbol type="integer" name="config_doublePressOnStemPrimaryBehavior" />
|
||||||
<java-symbol type="integer" name="config_triplePressOnStemPrimaryBehavior" />
|
<java-symbol type="integer" name="config_triplePressOnStemPrimaryBehavior" />
|
||||||
<java-symbol type="string" name="config_doublePressOnPowerTargetActivity" />
|
<java-symbol type="string" name="config_doublePressOnPowerTargetActivity" />
|
||||||
|
<java-symbol type="integer" name="config_searchKeyBehavior" />
|
||||||
|
<java-symbol type="string" name="config_searchKeyTargetActivity" />
|
||||||
<java-symbol type="integer" name="config_windowOutsetBottom" />
|
<java-symbol type="integer" name="config_windowOutsetBottom" />
|
||||||
<java-symbol type="integer" name="db_connection_pool_size" />
|
<java-symbol type="integer" name="db_connection_pool_size" />
|
||||||
<java-symbol type="integer" name="db_journal_size_limit" />
|
<java-symbol type="integer" name="db_journal_size_limit" />
|
||||||
|
|||||||
@@ -322,6 +322,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
static final int TRIPLE_PRESS_PRIMARY_NOTHING = 0;
|
static final int TRIPLE_PRESS_PRIMARY_NOTHING = 0;
|
||||||
static final int TRIPLE_PRESS_PRIMARY_TOGGLE_ACCESSIBILITY = 1;
|
static final int TRIPLE_PRESS_PRIMARY_TOGGLE_ACCESSIBILITY = 1;
|
||||||
|
|
||||||
|
// Must match: config_searchKeyBehavior in config.xml
|
||||||
|
static final int SEARCH_BEHAVIOR_DEFAULT_SEARCH = 0;
|
||||||
|
static final int SEARCH_BEHAVIOR_TARGET_ACTIVITY = 1;
|
||||||
|
|
||||||
static public final String SYSTEM_DIALOG_REASON_KEY = "reason";
|
static public final String SYSTEM_DIALOG_REASON_KEY = "reason";
|
||||||
static public final String SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions";
|
static public final String SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions";
|
||||||
static public final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps";
|
static public final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps";
|
||||||
@@ -525,6 +529,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
boolean mWakeOnAssistKeyPress;
|
boolean mWakeOnAssistKeyPress;
|
||||||
boolean mWakeOnBackKeyPress;
|
boolean mWakeOnBackKeyPress;
|
||||||
long mWakeUpToLastStateTimeout;
|
long mWakeUpToLastStateTimeout;
|
||||||
|
int mSearchKeyBehavior;
|
||||||
|
ComponentName mSearchKeyTargetActivity;
|
||||||
|
|
||||||
private boolean mHandleVolumeKeysInWM;
|
private boolean mHandleVolumeKeysInWM;
|
||||||
|
|
||||||
@@ -2039,6 +2045,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
mWakeUpToLastStateTimeout = mContext.getResources().getInteger(
|
mWakeUpToLastStateTimeout = mContext.getResources().getInteger(
|
||||||
com.android.internal.R.integer.config_wakeUpToLastStateTimeoutMillis);
|
com.android.internal.R.integer.config_wakeUpToLastStateTimeoutMillis);
|
||||||
|
|
||||||
|
mSearchKeyBehavior = mContext.getResources().getInteger(
|
||||||
|
com.android.internal.R.integer.config_searchKeyBehavior);
|
||||||
|
|
||||||
|
mSearchKeyTargetActivity = ComponentName.unflattenFromString(
|
||||||
|
mContext.getResources().getString(
|
||||||
|
com.android.internal.R.string.config_searchKeyTargetActivity));
|
||||||
readConfigurationDependentBehaviors();
|
readConfigurationDependentBehaviors();
|
||||||
|
|
||||||
mDisplayFoldController = DisplayFoldController.create(context, DEFAULT_DISPLAY);
|
mDisplayFoldController = DisplayFoldController.create(context, DEFAULT_DISPLAY);
|
||||||
@@ -2942,7 +2954,19 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
toggleNotificationPanel();
|
toggleNotificationPanel();
|
||||||
}
|
}
|
||||||
return key_consumed;
|
return key_consumed;
|
||||||
|
case KeyEvent.KEYCODE_SEARCH:
|
||||||
|
if (down && repeatCount == 0 && !keyguardOn()) {
|
||||||
|
switch(mSearchKeyBehavior) {
|
||||||
|
case SEARCH_BEHAVIOR_TARGET_ACTIVITY: {
|
||||||
|
launchTargetSearchActivity();
|
||||||
|
return key_consumed;
|
||||||
|
}
|
||||||
|
case SEARCH_BEHAVIOR_DEFAULT_SEARCH:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
case KeyEvent.KEYCODE_SPACE:
|
case KeyEvent.KEYCODE_SPACE:
|
||||||
// Handle keyboard layout switching. (META + SPACE)
|
// Handle keyboard layout switching. (META + SPACE)
|
||||||
if ((metaState & KeyEvent.META_META_MASK) == 0) {
|
if ((metaState & KeyEvent.META_META_MASK) == 0) {
|
||||||
@@ -6003,4 +6027,22 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void launchTargetSearchActivity() {
|
||||||
|
Intent intent;
|
||||||
|
if (mSearchKeyTargetActivity != null) {
|
||||||
|
intent = new Intent();
|
||||||
|
intent.setComponent(mSearchKeyTargetActivity);
|
||||||
|
} else {
|
||||||
|
intent = new Intent(Intent.ACTION_WEB_SEARCH);
|
||||||
|
}
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
|
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
|
||||||
|
try {
|
||||||
|
startActivityAsUser(intent, UserHandle.CURRENT_OR_SELF);
|
||||||
|
} catch (ActivityNotFoundException ignore) {
|
||||||
|
Slog.e(TAG, "Could not resolve activity with : "
|
||||||
|
+ intent.getComponent().flattenToString()
|
||||||
|
+ " name.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user