Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit cc553af
Merge: 7c61dd9 c58528f
Author: Jörg F. Wittenberger <[email protected]>
Date:   Sun Nov 29 15:41:58 2020 +0100

    Merge branch 'merge-upstream-silly-rename-of-lnjscheme-to-ln_jscheme' of ssh://github.com/0-8-15/lambdanative into development

commit c58528f
Merge: 54bc984 51dfeed
Author: Jörg F. Wittenberger <[email protected]>
Date:   Sun Nov 29 15:35:38 2020 +0100

    Merge branch 'master' of https://github.com/part-cw/lambdanative into merge-upstream-silly-rename-of-lnjscheme-to-ln_jscheme

commit 51dfeed
Author: Peter Lewis <[email protected]>
Date:   Fri Nov 27 11:57:52 2020 -0800

    ANDROID: request permissions from Manifest

    This reads permissions from the manifest and requests all that are needed. Apps and modules should add necessary permissions to ANDROID_xml_permissions. Moved the initial setContentView back to before @ANDROID_JAVA_ONCREATE@ so that apps can set a content view in ANDROID_java_oncreate

commit 1e4c9f3
Author: 0-8-15 <[email protected]>
Date:   Thu Nov 26 22:25:11 2020 -0800

    WEBVIEW: Add another webview - ANDROID only! (part-cw#387)

    Moved the 'webview' script from DemoAndroidLNjScheme into a module of its own; this module is a bit of a stub. Might receive updates to become a nicer looking browser. Meanwhile still intended to showcase how to call Java via jScheme

commit 1cbc09b
Author: 0-8-15 <[email protected]>
Date:   Thu Nov 26 22:14:54 2020 -0800

    LN_JSCHEME: New module to call any Android API without JNI (part-cw#387)

    Moves LNjScheme from DemoAndroidLNjScheme to its own module. Also updates DemoAndroidLNjScheme to use of ln_jscheme and webview

commit 7e6fcb3
Author: 0-8-15 <[email protected]>
Date:   Thu Nov 26 21:25:10 2020 -0800

    EVENTLOOP: Add support for a new jScheme related event (part-cw#387)

    Allocates a single event number (126) and dispatches it to a possibly registered receiver - or is ignored as before.

commit 20b33a1
Author: 0-8-15 <[email protected]>
Date:   Thu Nov 26 01:38:46 2020 -0800

    ANDROID: Fix rendering freeze upon startup

commit 7c61dd9
Author: Jörg F. Wittenberger <[email protected]>
Date:   Tue Nov 24 20:07:56 2020 +0100

    NATIVE-KEYPAD+ANDROID: more error checking in JNI

commit 9d8e809
Author: Jörg F. Wittenberger <[email protected]>
Date:   Tue Nov 24 14:20:44 2020 +0100

    ANDROID: fix rendering freeze upon startup

commit c77a547
Author: Jörg F. Wittenberger <[email protected]>
Date:   Tue Nov 24 12:58:39 2020 +0100

    ANDROID: try harder to handle onStop and onPause

    Note: This is at the moment meant for evaluation.  Works for me, can't
    break it.

    However if this is going to be the final call, those file names
    ANDROID_java_oncreate are no longer telling exactly where the code
    ends up.

    That's bad, bnut renaming them is likely even worse.

commit c351669
Merge: 6e0c757 8d0d7ed
Author: Jörg F. Wittenberger <[email protected]>
Date:   Tue Nov 24 12:57:32 2020 +0100

    Merge branch 'stable-0815' of ssh://github.com/0-8-15/lambdanative into development

commit 6e0c757
Author: Jörg F. Wittenberger <[email protected]>
Date:   Mon Nov 23 21:43:02 2020 +0100

    LNjSCHEME: revert change breaking things

commit 865b6c7
Author: Jörg F. Wittenberger <[email protected]>
Date:   Mon Nov 23 21:24:30 2020 +0100

    LNjSCHEME: make initialization once only

    Also move ANDROID_xml_permissions to webview, where they belong.

commit 603d630
Author: Jörg F. Wittenberger <[email protected]>
Date:   Mon Nov 23 20:54:57 2020 +0100

    ANDROID: make mGLView static and initialization once only

    This appears to be the correct way and seems to actually solve the
    issue observed and not fixed by da86a5160 ff.

commit fa19aa9
Author: Jörg F. Wittenberger <[email protected]>
Date:   Mon Nov 23 19:20:12 2020 +0100

    JNI: conservative coding

    - #defines LAMBDANATIVE_JNI_VERSION to JNI_VERSION_1_4
    - uses `jint` as if it was an opaque type
    - checks via GetEnv before attaching a thread
      (there are claims on the Internet that this may save some overhead)
    - use AttachCurrentThreadAsDaemon instead of AttachCurrentThread for
      gut feeling

commit 70752a2
Author: Jörg F. Wittenberger <[email protected]>
Date:   Sun Nov 22 16:56:37 2020 +0100

    JNI: be careful to free local references

commit 34ccd0d
Author: Jörg F. Wittenberger <[email protected]>
Date:   Sun Nov 22 13:01:30 2020 +0100

    ANDROID: use systemapp directry

commit 270193a
Author: Jörg F. Wittenberger <[email protected]>
Date:   Sun Nov 22 12:58:40 2020 +0100

    ANDROID: do not call ReleaseStringUTFChars with an unrelated pointer

commit c752898
Author: Jörg F. Wittenberger <[email protected]>
Date:   Sat Nov 21 14:26:16 2020 +0100

    ANDROID: error out when build requires to write system directories

commit d3dd374
Author: Jörg F. Wittenberger <[email protected]>
Date:   Sat Nov 21 13:43:05 2020 +0100

    BACKPORT: use upstreams version of camera

commit 5b9a30f
Author: Jörg F. Wittenberger <[email protected]>
Date:   Sat Nov 21 13:12:00 2020 +0100

    remove old debug code

commit c48c7b1
Author: Jörg F. Wittenberger <[email protected]>
Date:   Sat Nov 21 13:04:21 2020 +0100

    CLIPBOARD: fix compiler complaints

    warning: returning 'const char *' from a function with result type 'char *' discards qualifiers

commit cd86684
Author: Jörg F. Wittenberger <[email protected]>
Date:   Sat Nov 21 12:38:46 2020 +0100

    20201121: Snapshot, preserve possibly important debug state

commit 5f82a22
Author: Jörg F. Wittenberger <[email protected]>
Date:   Fri Nov 20 19:43:56 2020 +0100

    GLGUI: 20201120; Snapshot: alternative implementation - active for a while

commit b555356
Author: Jörg F. Wittenberger <[email protected]>
Date:   Fri Nov 20 20:58:24 2020 +0100

    ANDROID: verbose signing

commit 0a58fa3
Author: Jörg F. Wittenberger <[email protected]>
Date:   Fri Nov 20 20:55:19 2020 +0100

    outdated: srfi-179 port

commit b4dac9a
Author: Jörg F. Wittenberger <[email protected]>
Date:   Fri Nov 20 20:53:15 2020 +0100

    CORE: flow/fix-issue related changes

commit ddaa1db
Author: Jörg F. Wittenberger <[email protected]>
Date:   Fri Nov 20 19:42:19 2020 +0100

    CORE: flow/fix-issue related changes

commit 985ddd5
Author: Jörg F. Wittenberger <[email protected]>
Date:   Fri Nov 20 19:34:57 2020 +0100

    CORE: better version of make-list

commit e72c158
Author: Jörg F. Wittenberger <[email protected]>
Date:   Fri Nov 20 19:11:35 2020 +0100

    TENTATIVE: config: commented out - should become debug option

commit 41d480b
Author: Jörg F. Wittenberger <[email protected]>
Date:   Fri Nov 20 19:10:35 2020 +0100

    ANDROID: keep checking for API 26 break

commit 0186693
Author: Jörg F. Wittenberger <[email protected]>
Date:   Fri Nov 20 19:07:16 2020 +0100

    ANDROID: support install of additional dynamic libraries

commit a54d93a
Author: Jörg F. Wittenberger <[email protected]>
Date:   Fri Nov 20 19:02:34 2020 +0100

    ANDROID: keep TODO comment
  • Loading branch information
0-8-15 committed Dec 1, 2020
1 parent 54bc984 commit 7fa9fbc
Show file tree
Hide file tree
Showing 32 changed files with 352 additions and 4,149 deletions.
2 changes: 1 addition & 1 deletion LNCONFIG.h.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
LambdaNative - a cross-platform Scheme framework
Copyright (c) 2009-2013, University of British Columbia
Copyright (c) 2009-2020, University of British Columbia
All rights reserved.

Redistribution and use in source and binary forms, with or
Expand Down
2 changes: 1 addition & 1 deletion apps/DemoAndroidLNjScheme/MODULES
Original file line number Diff line number Diff line change
@@ -1 +1 @@
eventloop ln_glgui lnjscheme webview uiform
eventloop ln_glgui ln_jscheme webview uiform
1 change: 0 additions & 1 deletion apps/DemoAndroidLNjScheme/lnjstest.scm
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
;; Just to see an error:
;;
(error "nananana")

2 changes: 1 addition & 1 deletion loaders/android/AndroidManifest.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@ANDROID_XML_SERVICES@
@ANDROID_XML_PROVIDERS@
</application>
@ANDROID_XML_PERMISSIONS@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
@ANDROID_XML_PERMISSIONS@
</manifest>
# eof
36 changes: 34 additions & 2 deletions loaders/android/bootstrap.java.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.BroadcastReceiver;
import android.content.res.Configuration;
import android.content.pm.PackageManager;
import android.content.pm.PackageInfo;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.os.PowerManager;
Expand Down Expand Up @@ -108,6 +110,29 @@ public class @SYS_APPNAME@ extends Activity implements @ANDROID_JAVA_IMPLEMENTS@
return true;
}

public boolean requestAllPermissions() {
@IF_ANDROIDAPI_GT_22@
PackageManager pm = getPackageManager();
try
{
PackageInfo packageInfo = pm.getPackageInfo(getPackageName(), PackageManager.GET_PERMISSIONS);
String[] requestedPermissions = null;
if (packageInfo != null)
requestedPermissions = packageInfo.requestedPermissions;

if (requestedPermissions != null && requestedPermissions.length > 0)
requestPermissions(requestedPermissions, 1);
}
catch (PackageManager.NameNotFoundException e)
{
System.err.print("requestAllPermissions error: " + e);
e.printStackTrace(System.err);
return false;
}
/* end of IF_ANDROIDAPI_GT_22 */
return true;
}

@Override
public void startActivityForResult(Intent intent, int cont) {
try {
Expand All @@ -131,6 +156,7 @@ public class @SYS_APPNAME@ extends Activity implements @ANDROID_JAVA_IMPLEMENTS@
@Override
public void setContentView(android.view.View view) {
if(current_ContentView != view) {
// Note: this is a bit brain dead as it ONLY handles GLSurfaceView
if(current_ContentView instanceof android.opengl.GLSurfaceView) {
((android.opengl.GLSurfaceView)current_ContentView).onPause();
}
Expand Down Expand Up @@ -177,8 +203,13 @@ public class @SYS_APPNAME@ extends Activity implements @ANDROID_JAVA_IMPLEMENTS@

mSensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);

checkOrRequestPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
// Additions and permissions needed by modules, e.g. gps
requestAllPermissions();

// MUST NOT run before nativeInstanceInit completed
// and MUST NOT run before permission checks
setContentView(current_ContentView==null ? mGLView : current_ContentView);

// Additions needed by modules, e.g. gps
@ANDROID_JAVA_ONCREATE@

// MUST NOT run before nativeInstanceInit completed
Expand All @@ -187,6 +218,7 @@ public class @SYS_APPNAME@ extends Activity implements @ANDROID_JAVA_IMPLEMENTS@
// start EVENT_IDLE
if(idle_tmScheduleRate > 0) idle_tm.scheduleAtFixedRate(idle_task, 0, idle_tmScheduleRate);
}

@Override
protected void onDestroy() {
setContentView(mGLView);
Expand Down
15 changes: 15 additions & 0 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,20 @@ compile_payload()
$SYS_RANLIB $tgtlib 2> /dev/null
assertfile "$tgtlib"
echo " == $tgtlib"
# transfering additonal .so's files
if [ "$SYS_PLATFORM" = android ]; then
sofilesdir=`locatedir apps/$SYS_APPNAME/android_sos silent`
if [ -d "$sofilesdir" ]; then
echo " => building additional library files.."
## (cd $sofilesdir; make)
# cp -La $sofilesdir $tmpdir
env
( export SYS_ROOT SYS_PATH SYS_CXX SYS_PREFIX SYS_CC SYS_GSC APP_ABI=$abi SYS_STRIP SYS_PLATFORM_VARIANT
cd $sofilesdir && make SYS_PREFIX=${SYS_PREFIX} INSTALL_DIR=$SYS_PREFIX/lib -r) || exit 1
else
echo "not building additional .so files"
fi
fi
dmsg_make "payload : $tgtlib"
dmsg_make "leaving compile_payload"
}
Expand Down Expand Up @@ -1099,6 +1113,7 @@ make_setup_target()
ac_subst SYS_APPVERSIONCODE
ac_subst SYS_ANDROIDAPI
ac_subst IF_ANDROIDAPI_GT_22 "`if [ $SYS_ANDROIDAPI -lt 23 ]; then echo '/* IF_ANDROIDAPI_GT_22 commented out:'; else echo '/* IF_ANDROIDAPI_GT_22 active here:*/'; fi`"
ac_subst IF_ANDROIDAPI_GT_25 "`if [ $SYS_ANDROIDAPI -lt 26 ]; then echo '/* IF_ANDROIDAPI_GT_25 commented out:'; else echo '/* IF_ANDROIDAPI_GT_25 active here:*/'; fi`"
ac_subst SYS_ANDROIDSDK
ac_subst SYS_ANDROIDNDK
ac_subst SYS_BUILDHASH
Expand Down
2 changes: 0 additions & 2 deletions modules/camera/ANDROID_java_oncreate

This file was deleted.

12 changes: 11 additions & 1 deletion modules/config/config.scm
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ end-of-c-declare
;; repl and simillar situations.
(set! ##exit
(lambda (#!optional (code 0))
#;(println port: (current-error-port)
(call-with-output-string
(lambda (port)
(continuation-capture
(lambda (cont)
(display-exception-in-context code cont port)
(display-continuation-backtrace cont port)))))
"##exit")
((c-lambda (int) void "lambdanative_exit") code)))

(if (not (file-exists? (system-directory)))
Expand All @@ -109,7 +117,9 @@ end-of-c-declare

(cond-expand
(android
(define (android-PackageCodePath) ((c-lambda () char-string "android_getPackageCodePath"))))
(define android-FilesDir (c-lambda () char-string "android_getFilesDir"))
(set! system-appdirectory android-FilesDir)
(define android-PackageCodePath (c-lambda () char-string "android_getPackageCodePath")))
(else #!void))

;; Gain access to Android app_directory_files and app_code_path
Expand Down
13 changes: 8 additions & 5 deletions modules/eventloop/eventloop.scm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#|
LambdaNative - a cross-platform Scheme framework
Copyright (c) 2009-2016, University of British Columbia
Copyright (c) 2009-2020, University of British Columbia
All rights reserved.

Redistribution and use in source and binary forms, with or
Expand Down Expand Up @@ -149,9 +149,11 @@ end-of-c-declare
(define (event-push t x y)
(set! event:fifo (append event:fifo (list (list t x y)))))
(define (event-pop)
(if (null? event:fifo) #f
(if (null? event:fifo)
#f
(let ((ret (car event:fifo)))
(set! event:fifo (cdr event:fifo)) ret)))
(set! event:fifo (cdr event:fifo))
ret)))

(define on-jscm-result
(let ((mux (make-mutex 'on-jscm-result)))
Expand Down Expand Up @@ -200,8 +202,9 @@ end-of-c-declare
;; handle potential scaling (running stretched on a device)
(hook:event t (if app:scale? (fix (* app:xscale x)) x)
(if app:scale? (fix (* app:yscale y)) y))
)
((fx= t EVENT_JSCM_RESULT) ((on-jscm-result) t x y))
)
((fx= t EVENT_JSCM_RESULT)
((on-jscm-result) t x y))
((fx= t EVENT_INIT)
;; prevent multiple inits
(if app:mustinit (begin
Expand Down
2 changes: 0 additions & 2 deletions modules/gps/ANDROID_java_oncreate
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)){
criteria.setAccuracy(Criteria.ACCURACY_FINE);
checkOrRequestPermission(android.Manifest.permission.ACCESS_FINE_LOCATION);
} else {
criteria.setPowerRequirement(Criteria.POWER_LOW);
criteria.setAccuracy(Criteria.ACCURACY_COARSE);
checkOrRequestPermission(android.Manifest.permission.ACCESS_COARSE_LOCATION);
}
provider = locationManager.getBestProvider(criteria, false);
Location location = locationManager.getLastKnownLocation(provider);
Expand Down
3 changes: 0 additions & 3 deletions modules/hybridapp-xwalk/ANDROID_java_oncreate
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// permissions

checkOrRequestPermission(android.Manifest.permission.ACCESS_FINE_LOCATION);

// webview

Expand Down
3 changes: 0 additions & 3 deletions modules/hybridapp/ANDROID_java_oncreate
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// permissions

checkOrRequestPermission(android.Manifest.permission.ACCESS_FINE_LOCATION);

// webview

Expand Down
7 changes: 7 additions & 0 deletions modules/ln_core/flofix.scm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

(define fix:fixnum-max-as-flonum (##fixnum->flonum ##max-fixnum))

(##namespace ("lambdanative#" flo fix))

(define (fix n)
(declare (not safe))
(cond
Expand All @@ -60,6 +62,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

;; Note that macro-fix and macro-flo are only visible within ln_core.scm,
;; but are much faster. fix and flo are available everywhere but costlier.
(##namespace (""))

(define flo lambdanative#flo)
(define fix lambdanative#fix)

(define-macro (macro-fix n)
`(cond
((##fixnum? ,n) ,n)
Expand Down
11 changes: 7 additions & 4 deletions modules/ln_core/list.scm
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
(define (list-notempty? lst) (and (list? lst) (not (null? lst))))

;; Make a list of length n, where each element is set to elem
(define (make-list n #!optional (elem 0))
(if (zero? n) '()
(cons elem (make-list (- n 1) elem))))
(define (make-list n #!optional (fill 0))
(if (and (exact-integer? n) (not (negative? n)))
(do ((i n (fx- i 1)) (result '() (cons fill result)))
((fx= i 0) result))
(error "make-list: The first argument must be a nonnegative integer: " n fill)))

;; mar 2010: changed implementation
;;(define (list-head l n)
Expand Down Expand Up @@ -72,6 +74,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;; mapS behaves like map, except for stripping empty lists from the returned list
;; Usage: (maps FunctionToBeCalledForEachElement ListToWorkOn)
(define (maps fcn lst)
;;; FIXME: O(2^horror)
(list-keep (map fcn lst) (lambda (l) (not (and (list? l) (= (length l) 0))))))

;; do a continuous lookup
Expand Down Expand Up @@ -102,7 +105,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

(define (list-delete-item lst item)
(cond
((fx= (length lst) 0) lst)
((null? lst) lst)
((equal? item (car lst)) (cdr lst))
(else (cons (car lst) (list-delete-item (cdr lst) item)))
)
Expand Down
26 changes: 26 additions & 0 deletions modules/ln_core/ln_core-macros.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
;;; This file contains a few definitions enabling the gambit compiler
;;; replace calls to the procedures with the same name with inline
;;; code.
;;;
;;; BEWARE: These MIRROR the code from the definitions of the exported
;;; procedures of the same name.
;;;
;;; We need to keep those symbols bound to the procedures for the
;;; foreseeable future. Therefore we can't share the code.

(define-macro (fix n)
`(cond
((##fixnum? ,n) ,n)
((##flonum? ,n)
(if (##fl< ,n fix:fixnum-max-as-flonum)
(##flonum->fixnum ,n) (##flonum->exact-int ,n)))
((##bignum? ,n) ,n)
((##ratnum? ,n) (##floor ,n))
(else #f) ;; no complex numbers
))

(define-macro (flo n)
`(cond
((##flonum? ,n) ,n)
((##fixnum? ,n) (##fixnum->flonum ,n))
(else (##exact->inexact ,n))))
19 changes: 19 additions & 0 deletions modules/ln_core/log.scm
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ end-of-c-declare
(log-error "HALT pid " ((c-lambda () int "getpid")))
(exit 70))

(cond-expand
((or linux debug)
(set!
log-error
(let ((log-error log-error))
(lambda args
(apply println port: (current-error-port) args)
(apply log-error args)))))
(else))

;; catch primordial thread exceptions
(current-exception-handler log:exception-handler)

Expand All @@ -159,5 +169,14 @@ end-of-c-declare
;; let's say hello to ourselves
(log-system "Application " (system-appname) " v" (system-appversion) " built " (system-builddatetime))
(log-system "Git hash " (system-buildhash))
(log-system "System directory " (system-directory))
(cond-expand
(android
(log-system "Examining Android...")
(c-declare "extern char* android_getFilesDir();")
(log-system "System APP dir: " ((c-lambda () char-string "___return(android_getFilesDir());")))
(log-system "Done with Android checks"))
(else #!void))
(log-system "System app directory " (system-appdirectory))

;; eof
Loading

0 comments on commit 7fa9fbc

Please sign in to comment.