Bug 1320072 - Backout intent change - broke partner Google test. r?snorp
MozReview-Commit-ID: A3wJnvdYjOZ
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/mozglue/SafeIntent.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/mozglue/SafeIntent.java
@@ -5,17 +5,16 @@
*/
// This should be in util/, but is here because of build dependency issues.
package org.mozilla.gecko.mozglue;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
-import android.support.annotation.Nullable;
import android.util.Log;
import java.util.ArrayList;
/**
* External applications can pass values into Intents that can cause us to crash: in defense,
* we wrap {@link Intent} and catch the exceptions they may force us to throw. See bug 1090385
* for more.
@@ -72,29 +71,16 @@ public class SafeIntent {
Log.w(LOGTAG, "Couldn't get intent extras: OOM. Malformed?");
return null;
} catch (RuntimeException e) {
Log.w(LOGTAG, "Couldn't get intent extras.", e);
return null;
}
}
- @Nullable
- public Bundle getExtras() {
- try {
- return intent.getExtras();
- } catch (OutOfMemoryError e) {
- Log.w(LOGTAG, "Couldn't get intent extras: OOM. Malformed?");
- return null;
- } catch (RuntimeException e) {
- Log.w(LOGTAG, "Couldn't get intent extras.", e);
- return null;
- }
- }
-
public Bundle getBundleExtra(final String name) {
try {
return intent.getBundleExtra(name);
} catch (OutOfMemoryError e) {
Log.w(LOGTAG, "Couldn't get intent extras: OOM. Malformed?");
return null;
} catch (RuntimeException e) {
Log.w(LOGTAG, "Couldn't get intent extras.", e);
--- a/mobile/android/search/java/org/mozilla/search/SearchActivity.java
+++ b/mobile/android/search/java/org/mozilla/search/SearchActivity.java
@@ -1,37 +1,34 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.search;
-import android.app.SearchManager;
import android.support.annotation.NonNull;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.Locales;
import org.mozilla.gecko.R;
import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.TelemetryContract;
import org.mozilla.gecko.db.BrowserContract.SearchHistory;
import org.mozilla.gecko.distribution.Distribution;
-import org.mozilla.gecko.mozglue.SafeIntent;
import org.mozilla.gecko.search.SearchEngine;
import org.mozilla.gecko.search.SearchEngineManager;
import org.mozilla.gecko.search.SearchEngineManager.SearchEngineCallback;
import org.mozilla.search.autocomplete.SearchBar;
import org.mozilla.search.autocomplete.SuggestionsFragment;
import android.content.AsyncQueryHandler;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
-import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Interpolator;
import android.animation.Animator;
import android.animation.AnimatorSet;
@@ -45,18 +42,17 @@ import android.animation.ObjectAnimator;
*/
public class SearchActivity extends Locales.LocaleAwareFragmentActivity
implements AcceptsSearchQuery, SearchEngineCallback {
private static final String LOGTAG = "GeckoSearchActivity";
private static final String KEY_SEARCH_STATE = "search_state";
private static final String KEY_EDIT_STATE = "edit_state";
- private static final String KEY_QUERY = SearchManager.QUERY;
- private static final String KEY_INCOMING_QUERY = "incoming_query";
+ private static final String KEY_QUERY = "query";
static enum SearchState {
PRESEARCH,
POSTSEARCH
}
static enum EditState {
WAITING,
@@ -173,68 +169,34 @@ public class SearchActivity extends Loca
suggestions = findViewById(R.id.suggestions);
animationCard = findViewById(R.id.animation_card);
cardPaddingX = getResources().getDimensionPixelSize(R.dimen.search_row_padding);
cardPaddingY = getResources().getDimensionPixelSize(R.dimen.search_row_padding);
- final String query;
-
- final String incomingQuery = extractQuery(getIntent());
- final String previousInstanceQuery = extractQuery(savedInstanceState);
- final String previousIncomingQuery = savedInstanceState == null ? null : savedInstanceState.getString(KEY_INCOMING_QUERY);
-
- if (savedInstanceState != null && (TextUtils.isEmpty(incomingQuery) || incomingQuery.equals(previousIncomingQuery))) {
+ if (savedInstanceState != null) {
setSearchState(SearchState.valueOf(savedInstanceState.getString(KEY_SEARCH_STATE)));
setEditState(EditState.valueOf(savedInstanceState.getString(KEY_EDIT_STATE)));
- query = previousInstanceQuery;
- } else {
- query = incomingQuery;
- if (!TextUtils.isEmpty(query)) {
- setSearchState(SearchState.POSTSEARCH);
- }
- }
- if (!TextUtils.isEmpty(query)) {
+ final String query = savedInstanceState.getString(KEY_QUERY);
searchBar.setText(query);
+
// If we're in the postsearch state, we need to re-do the query.
if (searchState == SearchState.POSTSEARCH) {
- onSearch(query);
+ startSearch(query);
}
} else {
// If there isn't a state to restore, the activity will start in the presearch state,
// and we should enter editing mode to bring up the keyboard.
setEditState(EditState.EDITING);
}
}
- @Nullable
- private String extractQuery(Intent intent) {
- return extractQuery(intent == null ? null : new SafeIntent(intent).getExtras());
- }
-
- @Nullable
- private String extractQuery(Bundle bundle) {
- if (bundle == null) {
- return null;
- }
-
- String queryString = (String) bundle.getCharSequence("android.intent.extra.PROCESS_TEXT_READONLY");;
- if (TextUtils.isEmpty(queryString)) {
- queryString = (String) bundle.getCharSequence("android.intent.extra.PROCESS_TEXT");
- }
- if (TextUtils.isEmpty(queryString)) {
- queryString = bundle.getString(KEY_QUERY);
- }
-
- return queryString;
- }
-
@Override
protected void onDestroy() {
super.onDestroy();
searchEngineManager.unregisterListeners();
engine = null;
suggestionsFragment = null;
postSearchFragment = null;
queryHandler = null;
@@ -258,34 +220,26 @@ public class SearchActivity extends Loca
Telemetry.stopUISession(TelemetryContract.Session.SEARCH_ACTIVITY);
}
@Override
public void onNewIntent(Intent intent) {
// Reset the activity in the presearch state if it was launched from a new intent.
setSearchState(SearchState.PRESEARCH);
- final String queryString = extractQuery(intent);
- if(!TextUtils.isEmpty(queryString)) {
- setSearchState(SearchState.POSTSEARCH);
- searchBar.setText(queryString);
- onSearch(queryString);
- } else {
- // Enter editing mode and reset the query. We must reset the query after entering
- // edit mode in order for the suggestions to update.
- setEditState(EditState.EDITING);
- searchBar.setText("");
- }
+ // Enter editing mode and reset the query. We must reset the query after entering
+ // edit mode in order for the suggestions to update.
+ setEditState(EditState.EDITING);
+ searchBar.setText("");
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
- outState.putString(KEY_INCOMING_QUERY, extractQuery(getIntent()));
outState.putString(KEY_SEARCH_STATE, searchState.toString());
outState.putString(KEY_EDIT_STATE, editState.toString());
outState.putString(KEY_QUERY, searchBar.getText());
}
@Override
public void onSuggest(String query) {
searchBar.setText(query);
--- a/mobile/android/search/manifests/SearchAndroidManifest_activities.xml.in
+++ b/mobile/android/search/manifests/SearchAndroidManifest_activities.xml.in
@@ -4,29 +4,20 @@
android:launchMode="singleTop"
android:taskAffinity="@ANDROID_PACKAGE_NAME@.SEARCH"
android:icon="@drawable/search_launcher"
android:label="@string/search_app_name"
android:configChanges="orientation|screenSize"
android:theme="@style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.ASSIST"/>
- <action android:name="android.intent.action.SEARCH"/>
- <action android:name="android.intent.action.SEARCH_LONG_PRESS"/>
- <action android:name="android.intent.action.WEB_SEARCH"/>
- <action android:name="com.google.android.gms.actions.SEARCH_ACTION"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.PROCESS_TEXT"/>
- <data android:mimeType="text/plain"/>
- </intent-filter>
-
<!-- Pre Lollipop devices display a generic search icon, if none is
provided here. To use this we need to set the resource to 0.
For Lollipop and later the search launcher icon ist used.
To retrieve the resource value the Bundle.getInt() method is
used, so we use integer resources instead of drawables, because
setting a drawable referenced to 0 results in errors when used
as a real drawable resource somewhere else. -->
<meta-data