wiki:AndroidBoincImpl

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

--

AndroidBOINC

AndroidBOINC is a port of BOINC to Android devices. Using AndroidBOINC, BOINC projects can distribute scientific tasks to Android 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.

Architecture

The Android application consists of the regular BOINC Client and an Android-specific GUI. AndroidBOINC combines the two independent BOINC components of Client and GUI.

The BOINC Client was 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 GUI, developed for Android using the common design patterns. AndroidBOINC bundles those two components together, to be distributed in a single APK.

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

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 the 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.
  • Battery temperature: Computation is stopped if battery temperature is above 45 C.
  • Battery charge: Computation is stopped if battery charge is below 95%.

Config file

A config file (currently prefs.xml, should be renamed) will contain

  • "run at boot?"
  • "seen welcome?" (has the user seen the welcome dialog?)

Installation

Unlike Win/Mac?, can't do any logic in the installer.

At end of installation, user is asked whether they want to run app. If so, the GUI does the following:

show "Welcome" dialog; say:
	- 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
start client

If the user doesn't run the app, nothing will happen until the next time they boot the device (see below).

Boot time

"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
	start 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
    • then restart client
  • client
    • don't launch any app if low memory
    • Is there a C++ func to find if low mem?
  • wrapper
    • if task got SIGKILL, temporary_exit(60)

GUI exit

  • leave the client running
  • need an "exit all" button some