Make miscellaneous improvements to the Android port
* java/org/gnu/emacs/EmacsActivity.java (onCreate): Deal with omitted calls to onWindowFocusChanged after activity recreation. * java/org/gnu/emacs/EmacsService.java (clearWindow, clearArea): Delete redundant wrapper functions. (getUsefulContentResolver, getContentResolverContext): Delete functions. (openContentUri, checkContentUri): Stop searching for an activity content resolver, as that's actually not necessary. * src/android.c (android_init_emacs_service) (android_init_emacs_window, android_clear_window) (android_clear_area): Adjust to match.
This commit is contained in:
parent
6568a9a009
commit
e7d1b12878
3 changed files with 16 additions and 78 deletions
|
@ -247,6 +247,10 @@ public class EmacsActivity extends Activity
|
|||
}
|
||||
|
||||
super.onCreate (savedInstanceState);
|
||||
|
||||
/* Call `onWindowFocusChanged' to read the focus state, which fails
|
||||
to be called after an activity is recreated. */
|
||||
onWindowFocusChanged (false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -449,21 +449,6 @@ invocation of app_process (through android-emacs) can
|
|||
EmacsDrawPoint.perform (drawable, gc, x, y);
|
||||
}
|
||||
|
||||
public void
|
||||
clearWindow (EmacsWindow window)
|
||||
{
|
||||
checkEmacsThread ();
|
||||
window.clearWindow ();
|
||||
}
|
||||
|
||||
public void
|
||||
clearArea (EmacsWindow window, int x, int y, int width,
|
||||
int height)
|
||||
{
|
||||
checkEmacsThread ();
|
||||
window.clearArea (x, y, width, height);
|
||||
}
|
||||
|
||||
@SuppressWarnings ("deprecation")
|
||||
public void
|
||||
ringBell (int duration)
|
||||
|
@ -926,48 +911,6 @@ invocation of app_process (through android-emacs) can
|
|||
|
||||
/* Content provider functions. */
|
||||
|
||||
/* Return a ContentResolver capable of accessing as many files as
|
||||
possible, namely the content resolver of the last selected
|
||||
activity if available: only they posses the rights to access drag
|
||||
and drop files. */
|
||||
|
||||
public ContentResolver
|
||||
getUsefulContentResolver ()
|
||||
{
|
||||
EmacsActivity activity;
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
|
||||
/* Since the system predates drag and drop, return this resolver
|
||||
to avoid any unforeseen difficulties. */
|
||||
return resolver;
|
||||
|
||||
activity = EmacsActivity.lastFocusedActivity;
|
||||
if (activity == null)
|
||||
return resolver;
|
||||
|
||||
return activity.getContentResolver ();
|
||||
}
|
||||
|
||||
/* Return a context whose ContentResolver is granted access to most
|
||||
files, as in `getUsefulContentResolver'. */
|
||||
|
||||
public Context
|
||||
getContentResolverContext ()
|
||||
{
|
||||
EmacsActivity activity;
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
|
||||
/* Since the system predates drag and drop, return this resolver
|
||||
to avoid any unforeseen difficulties. */
|
||||
return this;
|
||||
|
||||
activity = EmacsActivity.lastFocusedActivity;
|
||||
if (activity == null)
|
||||
return this;
|
||||
|
||||
return activity;
|
||||
}
|
||||
|
||||
/* Open a content URI described by the bytes BYTES, a non-terminated
|
||||
string; make it writable if WRITABLE, and readable if READABLE.
|
||||
Truncate the file if TRUNCATE.
|
||||
|
@ -981,9 +924,6 @@ invocation of app_process (through android-emacs) can
|
|||
String name, mode;
|
||||
ParcelFileDescriptor fd;
|
||||
int i;
|
||||
ContentResolver resolver;
|
||||
|
||||
resolver = getUsefulContentResolver ();
|
||||
|
||||
/* Figure out the file access mode. */
|
||||
|
||||
|
@ -1045,12 +985,8 @@ invocation of app_process (through android-emacs) can
|
|||
ParcelFileDescriptor fd;
|
||||
Uri uri;
|
||||
int rc, flags;
|
||||
Context context;
|
||||
ContentResolver resolver;
|
||||
ParcelFileDescriptor descriptor;
|
||||
|
||||
context = getContentResolverContext ();
|
||||
|
||||
uri = Uri.parse (name);
|
||||
flags = 0;
|
||||
|
||||
|
@ -1060,7 +996,7 @@ invocation of app_process (through android-emacs) can
|
|||
if (writable)
|
||||
flags |= Intent.FLAG_GRANT_WRITE_URI_PERMISSION;
|
||||
|
||||
rc = context.checkCallingUriPermission (uri, flags);
|
||||
rc = checkCallingUriPermission (uri, flags);
|
||||
|
||||
if (rc == PackageManager.PERMISSION_GRANTED)
|
||||
return true;
|
||||
|
@ -1074,7 +1010,6 @@ invocation of app_process (through android-emacs) can
|
|||
|
||||
try
|
||||
{
|
||||
resolver = context.getContentResolver ();
|
||||
descriptor = resolver.openFileDescriptor (uri, "r");
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -113,6 +113,8 @@ struct android_emacs_window
|
|||
jmethodID define_cursor;
|
||||
jmethodID damage_rect;
|
||||
jmethodID recreate_activity;
|
||||
jmethodID clear_window;
|
||||
jmethodID clear_area;
|
||||
};
|
||||
|
||||
struct android_emacs_cursor
|
||||
|
@ -1605,10 +1607,6 @@ android_init_emacs_service (void)
|
|||
FIND_METHOD (draw_point, "drawPoint",
|
||||
"(Lorg/gnu/emacs/EmacsDrawable;"
|
||||
"Lorg/gnu/emacs/EmacsGC;II)V");
|
||||
FIND_METHOD (clear_window, "clearWindow",
|
||||
"(Lorg/gnu/emacs/EmacsWindow;)V");
|
||||
FIND_METHOD (clear_area, "clearArea",
|
||||
"(Lorg/gnu/emacs/EmacsWindow;IIII)V");
|
||||
FIND_METHOD (ring_bell, "ringBell", "(I)V");
|
||||
FIND_METHOD (query_tree, "queryTree",
|
||||
"(Lorg/gnu/emacs/EmacsWindow;)[S");
|
||||
|
@ -1832,6 +1830,8 @@ android_init_emacs_window (void)
|
|||
android_damage_window. */
|
||||
FIND_METHOD (damage_rect, "damageRect", "(IIII)V");
|
||||
FIND_METHOD (recreate_activity, "recreateActivity", "()V");
|
||||
FIND_METHOD (clear_window, "clearWindow", "()V");
|
||||
FIND_METHOD (clear_area, "clearArea", "(IIII)V");
|
||||
#undef FIND_METHOD
|
||||
}
|
||||
|
||||
|
@ -3431,10 +3431,9 @@ android_clear_window (android_window handle)
|
|||
window = android_resolve_handle (handle, ANDROID_HANDLE_WINDOW);
|
||||
|
||||
(*android_java_env)->CallNonvirtualVoidMethod (android_java_env,
|
||||
emacs_service,
|
||||
service_class.class,
|
||||
service_class.clear_window,
|
||||
window);
|
||||
window,
|
||||
window_class.class,
|
||||
window_class.clear_window);
|
||||
android_exception_check ();
|
||||
}
|
||||
|
||||
|
@ -4745,10 +4744,10 @@ android_clear_area (android_window handle, int x, int y,
|
|||
window = android_resolve_handle (handle, ANDROID_HANDLE_WINDOW);
|
||||
|
||||
(*android_java_env)->CallNonvirtualVoidMethod (android_java_env,
|
||||
emacs_service,
|
||||
service_class.class,
|
||||
service_class.clear_area,
|
||||
window, (jint) x, (jint) y,
|
||||
window,
|
||||
window_class.class,
|
||||
window_class.clear_area,
|
||||
(jint) x, (jint) y,
|
||||
(jint) width, (jint) height);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue