[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 2823eae0b7c: Remove leftover tasks from previous Emacs sessions o
From: |
Po Lu |
Subject: |
master 2823eae0b7c: Remove leftover tasks from previous Emacs sessions on startup |
Date: |
Sat, 13 Apr 2024 22:37:05 -0400 (EDT) |
branch: master
commit 2823eae0b7cb3bd3f2472fde9e13016a8d406a9a
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Remove leftover tasks from previous Emacs sessions on startup
* java/org/gnu/emacs/EmacsService.java (onCreate): Call
removeOldTasks.
* java/org/gnu/emacs/EmacsWindowManager.java (removeOldTasks):
New function.
* java/proguard.conf: Optimize optimizer configuration.
---
java/org/gnu/emacs/EmacsService.java | 12 ++++++---
java/org/gnu/emacs/EmacsWindowManager.java | 41 ++++++++++++++++++++++++++++++
java/proguard.conf | 32 +++++++++++------------
3 files changed, 66 insertions(+), 19 deletions(-)
diff --git a/java/org/gnu/emacs/EmacsService.java
b/java/org/gnu/emacs/EmacsService.java
index b8ff98e79a7..fd052653087 100644
--- a/java/org/gnu/emacs/EmacsService.java
+++ b/java/org/gnu/emacs/EmacsService.java
@@ -234,6 +234,8 @@ public final class EmacsService extends Service
final double scaledDensity;
double tempScaledDensity;
+ super.onCreate ();
+
SERVICE = this;
handler = new Handler (Looper.getMainLooper ());
manager = getAssets ();
@@ -247,9 +249,9 @@ public final class EmacsService extends Service
resolver = getContentResolver ();
mainThread = Thread.currentThread ();
- /* If the density used to compute the text size is lesser than
- 160, there's likely a bug with display density computation.
- Reset it to 160 in that case.
+ /* If the density used to compute the text size is smaller than 160,
+ there's likely a bug with display density computation. Reset it
+ to 160 in that case.
Note that Android uses 160 ``dpi'' as the density where 1 point
corresponds to 1 pixel, not 72 or 96 as used elsewhere. This
@@ -262,6 +264,10 @@ public final class EmacsService extends Service
the nested function below. */
scaledDensity = tempScaledDensity;
+ /* Remove all tasks from previous Emacs sessions but the task
+ created by the system at startup. */
+ EmacsWindowManager.MANAGER.removeOldTasks (this);
+
try
{
/* Configure Emacs with the asset manager and other necessary
diff --git a/java/org/gnu/emacs/EmacsWindowManager.java
b/java/org/gnu/emacs/EmacsWindowManager.java
index a193d49d0ec..49f0ebd5841 100644
--- a/java/org/gnu/emacs/EmacsWindowManager.java
+++ b/java/org/gnu/emacs/EmacsWindowManager.java
@@ -27,6 +27,7 @@ import android.app.ActivityManager.RecentTaskInfo;
import android.app.ActivityManager;
import android.app.ActivityOptions;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -385,4 +386,44 @@ public final class EmacsWindowManager
window.onActivityDetached ();
}
}
+
+ /* Iterate over each of Emacs's tasks to delete such as belong to a
+ previous Emacs session, i.e., tasks created for a previous
+ session's non-initial frames. CONTEXT should be a context from
+ which to obtain a reference to the activity manager. */
+
+ public void
+ removeOldTasks (Context context)
+ {
+ List<AppTask> appTasks;
+ RecentTaskInfo info;
+ ComponentName name;
+ String target;
+ Object object;
+
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
+ return;
+
+ if (activityManager == null)
+ {
+ object = context.getSystemService (Context.ACTIVITY_SERVICE);
+ activityManager = (ActivityManager) object;
+ }
+
+ appTasks = activityManager.getAppTasks ();
+ target = ".EmacsMultitaskActivity";
+
+ for (AppTask task : appTasks)
+ {
+ info = task.getTaskInfo ();
+
+ /* Test whether info is a reference to
+ EmacsMultitaskActivity. */
+ if (info.baseIntent != null
+ && (name = info.baseIntent.getComponent ()) != null
+ && name.getShortClassName ().equals (target))
+ /* Delete the task. */
+ task.finishAndRemoveTask ();
+ }
+ }
};
diff --git a/java/proguard.conf b/java/proguard.conf
index e6b08f76fe4..5da402946bb 100644
--- a/java/proguard.conf
+++ b/java/proguard.conf
@@ -20,22 +20,22 @@
# The effect of the following lines is to inhibit the removal of variable or
# method symbol names from symbols referenced from C.
--keep,allowoptimization class org.gnu.emacs.EmacsClipboard
{ <methods>; }
--keep,allowoptimization class org.gnu.emacs.EmacsContextMenu
{ <methods>; }
--keep,allowoptimization class org.gnu.emacs.EmacsCursor
{ <methods>; }
--keep,allowoptimization class org.gnu.emacs.EmacsDesktopNotification
{ <methods>; }
--keep,allowoptimization class org.gnu.emacs.EmacsDialog
{ <methods>; }
--keep,allowoptimization class org.gnu.emacs.EmacsDirectoryEntry
{ <fields>; }
--keep,allowoptimization class org.gnu.emacs.EmacsFontDriver
{ <methods>; }
--keep,allowoptimization class org.gnu.emacs.EmacsFontDriver$*
{ <fields>; }
--keep,allowoptimization class org.gnu.emacs.EmacsGC
{ <methods>; <fields>; }
--keep,allowoptimization class org.gnu.emacs.EmacsHandleObject
{ <methods>; }
--keep,allowoptimization class org.gnu.emacs.EmacsPixmap
{ <methods>; }
--keep,allowoptimization class org.gnu.emacs.EmacsService
{ <methods>; }
--keep,allowoptimization class org.gnu.emacs.EmacsWindow
{ <methods>; }
--keep,allowoptimization class org.gnu.emacs.EmacsNative
{ <methods>; }
--keep,allowoptimization class org.gnu.emacs.EmacsNoninteractive
{ <methods>; }
--keep,allowoptimization interface org.gnu.emacs.EmacsDrawable
{ <methods>; }
+-keep,allowoptimization class org.gnu.emacs.EmacsClipboard
{ public <methods>; }
+-keep,allowoptimization class org.gnu.emacs.EmacsContextMenu
{ public <methods>; }
+-keep,allowoptimization class org.gnu.emacs.EmacsCursor
{ public <methods>; }
+-keep,allowoptimization class org.gnu.emacs.EmacsDesktopNotification
{ public <methods>; }
+-keep,allowoptimization class org.gnu.emacs.EmacsDialog
{ public <methods>; }
+-keep,allowoptimization class org.gnu.emacs.EmacsDirectoryEntry
{ public <fields>; }
+-keep,allowoptimization class org.gnu.emacs.EmacsFontDriver
{ public <methods>; }
+-keep,allowoptimization class org.gnu.emacs.EmacsFontDriver$*
{ public <fields>; }
+-keep,allowoptimization class org.gnu.emacs.EmacsGC
{ public <methods>; public <fields>; }
+-keep,allowoptimization class org.gnu.emacs.EmacsHandleObject
{ public <methods>; }
+-keep,allowoptimization class org.gnu.emacs.EmacsPixmap
{ public <methods>; }
+-keep,allowoptimization class org.gnu.emacs.EmacsService
{ public <methods>; }
+-keep,allowoptimization class org.gnu.emacs.EmacsWindow
{ public <methods>; }
+-keep,allowoptimization class org.gnu.emacs.EmacsNative
{ public <methods>; }
+-keep,allowoptimization class org.gnu.emacs.EmacsNoninteractive
{ public <methods>; }
+-keep,allowoptimization interface org.gnu.emacs.EmacsDrawable
{ public <methods>; }
# And these lines inhibit the deletion of symbols that are referenced by
# the operating system while enabling the compiler to minify or delete
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 2823eae0b7c: Remove leftover tasks from previous Emacs sessions on startup,
Po Lu <=