Fields Summary |
---|
private static final boolean | DEBUG |
private static final String | TAG |
public static final int | TYPE_TUNERTV input type: the TV input service is a tuner which provides channels. |
public static final int | TYPE_OTHERTV input type: a generic hardware TV input type. |
public static final int | TYPE_COMPOSITETV input type: the TV input service represents a composite port. |
public static final int | TYPE_SVIDEOTV input type: the TV input service represents a SVIDEO port. |
public static final int | TYPE_SCARTTV input type: the TV input service represents a SCART port. |
public static final int | TYPE_COMPONENTTV input type: the TV input service represents a component port. |
public static final int | TYPE_VGATV input type: the TV input service represents a VGA port. |
public static final int | TYPE_DVITV input type: the TV input service represents a DVI port. |
public static final int | TYPE_HDMITV input type: the TV input service is HDMI. (e.g. HDMI 1) |
public static final int | TYPE_DISPLAY_PORTTV input type: the TV input service represents a display port. |
public static final String | EXTRA_INPUT_IDThe ID of the TV input to provide to the setup activity and settings activity. |
private static android.util.SparseIntArray | sHardwareTypeToTvInputType |
private static final String | XML_START_TAG_NAME |
private static final String | DELIMITER_INFO_IN_ID |
private static final String | PREFIX_HDMI_DEVICE |
private static final String | PREFIX_HARDWARE_DEVICE |
private static final int | LENGTH_HDMI_PHYSICAL_ADDRESS |
private static final int | LENGTH_HDMI_DEVICE_ID |
private final android.content.pm.ResolveInfo | mService |
private final String | mId |
private final String | mParentId |
private String | mSetupActivity |
private String | mSettingsActivity |
private int | mType |
private android.hardware.hdmi.HdmiDeviceInfo | mHdmiDeviceInfo |
private String | mLabel |
private android.net.Uri | mIconUri |
private boolean | mIsConnectedToHdmiSwitch |
public static final Parcelable.Creator | CREATOR |
Methods Summary |
---|
public android.content.Intent | createSettingsIntent()Returns an intent to start the settings activity for this TV input.
if (!TextUtils.isEmpty(mSettingsActivity)) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName(mService.serviceInfo.packageName, mSettingsActivity);
intent.putExtra(EXTRA_INPUT_ID, getId());
return intent;
}
return null;
|
public android.content.Intent | createSetupIntent()Returns an intent to start the setup activity for this TV input.
if (!TextUtils.isEmpty(mSetupActivity)) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName(mService.serviceInfo.packageName, mSetupActivity);
intent.putExtra(EXTRA_INPUT_ID, getId());
return intent;
}
return null;
|
public static android.media.tv.TvInputInfo | createTvInputInfo(android.content.Context context, android.content.pm.ResolveInfo service)Create a new instance of the TvInputInfo class,
instantiating it from the given Context and ResolveInfo.
sHardwareTypeToTvInputType.put(TvInputHardwareInfo.TV_INPUT_TYPE_OTHER_HARDWARE,
TYPE_OTHER);
sHardwareTypeToTvInputType.put(TvInputHardwareInfo.TV_INPUT_TYPE_TUNER, TYPE_TUNER);
sHardwareTypeToTvInputType.put(TvInputHardwareInfo.TV_INPUT_TYPE_COMPOSITE, TYPE_COMPOSITE);
sHardwareTypeToTvInputType.put(TvInputHardwareInfo.TV_INPUT_TYPE_SVIDEO, TYPE_SVIDEO);
sHardwareTypeToTvInputType.put(TvInputHardwareInfo.TV_INPUT_TYPE_SCART, TYPE_SCART);
sHardwareTypeToTvInputType.put(TvInputHardwareInfo.TV_INPUT_TYPE_COMPONENT, TYPE_COMPONENT);
sHardwareTypeToTvInputType.put(TvInputHardwareInfo.TV_INPUT_TYPE_VGA, TYPE_VGA);
sHardwareTypeToTvInputType.put(TvInputHardwareInfo.TV_INPUT_TYPE_DVI, TYPE_DVI);
sHardwareTypeToTvInputType.put(TvInputHardwareInfo.TV_INPUT_TYPE_HDMI, TYPE_HDMI);
sHardwareTypeToTvInputType.put(TvInputHardwareInfo.TV_INPUT_TYPE_DISPLAY_PORT,
TYPE_DISPLAY_PORT);
return createTvInputInfo(context, service, generateInputIdForComponentName(
new ComponentName(service.serviceInfo.packageName, service.serviceInfo.name)),
null, TYPE_TUNER, null, null, false);
|
public static android.media.tv.TvInputInfo | createTvInputInfo(android.content.Context context, android.content.pm.ResolveInfo service, android.hardware.hdmi.HdmiDeviceInfo hdmiDeviceInfo, java.lang.String parentId, java.lang.String label, android.net.Uri iconUri)Create a new instance of the TvInputInfo class, instantiating it from the given Context,
ResolveInfo, and HdmiDeviceInfo.
boolean isConnectedToHdmiSwitch = (hdmiDeviceInfo.getPhysicalAddress() & 0x0FFF) != 0;
TvInputInfo input = createTvInputInfo(context, service, generateInputIdForHdmiDevice(
new ComponentName(service.serviceInfo.packageName, service.serviceInfo.name),
hdmiDeviceInfo), parentId, TYPE_HDMI, label, iconUri, isConnectedToHdmiSwitch);
input.mHdmiDeviceInfo = hdmiDeviceInfo;
return input;
|
public static android.media.tv.TvInputInfo | createTvInputInfo(android.content.Context context, android.content.pm.ResolveInfo service, TvInputHardwareInfo hardwareInfo, java.lang.String label, android.net.Uri iconUri)Create a new instance of the TvInputInfo class, instantiating it from the given Context,
ResolveInfo, and TvInputHardwareInfo.
int inputType = sHardwareTypeToTvInputType.get(hardwareInfo.getType(), TYPE_TUNER);
return createTvInputInfo(context, service, generateInputIdForHardware(
new ComponentName(service.serviceInfo.packageName, service.serviceInfo.name),
hardwareInfo), null, inputType, label, iconUri, false);
|
private static android.media.tv.TvInputInfo | createTvInputInfo(android.content.Context context, android.content.pm.ResolveInfo service, java.lang.String id, java.lang.String parentId, int inputType, java.lang.String label, android.net.Uri iconUri, boolean isConnectedToHdmiSwitch)
ServiceInfo si = service.serviceInfo;
PackageManager pm = context.getPackageManager();
XmlResourceParser parser = null;
try {
parser = si.loadXmlMetaData(pm, TvInputService.SERVICE_META_DATA);
if (parser == null) {
throw new XmlPullParserException("No " + TvInputService.SERVICE_META_DATA
+ " meta-data for " + si.name);
}
Resources res = pm.getResourcesForApplication(si.applicationInfo);
AttributeSet attrs = Xml.asAttributeSet(parser);
int type;
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
&& type != XmlPullParser.START_TAG) {
}
String nodeName = parser.getName();
if (!XML_START_TAG_NAME.equals(nodeName)) {
throw new XmlPullParserException(
"Meta-data does not start with tv-input-service tag in " + si.name);
}
TvInputInfo input = new TvInputInfo(service, id, parentId, inputType);
TypedArray sa = res.obtainAttributes(attrs,
com.android.internal.R.styleable.TvInputService);
input.mSetupActivity = sa.getString(
com.android.internal.R.styleable.TvInputService_setupActivity);
if (DEBUG) {
Log.d(TAG, "Setup activity loaded. [" + input.mSetupActivity + "] for " + si.name);
}
if (inputType == TYPE_TUNER && TextUtils.isEmpty(input.mSetupActivity)) {
throw new XmlPullParserException("Setup activity not found in " + si.name);
}
input.mSettingsActivity = sa.getString(
com.android.internal.R.styleable.TvInputService_settingsActivity);
if (DEBUG) {
Log.d(TAG, "Settings activity loaded. [" + input.mSettingsActivity + "] for "
+ si.name);
}
sa.recycle();
input.mLabel = label;
input.mIconUri = iconUri;
input.mIsConnectedToHdmiSwitch = isConnectedToHdmiSwitch;
return input;
} catch (NameNotFoundException e) {
throw new XmlPullParserException("Unable to create context for: " + si.packageName);
} finally {
if (parser != null) {
parser.close();
}
}
|
public int | describeContents()
return 0;
|
public boolean | equals(java.lang.Object o)
if (o == this) {
return true;
}
if (!(o instanceof TvInputInfo)) {
return false;
}
TvInputInfo obj = (TvInputInfo) o;
return mId.equals(obj.mId);
|
private static final java.lang.String | generateInputIdForComponentName(android.content.ComponentName name)Used to generate an input id from a ComponentName.
return name.flattenToShortString();
|
private static final java.lang.String | generateInputIdForHardware(android.content.ComponentName name, TvInputHardwareInfo hardwareInfo)Used to generate an input id from a ComponentName and TvInputHardwareInfo
return name.flattenToShortString() + String.format("%s%s%d",
DELIMITER_INFO_IN_ID, PREFIX_HARDWARE_DEVICE, hardwareInfo.getDeviceId());
|
private static final java.lang.String | generateInputIdForHdmiDevice(android.content.ComponentName name, android.hardware.hdmi.HdmiDeviceInfo deviceInfo)Used to generate an input id from a ComponentName and HdmiDeviceInfo.
// Example of the format : "/HDMI%04X%02X"
String format = String.format("%s%s%%0%sX%%0%sX", DELIMITER_INFO_IN_ID, PREFIX_HDMI_DEVICE,
LENGTH_HDMI_PHYSICAL_ADDRESS, LENGTH_HDMI_DEVICE_ID);
return name.flattenToShortString() + String.format(format,
deviceInfo.getPhysicalAddress(), deviceInfo.getId());
|
public android.content.ComponentName | getComponent()Returns the component of the service that implements this TV input.
return new ComponentName(mService.serviceInfo.packageName, mService.serviceInfo.name);
|
public android.hardware.hdmi.HdmiDeviceInfo | getHdmiDeviceInfo()Returns the HDMI device information of this TV input.
if (mType == TYPE_HDMI) {
return mHdmiDeviceInfo;
}
return null;
|
public java.lang.String | getId()Returns a unique ID for this TV input. The ID is generated from the package and class name
implementing the TV input service.
return mId;
|
public java.lang.String | getParentId()Returns the parent input ID.
A TV input may have a parent input if the TV input is actually a logical representation of
a device behind the hardware port represented by the parent input.
For example, a HDMI CEC logical device, connected to a HDMI port, appears as another TV
input. In this case, the parent input of this logical device is the HDMI port.
Applications may group inputs by parent input ID to provide an easier access to inputs
sharing the same physical port. In the example of HDMI CEC, logical HDMI CEC devices behind
the same HDMI port have the same parent ID, which is the ID representing the port. Thus
applications can group the hardware HDMI port and the logical HDMI CEC devices behind it
together using this method.
return mParentId;
|
public android.content.pm.ServiceInfo | getServiceInfo()Returns the information of the service that implements this TV input.
return mService.serviceInfo;
|
public int | getType()Returns the type of this TV input.
return mType;
|
public int | hashCode()
return mId.hashCode();
|
public boolean | isConnectedToHdmiSwitch()Returns {@code true}, if a CEC device for this TV input is connected to an HDMI switch, i.e.,
the device isn't directly connected to a HDMI port.
return mIsConnectedToHdmiSwitch;
|
public boolean | isHidden(android.content.Context context)Checks if this TV input is marked hidden by the user in the settings.
return TvInputSettings.isHidden(context, mId, UserHandle.myUserId());
|
public boolean | isPassthroughInput()Returns {@code true} if this TV input is pass-though which does not have any real channels in
TvProvider. {@code false} otherwise.
return mType != TYPE_TUNER;
|
public java.lang.CharSequence | loadCustomLabel(android.content.Context context)Loads the custom label set by user in settings.
return TvInputSettings.getCustomLabel(context, mId, UserHandle.myUserId());
|
public android.graphics.drawable.Drawable | loadIcon(android.content.Context context)Loads the user-displayed icon for this TV input.
if (mIconUri == null) {
return loadServiceIcon(context);
}
try (InputStream is = context.getContentResolver().openInputStream(mIconUri)) {
Drawable drawable = Drawable.createFromStream(is, null);
if (drawable == null) {
return loadServiceIcon(context);
}
return drawable;
} catch (IOException e) {
Log.w(TAG, "Loading the default icon due to a failure on loading " + mIconUri, e);
return loadServiceIcon(context);
}
|
public java.lang.CharSequence | loadLabel(android.content.Context context)Loads the user-displayed label for this TV input.
if (TextUtils.isEmpty(mLabel)) {
return mService.loadLabel(context.getPackageManager());
} else {
return mLabel;
}
|
private android.graphics.drawable.Drawable | loadServiceIcon(android.content.Context context)
if (mService.serviceInfo.icon == 0
&& mService.serviceInfo.applicationInfo.icon == 0) {
return null;
}
return mService.serviceInfo.loadIcon(context.getPackageManager());
|
public java.lang.String | toString()
return "TvInputInfo{id=" + mId
+ ", pkg=" + mService.serviceInfo.packageName
+ ", service=" + mService.serviceInfo.name + "}";
|
public void | writeToParcel(android.os.Parcel dest, int flags)Used to package this object into a {@link Parcel}.
dest.writeString(mId);
dest.writeString(mParentId);
mService.writeToParcel(dest, flags);
dest.writeString(mSetupActivity);
dest.writeString(mSettingsActivity);
dest.writeInt(mType);
dest.writeParcelable(mHdmiDeviceInfo, flags);
dest.writeParcelable(mIconUri, flags);
dest.writeString(mLabel);
dest.writeByte(mIsConnectedToHdmiSwitch ? (byte) 1 : 0);
|