We concluded that it started with version 2.0.1. This seems to be intentional, perhaps part of the extended battery life that was touted as a feature. We had a working jitter to wake or unlock on 2.0, then it broke in the update, and we could not get any solution .; (It doesnβt matter if the processor is partially blocked, which should always prevent the processor from sleeping. From what I saw when debugging debugging via USB, sometimes there is a mention of changes in the sensor listener when the sleep mode occurs.
The user posted a workaround that he claimed works on Motorola devices - https://sites.google.com/a/bug-br.org.br/android/technical-documents
I tested the workaround by entering the following code from the tutorial and some manual revision (the code contains a few errors code):
public class ShakeWakeupService extends Service implements SensorEventListener{ private Context mContext; SensorManager mSensorEventManager; Sensor mSensor; // BroadcastReceiver for handling ACTION_SCREEN_OFF. public BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // Check action just to be on the safe side. if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { Log.v("shake mediator screen off","trying re-registration"); // Unregisters the listener and registers it again. mSensorEventManager.unregisterListener(ShakeWakeupService.this); mSensorEventManager.registerListener(ShakeWakeupService.this, mSensor, SensorManager.SENSOR_DELAY_NORMAL); } } }; @Override public void onCreate() { super.onCreate(); Log.v("shake service startup","registering for shake"); mContext = getApplicationContext(); // Obtain a reference to system-wide sensor event manager. mSensorEventManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE); // Get the default sensor for accel mSensor = mSensorEventManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); // Register for events. mSensorEventManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL); // Register our receiver for the ACTION_SCREEN_OFF action. This will make our receiver // code be called whenever the phone enters standby mode. IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF); registerReceiver(mReceiver, filter); } @Override public void onDestroy() { // Unregister our receiver. unregisterReceiver(mReceiver); // Unregister from SensorManager. mSensorEventManager.unregisterListener(this); } @Override public IBinder onBind(Intent intent) { // We don't need a IBinder interface. return null; } public void onShake() { //Poke a user activity to cause wake? } public void onAccuracyChanged(Sensor sensor, int accuracy) { //not used right now } //Used to decide if it is a shake public void onSensorChanged(SensorEvent event) { if(event.sensor.getType() != Sensor.TYPE_ACCELEROMETER) return; Log.v("sensor","sensor change is verifying"); } }
The workaround works for me, but it doesn't work while I run screebl, which is a feature that many of my users really want to work along with what I'm developing.
mylock Jan 30 '10 at 8:44 2010-01-30 08:44
source share