Merge "TIAF: handling null objects in DsmccResponse class" into tm-dev
This commit is contained in:
@@ -122,11 +122,12 @@ public final class DsmccResponse extends BroadcastInfoResponse implements Parcel
|
|||||||
mBiopMessageType = BIOP_MESSAGE_TYPE_STREAM;
|
mBiopMessageType = BIOP_MESSAGE_TYPE_STREAM;
|
||||||
mFileDescriptor = null;
|
mFileDescriptor = null;
|
||||||
mChildList = null;
|
mChildList = null;
|
||||||
mEventIds = eventIds;
|
if (!((eventIds != null && eventNames != null && eventIds.length == eventNames.length)
|
||||||
mEventNames = eventNames;
|
|| (eventIds == null && eventNames == null))) {
|
||||||
if (mEventIds.length != eventNames.length) {
|
|
||||||
throw new IllegalStateException("The size of eventIds and eventNames must be equal");
|
throw new IllegalStateException("The size of eventIds and eventNames must be equal");
|
||||||
}
|
}
|
||||||
|
mEventIds = eventIds;
|
||||||
|
mEventNames = eventNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DsmccResponse(@NonNull Parcel source) {
|
private DsmccResponse(@NonNull Parcel source) {
|
||||||
@@ -137,10 +138,13 @@ public final class DsmccResponse extends BroadcastInfoResponse implements Parcel
|
|||||||
case BIOP_MESSAGE_TYPE_SERVICE_GATEWAY:
|
case BIOP_MESSAGE_TYPE_SERVICE_GATEWAY:
|
||||||
case BIOP_MESSAGE_TYPE_DIRECTORY:
|
case BIOP_MESSAGE_TYPE_DIRECTORY:
|
||||||
int childNum = source.readInt();
|
int childNum = source.readInt();
|
||||||
mChildList = new ArrayList<>();
|
if (childNum > 0) {
|
||||||
for (int i = 0; i < childNum; i++) {
|
mChildList = new ArrayList<>();
|
||||||
mChildList.add(source.readString());
|
for (int i = 0; i < childNum; i++) {
|
||||||
}
|
mChildList.add(source.readString());
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
mChildList = null;
|
||||||
mFileDescriptor = null;
|
mFileDescriptor = null;
|
||||||
mEventIds = null;
|
mEventIds = null;
|
||||||
mEventNames = null;
|
mEventNames = null;
|
||||||
@@ -153,11 +157,16 @@ public final class DsmccResponse extends BroadcastInfoResponse implements Parcel
|
|||||||
break;
|
break;
|
||||||
case BIOP_MESSAGE_TYPE_STREAM:
|
case BIOP_MESSAGE_TYPE_STREAM:
|
||||||
int eventNum = source.readInt();
|
int eventNum = source.readInt();
|
||||||
mEventIds = new int[eventNum];
|
if (eventNum > 0) {
|
||||||
mEventNames = new String[eventNum];
|
mEventIds = new int[eventNum];
|
||||||
for (int i = 0; i < eventNum; i++) {
|
mEventNames = new String[eventNum];
|
||||||
mEventIds[i] = source.readInt();
|
for (int i = 0; i < eventNum; i++) {
|
||||||
mEventNames[i] = source.readString();
|
mEventIds[i] = source.readInt();
|
||||||
|
mEventNames[i] = source.readString();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mEventIds = null;
|
||||||
|
mEventNames = null;
|
||||||
}
|
}
|
||||||
mChildList = null;
|
mChildList = null;
|
||||||
mFileDescriptor = null;
|
mFileDescriptor = null;
|
||||||
@@ -196,7 +205,7 @@ public final class DsmccResponse extends BroadcastInfoResponse implements Parcel
|
|||||||
&& !mBiopMessageType.equals(BIOP_MESSAGE_TYPE_SERVICE_GATEWAY)) {
|
&& !mBiopMessageType.equals(BIOP_MESSAGE_TYPE_SERVICE_GATEWAY)) {
|
||||||
throw new IllegalStateException("Not directory object");
|
throw new IllegalStateException("Not directory object");
|
||||||
}
|
}
|
||||||
return new ArrayList<String>(mChildList);
|
return mChildList != null ? new ArrayList<String>(mChildList) : new ArrayList<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -207,7 +216,7 @@ public final class DsmccResponse extends BroadcastInfoResponse implements Parcel
|
|||||||
if (!mBiopMessageType.equals(BIOP_MESSAGE_TYPE_STREAM)) {
|
if (!mBiopMessageType.equals(BIOP_MESSAGE_TYPE_STREAM)) {
|
||||||
throw new IllegalStateException("Not stream event object");
|
throw new IllegalStateException("Not stream event object");
|
||||||
}
|
}
|
||||||
return mEventIds;
|
return mEventIds != null ? mEventIds : new int[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -218,7 +227,7 @@ public final class DsmccResponse extends BroadcastInfoResponse implements Parcel
|
|||||||
if (!mBiopMessageType.equals(BIOP_MESSAGE_TYPE_STREAM)) {
|
if (!mBiopMessageType.equals(BIOP_MESSAGE_TYPE_STREAM)) {
|
||||||
throw new IllegalStateException("Not stream event object");
|
throw new IllegalStateException("Not stream event object");
|
||||||
}
|
}
|
||||||
return mEventNames;
|
return mEventNames != null ? mEventNames : new String[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -233,20 +242,26 @@ public final class DsmccResponse extends BroadcastInfoResponse implements Parcel
|
|||||||
switch (mBiopMessageType) {
|
switch (mBiopMessageType) {
|
||||||
case BIOP_MESSAGE_TYPE_SERVICE_GATEWAY:
|
case BIOP_MESSAGE_TYPE_SERVICE_GATEWAY:
|
||||||
case BIOP_MESSAGE_TYPE_DIRECTORY:
|
case BIOP_MESSAGE_TYPE_DIRECTORY:
|
||||||
dest.writeInt(mChildList.size());
|
if (mChildList != null && mChildList.size() > 0) {
|
||||||
for (String child : mChildList) {
|
dest.writeInt(mChildList.size());
|
||||||
dest.writeString(child);
|
for (String child : mChildList) {
|
||||||
}
|
dest.writeString(child);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
dest.writeInt(0);
|
||||||
break;
|
break;
|
||||||
case BIOP_MESSAGE_TYPE_FILE:
|
case BIOP_MESSAGE_TYPE_FILE:
|
||||||
dest.writeFileDescriptor(mFileDescriptor.getFileDescriptor());
|
dest.writeFileDescriptor(mFileDescriptor.getFileDescriptor());
|
||||||
break;
|
break;
|
||||||
case BIOP_MESSAGE_TYPE_STREAM:
|
case BIOP_MESSAGE_TYPE_STREAM:
|
||||||
dest.writeInt(mEventIds.length);
|
if (mEventIds != null && mEventIds.length > 0) {
|
||||||
for (int i = 0; i < mEventIds.length; i++) {
|
dest.writeInt(mEventIds.length);
|
||||||
dest.writeInt(mEventIds[i]);
|
for (int i = 0; i < mEventIds.length; i++) {
|
||||||
dest.writeString(mEventNames[i]);
|
dest.writeInt(mEventIds[i]);
|
||||||
}
|
dest.writeString(mEventNames[i]);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
dest.writeInt(0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("unexpected BIOP message type");
|
throw new IllegalStateException("unexpected BIOP message type");
|
||||||
|
|||||||
Reference in New Issue
Block a user