Topics

Using BBCSDL to access GPS under Android.

Andrew Cool
 

Hello All,

I have a need (aka my wife has requested), to create a small app for Android phones that will :-

1. Accept a series of three floating numbers, and

2. Average each group of 3 numbers, and

3. Retrieve GPS coords from the phone's GPS unit, and

4. Write out to a file a table of 

    Date/Timestamp    GPS coords    Group Average (from 2 above)

e.g.

    20170422_034432    -34.654353    139.345678    21.4

and so on,and then

5. Email the file to some pre-determined email address.


Mostly very doable I suspect, though I'm not at all sure about getting the GPS coords from the phone.

Can BBCSDL do that?


Cheers,

Andrew



Richard Russell
 

On Fri, Apr 21, 2017 at 10:47 pm, Andrew Cool wrote:
Can BBCSDL do that?

As previously discussed, I have deliberately set the permissions requested by BBCSDL to the bare minimum required for it to run, which means permission to access your memory card but nothing else.  It is arguable that a 'general purpose' programming language like BBC BASIC ought to seek permission to do 'everything' (since you cannot predict what somebody might want their program to do) but I am concerned that if the user is presented with a long list of requested permissions - including some which have privacy implications - they will simply refuse to install it.

To access GPS data you will need ACCESS_FINE_LOCATION permission and this is considered by Android to be a 'dangerous' permission because it gives an app access to 'confidential' data.  I will need to build a version for you that requests that permission; not difficult, but some consideration will need to be given to whether it is acceptable for the 'standard' version to do so or only a special custom version for you.  I would be interested in your views and those of other members who may have installed, or are considering installing, the Android edition of BBC BASIC.

Once you have a version which requests that permission the rest is 'just' BASIC coding.  As you will know from previous posts, accessing the Android Java API via JNI is a pain (compared with accessing the Windows API for example) but there's no alternative and like everything else it becomes easier with practice.  I will be very interested indeed to see the results of this endeavour and it could be a useful building block for others.

Richard.

 

On Sat, 22 Apr 2017, at 10:14, Richard Russell wrote:

To access GPS data you will need ACCESS_FINE_LOCATION permission and this
is considered by Android to be a 'dangerous' permission because it gives
an app access to 'confidential' data.  I will need to build a version for
you that requests that permission; not difficult, but some consideration
will need to be given to whether it is acceptable for the 'standard'
version to do so or only a special custom version for you.  I would be
interested in your views and those of other members who may have
installed, or are considering installing, the Android edition of BBC
BASIC.
I've not yet tried the Android version, but might do so when I have time
(though
that won't be soon as I've got a relative's house to clear & sell asap),
since I noted
with interest when you made it work for non-Intel processors (I fairly
recently got
a cheap chinese smartphone that I've barely got to grips with, so far.)

It's impractical, surely, for you to build multiple versions with
multiple permissions
theoretically available? Is it however possible for you to build one
that is described
somewhere "for use of adventurous programmers only" that asks for them
all? And
if so is it possible for programs written in that not actually to have
access to risky
parts of the API unless some BBCSDL flag(s) (to be invented) is/are set?
I mean, is
there something you can do to limit the use to which such an environment
might be
put so that programmers can't casually shoot themselves in the foot?

--
Jeremy Nicoll - my opinions are my own.

Andrew Cool
 

Hello Richard,

There's probably not much point in going to the effort of creating a special once off version for me - which woudl no doubt lead to once versions

for other people, and create an enormous rod for your own back in maintinaing and supporting them.


I tend to agree with Jeremy that a fully featured "for use of adventurous programmers only" version would be better.

I routinely install apps that ask for all sorts of permissions - but they are apps that I downloaded myself for a purpose, so enabling a few

permissions is not a particular concern to me.


I suggest simply making it plain to the user on the tin label that the Danger-enabled version will request many permissions so that there are no

surprises.


Andrew



Richard Russell
 

On Sat, Apr 22, 2017 at 03:49 am, Jeremy Nicoll wrote:
is it possible for programs written in that not actually to have access to risky
parts of the API unless some BBCSDL flag(s) (to be invented) is/are set?
I mean, is there something you can do to limit the use to which such an environment
might be put so that programmers can't casually shoot themselves in the foot?

There's nothing to stop you "shooting yourself in the foot" in BB4W (or indeed BBCSDL running on Windows, Linux or Mac OS) since 'desktop apps' don't have a culture of protecting the user from his own stupidity (or carelessness).  For example you can very easily write a BB4W program that will delete all the user's personal files, or damage his section of the registry etc.  So, personally, I don't feel that there is any need to 'limit' what is possible, in the way you suggest, even if such a thing could be achieved.  I am content that users should be aware that a general-purpose programming language can, of its nature, do both good things and bad things and it's up to them to be responsible and careful - both on desktop platforms and on Android.

As far as Android permissions are concerned it's hard to know how they could best be managed in a 'complete', 'released' version of BBCSDL.  I suppose a dual regular/adventurous version approach as you suggest would be one option, although Android permissions are a 'moveable feast' and new capabilities (and associated permissions) are bound to be added as the OS - and the devices it runs on - evolve.   But frankly it is so unlikely that such a version will ever exist that I'm happy to put such considerations on the 'back burner'; for the foreseeable future there will only be pre-release 'development' versions of BBCSDL as I find the time (and have the inclination) to make changes, and as the 'user community' submits their own contributions (which I am relying upon, but of which there seems to be little evidence to date).  In that case generating ad-hoc versions with permissions tailored to an individual user's requirements is not such a hardship for me.

Things are more straightforward when it comes to creating standalone Android applications using BBC BASIC.  Although I have not attempted to automate this process (I'm not sure how practical that would be) I have explained what is involved to those who have expressed an interest in doing so, and hopefully we may see one or two such applications being developed before too long.  In that case the required permissions can be set on a case-by-case basis, each application requesting only the permission(s) that it needs.  That is how all normal apps work so it doesn't introduce any particular complications.

Richard.

Richard Russell
 

On Sat, Apr 22, 2017 at 04:07 am, Andrew Cool wrote:
I tend to agree with Jeremy that a fully featured "for use of adventurous programmers only" version would be better.

In that case can you suggest a tentative set of permissions that it should request?  I don't think it's reasonable to say 'everything', not least because there's little point in (say) requesting permission to access the internet when BBCSDL isn't (currently) linked with SDL_net and therefore doesn't have the infrastructure to achieve that straightforwardly anyway.  I don't even know that I've seen anything which claims to be a 'definitive' list of Android permissions published, but I've not looked very hard.

If you can supply a list, perhaps in collaboration with other interested users, I will see what can be done about creating a version that requests them.

Richard.