コード例 #1
0
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;
}
コード例 #2
0
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()));
    }
}
コード例 #3
0
void android_view_InputChannel_setDisposeCallback(JNIEnv* env, jobject inputChannelObj,
        InputChannelObjDisposeCallback callback, void* data) {
    NativeInputChannel* nativeInputChannel =
            android_view_InputChannel_getNativeInputChannel(env, inputChannelObj);
    if (nativeInputChannel == NULL) {
        ALOGW("Cannot set dispose callback because input channel object has not been initialized.");
    } else {
        nativeInputChannel->setDisposeCallback(callback, data);
    }
}
コード例 #4
0
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;
}
コード例 #5
0
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;
    }
}
コード例 #6
0
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);
        }
    }
}
コード例 #7
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;
}
コード例 #8
0
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;
}