summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2013-03-07 02:17:49 +0200
committerTor Lillqvist <tml@iki.fi>2013-03-07 02:33:42 +0200
commit0ce2d740a2ed93a029a290fe88748ac92baff9a0 (patch)
tree3751cf456702440375fac64790df35bbf46a2dd2 /android
parent8ba203c726df97039125ad8b3223802fc80a9110 (diff)
Handle damage tracking and redrawing properly in the "desktop" Android app
In the damaged() method do a callback up to Java code in Desktop that invalidates the view. For now store the view in a static field, but need to do that in a cleaner way eventually. There might in some circumstancest be several instances of the Desktop activity present. Obviously should also run just one LO thread. Get rid of the temporary self-invalidattion in onDraw() silliness. Start the LO thread that runs soffice_main() from Java, not from native code. Apparently only threads created from Java have proper class loaders in Android. No need for an own DoReleaseYield() in AndroidSalInstance, the one in the SvpSalInstance base class does what needs to be done. Change-Id: I4cb85b352fca1f1375f726620ec8c93d2047f113
Diffstat (limited to 'android')
-rw-r--r--android/experimental/desktop/native-code.cxx9
-rw-r--r--android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java51
2 files changed, 47 insertions, 13 deletions
diff --git a/android/experimental/desktop/native-code.cxx b/android/experimental/desktop/native-code.cxx
index f93c8ad20bd6..117a2badd4c4 100644
--- a/android/experimental/desktop/native-code.cxx
+++ b/android/experimental/desktop/native-code.cxx
@@ -112,10 +112,11 @@ lo_get_libmap(void)
{ NULL, NULL }
};
- // We need to pull these in, too, as they aren't in any of the libs we
- // link with -Wl,--whole-archive.
- extern void Java_org_libreoffice_experimental_desktop_Desktop_spawnMain();
- volatile void *p = (void *) Java_org_libreoffice_experimental_desktop_Desktop_spawnMain;
+ // Guard against possible function-level link-time pruning of
+ // "unused" code. We need to pull these in, too, as they aren't in
+ // any of the libs we link with -Wl,--whole-archive. Is this necessary?
+ extern void Java_org_libreoffice_experimental_desktop_Desktop_runMain();
+ volatile void *p = (void *) Java_org_libreoffice_experimental_desktop_Desktop_runMain;
extern void Java_org_libreoffice_experimental_desktop_Desktop_renderVCL();
p = (void *) Java_org_libreoffice_experimental_desktop_Desktop_renderVCL;
diff --git a/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java b/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java
index 6d6692645695..c10df22b717a 100644
--- a/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java
+++ b/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java
@@ -41,10 +41,10 @@ public class Desktop
{
private static final String TAG = "LODesktop";
- /* implementend by desktop */
- private static native void spawnMain();
+ /* In desktop */
+ private static native void runMain();
- /* implementend by vcl */
+ /* In vcl */
public static native void renderVCL(Bitmap bitmap);
public static native void setViewSize(int width, int height);
public static native void key(char c);
@@ -70,6 +70,28 @@ public class Desktop
Bootstrap.putenv("SAL_LOG=+WARN+INFO");
}
+ // This sucks, we need to experiment and think, can an app process
+ // have several instances of this Activity active?
+ static BitmapView theView;
+
+ // This is called back from LO in the LO thread
+ static public void callbackDamaged()
+ {
+ synchronized (theView) {
+ if (!invalidatePosted)
+ theView.post(new Runnable() {
+ @Override public void run() {
+ synchronized (theView) {
+ theView.invalidate();
+ invalidatePosted = false;
+ }
+ }
+ });
+ invalidatePosted = true;
+ }
+ }
+ static boolean invalidatePosted;
+
@Override public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
@@ -111,9 +133,22 @@ public class Desktop
initBootstrapContext();
Log.i(TAG, "onCreate - set content view");
- setContentView(new BitmapView());
-
- spawnMain();
+ theView = new BitmapView();
+ setContentView(theView);
+
+ // Start a Java thread to run soffice_main(). We don't
+ // want to start the thread from native code becauce
+ // native threads apparently have no Java class loaders in
+ // Android, or someghin. So for instance FindClass fails.
+
+ // See https://groups.google.com/group/android-ndk/msg/a0793f009e6e71f7?dmode=source
+ // .
+
+ new Thread(new Runnable() {
+ @Override public void run() {
+ runMain();
+ }
+ }).start();
}
catch (Exception e) {
e.printStackTrace(System.err);
@@ -199,9 +234,6 @@ public class Desktop
canvas.drawBitmap(mBitmap, 0, 0, null);
canvas.restore();
renderedOnce = true;
-
- // re-call ourselves a bit later ...
- invalidate();
}
@Override public boolean onKeyDown(int keyCode, KeyEvent event)
@@ -302,6 +334,7 @@ public class Desktop
return true;
}
}
+
}
// vim:set shiftwidth=4 softtabstop=4 expandtab: