mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
Prevent crashes and related issues if initial activity is destroyed on Android
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow) <initialWindowCreated>: New variable. (EmacsWindow): If the initial frame has not yet been created, set attachmentToken to -1. * java/org/gnu/emacs/EmacsWindowManager.java (registerWindow): When the window's attachment token is -1 (i.e., it is the default window), start EmacsActivity rather than EmacsMultitaskActivity. Catch exceptions around startActivity.
This commit is contained in:
parent
d5c6eb1f96
commit
860840621a
2 changed files with 47 additions and 7 deletions
|
|
@ -74,6 +74,9 @@ public final class EmacsWindow extends EmacsHandleObject
|
||||||
{
|
{
|
||||||
private static final String TAG = "EmacsWindow";
|
private static final String TAG = "EmacsWindow";
|
||||||
|
|
||||||
|
/* Whether any windows have yet been created in this session. */
|
||||||
|
private static boolean initialWindowCreated;
|
||||||
|
|
||||||
private static class Coordinate
|
private static class Coordinate
|
||||||
{
|
{
|
||||||
/* Integral coordinate. */
|
/* Integral coordinate. */
|
||||||
|
|
@ -192,6 +195,14 @@ public final class EmacsWindow extends EmacsHandleObject
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.overrideRedirect = overrideRedirect;
|
this.overrideRedirect = overrideRedirect;
|
||||||
|
|
||||||
|
/* The initial frame should always be bound to the startup
|
||||||
|
activity. */
|
||||||
|
if (!initialWindowCreated)
|
||||||
|
{
|
||||||
|
this.attachmentToken = -1;
|
||||||
|
initialWindowCreated = true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Create the list of children. */
|
/* Create the list of children. */
|
||||||
children = new ArrayList<EmacsWindow> ();
|
children = new ArrayList<EmacsWindow> ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,27 @@ public final class EmacsWindowManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Do not create a multitasking activity for the initial frame,
|
||||||
|
but arrange to start EmacsActivity. */
|
||||||
|
if (window.attachmentToken == -1)
|
||||||
|
{
|
||||||
|
intent = new Intent (EmacsService.SERVICE,
|
||||||
|
EmacsActivity.class);
|
||||||
|
intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
EmacsService.SERVICE.startActivity (intent);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.w (TAG, "an activity could not be started on behalf"
|
||||||
|
+ " of the mapped default window " + window.handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
intent = new Intent (EmacsService.SERVICE,
|
intent = new Intent (EmacsService.SERVICE,
|
||||||
EmacsMultitaskActivity.class);
|
EmacsMultitaskActivity.class);
|
||||||
|
|
||||||
|
|
@ -205,14 +226,22 @@ public final class EmacsWindowManager
|
||||||
window.attachmentToken = token;
|
window.attachmentToken = token;
|
||||||
intent.putExtra (ACTIVITY_TOKEN, token);
|
intent.putExtra (ACTIVITY_TOKEN, token);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
|
try
|
||||||
EmacsService.SERVICE.startActivity (intent);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
/* Specify the desired window size. */
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
|
||||||
options = ActivityOptions.makeBasic ();
|
EmacsService.SERVICE.startActivity (intent);
|
||||||
options.setLaunchBounds (window.getGeometry ());
|
else
|
||||||
EmacsService.SERVICE.startActivity (intent, options.toBundle ());
|
{
|
||||||
|
/* Specify the desired window size. */
|
||||||
|
options = ActivityOptions.makeBasic ();
|
||||||
|
options.setLaunchBounds (window.getGeometry ());
|
||||||
|
EmacsService.SERVICE.startActivity (intent, options.toBundle ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.w (TAG, "an activity could not be started on behalf"
|
||||||
|
+ " of a mapped window, " + window.handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
pruneWindows ();
|
pruneWindows ();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue