Java Code Examples for org.chromium.base.ActivityState#STOPPED

The following examples show how to use org.chromium.base.ActivityState#STOPPED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChromeFullscreenManager.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityStateChange(Activity activity, int newState) {
    if (newState == ActivityState.STOPPED) {
        // Exit fullscreen in onStop to ensure the system UI flags are set correctly when
        // showing again (on JB MR2+ builds, the omnibox would be covered by the
        // notification bar when this was done in onStart()).
        setPersistentFullscreenMode(false);
    } else if (newState == ActivityState.STARTED) {
        // Force the controls to be shown until we get an update from a Tab.  This is a
        // workaround for when the renderer is killed but the Tab is not notified.
        mActivityShowToken = showControlsPersistentAndClearOldToken(mActivityShowToken);
    } else if (newState == ActivityState.DESTROYED) {
        ApplicationStatus.unregisterActivityStateListener(this);
        ((BaseChromiumApplication) mWindow.getContext().getApplicationContext())
                .unregisterWindowFocusChangedListener(this);
    }
}
 
Example 2
Source File: OverlayPanel.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityStateChange(Activity activity, int newState) {
    boolean isMultiWindowMode = MultiWindowUtils.getInstance().isLegacyMultiWindow(mActivity)
            || MultiWindowUtils.getInstance().isInMultiWindowMode(mActivity);

    // In multi-window mode the activity that was interacted with last is resumed and
    // all others are paused. We should not close Contextual Search in this case,
    // because the activity may be visible even though it is paused.
    if (isMultiWindowMode
            && (newState == ActivityState.PAUSED || newState == ActivityState.RESUMED)) {
        return;
    }

    if (newState == ActivityState.RESUMED
            || newState == ActivityState.STOPPED
            || newState == ActivityState.DESTROYED) {
        closePanel(StateChangeReason.UNKNOWN, false);
    }
}
 
Example 3
Source File: ChromeFullscreenManager.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityStateChange(Activity activity, int newState) {
    if (newState == ActivityState.STOPPED && mExitFullscreenOnStop) {
        // Exit fullscreen in onStop to ensure the system UI flags are set correctly when
        // showing again (on JB MR2+ builds, the omnibox would be covered by the
        // notification bar when this was done in onStart()).
        setPersistentFullscreenMode(false);
    } else if (newState == ActivityState.STARTED) {
        ThreadUtils.postOnUiThreadDelayed(new Runnable() {
            @Override
            public void run() {
                mBrowserVisibilityDelegate.showControlsTransient();
            }
        }, ACTIVITY_RETURN_SHOW_REQUEST_DELAY_MS);
    } else if (newState == ActivityState.DESTROYED) {
        ApplicationStatus.unregisterActivityStateListener(this);
        ((BaseChromiumApplication) mWindow.getContext().getApplicationContext())
                .unregisterWindowFocusChangedListener(this);

        mTabModelObserver.destroy();
    }
}
 
Example 4
Source File: IncognitoNotificationService.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private Set<Integer> getTaskIdsForVisibleActivities() {
    List<WeakReference<Activity>> runningActivities =
            ApplicationStatus.getRunningActivities();
    Set<Integer> visibleTaskIds = new HashSet<>();
    for (int i = 0; i < runningActivities.size(); i++) {
        Activity activity = runningActivities.get(i).get();
        if (activity == null) continue;

        int activityState = ApplicationStatus.getStateForActivity(activity);
        if (activityState != ActivityState.STOPPED
                && activityState != ActivityState.DESTROYED) {
            visibleTaskIds.add(activity.getTaskId());
        }
    }
    return visibleTaskIds;
}
 
Example 5
Source File: OverlayPanel.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityStateChange(Activity activity, int newState) {
    boolean isMultiWindowMode = MultiWindowUtils.getInstance().isLegacyMultiWindow(mActivity)
            || MultiWindowUtils.getInstance().isInMultiWindowMode(mActivity);

    // In multi-window mode the activity that was interacted with last is resumed and
    // all others are paused. We should not close Contextual Search in this case,
    // because the activity may be visible even though it is paused.
    if (isMultiWindowMode
            && (newState == ActivityState.PAUSED || newState == ActivityState.RESUMED)) {
        return;
    }

    if (newState == ActivityState.RESUMED
            || newState == ActivityState.STOPPED
            || newState == ActivityState.DESTROYED) {
        closePanel(StateChangeReason.UNKNOWN, false);
    }
}
 
Example 6
Source File: ChromeFullscreenManager.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityStateChange(Activity activity, int newState) {
    if (newState == ActivityState.STOPPED) {
        // Exit fullscreen in onStop to ensure the system UI flags are set correctly when
        // showing again (on JB MR2+ builds, the omnibox would be covered by the
        // notification bar when this was done in onStart()).
        setPersistentFullscreenMode(false);
    } else if (newState == ActivityState.STARTED) {
        ThreadUtils.postOnUiThreadDelayed(new Runnable() {
            @Override
            public void run() {
                mBrowserVisibilityDelegate.showControlsTransient();
            }
        }, ACTIVITY_RETURN_SHOW_REQUEST_DELAY_MS);
    } else if (newState == ActivityState.DESTROYED) {
        ApplicationStatus.unregisterActivityStateListener(this);
        ((BaseChromiumApplication) mWindow.getContext().getApplicationContext())
                .unregisterWindowFocusChangedListener(this);

        mTabModelObserver.destroy();
    }
}
 
Example 7
Source File: IncognitoNotificationService.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private Set<Integer> getTaskIdsForVisibleActivities() {
    List<WeakReference<Activity>> runningActivities =
            ApplicationStatus.getRunningActivities();
    Set<Integer> visibleTaskIds = new HashSet<>();
    for (int i = 0; i < runningActivities.size(); i++) {
        Activity activity = runningActivities.get(i).get();
        if (activity == null) continue;

        int activityState = ApplicationStatus.getStateForActivity(activity);
        if (activityState != ActivityState.STOPPED
                && activityState != ActivityState.DESTROYED) {
            visibleTaskIds.add(activity.getTaskId());
        }
    }
    return visibleTaskIds;
}
 
Example 8
Source File: VrWindowAndroid.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityStateChange(Activity activity, int newState) {
    if (newState == ActivityState.STOPPED) {
        onActivityStopped();
    } else if (newState == ActivityState.STARTED) {
        onActivityStarted();
    }
}
 
Example 9
Source File: ActivityWindowAndroid.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityStateChange(Activity activity, int newState) {
    if (newState == ActivityState.STOPPED) {
        onActivityStopped();
    } else if (newState == ActivityState.STARTED) {
        onActivityStarted();
    }
}
 
Example 10
Source File: SigninManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Returns whether the sign-in flow activity was set but is no longer visible to the user.
 */
private boolean isActivityInvisible() {
    return activity != null
            && (ApplicationStatus.getStateForActivity(activity) == ActivityState.STOPPED
                       || ApplicationStatus.getStateForActivity(activity)
                               == ActivityState.DESTROYED);
}
 
Example 11
Source File: TabWebContentsDelegateAndroid.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void activateContents() {
    ChromeActivity activity = mTab.getActivity();
    if (activity == null) {
        Log.e(TAG, "Activity not set activateContents().  Bailing out.");
        return;
    }
    if (activity.isActivityDestroyed()) {
        Log.e(TAG, "Activity destroyed before calling activateContents().  Bailing out.");
        return;
    }
    if (!mTab.isInitialized()) {
        Log.e(TAG, "Tab not initialized before calling activateContents().  Bailing out.");
        return;
    }

    // Do nothing if the tab can currently be interacted with by the user.
    if (mTab.isUserInteractable()) return;

    TabModel model = getTabModel();
    int index = model.indexOf(mTab);
    if (index == TabModel.INVALID_TAB_INDEX) return;
    TabModelUtils.setIndex(model, index);

    // Do nothing if the activity is visible (STOPPED is the only valid invisible state as we
    // explicitly check isActivityDestroyed above).
    if (ApplicationStatus.getStateForActivity(activity) == ActivityState.STOPPED) {
        bringActivityToForeground();
    }
}
 
Example 12
Source File: SigninManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Returns whether the sign-in flow activity was set but is no longer visible to the user.
 */
private boolean isActivityInvisible() {
    return activity != null
            && (ApplicationStatus.getStateForActivity(activity) == ActivityState.STOPPED
                       || ApplicationStatus.getStateForActivity(activity)
                               == ActivityState.DESTROYED);
}
 
Example 13
Source File: VrWindowAndroid.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityStateChange(Activity activity, int newState) {
    if (newState == ActivityState.STOPPED) {
        onActivityStopped();
    } else if (newState == ActivityState.STARTED) {
        onActivityStarted();
    }
}
 
Example 14
Source File: ChromeActivity.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    Tab tab = getActivityTab();
    if (tab == null) return;
    if (hasFocus) {
        tab.onActivityShown();
    } else {
        boolean stopped = ApplicationStatus.getStateForActivity(this) == ActivityState.STOPPED;
        if (stopped) tab.onActivityHidden();
    }
}
 
Example 15
Source File: SigninManager.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Returns whether the sign-in flow activity was set but is no longer visible to the user.
 */
private boolean isActivityInvisible() {
    return activity != null
            && (ApplicationStatus.getStateForActivity(activity) == ActivityState.STOPPED
                       || ApplicationStatus.getStateForActivity(activity)
                               == ActivityState.DESTROYED);
}
 
Example 16
Source File: ChromeActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);

    maybeRemoveWindowBackground();

    Tab tab = getActivityTab();
    if (tab == null) return;
    if (hasFocus) {
        tab.onActivityShown();
    } else {
        boolean stopped = ApplicationStatus.getStateForActivity(this) == ActivityState.STOPPED;
        if (stopped) tab.onActivityHidden();
    }
}
 
Example 17
Source File: TabModelSelectorUma.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityStateChange(Activity activity, int newState) {
    if (newState != ActivityState.STOPPED) return;
    if (mRestoredTabId != -1) {
        recordUserActionDuringTabRestore(USER_LEFT_CHROME_DURING_RESTORE);
        mRestoredTabId = -1;
    }
}
 
Example 18
Source File: TabWebContentsObserver.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public void renderProcessGone(boolean processWasOomProtected) {
    Log.i(TAG, "renderProcessGone() for tab id: " + mTab.getId()
            + ", oom protected: " + Boolean.toString(processWasOomProtected)
            + ", already needs reload: " + Boolean.toString(mTab.needsReload()));
    // Do nothing for subsequent calls that happen while the tab remains crashed. This
    // can occur when the tab is in the background and it shares the renderer with other
    // tabs. After the renderer crashes, the WebContents of its tabs are still around
    // and they still share the RenderProcessHost. When one of the tabs reloads spawning
    // a new renderer for the shared RenderProcessHost and the new renderer crashes
    // again, all tabs sharing this renderer will be notified about the crash (including
    // potential background tabs that did not reload yet).
    if (mTab.needsReload() || mTab.isShowingSadTab()) return;

    // This will replace TabRendererCrashStatus if numbers line up.
    int appState = ApplicationStatus.getStateForApplication();
    boolean applicationRunning = (appState == ApplicationState.HAS_RUNNING_ACTIVITIES);
    boolean applicationPaused = (appState == ApplicationState.HAS_PAUSED_ACTIVITIES);
    @TabRendererExitStatus int rendererExitStatus = TAB_RENDERER_EXIT_STATUS_MAX;
    if (processWasOomProtected) {
        if (applicationRunning) {
            rendererExitStatus = TAB_RENDERER_EXIT_STATUS_OOM_PROTECTED_IN_RUNNING_APP;
        } else if (applicationPaused) {
            rendererExitStatus = TAB_RENDERER_EXIT_STATUS_OOM_PROTECTED_IN_PAUSED_APP;
        } else {
            rendererExitStatus = TAB_RENDERER_EXIT_STATUS_OOM_PROTECTED_IN_BACKGROUND_APP;
        }
    } else {
        if (applicationRunning) {
            rendererExitStatus = TAB_RENDERER_EXIT_STATUS_NOT_PROTECTED_IN_RUNNING_APP;
        } else if (applicationPaused) {
            rendererExitStatus = TAB_RENDERER_EXIT_STATUS_NOT_PROTECTED_IN_PAUSED_APP;
        } else {
            rendererExitStatus = TAB_RENDERER_EXIT_STATUS_NOT_PROTECTED_IN_BACKGROUND_APP;
        }
    }
    RecordHistogram.recordEnumeratedHistogram(
            "Tab.RendererExitStatus", rendererExitStatus, TAB_RENDERER_EXIT_STATUS_MAX);

    int activityState = ApplicationStatus.getStateForActivity(
            mTab.getWindowAndroid().getActivity().get());
    int rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_MAX;
    if (!processWasOomProtected
            || activityState == ActivityState.PAUSED
            || activityState == ActivityState.STOPPED
            || activityState == ActivityState.DESTROYED) {
        // The tab crashed in background or was killed by the OS out-of-memory killer.
        //setNeedsReload(true);
        mTab.setNeedsReload(true);
        if (applicationRunning) {
            rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_HIDDEN_IN_FOREGROUND_APP;
        } else {
            rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_HIDDEN_IN_BACKGROUND_APP;
        }
    } else {
        rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_SHOWN_IN_FOREGROUND_APP;
        mTab.showSadTab();
        // This is necessary to correlate histogram data with stability counts.
        UmaSessionStats.logRendererCrash();
    }
    RecordHistogram.recordEnumeratedHistogram(
            "Tab.RendererCrashStatus", rendererCrashStatus, TAB_RENDERER_CRASH_STATUS_MAX);

    mTab.handleTabCrash();

    boolean sadTabShown = mTab.isShowingSadTab();
    RewindableIterator<TabObserver> observers = mTab.getTabObservers();
    while (observers.hasNext()) {
        observers.next().onCrash(mTab, sadTabShown);
    }
}
 
Example 19
Source File: WebApkUpdateManager.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/** Returns whether the associated WebApkActivity is running in foreground. */
protected boolean isInForeground() {
    int state = ApplicationStatus.getStateForActivity(mActivity);
    return (state != ActivityState.STOPPED && state != ActivityState.DESTROYED);
}
 
Example 20
Source File: TabWebContentsObserver.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public void renderProcessGone(boolean processWasOomProtected) {
    Log.i(TAG, "renderProcessGone() for tab id: " + mTab.getId()
            + ", oom protected: " + Boolean.toString(processWasOomProtected)
            + ", already needs reload: " + Boolean.toString(mTab.needsReload()));
    // Do nothing for subsequent calls that happen while the tab remains crashed. This
    // can occur when the tab is in the background and it shares the renderer with other
    // tabs. After the renderer crashes, the WebContents of its tabs are still around
    // and they still share the RenderProcessHost. When one of the tabs reloads spawning
    // a new renderer for the shared RenderProcessHost and the new renderer crashes
    // again, all tabs sharing this renderer will be notified about the crash (including
    // potential background tabs that did not reload yet).
    if (mTab.needsReload() || mTab.isShowingSadTab()) return;

    // This will replace TabRendererCrashStatus if numbers line up.
    int appState = ApplicationStatus.getStateForApplication();
    boolean applicationRunning = (appState == ApplicationState.HAS_RUNNING_ACTIVITIES);
    boolean applicationPaused = (appState == ApplicationState.HAS_PAUSED_ACTIVITIES);
    @TabRendererExitStatus int rendererExitStatus = TAB_RENDERER_EXIT_STATUS_MAX;
    if (processWasOomProtected) {
        if (applicationRunning) {
            rendererExitStatus = TAB_RENDERER_EXIT_STATUS_OOM_PROTECTED_IN_RUNNING_APP;
        } else if (applicationPaused) {
            rendererExitStatus = TAB_RENDERER_EXIT_STATUS_OOM_PROTECTED_IN_PAUSED_APP;
        } else {
            rendererExitStatus = TAB_RENDERER_EXIT_STATUS_OOM_PROTECTED_IN_BACKGROUND_APP;
        }
    } else {
        if (applicationRunning) {
            rendererExitStatus = TAB_RENDERER_EXIT_STATUS_NOT_PROTECTED_IN_RUNNING_APP;
        } else if (applicationPaused) {
            rendererExitStatus = TAB_RENDERER_EXIT_STATUS_NOT_PROTECTED_IN_PAUSED_APP;
        } else {
            rendererExitStatus = TAB_RENDERER_EXIT_STATUS_NOT_PROTECTED_IN_BACKGROUND_APP;
        }
    }
    RecordHistogram.recordEnumeratedHistogram(
            "Tab.RendererExitStatus", rendererExitStatus, TAB_RENDERER_EXIT_STATUS_MAX);

    int activityState = ApplicationStatus.getStateForActivity(
            mTab.getWindowAndroid().getActivity().get());
    int rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_MAX;
    if (!processWasOomProtected
            || activityState == ActivityState.PAUSED
            || activityState == ActivityState.STOPPED
            || activityState == ActivityState.DESTROYED) {
        // The tab crashed in background or was killed by the OS out-of-memory killer.
        //setNeedsReload(true);
        mTab.setNeedsReload(true);
        if (applicationRunning) {
            rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_HIDDEN_IN_FOREGROUND_APP;
        } else {
            rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_HIDDEN_IN_BACKGROUND_APP;
        }
    } else {
        rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_SHOWN_IN_FOREGROUND_APP;
        mTab.showSadTab();
        // This is necessary to correlate histogram data with stability counts.
        UmaSessionStats.logRendererCrash();
    }
    RecordHistogram.recordEnumeratedHistogram(
            "Tab.RendererCrashStatus", rendererCrashStatus, TAB_RENDERER_CRASH_STATUS_MAX);

    mTab.handleTabCrash();

    boolean sadTabShown = mTab.isShowingSadTab();
    RewindableIterator<TabObserver> observers = mTab.getTabObservers();
    while (observers.hasNext()) {
        observers.next().onCrash(mTab, sadTabShown);
    }
}