eclair snapshot

This commit is contained in:
Jean-Baptiste Queru
2009-11-12 18:45:53 -08:00
parent 6c63ee4fc4
commit 9db3d07b96
3587 changed files with 991748 additions and 69172 deletions

View File

@@ -84,12 +84,16 @@ class SensorService extends ISensorService.Stub {
if (hasSensor(sensor)) {
removeSensor(sensor);
try {
deactivateIfUnused(sensor);
deactivateIfUnusedLocked(sensor);
} catch (RemoteException e) {
Log.w(TAG, "RemoteException in binderDied");
}
}
}
if (mListeners.size() == 0) {
_sensors_control_wake();
_sensors_control_close();
}
mListeners.notify();
}
}
@@ -102,9 +106,12 @@ class SensorService extends ISensorService.Stub {
}
public Bundle getDataChannel() throws RemoteException {
return _sensors_control_open();
// synchronize so we do not require sensor HAL to be thread-safe.
synchronized(mListeners) {
return _sensors_control_open();
}
}
public boolean enableSensor(IBinder binder, String name, int sensor, int enable)
throws RemoteException {
if (localLOGV) Log.d(TAG, "enableSensor " + name + "(#" + sensor + ") " + enable);
@@ -163,7 +170,7 @@ class SensorService extends ISensorService.Stub {
l.addSensor(sensor, enable);
} else {
l.removeSensor(sensor);
deactivateIfUnused(sensor);
deactivateIfUnusedLocked(sensor);
if (l.mSensors == 0) {
mListeners.remove(l);
binder.unlinkToDeath(l, 0);
@@ -173,12 +180,13 @@ class SensorService extends ISensorService.Stub {
if (mListeners.size() == 0) {
_sensors_control_wake();
_sensors_control_close();
}
}
return true;
}
void deactivateIfUnused(int sensor) throws RemoteException {
private void deactivateIfUnusedLocked(int sensor) throws RemoteException {
int size = mListeners.size();
for (int i=0 ; i<size ; i++) {
if (mListeners.get(i).hasSensor(sensor))
@@ -187,10 +195,11 @@ class SensorService extends ISensorService.Stub {
_sensors_control_activate(sensor, false);
}
ArrayList<Listener> mListeners = new ArrayList<Listener>();
private ArrayList<Listener> mListeners = new ArrayList<Listener>();
private static native int _sensors_control_init();
private static native Bundle _sensors_control_open();
private static native int _sensors_control_close();
private static native boolean _sensors_control_activate(int sensor, boolean activate);
private static native int _sensors_control_set_delay(int ms);
private static native int _sensors_control_wake();