I was confused by the code of auto brightness control. The following is the code in PowerManagerService.java,
2728 SensorEventListener mLightListener = new SensorEventListener() { 2729 public void onSensorChanged(SensorEvent event) { 2730 synchronized (mLocks) { 2731 // ignore light sensor while screen is turning off 2732 if (isScreenTurningOffLocked()) { 2733 return; 2734 } 2735 2736 int value = (int)event.values[0]; 2737 long milliseconds = SystemClock.elapsedRealtime(); 2738 if (mDebugLightSensor) { 2739 Slog.d(TAG, "onSensorChanged: light value: " + value); 2740 } 2741 mHandler.removeCallbacks(mAutoBrightnessTask); 2742 if (mLightSensorValue != value) { 2743 if (mLightSensorValue == -1 || 2744 milliseconds < mLastScreenOnTime + mLightSensorWarmupTime) { 2745 // process the value immediately if screen has just turned on 2746 lightSensorChangedLocked(value); 2747 } else { 2748 // delay processing to debounce the sensor 2749 mLightSensorPendingValue = value; 2750 mHandler.postDelayed(mAutoBrightnessTask, LIGHT_SENSOR_DELAY); 2751 } 2752 } else { 2753 mLightSensorPendingValue = -1; 2754 } 2755 } 2756 } 2757 2758 public void onAccuracyChanged(Sensor sensor, int accuracy) { 2759 // ignore 2760 } 2761 }; (2741) will remove the unfinished task (previous event), then in this event(2750), it will call postDelayed() to launch a new task (but it will be delayed accroding to LIGHT_SENSOR_DELAY) my question is, event listener uses "NORMAL DELAY(200ms)", but postDelayed uses LIGHT_SENSOR_DELAY(2000ms) the task will not be executed forever (always be canceled by next event) Am I misunderstanding something? -- unsubscribe: android-porting+unsubscr...@googlegroups.com website: http://groups.google.com/group/android-porting