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

Commit 393fc7f0 authored by Jaesung Chung's avatar Jaesung Chung Committed by Android Git Automerger
Browse files

am f5edb20a: Merge "TIF: Add DVB device handling to TvInputManagerService" into mnc-dev

* commit 'f5edb20a':
  TIF: Add DVB device handling to TvInputManagerService
parents cb05fff4 f5edb20a
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1107,6 +1107,11 @@
    <permission android:name="android.permission.CAPTURE_TV_INPUT"
        android:protectionLevel="signatureOrSystem" />

    <!-- @hide Allows TvInputService to access DVB device.
   <p>Not for use by third-party applications. -->
    <permission android:name="android.permission.DVB_DEVICE"
        android:protectionLevel="signatureOrSystem" />

    <!-- @hide Allows enabling/disabling OEM unlock
   <p>Not for use by third-party applications. -->
    <permission android:name="android.permission.OEM_UNLOCK_STATE"
+20 −0
Original line number Diff line number Diff line
/*
 *
 * Copyright 2015, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.media.tv;

parcelable DvbDeviceInfo;
 No newline at end of file
+97 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.media.tv;

import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import android.media.tv.TvInputManager;
import android.util.Log;

import java.lang.IllegalArgumentException;

/**
 * Simple container for information about DVB device.
 * Not for third-party developers.
 *
 * @hide
 */
public final class DvbDeviceInfo implements Parcelable {
    static final String TAG = "DvbDeviceInfo";

    public static final Parcelable.Creator<DvbDeviceInfo> CREATOR =
            new Parcelable.Creator<DvbDeviceInfo>() {
                @Override
                public DvbDeviceInfo createFromParcel(Parcel source) {
                    try {
                        return new DvbDeviceInfo(source);
                    } catch (Exception e) {
                        Log.e(TAG, "Exception creating DvbDeviceInfo from parcel", e);
                        return null;
                    }
                }

                @Override
                public DvbDeviceInfo[] newArray(int size) {
                    return new DvbDeviceInfo[size];
                }
            };

    private final int mAdapterId;
    private final int mDeviceId;

    private DvbDeviceInfo(Parcel source) {
        mAdapterId = source.readInt();
        mDeviceId = source.readInt();
    }

    /**
     * Constructs a new {@link DvbDeviceInfo} with the given adapter ID and device ID.
     */
    public DvbDeviceInfo(int adapterId, int deviceId) {
        mAdapterId = adapterId;
        mDeviceId = deviceId;
    }

    /**
     * Returns the adapter ID of DVB device, in terms of enumerating the DVB device adapters
     * installed in the system. The adapter ID counts from zero.
     */
    public int getAdapterId() {
        return mAdapterId;
    }

    /**
     * Returns the device ID of DVB device, in terms of enumerating the DVB devices attached to
     * the same device adapter. The device ID counts from zero.
     */
    public int getDeviceId() {
        return mDeviceId;
    }

    // Parcelable
    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(mAdapterId);
        dest.writeInt(mDeviceId);
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.media.tv;

import android.content.ComponentName;
import android.graphics.Rect;
import android.media.tv.DvbDeviceInfo;
import android.media.tv.ITvInputClient;
import android.media.tv.ITvInputHardware;
import android.media.tv.ITvInputHardwareCallback;
@@ -29,6 +30,7 @@ import android.media.tv.TvStreamConfig;
import android.media.tv.TvTrackInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.view.Surface;

/**
@@ -91,4 +93,8 @@ interface ITvInputManager {
    boolean captureFrame(in String inputId, in Surface surface, in TvStreamConfig config,
            int userId);
    boolean isSingleSessionActive(int userId);

    // For DVB device binding
    List<DvbDeviceInfo> getDvbDeviceList();
    ParcelFileDescriptor openDvbDevice(in DvbDeviceInfo info, int device);
}
+59 −0
Original line number Diff line number Diff line
@@ -21,12 +21,14 @@ import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.graphics.Rect;
import android.media.MediaPlayer;
import android.media.tv.DvbDeviceInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.util.ArrayMap;
import android.util.Log;
@@ -42,6 +44,7 @@ import android.view.View;

import com.android.internal.util.Preconditions;

import java.lang.IllegalArgumentException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
@@ -55,6 +58,25 @@ import java.util.Map;
public final class TvInputManager {
    private static final String TAG = "TvInputManager";

    static final int DVB_DEVICE_START = 0;
    static final int DVB_DEVICE_END = 2;

    /**
     * A demux device of DVB API for controlling the filters of DVB hardware/software.
     * @hide
     */
    public static final int DVB_DEVICE_DEMUX = DVB_DEVICE_START;
     /**
     * A DVR device of DVB API for reading transport streams.
     * @hide
     */
    public static final int DVB_DEVICE_DVR = 1;
    /**
     * A frontend device of DVB API for controlling the tuner and DVB demodulator hardware.
     * @hide
     */
    public static final int DVB_DEVICE_FRONTEND = DVB_DEVICE_END;

    static final int VIDEO_UNAVAILABLE_REASON_START = 0;
    static final int VIDEO_UNAVAILABLE_REASON_END = 4;

@@ -1257,6 +1279,43 @@ public final class TvInputManager {
        }
    }

    /**
     * Returns the list of currently available DVB devices on the system.
     *
     * @return the list of {@link DvbDeviceInfo} objects representing available DVB devices.
     * @hide
     */
    public List<DvbDeviceInfo> getDvbDeviceList() {
        try {
            return mService.getDvbDeviceList();
        } catch (RemoteException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * Returns a {@link ParcelFileDescriptor} of a specified DVB device for a given
     * {@link DvbDeviceInfo}
     *
     * @param info A {@link DvbDeviceInfo} to open a DVB device.
     * @param device A DVB device. The DVB device can be {@link DVB_DEVICE_DEMUX},
     *            {@link DVB_DEVICE_DVR} or {@link DVB_DEVICE_FRONTEND}.
     * @return a {@link ParcelFileDescriptor} of a specified DVB device for a given
     *            {@link DvbDeviceInfo}, or {@code null} if the given {@link DvbDeviceInfo} was
     *            invalid or the specified DVB device was busy with a previous request.
     * @hide
     */
    public ParcelFileDescriptor openDvbDevice(DvbDeviceInfo info, int device) {
        try {
            if (DVB_DEVICE_START > device || DVB_DEVICE_END < device) {
                throw new IllegalArgumentException("Invalid DVB device: " + device);
            }
            return mService.openDvbDevice(info, device);
        } catch (RemoteException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * The Session provides the per-session functionality of TV inputs.
     * @hide
Loading