Making a distributed system

by ThemePark » Sun, 02 Nov 2008 23:22:11 GMT

Sponsored Links
 I've been reading through a bit of the Android documentation, and this
seems to be perfect for developing one of my projects. But in order to
make sure, I need to get some things straight.

Android has processes (background processes being especially
interesting), life cycles, and as far as I can tell, the ability to
connect to networks. So as far as I can tell, I should be able to
build a distributed system, by having a server with my program and
some data, and then any number of G1  phones, that have downloaded and
installed another program for downloading some of the data, running
calculations on it, and uploading it back to the server.

Am I right about being able to do that, and how should I go about with
it? What things should I be careful of/look out for?


Making a distributed system

by Al Sutton » Sun, 02 Nov 2008 23:25:51 GMT

 Your app will most either kill battery life or spend most of it's time 
suspended, making it either unpopular or very slow.

Most battery powered devices (such as the G1) try to increase battery 
life by reducing processing load, so when you whack up the lock the 
battery suffers.


Al Sutton



Sponsored Links

Making a distributed system

by ThemePark » Sun, 02 Nov 2008 23:51:20 GMT

 I saw a YouTube video from the Android team about running multiple
processes, showing how the phone is looking for new pictures on a
Flickr account, while doing something else.

With that in mind, wouldn't it be possible for me to run it as a
background process, possibly only running when the phone is not being
used (if at all possible), and that way not use a whole lot of battery
time and not making it slow either? Think of the way SETI works.


Making a distributed system

by Mark Murphy » Mon, 03 Nov 2008 00:02:40 GMT


[EMAIL PROTECTED] is usually used on machines plugged into AC power. Mobile 
devices are infrequently plugged into AC power.

On a mobile device, every executed instruction eats a tiny bit of 
battery power. What you're suggesting is to execute a whole lot of 
instructions while users are thinking their phone is asleep and 
therefore is not using (much) power.

If Android starts getting used for devices more frequently connected to 
power, using it for a distributed computation cloud might make sense.

Mark Murphy (a Commons Guy) 

Android Training on the Ranch! -- Mar 16-20, 2009 


Making a distributed system

by ThemePark » Mon, 03 Nov 2008 01:21:42 GMT

 Point taken. I didn't think it would use up a lot of battery power,
but you're right, a lot of little bits certain would.

Let's say that Android does get used more on AC powered devices (it
will take me a couple of years to fully make the app anyway, so it's
entirely possible). Then back to my original question. How would I go
about doing that? I'm not so concerned with how to upload and download
data through networks, but more how I would go about with sending data
from one application to another, and how to receive it in an
application as well. I've been reading about using stuff like messages
and threads in general, but I am unsure of what I should use
specifically in Android.


Making a distributed system

by David Given » Mon, 03 Nov 2008 01:51:36 GMT


It would be entirely possible to have the app only run when the device
is charging; given that most people with smartphones leave them on
charge overnight, this would still get you reasonable run time. There's
an ACTION_BATTERY_CHANGED intent that you can register for to get
notified when the AC power status changes, but I don't know offhand how
you'd poll for the current status.

You probably want to read up on this: 

Note that you only really need to do this for IPC between different apps
on the same device. The most common use for this is to allow one app to
communicate with a library that's actually part of another app ---
ContentProviders, for example. For a distributed processing app, the
most likely scenario is to have the actual calculator running as a
background service, with a separate app communicating with it via IPC to
show the results to the user, that only runs when the user actually
wants to watch things happening.

€€  €€€€€  €€€€€
--- Conway's Game Of Life, in one line of APL

Making a distributed system

by Jean-Baptiste Queru » Mon, 03 Nov 2008 07:57:41 GMT

 -Running the CPU at full speed on a G1 will drain the battery in a few hours.

-Running the CPU at full speed on a G1 while the device is charging
will slow down the speed at which the device recharges.

-Running the CPU at full speed on a G1 for any extended period of time
will make the device hot to the touch.


PS: pushing to the extreme, which doesn't seem to be the case here,
it's possible to make a G1 draw so much power that the battery almost
stops charging or even discharges while the device is plugged in,
especially when charging over USB which provides less power than a
wall charger. The CPU alone isn't enough for this, but if you start to
add up enough power-draining peripherals (network, screen, GPS,
accelerometer) you could be consuming several watts.


Other Threads

1. Changing one TextView with onSensorChanged without Redrawing the Entire Layout

Hello everyone,

I am having a bit of trouble with my current application.  With a
button at the beginning of my app, I send out Intents for two
activities, one gets a camera object, and starts a preview screen.  On
top of that, in a separate layout, there is an activity with a
translucent view, which shows a resource image (the user is trying to
get the image he is actually taking to align with the translucent
image) and a couple of textviews displaying a target phone orientation
as well as the user's current phone orientation.

Here is my problem:  when I update the text value of one of my text
views in my onSensorChanged() field, the system constantly reallocates
1.22MB and garbage collects it.  I can only assume that this is
because it is redrawing the entire layout with the translucent image
and the text fields, because if I remove the view containing the
translucent image from the layout, my text field updates 10x quicker
and I don't have ridiculous heap growing / garbage collecting.  I am
wondering how to go about getting the text fields to update without
redrawing the entire surface.  I am very new to UI design, and this
code was written by someone else before I took over the project, so I
don't understand much of what is going on in the custom view he wrote
to take care of the translucent image -- called MyView.  I will post
the code for the layout as well as the MyView code below.

A reiteration of my goal -- I want to update the TextView text without
the extraneous allocation / garbage collection that is coming as a
result of having MyView included in the layout.

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="

                android:layout_height="fill_parent" />

        <LinearLayout android:id="@+id/LinearLayout01"
android:layout_height="wrap_content" xmlns:android="http://" android:layout_gravity="bottom">
        <TextView android:id="@+id/TargetDirTextView"
        <TextView android:id="@+id/CurrentDirTextView"


MyView code:
public class MyView extends View{

    public MyView(Context context, int t) {
    public MyView(Context context, AttributeSet attrs)
        super(context, attrs);
    protected void onDraw(Canvas canvas) {

       is = null;
                if(Global.imageId == 0) {
                        is = getResources().openRawResource(R.drawable.eeb);
                else if(Global.imageId == 1) {
                        is = getResources().openRawResource(R.drawable.phe);
                else if(Global.imageId == 2) {
                        is = getResources().openRawResource(R.drawable.rth);
                else if(Global.imageId == 3) {
                        is = getResources().openRawResource(R.drawable.eeb);

                BitmapFactory.Options opts = new BitmapFactory.Options();
                Bitmap bm;

                opts.inJustDecodeBounds = true;
                bm = BitmapFactory.decodeStream(is, null, opts);

                // now opts.outWidth and opts.outHeight are the dimension of
                // bitmap, even though bm is null

                opts.inJustDecodeBounds = false;    // this will request the
                opts.inSampleSize = 1;             // scaled down by 4
                bm = BitmapFactory.decodeStream(is, null, opts);

                Bitmap bm2 = bm.copy(Bitmap.Config.ARGB_8888, true);
                int[] pixelArray = new int[bm2.getHeight()*bm2.getWidth
                bm2.getPixels(pixelArray, 0, bm2.getWidth(), 0, 0,
bm2.getWidth(), bm2.getHeight());
                int i;
                for(i=0; i<pixelArray.length; i++) {
                    pixelArray[i] ^= 0x55111111;
                bm2.setPixels(pixelArray, 0, bm2.getWidth(), 0, 0,
bm2.getWidth(), bm2.getHeight());
                canvas.drawBitmap(bm2, 10, 10, null);



2. wifi/wpa_supplicant

I am porting android to ARM platform and have problems with enable/
disable wifi.
Wifi is working but when i disable it wpa_supplicant process is not
being killed, and thus after i re enable wifi another instance of
wpa_supplicant is being created and no connection can be established.

Dhcpcd is killed properly (as i understand it kills itself when wifi
kernel module is removed, at least that what i found during debugging)
but wpa_supplicant process remains running.
I can add of cause the killing of the process inside the
wifi_stop_supplicant() function from libhardware_legacy/wifi.c but i
would rather understand why it is not being killed in the system
I am using propriety wifi chip and kernel module rather then android's
default TI.

Please help!

3. Passing pmem FDs from OMX to MIO

4. creating custom system.img

5. Android/iPhone costs in the UK

6. how to read radio stream for web

7. unable to launch Emulator.