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*)®ion); 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; }
static void android_view_InputChannel_nativeDup(JNIEnv* env, jobject obj, jobject otherObj) { NativeInputChannel* nativeInputChannel = android_view_InputChannel_getNativeInputChannel(env, obj); if (nativeInputChannel) { android_view_InputChannel_setNativeInputChannel(env, otherObj, new NativeInputChannel(nativeInputChannel->getInputChannel()->dup())); } }
static jstring android_view_InputChannel_nativeGetName(JNIEnv* env, jobject obj) { NativeInputChannel* nativeInputChannel = android_view_InputChannel_getNativeInputChannel(env, obj); if (! nativeInputChannel) { return NULL; } jstring name = env->NewStringUTF(nativeInputChannel->getInputChannel()->getName().string()); return name; }
static void android_view_InputChannel_nativeDispose(JNIEnv* env, jobject obj, jboolean finalized) { NativeInputChannel* nativeInputChannel = android_view_InputChannel_getNativeInputChannel(env, obj); if (nativeInputChannel) { if (finalized) { ALOGW("Input channel object '%s' was finalized without being disposed!", nativeInputChannel->getInputChannel()->getName().string()); } nativeInputChannel->invokeAndRemoveDisposeCallback(env, obj); android_view_InputChannel_setNativeInputChannel(env, obj, NULL); delete nativeInputChannel; } }
static void android_view_InputChannel_nativeWriteToParcel(JNIEnv* env, jobject obj, jobject parcelObj) { Parcel* parcel = parcelForJavaObject(env, parcelObj); if (parcel) { NativeInputChannel* nativeInputChannel = android_view_InputChannel_getNativeInputChannel(env, obj); if (nativeInputChannel) { sp<InputChannel> inputChannel = nativeInputChannel->getInputChannel(); parcel->writeInt32(1); parcel->writeString8(String8(inputChannel->getName().c_str())); parcel->writeDupFileDescriptor(inputChannel->getFd()); } else { parcel->writeInt32(0); } } }
sp<InputChannel> android_view_InputChannel_getInputChannel(JNIEnv* env, jobject inputChannelObj) { NativeInputChannel* nativeInputChannel = android_view_InputChannel_getNativeInputChannel(env, inputChannelObj); return nativeInputChannel != NULL ? nativeInputChannel->getInputChannel() : NULL; }
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*)®ionHandle); 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; }