TIF: fix NPE caused by invalid component name

Fixes NPE caused by invalid component name in TvInputInfo.Builder

Test: bug fix
Bug: 29457556
Change-Id: I92a77777373669c893299eaad7367a68aa458156
This commit is contained in:
Conrad Chen
2017-02-14 18:02:37 -08:00
parent 89f423d375
commit 735a8d8fe9

View File

@@ -694,10 +694,16 @@ public final class TvInputInfo implements Parcelable {
* {@link TvInputService}.
*/
public Builder(Context context, ComponentName component) {
mContext = context;
if (context == null) {
throw new IllegalArgumentException("context cannot be null.");
}
Intent intent = new Intent(TvInputService.SERVICE_INTERFACE).setComponent(component);
mResolveInfo = context.getPackageManager().resolveService(intent,
PackageManager.GET_SERVICES | PackageManager.GET_META_DATA);
if (mResolveInfo == null) {
throw new IllegalArgumentException("Invalid component. Can't find the service.");
}
mContext = context;
}
/**