Slow.... the build is so slow, it eats up my 50% of time.
I'm getting there. I still need to clean up the conntectivityservice. This class does now know anything other than wifi and mobile. I need to add etherent into it. But before that I will try out the basic functionality and release a test path .
Monday, August 24, 2009
Sunday, August 16, 2009
Add state tracker for etherent devices
Android has state tracker (the connection management) for both mobile connections and wifi connections. But it does not support ethernet devices.
This is not an issue for a phone , but it causes following issues with netbook:
1. you can not manage your ethernet device from UI at all
2. With current way of enabling ethernet device (netcfg eth0 dhcp). If you unplug/plug cable, you will not have your dhcp ip address reset
3. ethernet device can not report connectivity changes correctly
Now, I'm working on the ethernet state tracker support for Android-x86. This blog thread is created to track this work.
This is not an issue for a phone , but it causes following issues with netbook:
1. you can not manage your ethernet device from UI at all
2. With current way of enabling ethernet device (netcfg eth0 dhcp). If you unplug/plug cable, you will not have your dhcp ip address reset
3. ethernet device can not report connectivity changes correctly
Now, I'm working on the ethernet state tracker support for Android-x86. This blog thread is created to track this work.
Saturday, June 6, 2009
How to access a C native service from Java side in Android
I have mentioned how to add a native service by C. Now, it is the time to discuss about the client implementation. A client, in this document is a activity. It can talk to the native service to instruct the native service to do something for it.
It seems that there has no way to do this with a standard method supported by Android SDK. So I went to another route. I built a platform library. The platform library talks to the servicemanager.java to access the binder hence the native service. The code is very simple. To find out how to build and use a platform library, you can check out the android source code and take a look at the README.txt in the directory development/samples/PlatformLibrary
package com.servicelib.mybinder;
import android.util.Config;
import android.util.Log;
import android.os.ServiceManager;
import android.os.Binder;
import android.os.IBinder;
import android.os.Parcel;
import android.os.RemoteException;
public final class MyBinderLibrary {
private static IBinder mServiceManager = null;
public MyBinderLibrary() {
}
public static IBinder AttachService(String name) {
if (mServiceManager == null) {
mServiceManager = ServiceManager.getService(name);
}
return mServiceManager;
}
public static int SendKillSignal() throws RemoteException
{
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
int result;
try{
data.writeInterfaceToken(mServiceManager.getInterfaceDescriptor());
mServiceManager.transact(TRANSACTION_sendKill,data,reply,0);
reply.readException();
result = reply.readInt();
}
finally{
reply.recycle();
data.recycle();
}
return result;
}
static final int TRANSACTION_sendKill = (IBinder.FIRST_CALL_TRANSACTION+0);
}
So, in your activity, call the methods in this class directly. So that you can talk to the native service. You need to make sure the name of the service is correct.
It seems that there has no way to do this with a standard method supported by Android SDK. So I went to another route. I built a platform library. The platform library talks to the servicemanager.java to access the binder hence the native service. The code is very simple. To find out how to build and use a platform library, you can check out the android source code and take a look at the README.txt in the directory development/samples/PlatformLibrary
package com.servicelib.mybinder;
import android.util.Config;
import android.util.Log;
import android.os.ServiceManager;
import android.os.Binder;
import android.os.IBinder;
import android.os.Parcel;
import android.os.RemoteException;
public final class MyBinderLibrary {
private static IBinder mServiceManager = null;
public MyBinderLibrary() {
}
public static IBinder AttachService(String name) {
if (mServiceManager == null) {
mServiceManager = ServiceManager.getService(name);
}
return mServiceManager;
}
public static int SendKillSignal() throws RemoteException
{
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
int result;
try{
data.writeInterfaceToken(mServiceManager.getInterfaceDescriptor());
mServiceManager.transact(TRANSACTION_sendKill,data,reply,0);
reply.readException();
result = reply.readInt();
}
finally{
reply.recycle();
data.recycle();
}
return result;
}
static final int TRANSACTION_sendKill = (IBinder.FIRST_CALL_TRANSACTION+0);
}
So, in your activity, call the methods in this class directly. So that you can talk to the native service. You need to make sure the name of the service is correct.
Friday, May 29, 2009
connect G1 phone to adb on Ubuntu
You can find very detailed instructions on android page. But they missed one thing, that is adb needs to be run with root permission. So after you setup everything, do:
adb kill-server
sudo adb devices
adb kill-server
sudo adb devices
Thursday, May 28, 2009
The mouse cursor issue
I did the mouse cursor support for X86 platforms. As matter fact, the same change should be able to run anyway.
But when I try to drag the screen to switch to next screen, I see the screen keeps flicking. It looks like a bug. In order to debug this problem, I wrote a small application to just draw lines on the screen. When I start to draw, I can see the lines keep jumping back to position 0,0 during the mouse cursor movement . It seems that the mouse cursor keeps sending out wrong mouse position.
After some debugging, I found out that it is cause by the batching mode of mouse event. Current mouse cursor tries to simulate the touch events, in order to do that, I have to convert the rel_x/y to abs_x/y and this conversion was never done for batched events. Because of this, both rel_x/y and abs_x/y are sent with touch events.
I have published the patch to
http://code.google.com/p/patch-hosting-for-android-x86-support/downloads/list
But when I try to drag the screen to switch to next screen, I see the screen keeps flicking. It looks like a bug. In order to debug this problem, I wrote a small application to just draw lines on the screen. When I start to draw, I can see the lines keep jumping back to position 0,0 during the mouse cursor movement . It seems that the mouse cursor keeps sending out wrong mouse position.
After some debugging, I found out that it is cause by the batching mode of mouse event. Current mouse cursor tries to simulate the touch events, in order to do that, I have to convert the rel_x/y to abs_x/y and this conversion was never done for batched events. Because of this, both rel_x/y and abs_x/y are sent with touch events.
I have published the patch to
http://code.google.com/p/patch-hosting-for-android-x86-support/downloads/list
Friday, May 22, 2009
How to write Android native service by C contntinue
Here is some thing I did; first, I copied biner.c to my private directory and used it as a library to access kernel binder driver. And then, I wrote my service to use the functions in binder.c to talk to service manager.
In order to talk with service manager, we need following things:
1. an unique id for the service we are going to build. It is a string16
2. add permission for our service to service manager.
For the point 1, I create an uint16 array like
uint16_t svcmgr_id16[] = {
'B','i','n','d','e','r','.','T','e','s','t','.','I','B','i','n',
'd','e','r','t','e','s','t'
};
for the point 2, I'm kind of lazy, I add a new item to the allowd[] in servicemanager. It looks like this:
{10001, "Binder.Test.IBindertest"}
Ok, lets get something real, we need to do following steps to make everything to work:
1. connect to the binder by calling binder_open function. The binder_open function creates a shared memory with /dev/binder. I copied service manager code to create a 128K shared memory.
2.create an io block through bio_init function to talk with service manager through binder. You need to provide a buff to bio_init. I use an integer array with size of 128
3. fill in the target (servicemanager) and source(Binder.Test.IBindertest) by calling bio_put_string16_x
4. call binder_call with command SVC_MGR_ADD_SERVICE. It is a blocking call. You need to provide a binder_io object for the result.
5. if binder_call returns 0, call binder_loop with a message handler callback function to process messages sent from service client.
The message processing callback function:
The prototype of the message processing callback functions is:
static int binder_handler(struct binder_state *bs,
struct binder_txn *txn,
struct binder_io *msg,
struct binder_io *reply)
In the callback function, we at least need to handle INTERFACE_TRANSACTION so that our service client can find our service.
switch(txn->code) {
case INTERFACE_TRANSACTION:
bio_put_string16(reply,svcmgr_id16);
break;
case:
default:
error handling.
In order to talk with service manager, we need following things:
1. an unique id for the service we are going to build. It is a string16
2. add permission for our service to service manager.
For the point 1, I create an uint16 array like
uint16_t svcmgr_id16[] = {
'B','i','n','d','e','r','.','T','e','s','t','.','I','B','i','n',
'd','e','r','t','e','s','t'
};
for the point 2, I'm kind of lazy, I add a new item to the allowd[] in servicemanager. It looks like this:
{10001, "Binder.Test.IBindertest"}
Ok, lets get something real, we need to do following steps to make everything to work:
1. connect to the binder by calling binder_open function. The binder_open function creates a shared memory with /dev/binder. I copied service manager code to create a 128K shared memory.
2.create an io block through bio_init function to talk with service manager through binder. You need to provide a buff to bio_init. I use an integer array with size of 128
3. fill in the target (servicemanager) and source(Binder.Test.IBindertest) by calling bio_put_string16_x
4. call binder_call with command SVC_MGR_ADD_SERVICE. It is a blocking call. You need to provide a binder_io object for the result.
5. if binder_call returns 0, call binder_loop with a message handler callback function to process messages sent from service client.
The message processing callback function:
The prototype of the message processing callback functions is:
static int binder_handler(struct binder_state *bs,
struct binder_txn *txn,
struct binder_io *msg,
struct binder_io *reply)
In the callback function, we at least need to handle INTERFACE_TRANSACTION so that our service client can find our service.
switch(txn->code) {
case INTERFACE_TRANSACTION:
bio_put_string16(reply,svcmgr_id16);
break;
case
default:
error handling.
Monday, May 18, 2009
How to write Android native service by C
It is not as hard as I thought before I start. When I look into the frameworks/base/cmds/servicemanager, I realized that it should be an easy job. So I decide to give it a try. I will list what I do after I complete it.
Subscribe to:
Posts (Atom)