aboutsummaryrefslogtreecommitdiffstats
path: root/src/android.c
diff options
context:
space:
mode:
authorPo Lu2023-08-31 09:04:32 +0800
committerPo Lu2023-08-31 09:04:32 +0800
commit21a0caea771eae52c5e6f1fb4857f59bdc18f238 (patch)
tree9b8d393316e8c637a24790851ca89307291898e3 /src/android.c
parent128ed5c9f17fab87fdb679326035aa2598612658 (diff)
downloademacs-21a0caea771eae52c5e6f1fb4857f59bdc18f238.tar.gz
emacs-21a0caea771eae52c5e6f1fb4857f59bdc18f238.zip
Include installation date within asset files
* src/android.c (setEmacsParams): Set `emacs_installation_time' to the mtime of the class path file, which happens to be the time of Emacs's installation. (emacs_installation_time): New variable. * src/android.h (emacs_installation_time): Export new variable. * src/androidvfs.c (android_afs_stat): If emacs_installation_time is a valid timespec, set st_mtime to it.
Diffstat (limited to 'src/android.c')
-rw-r--r--src/android.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/android.c b/src/android.c
index 1ccb724247d..94aeb726fc6 100644
--- a/src/android.c
+++ b/src/android.c
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
18along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ 18along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
19 19
20#include <config.h> 20#include <config.h>
21
21#include <allocator.h> 22#include <allocator.h>
22#include <assert.h> 23#include <assert.h>
23#include <careadlinkat.h> 24#include <careadlinkat.h>
@@ -31,12 +32,15 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
31#include <pthread.h> 32#include <pthread.h>
32#include <semaphore.h> 33#include <semaphore.h>
33#include <signal.h> 34#include <signal.h>
35#include <stat-time.h>
34#include <stdckdint.h> 36#include <stdckdint.h>
35#include <string.h> 37#include <string.h>
36#include <sys/param.h>
37#include <timespec.h> 38#include <timespec.h>
38#include <unistd.h> 39#include <unistd.h>
39 40
41#include <sys/param.h>
42#include <sys/stat.h>
43
40/* Old NDK versions lack MIN and MAX. */ 44/* Old NDK versions lack MIN and MAX. */
41#include <minmax.h> 45#include <minmax.h>
42 46
@@ -47,6 +51,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
47#include "blockinput.h" 51#include "blockinput.h"
48#include "coding.h" 52#include "coding.h"
49#include "epaths.h" 53#include "epaths.h"
54#include "systime.h"
50 55
51/* Whether or not Emacs is running inside the application process and 56/* Whether or not Emacs is running inside the application process and
52 Android windowing should be enabled. */ 57 Android windowing should be enabled. */
@@ -187,6 +192,10 @@ static struct android_emacs_window window_class;
187/* Various methods associated with the EmacsCursor class. */ 192/* Various methods associated with the EmacsCursor class. */
188static struct android_emacs_cursor cursor_class; 193static struct android_emacs_cursor cursor_class;
189 194
195/* The time at which Emacs was installed, which also supplies the
196 mtime of asset files. */
197struct timespec emacs_installation_time;
198
190/* The last event serial used. This is a 32 bit value, but it is 199/* The last event serial used. This is a 32 bit value, but it is
191 stored in unsigned long to be consistent with X. */ 200 stored in unsigned long to be consistent with X. */
192unsigned int event_serial; 201unsigned int event_serial;
@@ -1247,6 +1256,7 @@ NATIVE_NAME (setEmacsParams) (JNIEnv *env, jobject object,
1247 int pipefd[2]; 1256 int pipefd[2];
1248 pthread_t thread; 1257 pthread_t thread;
1249 const char *java_string; 1258 const char *java_string;
1259 struct stat statb;
1250 1260
1251 /* Set the Android API level early, as it is used by 1261 /* Set the Android API level early, as it is used by
1252 `android_vfs_init'. */ 1262 `android_vfs_init'. */
@@ -1341,13 +1351,24 @@ NATIVE_NAME (setEmacsParams) (JNIEnv *env, jobject object,
1341 1351
1342 android_class_path = strdup ((const char *) java_string); 1352 android_class_path = strdup ((const char *) java_string);
1343 1353
1344 if (!android_files_dir) 1354 if (!android_class_path)
1345 emacs_abort (); 1355 emacs_abort ();
1346 1356
1347 (*env)->ReleaseStringUTFChars (env, (jstring) class_path, 1357 (*env)->ReleaseStringUTFChars (env, (jstring) class_path,
1348 java_string); 1358 java_string);
1349 } 1359 }
1350 1360
1361 /* Derive the installation date from the modification time of the
1362 file constitituing the class path. */
1363
1364 emacs_installation_time = invalid_timespec ();
1365
1366 if (class_path)
1367 {
1368 if (!stat (android_class_path, &statb))
1369 emacs_installation_time = get_stat_mtime (&statb);
1370 }
1371
1351 /* Calculate the site-lisp path. */ 1372 /* Calculate the site-lisp path. */
1352 1373
1353 android_site_load_path = malloc (PATH_MAX + 1); 1374 android_site_load_path = malloc (PATH_MAX + 1);