1

My application uses proximity sensor with following code:

public class WakeLockHelper {
  static final String WAKE_LOCK_STR = "My.WakeLockHelper";
  static final int PROXIMITY_SCREEN_OFF_WAKE_LOCK = 32;

  private static WakeLock mScreenLock = null;

  private static WakeLock doWakeLock( final WakeLock inputWl, int flags, boolean lock ) {
    try {
      WakeLock wl = inputWl;
      if ( lock ) {
        if ( wl == null ) {
          PowerManager pm = (PowerManager) SJPhone.getContext().getSystemService( Context.POWER_SERVICE );
          wl = pm.newWakeLock( flags, WAKE_LOCK_STR );
          wl.setReferenceCounted( false );
          wl.acquire();
        }        
      }
      else {
        if ( wl != null ) {
          wl.release();
          if ( !wl.isHeld() ) {
            wl = null;
          }
        }
      }
      return wl;
    }
    catch ( Exception e ) {
      Log.e( e );
    }
    return null;
  }

  public static synchronized void screenLock( boolean lock ) {
    mScreenLock = doWakeLock( mScreenLock, PROXIMITY_SCREEN_OFF_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, lock );
  }
}

Everything works fine, but only on one device, Lenovo Tablet K1 I receive a lot of errors in logcat like this:

04-17 15:11:34.450 E/Sensors (  162): proximity file handle not opened
04-17 15:11:34.450 E/Sensors (  162): proximity file handle not opened

Does anyone know what is this and how can it be avoided?

Andrey Starodubtsev
  • 5,139
  • 3
  • 32
  • 46

2 Answers2

2

To remove this annoying log - uncheck the Auto check box in the screen bright in settings.

lironhel
  • 141
  • 1
  • 5
1

Just a quick check to confirm. Is the "LOGTAG" of your application "Sensors"?
If not, then the log in question is from the sensor-HAL.

04-17 15:11:34.450 E/Sensors (  162): proximity file handle not opened

The above log seems to be a LOGE() from the sensor-HAL,
(which usually developers tag with the "Sensors" LOGTAG.)

As long as you are getting proper proximity events, the above log is safe to ignore.
The developer most likely forgot to clean out debug logs from the sensor-HAL.

TheCodeArtist
  • 21,479
  • 4
  • 69
  • 130
  • 1
    Yes, 'Sensors' is not log tag of my application, these messages are produced by some 3-rd party component on device. It's just suspicious when there's HUGE amount ( about 10^4 for 24h stress test ) of such messages. I just hoped that may be any of those forgetful developers will read this post =) – Andrey Starodubtsev Jul 31 '12 at 12:16