Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit da0e4af7 authored by Hongguang Chen's avatar Hongguang Chen Committed by Automerger Merge Worker
Browse files

Merge "[TIAF] Fix FD leak in AdBuffer" into udc-dev am: c246ee42

parents 2f35dc5f c246ee42
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.os.SharedMemory;

import java.io.IOException;

/**
 * Buffer for advertisement data.
 */
@@ -57,6 +59,16 @@ public final class AdBuffer implements Parcelable {
        this.mFlags = flags;
    }

    /** @hide **/
    public static AdBuffer dupAdBuffer(AdBuffer buffer) throws IOException {
        if (buffer == null) {
            return null;
        }
        return new AdBuffer(buffer.mId, buffer.mMimeType,
                SharedMemory.fromFileDescriptor(buffer.mBuffer.getFdDup()), buffer.mOffset,
                buffer.mLength, buffer.mPresentationTimeUs, buffer.mFlags);
    }

    /**
     * Gets corresponding AD request ID.
     *
+16 −0
Original line number Diff line number Diff line
@@ -72,6 +72,22 @@ public final class AdRequest implements Parcelable {
    private final Bundle mMetadata;
    private final Uri mUri;

    /**
     * The key for video metadata.
     *
     * @see #getMetadata()
     * @hide
     */
    public static final String KEY_VIDEO_METADATA = "key_video_metadata";

    /**
     * The key for audio metadata.
     *
     * @see #getMetadata()
     * @hide
     */
    public static final String KEY_AUDIO_METADATA = "key_audio_metadata";

    public AdRequest(int id, @RequestType int requestType,
            @Nullable ParcelFileDescriptor fileDescriptor, long startTime, long stopTime,
            long echoInterval, @Nullable String mediaFileType, @NonNull Bundle metadata) {
+4 −0
Original line number Diff line number Diff line
@@ -3737,6 +3737,10 @@ public final class TvInputManager {
                mService.notifyAdBufferReady(mToken, buffer, mUserId);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            } finally {
                if (buffer != null) {
                    buffer.getSharedMemory().close();
                }
            }
        }

+4 −0
Original line number Diff line number Diff line
@@ -1608,6 +1608,10 @@ public final class TvInteractiveAppManager {
                mService.notifyAdBufferConsumed(mToken, buffer, mUserId);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            } finally {
                if (buffer != null) {
                    buffer.getSharedMemory().close();
                }
            }
        }

+3 −2
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ import android.widget.FrameLayout;

import com.android.internal.os.SomeArgs;

import java.io.IOException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
@@ -1973,9 +1974,9 @@ public abstract class TvInteractiveAppService extends Service {
                                    "notifyAdBufferReady(buffer=" + buffer + ")");
                        }
                        if (mSessionCallback != null) {
                            mSessionCallback.onAdBufferReady(buffer);
                            mSessionCallback.onAdBufferReady(AdBuffer.dupAdBuffer(buffer));
                        }
                    } catch (RemoteException e) {
                    } catch (RemoteException | IOException e) {
                        Log.w(TAG, "error in notifyAdBuffer", e);
                    }
                }
Loading