wiki:AndroidBoincImpl

Version 5 (modified by davea, 12 years ago) (diff)

--

AndroidBOINC

AndroidBOINC is an attempt to port the Berkeley Open Infrastructure for Network Computing to Android-powered devices.

The Android application consists of the regular BOINC Client and an Android-specific BOINC Manager. Using AndroidBOINC, BOINC projects can distribute scientific tasks to Android-powered devices, enabling volunteers to contribute CPU time of modern smartphones and tablet computers.

Projects are free to download the sources of AndroidBOINC from UCB's BOINC repository and configure the client. Projects are in charge of their version's distribution e.g. on Google's PlayStore. Note that AndroidBOINC currently supports only a single project.

Architecture

AndroidBOINC combines the two independent BOINC components of Client and Manager.

The BOINC Client got adapted to accommodate the needs of mobile devices and can be cross compiled to run on ARM-Android-based devices. To allow volunteers to control the Client, AndroidBOINC's second component is a BOINC Manager, developed for Android using the common design patterns. AndroidBOINC bundles those two components together, to be distributed in a single APK.

Client and Manager communicate via RPCs, similar to versions on Windows or Linux.

On startup the Android application executes the BOINC Client, which does not have Android-specific methods implemented and consists solely out of native source code. The Client and Manager run as two separate processes.

Talking Android, AndroidBOINC consists of a Service (called Monitor), which interacts with the BOINC Client and holds data (ClientStatus, AppPreferences) which is accessed from various Activities.

Aspects of Android platform

  • Storage: Applications are only allowed to write into two areas of a device's storage space. One is the app's directory, located at /data/data/*package.name*/, files in this directory can be set executable and run using the Java's Runtime.exec command. This space is "private", so only accessible by the application it belongs to. The second storage location is the device SD card (if present), this is generally accessible by all applications, but mounted non-executable.
  • Permissions: Android restricts access to certain features with its permission system. Required permissions have to be declared in the AndroidManifest file at compile-time, the user then gets prompted to grant access upon installation. AndroidBOINC requires the "Network" and permission in order to transmit workunits and setup socket for the RPC communication in-between Manager and Client. The permission "RECEIVE_BOOT_COMPLETED" is used to start the BOINC Client upon boot. Permissions get granted to the App-specific Linux User ID, and therefore also applies to its child-processes.
  • Lifecycle: Activities which are not visible at the moment can get killed by the system. If the user navigates back to a destroyed application, it gets reactivated. In most cases according lifecycle-methods are called, however those are not reliable. This behavior only applies to applications which are executed in Android's Dalvik virtual machine and not to native child-processes like the BOINC Client. As a consequence, the Manager tries to connect to a possibly existing BOINC Client. Only if this attempt fails, a new instance of the BOINC client is executed.
  • Distribution: Like every other application, AndroidBOINC comes in an APK package. The BOINC Client gets distributed as part of the Android app and resides in its "assets" directory. When executed, the Client gets copied to the local storage space and executed from there.

Considerations for mobile devices

In order to accommodate the limitations of mobile devices, two features got introduced to the BOINC Client:

  • Wifi detection: AndroidBOINC, by default, does communication with its project scheduler only when logged into a Wifi. This helps volunteers keeping control of limitations on a data plan.
  • Charging only: AndroidBOINC, by default, computes tasks only when the device is being connected to a power source, preventing battery drowns.

Limitation

The current version of AndroidBOINC can only be attached to a single project.

Acknowledgements

  • Pavol Michalec for his work on AndroBOINC (BOINC Manager for Android)
  • Mats for his work on NativeBOINC

Getting Started

To get your project running on Android, please note:

prefs.xml

"run at boot" "seen welcome"

client is started by "Monitor" (Java)

background thread can be killed by OS

Installation:

(can't do any logic)

if user chooses to run GUI:

GUI

prefs.xml doesn't exist show "Welcome" dialog

BOINC will run all the time only will compute when plugged in and battery mostly charged Can changes these using Preferences tab

create prefs.xml

run at boot = true seen welcome = true

starts client

if user doesn't choose to run app:

"boot receiver" function

if not "seen welcome" (e.g. prefs.xml doesn't exist)

send notification: "click to configure BOINC"

if "run at boot" set

starts the client (not GUI)

GUI startup

if newer version of client (based on MD5)

if client process running

kill it

copy executable start client

else

if client process not running

start client

App shutdown by OS

GUI

if lose connection to client

wait until system is not low on memory

how to do this on 2.3?

restart client

client

Is there a C++ func to find if low mem? don't launch any app if low memory

wrapper

if task got SIGKILL

temporary_exit(60)

GUI exit

need an "exit all" button some