從 InputManager.java 看到
/*
* Callbacks from native.
*/
private class Callbacks {
static final String TAG = "InputManager-Callbacks";
private static final boolean DEBUG_VIRTUAL_KEYS = false;
private static final String EXCLUDED_DEVICES_PATH = "etc/excluded-input-devices.xml";
private static final String CALIBRATION_DIR_PATH = "usr/idc/";
@SuppressWarnings("unused")
public void notifyConfigurationChanged(long whenNanos) {
mWindowManagerService.sendNewConfiguration();
}
....
@SuppressWarnings("unused")
public int interceptKeyBeforeQueueing(long whenNanos, int action, int flags,
int keyCode, int scanCode, int policyFlags, boolean isScreenOn) {
return mWindowManagerService.mInputMonitor.interceptKeyBeforeQueueing(
whenNanos, action, flags, keyCode, scanCode, policyFlags, isScreenOn);
}
然後 class InputManager 就有 private final Callbacks mCallbacks;
和 class Init 時.. nativeInit(mCallbacks);
nativeInit 實際上是 implement 在 C code : ./base/services/jni/com_android_server_InputManager.cpp:1300: { "nativeInit", "(Lcom/android/server/InputManager$Callbacks;)V",
.....
static void android_server_InputManager_nativeInit(JNIEnv* env, jclass clazz,
jobject callbacks) {
if (gNativeInputManager == NULL) {
gNativeInputManager = new NativeInputManager(callbacks);
} else {
LOGE("Input manager already initialized.");
jniThrowRuntimeException(env, "Input manager already initialized.");
}
}
這樣切開,看 com_android_server_InputManager.cpp 的 code .. 裡面都是 call InputManager.java 的 callback function。
--- 為什麼不都用 java 作算了呢?
com_android_server_InputManager.cpp 的 register_android_server_InputManager(JNIEnv*) 是由 onload.cpp 的 JNI_OnLoad( ) 呼叫的。
這個 (/frameworks/base/services/jni) Android.mk 的 target module name 是 libandroid_servers。
是由
./frameworks/base/services/java/com/android/server/SystemServer.java:634: System.loadLibrary("android_servers");
load 進來的。也就是 service.
亂入一下,設定系統時間是...
SystemClock.setCurrentTimeMillis(EARLIEST_SUPPORTED_TIME);
沒有留言:
張貼留言