MediaPlayerService: avoid invalid static cast

Bug: 30204103
Change-Id: Ie0dd3568a375f1e9fed8615ad3d85184bcc99028
(cherry picked from commit ee0a0e39acdcf8f97e0d6945c31ff36a06a36e9d)

status_t MediaPlayerService::Client::setVideoSurfaceTexture(
 const sp<IGraphicBufferProducer>& bufferProducer)
{
    ALOGV("[%d] setVideoSurfaceTexture(%p)", mConnId, bufferProducer.get());
    sp<MediaPlayerBase> p = getPlayer();
 if (p == 0) return UNKNOWN_ERROR;

    sp<IBinder> binder(IInterface::asBinder(bufferProducer));
 if (mConnectedWindowBinder == binder) {
 return OK;
 }

    sp<ANativeWindow> anw;
 if (bufferProducer != NULL) {
        anw = new Surface(bufferProducer, true /* controlledByApp */);
 status_t err = native_window_api_connect(anw.get(),
                NATIVE_WINDOW_API_MEDIA);

 if (err != OK) {
            ALOGE("setVideoSurfaceTexture failed: %d", err);
            reset();

            disconnectNativeWindow();

 return err;
 }
 }

 status_t err = p->setVideoSurfaceTexture(bufferProducer);

    disconnectNativeWindow();

    mConnectedWindow = anw;

 if (err == OK) {
        mConnectedWindowBinder = binder;
 } else {
        disconnectNativeWindow();
 }

 return err;
}

status_t MediaPlayerService::Client::setVideoSurfaceTexture(
 const sp<IGraphicBufferProducer>& bufferProducer)
{
    ALOGV("[%d] setVideoSurfaceTexture(%p)", mConnId, bufferProducer.get());
    sp<MediaPlayerBase> p = getPlayer();
 if (p == 0) return UNKNOWN_ERROR;

    sp<IBinder> binder(IInterface::asBinder(bufferProducer));
 if (mConnectedWindowBinder == binder) {
 return OK;
 }

    sp<ANativeWindow> anw;
 if (bufferProducer != NULL) {
        anw = new Surface(bufferProducer, true /* controlledByApp */);
 status_t err = native_window_api_connect(anw.get(),
                NATIVE_WINDOW_API_MEDIA);

 if (err != OK) {
            ALOGE("setVideoSurfaceTexture failed: %d", err);
            reset();

            disconnectNativeWindow();

 return err;
 }
 }

 status_t err = p->setVideoSurfaceTexture(bufferProducer);

    disconnectNativeWindow();

    mConnectedWindow = anw;

 if (err == OK) {
        mConnectedWindowBinder = binder;
 } else {
        disconnectNativeWindow();
 }

 return err;
}
