Commit 78f52b84 authored by Haiyang Pan's avatar Haiyang Pan Committed by Commit Bot

Revert "Reland "Reland "[Omnibox] Use ActivityState to check if we are in browser mode"""

This reverts commit 5d52e576.

Reason for revert: org.chromium.chrome.browser.omnibox.suggestions.SwitchToTabTest#testSwitchToTabSuggestion flakily fails with java.lang.NullPointerException
For example:
https://ci.chromium.org/p/chromium/builders/ci/android-pie-x86-rel/1524
https://ci.chromium.org/p/chromium/builders/ci/android-pie-x86-rel/1525
https://ci.chromium.org/p/chromium/builders/ci/android-marshmallow-x86-fyi-rel/1272

Also, it is flaky in android-pie-arm64-rel. See https://analysis.chromium.org/p/chromium/flake-portal/flakes/occurrences?key=ag9zfmZpbmRpdC1mb3ItbWVyhAELEgVGbGFrZSJ5Y2hyb21pdW1AY2hyb21lX3B1YmxpY190ZXN0X2Fwa0BvcmcuY2hyb21pdW0uY2hyb21lLmJyb3dzZXIub21uaWJveC5zdWdnZXN0aW9ucy5Td2l0Y2hUb1RhYlRlc3QjdGVzdFN3aXRjaFRvVGFiU3VnZ2VzdGlvbgw

Original change's description:
> Reland "Reland "[Omnibox] Use ActivityState to check if we are in browser mode""
> 
> This is a reland of 5ae112d1
> 
> Original change's description:
> > Reland "[Omnibox] Use ActivityState to check if we are in browser mode"
> > 
> > This is a reland of be1e9636
> > 
> > Update the test to run on UI thread.
> > 
> > Original change's description:
> > > [Omnibox] Use ActivityState to check if we are in browser mode
> > >
> > >
> > > In multi windows mode, check if we are in browser mode by WindowAndroid
> > > is not working, should check ActivityState instead.
> > >
> > > Bug: 1102640
> > > Change-Id: I35a720a2aa6f337cc9f9ae43e39d83c9368fcb5a
> > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2286478
> > > Commit-Queue: Gang Wu <gangwu@chromium.org>
> > > Reviewed-by: Ted Choc <tedchoc@chromium.org>
> > > Cr-Commit-Position: refs/heads/master@{#786636}
> > 
> > Bug: 1102640
> > Change-Id: Iefba5a5d0c181535bd7fb86cf0e073be2ebdbcdb
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2293074
> > Reviewed-by: Ted Choc <tedchoc@chromium.org>
> > Commit-Queue: Gang Wu <gangwu@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#788816}
> 
> Bug: 1102640
> Change-Id: I6da3c7ad8402cef83083a53f7ffc517f975720f8
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2301285
> Commit-Queue: Gang Wu <gangwu@chromium.org>
> Reviewed-by: Ted Choc <tedchoc@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#789727}

TBR=tedchoc@chromium.org,gangwu@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1102640
Change-Id: I2227da6e687932a6a90c3eb73f2a5386ba2c6d9f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2306749Reviewed-by: default avatarHaiyang Pan <hypan@google.com>
Commit-Queue: Haiyang Pan <hypan@google.com>
Cr-Commit-Position: refs/heads/master@{#789802}
parent 8a5cd716
...@@ -20,7 +20,6 @@ import androidx.annotation.Px; ...@@ -20,7 +20,6 @@ import androidx.annotation.Px;
import androidx.annotation.StringRes; import androidx.annotation.StringRes;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import org.chromium.base.ActivityState;
import org.chromium.base.Callback; import org.chromium.base.Callback;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.IntentUtils; import org.chromium.base.IntentUtils;
...@@ -577,10 +576,9 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, StartStopWi ...@@ -577,10 +576,9 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, StartStopWi
} }
// When invoked directly from a browser, we want to trigger switch to tab animation. // When invoked directly from a browser, we want to trigger switch to tab animation.
// If invoked from other activities, ex. searchActivity, we do not need to trigger the // If invoded from other activitiies, ex. searchActivity, we do not need to trigger the
// animation since Android will show the animation for switching apps. // animation since Android will show the animation for switching apps.
if (tab.getWindowAndroid().getActivityState() != ActivityState.STOPPED if (mWindowAndroid.equals(tab.getWindowAndroid())) {
&& tab.getWindowAndroid().getActivityState() != ActivityState.DESTROYED) {
// TODO(1097292): Do not use Activity to get TabModelSelector. // TODO(1097292): Do not use Activity to get TabModelSelector.
assert tab.getWindowAndroid().getActivity().get() instanceof ChromeActivity; assert tab.getWindowAndroid().getActivity().get() instanceof ChromeActivity;
...@@ -591,13 +589,13 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, StartStopWi ...@@ -591,13 +589,13 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, StartStopWi
chromeActivity.getTabModelSelector().getCurrentModel().setIndex( chromeActivity.getTabModelSelector().getCurrentModel().setIndex(
tabIndex, TabSelectionType.FROM_OMNIBOX); tabIndex, TabSelectionType.FROM_OMNIBOX);
} else { } else {
// Browser is in background, bring to to foreground and switch to the tab.
Intent newIntent = ChromeIntentUtil.createBringTabToFrontIntent(tab.getId()); Intent newIntent = ChromeIntentUtil.createBringTabToFrontIntent(tab.getId());
if (newIntent != null) { if (newIntent != null) {
newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
IntentUtils.safeStartActivity(ContextUtils.getApplicationContext(), newIntent); IntentUtils.safeStartActivity(ContextUtils.getApplicationContext(), newIntent);
} }
} }
recordMetrics(position, WindowOpenDisposition.SWITCH_TO_TAB, suggestion); recordMetrics(position, WindowOpenDisposition.SWITCH_TO_TAB, suggestion);
} }
......
...@@ -203,7 +203,7 @@ public class TestTouchUtils { ...@@ -203,7 +203,7 @@ public class TestTouchUtils {
* @param v The view to call performClick on. * @param v The view to call performClick on.
*/ */
public static void performClickOnMainSync(Instrumentation instrumentation, final View v) { public static void performClickOnMainSync(Instrumentation instrumentation, final View v) {
TestThreadUtils.runOnUiThreadBlocking(() -> { v.performClick(); }); instrumentation.runOnMainSync(() -> v.performClick());
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment