diff options
| author | Po Lu | 2023-11-18 14:15:55 +0800 |
|---|---|---|
| committer | Po Lu | 2023-11-18 14:15:55 +0800 |
| commit | 669e754f5bdc9f9130a68eec6966babe9a85ecae (patch) | |
| tree | 718d7fe3517a79ae69ed3380cd86e0f8c4716621 /src/androidfns.c | |
| parent | 05213345c04d4572afec46b99a58d206a111c846 (diff) | |
| download | emacs-669e754f5bdc9f9130a68eec6966babe9a85ecae.tar.gz emacs-669e754f5bdc9f9130a68eec6966babe9a85ecae.zip | |
Offer to grant storage permissions if absent
* java/org/gnu/emacs/EmacsService.java (externalStorageAvailable)
(requestStorageAccess23, requestStorageAccess30)
(requestStorageAccess): New functions.
* lisp/startup.el (fancy-startup-tail, normal-splash-screen):
Call android-win functions for inserting the new storage
permission notice.
* lisp/term/android-win.el
(android-display-storage-permission-popup)
(android-after-splash-screen): New functions.
* src/android.c (android_init_emacs_service): Link to new Java
functions.
(android_external_storage_available_p)
(android_request_storage_access): New functions.
* src/android.h: Update prototypes.
* src/androidfns.c (Fandroid_external_storage_available_p)
(Fandroid_request_storage_access): New functions.
(syms_of_androidfns): Register new subrs.
Diffstat (limited to 'src/androidfns.c')
| -rw-r--r-- | src/androidfns.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/androidfns.c b/src/androidfns.c index 772a4f51e78..785587d9282 100644 --- a/src/androidfns.c +++ b/src/androidfns.c | |||
| @@ -3096,6 +3096,42 @@ within the directory `/content/storage'. */) | |||
| 3096 | 3096 | ||
| 3097 | 3097 | ||
| 3098 | 3098 | ||
| 3099 | /* Functions concerning storage permissions. */ | ||
| 3100 | |||
| 3101 | DEFUN ("android-external-storage-available-p", | ||
| 3102 | Fandroid_external_storage_available_p, | ||
| 3103 | Sandroid_external_storage_available_p, 0, 0, 0, | ||
| 3104 | doc: /* Return whether Emacs is entitled to access external storage. | ||
| 3105 | Return nil if the requisite permissions for external storage access | ||
| 3106 | have not been granted to Emacs, t otherwise. Such permissions can be | ||
| 3107 | requested by means of the `android-request-storage-access' | ||
| 3108 | command. | ||
| 3109 | |||
| 3110 | External storage on Android encompasses the `/sdcard' and | ||
| 3111 | `/storage/emulated' directories, access to which is denied to programs | ||
| 3112 | absent these permissions. */) | ||
| 3113 | (void) | ||
| 3114 | { | ||
| 3115 | return android_external_storage_available_p () ? Qt : Qnil; | ||
| 3116 | } | ||
| 3117 | |||
| 3118 | DEFUN ("android-request-storage-access", Fandroid_request_storage_access, | ||
| 3119 | Sandroid_request_storage_access, 0, 0, "", | ||
| 3120 | doc: /* Request rights to access external storage. | ||
| 3121 | |||
| 3122 | Return nil whether access is accorded or not, immediately subsequent | ||
| 3123 | to displaying the permissions request dialog. | ||
| 3124 | |||
| 3125 | `android-external-storage-available-p' (which see) ascertains if Emacs | ||
| 3126 | has received such rights. */) | ||
| 3127 | (void) | ||
| 3128 | { | ||
| 3129 | android_request_storage_access (); | ||
| 3130 | return Qnil; | ||
| 3131 | } | ||
| 3132 | |||
| 3133 | |||
| 3134 | |||
| 3099 | /* Miscellaneous input method related stuff. */ | 3135 | /* Miscellaneous input method related stuff. */ |
| 3100 | 3136 | ||
| 3101 | /* Report X, Y, by the phys cursor width and height as the cursor | 3137 | /* Report X, Y, by the phys cursor width and height as the cursor |
| @@ -3302,6 +3338,8 @@ bell being rung. */); | |||
| 3302 | #ifndef ANDROID_STUBIFY | 3338 | #ifndef ANDROID_STUBIFY |
| 3303 | defsubr (&Sandroid_query_battery); | 3339 | defsubr (&Sandroid_query_battery); |
| 3304 | defsubr (&Sandroid_request_directory_access); | 3340 | defsubr (&Sandroid_request_directory_access); |
| 3341 | defsubr (&Sandroid_external_storage_available_p); | ||
| 3342 | defsubr (&Sandroid_request_storage_access); | ||
| 3305 | 3343 | ||
| 3306 | tip_timer = Qnil; | 3344 | tip_timer = Qnil; |
| 3307 | staticpro (&tip_timer); | 3345 | staticpro (&tip_timer); |