OSDN Git Service

InputReader: read the pointercal from TSCalibration2
authorChih-Wei Huang <cwhuang@linux.org.tw>
Sat, 17 May 2014 18:20:32 +0000 (02:20 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Tue, 22 Dec 2015 04:13:52 +0000 (12:13 +0800)
Watch the pointercal and reload it on changed.

services/core/java/com/android/server/input/InputManagerService.java

index 15dcd44..835e634 100644 (file)
@@ -57,6 +57,7 @@ import android.hardware.input.TouchCalibration;
 import android.os.Binder;
 import android.os.Bundle;
 import android.os.Environment;
+import android.os.FileObserver;
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.Looper;
@@ -258,6 +259,19 @@ public class InputManagerService extends IInputManager.Stub
     /** Whether to use the dev/input/event or uevent subsystem for the audio jack. */
     final boolean mUseDevInputEventForAudioJack;
 
+    private class TscalObserver extends FileObserver {
+        public TscalObserver() {
+            super("/data/misc/tscal/pointercal", CLOSE_WRITE);
+        }
+
+        @Override
+        public void onEvent(int event, String path) {
+            Slog.i(TAG, "detect pointercal changed");
+            reloadDeviceAliases();
+        }
+    }
+    private final TscalObserver mTscalObserver = new TscalObserver();
+
     public InputManagerService(Context context) {
         this.mContext = context;
         this.mHandler = new InputManagerHandler(DisplayThread.get().getLooper());
@@ -269,6 +283,7 @@ public class InputManagerService extends IInputManager.Stub
         mPtr = nativeInit(this, mContext, mHandler.getLooper().getQueue());
 
         LocalServices.addService(InputManagerInternal.class, new LocalService());
+        mTscalObserver.startWatching();
     }
 
     public void setWindowManagerCallbacks(WindowManagerCallbacks callbacks) {