Merge "TIF: Throw a more appropriate runtime exception when building TvInputInfo" into nyc-dev
am: 7996b96311
* commit '7996b96311eec2343c16d3677fb834d2ec7cf082':
TIF: Throw a more appropriate runtime exception when building TvInputInfo
Change-Id: I99540dd3060f1fe8467ac8207976e420c8b7635f
This commit is contained in:
@@ -22981,7 +22981,7 @@ package android.media.tv {
|
|||||||
|
|
||||||
public static final class TvInputInfo.Builder {
|
public static final class TvInputInfo.Builder {
|
||||||
ctor public TvInputInfo.Builder(android.content.Context, android.content.ComponentName);
|
ctor public TvInputInfo.Builder(android.content.Context, android.content.ComponentName);
|
||||||
method public android.media.tv.TvInputInfo build() throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
|
method public android.media.tv.TvInputInfo build();
|
||||||
method public android.media.tv.TvInputInfo.Builder setCanRecord(boolean);
|
method public android.media.tv.TvInputInfo.Builder setCanRecord(boolean);
|
||||||
method public android.media.tv.TvInputInfo.Builder setExtras(android.os.Bundle);
|
method public android.media.tv.TvInputInfo.Builder setExtras(android.os.Bundle);
|
||||||
method public android.media.tv.TvInputInfo.Builder setTunerCount(int);
|
method public android.media.tv.TvInputInfo.Builder setTunerCount(int);
|
||||||
|
|||||||
@@ -24683,7 +24683,7 @@ package android.media.tv {
|
|||||||
|
|
||||||
public static final class TvInputInfo.Builder {
|
public static final class TvInputInfo.Builder {
|
||||||
ctor public TvInputInfo.Builder(android.content.Context, android.content.ComponentName);
|
ctor public TvInputInfo.Builder(android.content.Context, android.content.ComponentName);
|
||||||
method public android.media.tv.TvInputInfo build() throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
|
method public android.media.tv.TvInputInfo build();
|
||||||
method public android.media.tv.TvInputInfo.Builder setCanRecord(boolean);
|
method public android.media.tv.TvInputInfo.Builder setCanRecord(boolean);
|
||||||
method public android.media.tv.TvInputInfo.Builder setExtras(android.os.Bundle);
|
method public android.media.tv.TvInputInfo.Builder setExtras(android.os.Bundle);
|
||||||
method public android.media.tv.TvInputInfo.Builder setHdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo);
|
method public android.media.tv.TvInputInfo.Builder setHdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo);
|
||||||
|
|||||||
@@ -23051,7 +23051,7 @@ package android.media.tv {
|
|||||||
|
|
||||||
public static final class TvInputInfo.Builder {
|
public static final class TvInputInfo.Builder {
|
||||||
ctor public TvInputInfo.Builder(android.content.Context, android.content.ComponentName);
|
ctor public TvInputInfo.Builder(android.content.Context, android.content.ComponentName);
|
||||||
method public android.media.tv.TvInputInfo build() throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
|
method public android.media.tv.TvInputInfo build();
|
||||||
method public android.media.tv.TvInputInfo.Builder setCanRecord(boolean);
|
method public android.media.tv.TvInputInfo.Builder setCanRecord(boolean);
|
||||||
method public android.media.tv.TvInputInfo.Builder setExtras(android.os.Bundle);
|
method public android.media.tv.TvInputInfo.Builder setExtras(android.os.Bundle);
|
||||||
method public android.media.tv.TvInputInfo.Builder setTunerCount(int);
|
method public android.media.tv.TvInputInfo.Builder setTunerCount(int);
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import android.util.Xml;
|
|||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
@@ -875,10 +876,8 @@ public final class TvInputInfo implements Parcelable {
|
|||||||
* for the {@link TvInputService} this TV input implements.
|
* for the {@link TvInputService} this TV input implements.
|
||||||
*
|
*
|
||||||
* @return TvInputInfo containing information about this TV input.
|
* @return TvInputInfo containing information about this TV input.
|
||||||
* @throws IOException If there was an I/O error.
|
|
||||||
* @throws XmlPullParserException If there was an XML parsing error.
|
|
||||||
*/
|
*/
|
||||||
public TvInputInfo build() throws IOException, XmlPullParserException {
|
public TvInputInfo build() {
|
||||||
ComponentName componentName = new ComponentName(mResolveInfo.serviceInfo.packageName,
|
ComponentName componentName = new ComponentName(mResolveInfo.serviceInfo.packageName,
|
||||||
mResolveInfo.serviceInfo.name);
|
mResolveInfo.serviceInfo.name);
|
||||||
String id;
|
String id;
|
||||||
@@ -925,15 +924,14 @@ public final class TvInputInfo implements Parcelable {
|
|||||||
+ tvInputHardwareInfo.getDeviceId();
|
+ tvInputHardwareInfo.getDeviceId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseServiceMetadata(int inputType)
|
private void parseServiceMetadata(int inputType) {
|
||||||
throws XmlPullParserException, IOException {
|
|
||||||
ServiceInfo si = mResolveInfo.serviceInfo;
|
ServiceInfo si = mResolveInfo.serviceInfo;
|
||||||
PackageManager pm = mContext.getPackageManager();
|
PackageManager pm = mContext.getPackageManager();
|
||||||
try (XmlResourceParser parser =
|
try (XmlResourceParser parser =
|
||||||
si.loadXmlMetaData(pm, TvInputService.SERVICE_META_DATA)) {
|
si.loadXmlMetaData(pm, TvInputService.SERVICE_META_DATA)) {
|
||||||
if (parser == null) {
|
if (parser == null) {
|
||||||
throw new XmlPullParserException("No " + TvInputService.SERVICE_META_DATA
|
throw new IllegalStateException("No " + TvInputService.SERVICE_META_DATA
|
||||||
+ " meta-data for " + si.name);
|
+ " meta-data found for " + si.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Resources res = pm.getResourcesForApplication(si.applicationInfo);
|
Resources res = pm.getResourcesForApplication(si.applicationInfo);
|
||||||
@@ -946,26 +944,19 @@ public final class TvInputInfo implements Parcelable {
|
|||||||
|
|
||||||
String nodeName = parser.getName();
|
String nodeName = parser.getName();
|
||||||
if (!XML_START_TAG_NAME.equals(nodeName)) {
|
if (!XML_START_TAG_NAME.equals(nodeName)) {
|
||||||
throw new XmlPullParserException(
|
throw new IllegalStateException("Meta-data does not start with "
|
||||||
"Meta-data does not start with tv-input-service tag in " + si.name);
|
+ XML_START_TAG_NAME + " tag for " + si.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
TypedArray sa = res.obtainAttributes(attrs,
|
TypedArray sa = res.obtainAttributes(attrs,
|
||||||
com.android.internal.R.styleable.TvInputService);
|
com.android.internal.R.styleable.TvInputService);
|
||||||
mSetupActivity = sa.getString(
|
mSetupActivity = sa.getString(
|
||||||
com.android.internal.R.styleable.TvInputService_setupActivity);
|
com.android.internal.R.styleable.TvInputService_setupActivity);
|
||||||
if (DEBUG) {
|
|
||||||
Log.d(TAG, "Setup activity loaded. [" + mSetupActivity + "] for " + si.name);
|
|
||||||
}
|
|
||||||
if (inputType == TYPE_TUNER && TextUtils.isEmpty(mSetupActivity)) {
|
if (inputType == TYPE_TUNER && TextUtils.isEmpty(mSetupActivity)) {
|
||||||
throw new XmlPullParserException("Setup activity not found in " + si.name);
|
throw new IllegalStateException("Setup activity not found for " + si.name);
|
||||||
}
|
}
|
||||||
mSettingsActivity = sa.getString(
|
mSettingsActivity = sa.getString(
|
||||||
com.android.internal.R.styleable.TvInputService_settingsActivity);
|
com.android.internal.R.styleable.TvInputService_settingsActivity);
|
||||||
if (DEBUG) {
|
|
||||||
Log.d(TAG, "Settings activity loaded. [" + mSettingsActivity + "] for "
|
|
||||||
+ si.name);
|
|
||||||
}
|
|
||||||
if (mCanRecord == null) {
|
if (mCanRecord == null) {
|
||||||
mCanRecord = sa.getBoolean(
|
mCanRecord = sa.getBoolean(
|
||||||
com.android.internal.R.styleable.TvInputService_canRecord, false);
|
com.android.internal.R.styleable.TvInputService_canRecord, false);
|
||||||
@@ -975,8 +966,10 @@ public final class TvInputInfo implements Parcelable {
|
|||||||
com.android.internal.R.styleable.TvInputService_tunerCount, 1);
|
com.android.internal.R.styleable.TvInputService_tunerCount, 1);
|
||||||
}
|
}
|
||||||
sa.recycle();
|
sa.recycle();
|
||||||
|
} catch (IOException | XmlPullParserException e) {
|
||||||
|
throw new IllegalStateException("Failed reading meta-data for " + si.packageName, e);
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
throw new XmlPullParserException("Unable to create context for: " + si.packageName);
|
throw new IllegalStateException("No resources found for " + si.packageName, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -331,7 +331,7 @@ public final class TvInputManagerService extends SystemService {
|
|||||||
try {
|
try {
|
||||||
TvInputInfo info = new TvInputInfo.Builder(mContext, ri).build();
|
TvInputInfo info = new TvInputInfo.Builder(mContext, ri).build();
|
||||||
inputList.add(info);
|
inputList.add(info);
|
||||||
} catch (XmlPullParserException | IOException e) {
|
} catch (Exception e) {
|
||||||
Slog.e(TAG, "failed to load TV input " + si.name, e);
|
Slog.e(TAG, "failed to load TV input " + si.name, e);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user