frameworks/base
修订版 | e789da8eb2ac19413e735488bb8e48502beffe59 (tree) |
---|---|
时间 | 2014-08-27 19:19:17 |
作者 | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
InputReader: read the pointercal from TSCalibration2
Watch the pointercal and reload it on changed.
@@ -2757,6 +2757,19 @@ void TouchInputMapper::configure(nsecs_t when, | ||
2757 | 2757 | configureSurface(when, &resetNeeded); |
2758 | 2758 | } |
2759 | 2759 | |
2760 | + if (!changes || (changes & InputReaderConfiguration::CHANGE_DEVICE_ALIAS)) { | |
2761 | + // Get 5-point calibration parameters | |
2762 | + int *p = mCalibration.fiveCal; | |
2763 | + p[6] = 0; | |
2764 | + if (FILE *file = fopen("/data/misc/tscal/pointercal", "r")) { | |
2765 | + if (fscanf(file, "%d %d %d %d %d %d %d", &p[0], &p[1], &p[2], &p[3], &p[4], &p[5], &p[6]) == 7) { | |
2766 | + p[0] *= mXScale, p[1] *= mYScale, p[3] *= mXScale, p[4] *= mYScale; | |
2767 | + ALOGD("pointercal loaded ok"); | |
2768 | + } | |
2769 | + fclose(file); | |
2770 | + } | |
2771 | + } | |
2772 | + | |
2760 | 2773 | if (changes && resetNeeded) { |
2761 | 2774 | // Send reset, unless this is the first time the device has been configured, |
2762 | 2775 | // in which case the reader will call reset itself after all mappers are ready. |
@@ -3479,16 +3492,6 @@ void TouchInputMapper::parseCalibration() { | ||
3479 | 3492 | coverageCalibrationString.string()); |
3480 | 3493 | } |
3481 | 3494 | } |
3482 | - | |
3483 | - // Get 5-point calibration parameters | |
3484 | - FILE *file = fopen("/data/system/tslib/pointercal", "r"); | |
3485 | - int *p = out.fiveCal; | |
3486 | - if (file) { | |
3487 | - fscanf(file, "%d %d %d %d %d %d %d", &p[0], &p[1], &p[2], &p[3], &p[4], &p[5], &p[6]); | |
3488 | - fclose(file); | |
3489 | - } else { | |
3490 | - p[6] = 0; | |
3491 | - } | |
3492 | 3495 | } |
3493 | 3496 | |
3494 | 3497 | void TouchInputMapper::resolveCalibration() { |
@@ -51,6 +51,7 @@ import android.hardware.input.KeyboardLayout; | ||
51 | 51 | import android.os.Binder; |
52 | 52 | import android.os.Bundle; |
53 | 53 | import android.os.Environment; |
54 | +import android.os.FileObserver; | |
54 | 55 | import android.os.Handler; |
55 | 56 | import android.os.IBinder; |
56 | 57 | import android.os.Looper; |
@@ -241,6 +242,19 @@ public class InputManagerService extends IInputManager.Stub | ||
241 | 242 | /** Whether to use the dev/input/event or uevent subsystem for the audio jack. */ |
242 | 243 | final boolean mUseDevInputEventForAudioJack; |
243 | 244 | |
245 | + private class TscalObserver extends FileObserver { | |
246 | + public TscalObserver() { | |
247 | + super("/data/misc/tscal/pointercal", CLOSE_WRITE); | |
248 | + } | |
249 | + | |
250 | + @Override | |
251 | + public void onEvent(int event, String path) { | |
252 | + Slog.i(TAG, "detect pointercal changed"); | |
253 | + reloadDeviceAliases(); | |
254 | + } | |
255 | + } | |
256 | + private final TscalObserver mTscalObserver = new TscalObserver(); | |
257 | + | |
244 | 258 | public InputManagerService(Context context, Handler handler) { |
245 | 259 | this.mContext = context; |
246 | 260 | this.mHandler = new InputManagerHandler(handler.getLooper()); |
@@ -250,6 +264,7 @@ public class InputManagerService extends IInputManager.Stub | ||
250 | 264 | Slog.i(TAG, "Initializing input manager, mUseDevInputEventForAudioJack=" |
251 | 265 | + mUseDevInputEventForAudioJack); |
252 | 266 | mPtr = nativeInit(this, mContext, mHandler.getLooper().getQueue()); |
267 | + mTscalObserver.startWatching(); | |
253 | 268 | } |
254 | 269 | |
255 | 270 | public void setWindowManagerCallbacks(WindowManagerCallbacks callbacks) { |