bool NativeInputApplicationHandle::updateInfo() {
    JNIEnv* env = AndroidRuntime::getJNIEnv();
    jobject obj = env->NewLocalRef(mObjWeak);
    if (!obj) {
        releaseInfo();
        return false;
    }

    if (!mInfo) {
        mInfo = new InputApplicationInfo();
    }

    jstring nameObj = jstring(env->GetObjectField(obj,
            gInputApplicationHandleClassInfo.name));
    if (nameObj) {
        const char* nameStr = env->GetStringUTFChars(nameObj, NULL);
        mInfo->name.setTo(nameStr);
        env->ReleaseStringUTFChars(nameObj, nameStr);
        env->DeleteLocalRef(nameObj);
    } else {
        mInfo->name.setTo("<null>");
    }

    mInfo->dispatchingTimeout = env->GetLongField(obj,
            gInputApplicationHandleClassInfo.dispatchingTimeoutNanos);

    env->DeleteLocalRef(obj);
    return true;
}
bool NativeInputWindowHandle::updateInfo()
{
    if (!mObject) {
        releaseInfo();
        return false;
    }

    if (!mInfo) {
        mInfo = new android::InputWindowInfo();
    }

    IInputChannel* inputChannelObj = mObject->mInputChannel;
    if (inputChannelObj) {
        NativeInputChannel* nativeInputChannel;
        inputChannelObj->GetNativeInputChannel((Handle32*)&nativeInputChannel);
        mInfo->inputChannel = nativeInputChannel != NULL ? nativeInputChannel->getInputChannel() : NULL;
    }
    else {
        mInfo->inputChannel.clear();
    }

    if (!mObject->mName.IsNull()) {
        mInfo->name.setTo((const char*)mObject->mName);
    }
    else {
        mInfo->name.setTo("<null>");
    }

    mInfo->layoutParamsFlags = mObject->mLayoutParamsFlags;
    mInfo->layoutParamsType = mObject->mLayoutParamsType;
    mInfo->dispatchingTimeout = mObject->mDispatchingTimeoutNanos;
    mInfo->frameLeft = mObject->mFrameLeft;
    mInfo->frameTop = mObject->mFrameTop;
    mInfo->frameRight = mObject->mFrameRight;
    mInfo->frameBottom = mObject->mFrameBottom;
    mInfo->scaleFactor = mObject->mScaleFactor;

    IRegion* regionObj = mObject->mTouchableRegion;
    if (regionObj) {
        SkRegion* region;
        regionObj->GetNativeRegion((Handle32*)&region);
        mInfo->touchableRegion.set(*region);
    }
    else {
        mInfo->touchableRegion.setEmpty();
    }

    mInfo->visible = mObject->mVisible;
    mInfo->canReceiveKeys = mObject->mCanReceiveKeys;
    mInfo->hasFocus = mObject->mHasFocus;
    mInfo->hasWallpaper = mObject->mHasWallpaper;
    mInfo->paused = mObject->mPaused;
    mInfo->layer = mObject->mLayer;
    mInfo->ownerPid = mObject->mOwnerPid;
    mInfo->ownerUid = mObject->mOwnerUid;
    mInfo->inputFeatures = mObject->mInputFeatures;
    mInfo->displayId = mObject->mDisplayId;

    return true;
}
bool NativeInputWindowHandle::updateInfo() {
    JNIEnv* env = AndroidRuntime::getJNIEnv();
    jobject obj = env->NewLocalRef(mObjWeak);
    if (!obj) {
        releaseInfo();
        return false;
    }

    if (!mInfo) {
        mInfo = new InputWindowInfo();
    }

    jobject inputChannelObj = env->GetObjectField(obj,
            gInputWindowHandleClassInfo.inputChannel);
    if (inputChannelObj) {
        mInfo->inputChannel = android_view_InputChannel_getInputChannel(env, inputChannelObj);
        env->DeleteLocalRef(inputChannelObj);
    } else {
        mInfo->inputChannel.clear();
    }

    jstring nameObj = jstring(env->GetObjectField(obj,
            gInputWindowHandleClassInfo.name));
    if (nameObj) {
        const char* nameStr = env->GetStringUTFChars(nameObj, NULL);
        mInfo->name.setTo(nameStr);
        env->ReleaseStringUTFChars(nameObj, nameStr);
        env->DeleteLocalRef(nameObj);
    } else {
        mInfo->name.setTo("<null>");
    }

    mInfo->layoutParamsFlags = env->GetIntField(obj,
            gInputWindowHandleClassInfo.layoutParamsFlags);
    mInfo->layoutParamsPrivateFlags = env->GetIntField(obj,
            gInputWindowHandleClassInfo.layoutParamsPrivateFlags);
    mInfo->layoutParamsType = env->GetIntField(obj,
            gInputWindowHandleClassInfo.layoutParamsType);
    mInfo->dispatchingTimeout = env->GetLongField(obj,
            gInputWindowHandleClassInfo.dispatchingTimeoutNanos);
    mInfo->frameLeft = env->GetIntField(obj,
            gInputWindowHandleClassInfo.frameLeft);
    mInfo->frameTop = env->GetIntField(obj,
            gInputWindowHandleClassInfo.frameTop);
    mInfo->frameRight = env->GetIntField(obj,
            gInputWindowHandleClassInfo.frameRight);
    mInfo->frameBottom = env->GetIntField(obj,
            gInputWindowHandleClassInfo.frameBottom);
    mInfo->scaleFactor = env->GetFloatField(obj,
            gInputWindowHandleClassInfo.scaleFactor);

    jobject regionObj = env->GetObjectField(obj,
            gInputWindowHandleClassInfo.touchableRegion);
    if (regionObj) {
        SkRegion* region = android_graphics_Region_getSkRegion(env, regionObj);
        mInfo->touchableRegion.set(*region);
        env->DeleteLocalRef(regionObj);
    } else {
        mInfo->touchableRegion.setEmpty();
    }

    mInfo->visible = env->GetBooleanField(obj,
            gInputWindowHandleClassInfo.visible);
    mInfo->canReceiveKeys = env->GetBooleanField(obj,
            gInputWindowHandleClassInfo.canReceiveKeys);
    mInfo->hasFocus = env->GetBooleanField(obj,
            gInputWindowHandleClassInfo.hasFocus);
    mInfo->hasWallpaper = env->GetBooleanField(obj,
            gInputWindowHandleClassInfo.hasWallpaper);
    mInfo->paused = env->GetBooleanField(obj,
            gInputWindowHandleClassInfo.paused);
    mInfo->layer = env->GetIntField(obj,
            gInputWindowHandleClassInfo.layer);
    mInfo->ownerPid = env->GetIntField(obj,
            gInputWindowHandleClassInfo.ownerPid);
    mInfo->ownerUid = env->GetIntField(obj,
            gInputWindowHandleClassInfo.ownerUid);
    mInfo->inputFeatures = env->GetIntField(obj,
            gInputWindowHandleClassInfo.inputFeatures);
    mInfo->displayId = env->GetIntField(obj,
            gInputWindowHandleClassInfo.displayId);

    env->DeleteLocalRef(obj);
    return true;
}
bool NativeInputWindowHandle::updateInfo()
{
    AutoPtr<IInputWindowHandle> obj;
    mObjWeak->Resolve(EIID_IInputWindowHandle, (IInterface**)&obj);
    if (!obj) {
        releaseInfo();
        return false;
    }

    if (!mInfo) {
        mInfo = new android::InputWindowInfo();
    }
    else {
        mInfo->touchableRegion.clear();
    }

    Elastos::Droid::Server::Input::InputWindowHandle* handle =
            (Elastos::Droid::Server::Input::InputWindowHandle*)obj.Get();
    AutoPtr<IInputChannel> inputChannelObj = handle->mInputChannel;
    if (inputChannelObj) {
        Handle64 ptr;
        inputChannelObj->GetNativeInputChannel(&ptr);
        NativeInputChannel* nativeInputChannel = reinterpret_cast<NativeInputChannel*>(ptr);
        mInfo->inputChannel = nativeInputChannel != NULL ? nativeInputChannel->getInputChannel() : NULL;
    }
    else {
        mInfo->inputChannel.clear();
    }

    if (!handle->mName.IsNull()) {
        mInfo->name.setTo(handle->mName.string());
    }
    else {
        mInfo->name.setTo("<null>");
    }

    mInfo->layoutParamsFlags = handle->mLayoutParamsFlags;
    mInfo->layoutParamsType = handle->mLayoutParamsType;
    mInfo->dispatchingTimeout = handle->mDispatchingTimeoutNanos;
    mInfo->frameLeft = handle->mFrameLeft;
    mInfo->frameTop = handle->mFrameTop;
    mInfo->frameRight = handle->mFrameRight;
    mInfo->frameBottom = handle->mFrameBottom;
    mInfo->scaleFactor = handle->mScaleFactor;

    AutoPtr<IRegion> regionObj = handle->mTouchableRegion;
    if (regionObj) {
        Int64 regionHandle;
        regionObj->GetNativeRegion((Handle64*)&regionHandle);
        SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle);
        SkASSERT(region != NULL);

        for (SkRegion::Iterator it(*region); !it.done(); it.next()) {
            const SkIRect& rect = it.rect();
            mInfo->addTouchableRegion(android::Rect(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom));
        }
    }

    mInfo->visible = handle->mVisible;
    mInfo->canReceiveKeys = handle->mCanReceiveKeys;
    mInfo->hasFocus = handle->mHasFocus;
    mInfo->hasWallpaper = handle->mHasWallpaper;
    mInfo->paused = handle->mPaused;
    mInfo->layer = handle->mLayer;
    mInfo->ownerPid = handle->mOwnerPid;
    mInfo->ownerUid = handle->mOwnerUid;
    mInfo->inputFeatures = handle->mInputFeatures;
    mInfo->displayId = handle->mDisplayId;

    return true;
}