1 // Copyright (c) 2013-2014 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.xwalk.core.internal;
7 import android.app.Activity;
8 import android.app.AlertDialog;
9 import android.app.ApplicationErrorReport;
10 import android.content.Context;
11 import android.content.DialogInterface;
12 import android.content.Intent;
13 import android.graphics.Rect;
14 import android.net.Uri;
15 import android.os.Bundle;
16 import android.os.Environment;
17 import android.os.Looper;
18 import android.util.AttributeSet;
19 import android.view.KeyEvent;
20 import android.view.ViewGroup;
21 import android.webkit.ValueCallback;
22 import android.widget.FrameLayout;
25 import java.io.PrintWriter;
26 import java.io.StringWriter;
27 import java.lang.ref.WeakReference;
29 import org.chromium.base.ActivityState;
30 import org.chromium.base.ApplicationStatus;
31 import org.chromium.base.ApplicationStatus.ActivityStateListener;
32 import org.chromium.base.CommandLine;
33 import org.xwalk.core.internal.extension.BuiltinXWalkExtensions;
36 * <p>XWalkViewInternal represents an Android view for web apps/pages. Thus most of attributes
37 * for Android view are valid for this class. Since it internally uses
38 * <a href="http://developer.android.com/reference/android/view/SurfaceView.html">
39 * android.view.SurfaceView</a> for rendering web pages by default, it can't be resized,
40 * rotated, transformed and animated due to the limitations of SurfaceView.
41 * Alternatively, if the preference key {@link XWalkPreferencesInternal#ANIMATABLE_XWALK_VIEW}
42 * is set to True, XWalkViewInternal can be transformed and animated because
43 * <a href="http://developer.android.com/reference/android/view/TextureView.html">
44 * TextureView</a> is intentionally used to render web pages for animation support.
45 * Besides, XWalkViewInternal won't be rendered if it's invisible.</p>
47 * <p>XWalkViewInternal needs hardware acceleration to render web pages. As a result, the
48 * AndroidManifest.xml of the caller's app must be appended with the attribute
49 * "android:hardwareAccelerated" and its value must be set as "true".</p>
51 * <application android:name="android.app.Application" android:label="XWalkUsers"
52 * android:hardwareAccelerated="true">
55 * <p>Crosswalk provides 2 major callback classes, namely {@link XWalkResourceClientInternal} and
56 * {@link XWalkUIClientInternal} for listening to the events related to resource loading and UI.
57 * By default, Crosswalk has a default implementation. Callers can override them if needed.</p>
59 * <p>Unlike other Android views, this class has to listen to system events like intents and activity result.
60 * The web engine inside this view need to get and handle them.
61 * With contianer activity's lifecycle change, XWalkViewInternal will pause all timers and other
62 * components like videos when activity paused, resume back them when activity resumed.
63 * When activity is about to destroy, XWalkViewInternal will destroy itself as well.
64 * Embedders can also call onHide() and pauseTimers() to explicitly pause XWalkViewInternal.
65 * Similarily with onShow(), resumeTimers() and onDestroy().
70 * import android.app.Activity;
71 * import android.os.Bundle;
73 * import org.xwalk.core.internal.XWalkResourceClientInternal;
74 * import org.xwalk.core.internal.XWalkUIClientInternal;
75 * import org.xwalk.core.internal.XWalkViewInternal;
77 * public class MyActivity extends Activity {
78 * XWalkViewInternal mXwalkView;
80 * class MyResourceClient extends XWalkResourceClientInternal {
81 * MyResourceClient(XWalkViewInternal view) {
86 * WebResourceResponse shouldInterceptLoadRequest(XWalkViewInternal view, String url) {
92 * class MyUIClient extends XWalkUIClientInternal {
93 * MyUIClient(XWalkViewInternal view) {
98 * void onFullscreenToggled(XWalkViewInternal view, String url) {
105 * protected void onCreate(Bundle savedInstanceState) {
106 * mXwalkView = new XWalkViewInternal(this, null);
107 * setContentView(mXwalkView);
108 * mXwalkView.setResourceClient(new MyResourceClient(mXwalkView));
109 * mXwalkView.setUIClient(new MyUIClient(mXwalkView));
110 * mXwalkView.load("http://www.crosswalk-project.org", null);
114 * protected void onActivityResult(int requestCode, int resultCode, Intent data) {
115 * if (mXwalkView != null) {
116 * mXwalkView.onActivityResult(requestCode, resultCode, data);
121 * protected void onNewIntent(Intent intent) {
122 * if (mXwalkView != null) {
123 * mXwalkView.onNewIntent(intent);
129 @XWalkAPI(extendClass = FrameLayout.class, createExternally = true)
130 public class XWalkViewInternal extends android.widget.FrameLayout {
132 private class XWalkActivityStateListener implements ActivityStateListener {
133 WeakReference<XWalkViewInternal> mXWalkViewRef;
135 XWalkActivityStateListener(XWalkViewInternal view) {
136 mXWalkViewRef = new WeakReference<XWalkViewInternal>(view);
140 public void onActivityStateChange(Activity activity, int newState) {
141 XWalkViewInternal view = mXWalkViewRef.get();
142 if (view == null) return;
143 view.onActivityStateChange(activity, newState);
147 static final String PLAYSTORE_DETAIL_URI = "market://details?id=";
149 private XWalkContent mContent;
150 private Activity mActivity;
151 private Context mContext;
152 private boolean mIsHidden;
153 private XWalkActivityStateListener mActivityStateListener;
156 * Normal reload mode as default.
160 public static final int RELOAD_NORMAL = 0;
162 * Reload mode with bypassing the cache.
166 public static final int RELOAD_IGNORE_CACHE = 1;
169 * Constructor for inflating via XML.
170 * @param context a Context object used to access application assets.
171 * @param attrs an AttributeSet passed to our parent.
174 @XWalkAPI(preWrapperLines = {
175 " super(${param1}, ${param2});"},
177 " if (bridge == null) return;",
178 " addView((FrameLayout)bridge, new FrameLayout.LayoutParams(",
179 " FrameLayout.LayoutParams.MATCH_PARENT,",
180 " FrameLayout.LayoutParams.MATCH_PARENT));"})
181 public XWalkViewInternal(Context context, AttributeSet attrs) {
182 super(convertContext(context), attrs);
185 mActivity = (Activity) context;
186 mContext = getContext();
187 init(mContext, attrs);
191 * Constructor for Crosswalk runtime. In shared mode, context isi
192 * different from activity. In embedded mode, they're same.
193 * @param context a Context object used to access application assets
194 * @param activity the activity for this XWalkViewInternal.
197 @XWalkAPI(preWrapperLines = {
198 " super(${param1}, null);"},
200 " if (bridge == null) return;",
201 " addView((FrameLayout)bridge, new FrameLayout.LayoutParams(",
202 " FrameLayout.LayoutParams.MATCH_PARENT,",
203 " FrameLayout.LayoutParams.MATCH_PARENT));"})
204 public XWalkViewInternal(Context context, Activity activity) {
205 super(convertContext(context), null);
208 // Make sure mActivity is initialized before calling 'init' method.
209 mActivity = activity;
210 mContext = getContext();
211 init(mContext, null);
214 private static Context convertContext(Context context) {
215 Context ret = context;
216 Context bridgeContext = ReflectionHelper.getBridgeContext();
217 if (bridgeContext == null || context == null ||
218 bridgeContext.getPackageName().equals(context.getPackageName())) {
219 // Not acrossing package
222 ret = new MixedContext(bridgeContext, context);
228 * Get the current activity passed from callers. It's never null.
229 * @return the activity instance passed from callers.
233 public Activity getActivity() {
234 if (mActivity != null) {
236 } else if (getContext() instanceof Activity) {
237 return (Activity)getContext();
240 // Never achieve here.
245 // TODO(yongsheng): we should remove this since we have getContext()?
249 public Context getViewContext() {
253 private void init(Context context, AttributeSet attrs) {
254 // Initialize chromium resources. Assign them the correct ids in
256 XWalkInternalResources.resetIds(context);
258 // Intialize library, paks and others.
260 XWalkViewDelegate.init(this);
261 mActivityStateListener = new XWalkActivityStateListener(this);
262 ApplicationStatus.registerStateListenerForActivity(
263 mActivityStateListener, getActivity());
264 } catch (Throwable e) {
265 // Try to find if there is UnsatisfiedLinkError in the cause chain of the met Throwable.
266 Throwable linkError = e;
268 if (linkError == null) throw new RuntimeException(e);
269 if (linkError instanceof UnsatisfiedLinkError) break;
270 if (linkError.getCause() == null ||
271 linkError.getCause().equals(linkError)) {
272 throw new RuntimeException(e);
274 linkError = linkError.getCause();
276 final UnsatisfiedLinkError err = (UnsatisfiedLinkError) linkError;
277 final Activity activity = getActivity();
278 final String packageName = context.getPackageName();
279 String missingArch = XWalkViewDelegate.isRunningOnIA() ? "Intel" : "ARM";
280 final String message =
281 context.getString(R.string.cpu_arch_mismatch_message, missingArch);
283 AlertDialog.Builder builder = new AlertDialog.Builder(activity);
284 builder.setTitle(R.string.cpu_arch_mismatch_title)
286 .setOnCancelListener(new DialogInterface.OnCancelListener() {
288 public void onCancel(DialogInterface dialog) {
291 }).setPositiveButton(R.string.goto_store_button_label,
292 new DialogInterface.OnClickListener() {
294 public void onClick(DialogInterface dialog, int which) {
295 activity.startActivity(new Intent(Intent.ACTION_VIEW,
296 Uri.parse(PLAYSTORE_DETAIL_URI + packageName)));
299 }).setNeutralButton(R.string.report_feedback_button_label,
300 new DialogInterface.OnClickListener() {
302 public void onClick(DialogInterface dialog, int which) {
303 ApplicationErrorReport report = new ApplicationErrorReport();
304 report.type = ApplicationErrorReport.TYPE_CRASH;
305 report.packageName = report.processName = packageName;
307 ApplicationErrorReport.CrashInfo crash =
308 new ApplicationErrorReport.CrashInfo();
309 crash.exceptionClassName = err.getClass().getSimpleName();
310 crash.exceptionMessage = "CPU architecture mismatch";
311 StringWriter writer = new StringWriter();
312 PrintWriter print = new PrintWriter(writer);
313 err.printStackTrace(print);
314 crash.stackTrace = writer.toString();
315 StackTraceElement stack = err.getStackTrace()[0];
316 crash.throwClassName = stack.getClassName();
317 crash.throwFileName = stack.getFileName();
318 crash.throwLineNumber = stack.getLineNumber();
319 crash.throwMethodName = stack.getMethodName();
321 report.crashInfo = crash;
322 report.systemApp = false;
323 report.time = System.currentTimeMillis();
325 Intent intent = new Intent(Intent.ACTION_APP_ERROR);
326 intent.putExtra(Intent.EXTRA_BUG_REPORT, report);
327 activity.startActivity(intent);
331 builder.create().show();
335 initXWalkContent(context, attrs);
338 private void initXWalkContent(Context context, AttributeSet attrs) {
340 mContent = new XWalkContent(context, attrs, this);
342 new FrameLayout.LayoutParams(
343 FrameLayout.LayoutParams.MATCH_PARENT,
344 FrameLayout.LayoutParams.MATCH_PARENT));
347 // Set default XWalkClientImpl.
348 setXWalkClient(new XWalkClient(this));
349 // Set default XWalkWebChromeClient and DownloadListener. The default actions
350 // are provided via the following clients if special actions are not needed.
351 setXWalkWebChromeClient(new XWalkWebChromeClient(this));
353 // Set with internal implementation. Could be overwritten by embedders'
355 setUIClient(new XWalkUIClientInternal(this));
356 setResourceClient(new XWalkResourceClientInternal(this));
358 setDownloadListener(new XWalkDownloadListenerImpl(context));
359 setNavigationHandler(new XWalkNavigationHandlerImpl(context));
360 setNotificationService(new XWalkNotificationServiceImpl(context, this));
362 if (!CommandLine.getInstance().hasSwitch("disable-xwalk-extensions")) {
363 BuiltinXWalkExtensions.load(context, getActivity());
365 XWalkPreferencesInternal.setValue(XWalkPreferencesInternal.ENABLE_EXTENSIONS, false);
368 XWalkPathHelper.initialize();
369 XWalkPathHelper.setCacheDirectory(
370 mContext.getApplicationContext().getCacheDir().getPath());
372 String state = Environment.getExternalStorageState();
373 if (Environment.MEDIA_MOUNTED.equals(state) ||
374 Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
375 File extCacheDir = mContext.getApplicationContext().getExternalCacheDir();
376 if (null != extCacheDir) {
377 XWalkPathHelper.setExternalCacheDirectory(extCacheDir.getPath());
383 * Load a web page/app from a given base URL or a content.
384 * If url is null or empty and content is null or empty, then this function
386 * If content is not null, load the web page/app from the content.
387 * If content is not null and the url is not set, return "about:blank" ifi
388 * calling {@link XWalkViewInternal#getUrl()}.
389 * If content is null, try to load the content from the url.
391 * It supports URL schemes like 'http:', 'https:' and 'file:'.
392 * It can also load files from Android assets, e.g. 'file:///android_asset/'.
393 * @param url the url for web page/app.
394 * @param content the content for the web page/app. Could be empty.
398 public void load(String url, String content) {
399 if (mContent == null) return;
401 mContent.loadUrl(url, content);
405 * Load a web app from a given manifest.json file. If content is not null,
406 * load the manifest.json from the content. If content is null, try to load
407 * the manifest.json from the url. Note that url should not be null if the
408 * launched path defined in manifest.json is relative.
410 * It supports URL schemes like 'http:', 'https:' and 'file:'.
411 * It can also load files from Android assets, e.g. 'file:///android_asset/'.
412 * @param url the url for manifest.json.
413 * @param content the content for manifest.json.
417 public void loadAppFromManifest(String url, String content) {
418 if (mContent == null) return;
420 mContent.loadAppFromManifest(url, content);
424 * Reload a web app with a given mode.
425 * @param mode the reload mode.
429 public void reload(int mode) {
430 if (mContent == null) return;
432 mContent.reload(mode);
436 * Stop current loading progress.
440 public void stopLoading() {
441 if (mContent == null) return;
443 mContent.stopLoading();
447 * Get the url of current web page/app. This may be different from what's passed
449 * @return the url for current web page/app.
453 public String getUrl() {
454 if (mContent == null) return null;
456 return mContent.getUrl();
460 * Get the title of current web page/app. This may be different from what's passed
462 * @return the title for current web page/app.
466 public String getTitle() {
467 if (mContent == null) return null;
469 return mContent.getTitle();
473 * Get the original url specified by caller.
474 * @return the original url.
478 public String getOriginalUrl() {
479 if (mContent == null) return null;
481 return mContent.getOriginalUrl();
485 * Get the navigation history for current XWalkViewInternal. It's synchronized with
486 * this XWalkViewInternal if any backward/forward and navigation operations.
487 * @return the navigation history.
491 public XWalkNavigationHistoryInternal getNavigationHistory() {
492 if (mContent == null) return null;
494 return mContent.getNavigationHistory();
498 * Injects the supplied Java object into this XWalkViewInternal.
499 * Each method defined in the class of the object should be
500 * marked with {@link JavascriptInterface} if it's called by JavaScript.
501 * @param object the supplied Java object, called by JavaScript.
502 * @param name the name injected in JavaScript.
506 public void addJavascriptInterface(Object object, String name) {
507 if (mContent == null) return;
509 mContent.addJavascriptInterface(object, name);
513 * Evaluate a fragment of JavaScript code and get the result via callback.
514 * @param script the JavaScript string.
515 * @param callback the callback to handle the evaluated result.
519 public void evaluateJavascript(String script, ValueCallback<String> callback) {
520 if (mContent == null) return;
522 mContent.evaluateJavascript(script, callback);
526 * Clear the resource cache. Note that the cache is per-application, so this
527 * will clear the cache for all XWalkViews used.
528 * @param includeDiskFiles indicate whether to clear disk files for cache.
532 public void clearCache(boolean includeDiskFiles) {
533 if (mContent == null) return;
535 mContent.clearCache(includeDiskFiles);
539 * Indicate that a HTML element is occupying the whole screen.
540 * @return true if any HTML element is occupying the whole screen.
544 public boolean hasEnteredFullscreen() {
545 if (mContent == null) return false;
547 return mContent.hasEnteredFullscreen();
551 * Leave fullscreen mode if it's. Do nothing if it's not
556 public void leaveFullscreen() {
557 if (mContent == null) return;
559 mContent.exitFullscreen();
563 * Pause all layout, parsing and JavaScript timers for all XWalkViewInternal instances.
564 * It will be called when the container Activity get paused. It can also be explicitly
565 * called to pause timers.
567 * Note that it will globally impact all XWalkViewInternal instances, not limited to
568 * just this XWalkViewInternal.
573 public void pauseTimers() {
574 if (mContent == null) return;
576 mContent.pauseTimers();
580 * Resume all layout, parsing and JavaScript timers for all XWalkViewInternal instances.
581 * It will be called when the container Activity get resumed. It can also be explicitly
582 * called to resume timers.
584 * Note that it will globally impact all XWalkViewInternal instances, not limited to
585 * just this XWalkViewInternal.
590 public void resumeTimers() {
591 if (mContent == null) return;
593 mContent.resumeTimers();
597 * Pause many other things except JavaScript timers inside rendering engine,
598 * like video player, modal dialogs, etc. See {@link #pauseTimers} about pausing
600 * It will be called when the container Activity get paused. It can also be explicitly
601 * called to pause above things.
605 public void onHide() {
606 if (mContent == null || mIsHidden) return;
612 * Resume video player, modal dialogs. Embedders are in charge of calling
613 * this during resuming this activity if they call onHide.
614 * Typically it should be called when the activity for this view is resumed.
615 * It will be called when the container Activity get resumed. It can also be explicitly
616 * called to resume above things.
620 public void onShow() {
621 if (mContent == null || !mIsHidden ) return;
627 * Release internal resources occupied by this XWalkViewInternal.
628 * It will be called when the container Activity get destroyed. It can also be explicitly
629 * called to release resources.
633 public void onDestroy() {
638 * Pass through activity result to XWalkViewInternal. Many internal facilities need this
639 * to handle activity result like JavaScript dialog, Crosswalk extensions, etc.
640 * See <a href="http://developer.android.com/reference/android/app/Activity.html">
641 * android.app.Activity.onActivityResult()</a>.
642 * @param requestCode passed from android.app.Activity.onActivityResult().
643 * @param resultCode passed from android.app.Activity.onActivityResult().
644 * @param data passed from android.app.Activity.onActivityResult().
648 public void onActivityResult(int requestCode, int resultCode, Intent data) {
649 if (mContent == null) return;
650 mContent.onActivityResult(requestCode, resultCode, data);
654 * Pass through intents to XWalkViewInternal. Many internal facilities need this
655 * to receive the intents like web notification. See
656 * <a href="http://developer.android.com/reference/android/app/Activity.html">
657 * android.app.Activity.onNewIntent()</a>.
658 * @param intent passed from android.app.Activity.onNewIntent().
662 public boolean onNewIntent(Intent intent) {
663 if (mContent == null) return false;
664 return mContent.onNewIntent(intent);
668 * Save current internal state of this XWalkViewInternal. This can help restore this state
669 * afterwards restoring.
670 * @param outState the saved state for restoring.
674 public boolean saveState(Bundle outState) {
675 if (mContent == null) return false;
676 mContent.saveState(outState);
681 * Restore the state from the saved bundle data.
682 * @param inState the state saved from saveState().
683 * @return true if it can restore the state.
687 public boolean restoreState(Bundle inState) {
688 if (mContent == null) return false;
689 if (mContent.restoreState(inState) != null) return true;
694 * Get the API version of Crosswalk embedding API.
695 * @return the string of API level.
698 // TODO(yongsheng): make it static?
700 public String getAPIVersion() {
705 * Get the Crosswalk version.
706 * @return the string of Crosswalk.
709 // TODO(yongsheng): make it static?
711 public String getXWalkVersion() {
712 if (mContent == null) return null;
713 return mContent.getXWalkVersion();
717 * Embedders use this to customize their handlers to events/callbacks related
719 * @param client the XWalkUIClientInternal defined by callers.
723 public void setUIClient(XWalkUIClientInternal client) {
724 if (mContent == null) return;
726 mContent.setUIClient(client);
730 * Embedders use this to customize their handlers to events/callbacks related
731 * to resource loading.
732 * @param client the XWalkResourceClientInternal defined by callers.
736 public void setResourceClient(XWalkResourceClientInternal client) {
737 if (mContent == null) return;
739 mContent.setResourceClient(client);
742 // TODO(yongsheng): this is not public.
746 public XWalkSettings getSettings() {
747 if (mContent == null) return null;
749 return mContent.getSettings();
753 * This method is used by Cordova for hacking.
754 * TODO(yongsheng): remove this and related test cases?
759 public void setNetworkAvailable(boolean networkUp) {
760 if (mContent == null) return;
762 mContent.setNetworkAvailable(networkUp);
766 * Enables remote debugging and returns the URL at which the dev tools server is listening
767 * for commands. The allowedUid argument can be used to specify the uid of the process that is
768 * permitted to connect.
769 * TODO(yongsheng): how to enable this in XWalkPreferencesInternal?
773 public String enableRemoteDebugging(int allowedUid) {
774 if (mContent == null) return null;
776 return mContent.enableRemoteDebugging(allowedUid);
780 * It's used for Presentation API.
783 public int getContentID() {
784 if (mContent == null) return -1;
785 return mContent.getRoutingID();
788 boolean canGoBack() {
789 if (mContent == null) return false;
791 return mContent.canGoBack();
795 if (mContent == null) return;
800 boolean canGoForward() {
801 if (mContent == null) return false;
803 return mContent.canGoForward();
807 if (mContent == null) return;
809 mContent.goForward();
812 void clearHistory() {
813 if (mContent == null) return;
815 mContent.clearHistory();
819 if (mContent == null) return;
820 ApplicationStatus.unregisterActivityStateListener(mActivityStateListener);
821 mActivityStateListener = null;
823 disableRemoteDebugging();
826 // Enables remote debugging and returns the URL at which the dev tools server is listening
827 // for commands. Only the current process is allowed to connect to the server.
828 String enableRemoteDebugging() {
829 return enableRemoteDebugging(mContext.getApplicationInfo().uid);
832 void disableRemoteDebugging() {
833 if (mContent == null) return;
835 mContent.disableRemoteDebugging();
838 private static void checkThreadSafety() {
839 if (Looper.myLooper() != Looper.getMainLooper()) {
840 Throwable throwable = new Throwable(
841 "Warning: A XWalkViewInternal method was called on thread '" +
842 Thread.currentThread().getName() + "'. " +
843 "All XWalkViewInternal methods must be called on the UI thread. ");
844 throw new RuntimeException(throwable);
848 boolean isOwnerActivityRunning() {
849 int status = ApplicationStatus.getStateForActivity(getActivity());
850 if (status == ActivityState.DESTROYED) return false;
854 void navigateTo(int offset) {
855 if (mContent == null) return;
856 mContent.navigateTo(offset);
859 void setOverlayVideoMode(boolean enabled) {
860 mContent.setOverlayVideoMode(enabled);
863 // Below methods are for test shell and instrumentation tests.
867 public void setXWalkClient(XWalkClient client) {
868 if (mContent == null) return;
870 mContent.setXWalkClient(client);
876 public void setXWalkWebChromeClient(XWalkWebChromeClient client) {
877 if (mContent == null) return;
879 mContent.setXWalkWebChromeClient(client);
885 public void setDownloadListener(DownloadListener listener) {
886 if (mContent == null) return;
888 mContent.setDownloadListener(listener);
894 public void setNavigationHandler(XWalkNavigationHandler handler) {
895 if (mContent == null) return;
897 mContent.setNavigationHandler(handler);
903 public void setNotificationService(XWalkNotificationService service) {
904 if (mContent == null) return;
906 mContent.setNotificationService(service);
913 public boolean dispatchKeyEvent(KeyEvent event) {
914 if (event.getAction() == KeyEvent.ACTION_UP &&
915 event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
916 // If there's navigation happens when app is fullscreen,
917 // the content will still be fullscreen after navigation.
918 // In such case, the back key will exit fullscreen first.
919 if (hasEnteredFullscreen()) {
922 } else if (canGoBack()) {
927 return super.dispatchKeyEvent(event);
930 private void onActivityStateChange(Activity activity, int newState) {
931 assert(getActivity() == activity);
933 case ActivityState.STARTED:
936 case ActivityState.PAUSED:
939 case ActivityState.RESUMED:
942 case ActivityState.DESTROYED:
945 case ActivityState.STOPPED: