auto import from //branches/cupcake/...@130745
diff --git a/libs/utils/Parcel.cpp b/libs/utils/Parcel.cpp
index 0eba0b0..0f4b647 100644
--- a/libs/utils/Parcel.cpp
+++ b/libs/utils/Parcel.cpp
@@ -658,15 +658,20 @@
status_t err;
err = writeInt32(handle.numFds);
if (err != NO_ERROR) return err;
-
+
err = writeInt32(handle.numInts);
if (err != NO_ERROR) return err;
-
+
for (int i=0 ; err==NO_ERROR && i<handle.numFds ; i++)
err = writeDupFileDescriptor(handle.data[i]);
-
+
+ if (err != NO_ERROR) {
+ LOGD("write native handle, write dup fd failed");
+ return err;
+ }
+
err = write(handle.data + handle.numFds, sizeof(int)*handle.numInts);
-
+
return err;
}
@@ -947,7 +952,7 @@
}
for (int i=0 ; err==NO_ERROR && i<numFds ; i++) {
- h->data[i] = readFileDescriptor();
+ h->data[i] = dup(readFileDescriptor());
if (h->data[i] < 0) err = BAD_VALUE;
}
diff --git a/libs/utils/ResourceTypes.cpp b/libs/utils/ResourceTypes.cpp
index 5a09fb4..71e7cd7 100644
--- a/libs/utils/ResourceTypes.cpp
+++ b/libs/utils/ResourceTypes.cpp
@@ -1736,7 +1736,7 @@
}
ssize_t ResTable::getResource(uint32_t resID, Res_value* outValue, bool mayBeBag,
- uint32_t* outSpecFlags) const
+ uint32_t* outSpecFlags, ResTable_config* outConfig) const
{
if (mError != NO_ERROR) {
return mError;
@@ -1809,7 +1809,7 @@
(const Res_value*)(((const uint8_t*)type) + offset);
ResTable_config thisConfig;
thisConfig.copyFromDtoH(type->config);
-
+
if (outSpecFlags != NULL) {
if (typeClass->typeSpecFlags != NULL) {
*outSpecFlags |= dtohl(typeClass->typeSpecFlags[e]);
@@ -1834,6 +1834,9 @@
outValue->res0 = bestValue->res0;
outValue->dataType = bestValue->dataType;
outValue->data = dtohl(bestValue->data);
+ if (outConfig != NULL) {
+ *outConfig = bestItem;
+ }
TABLE_NOISY(size_t len;
printf("Found value: pkg=%d, type=%d, str=%s, int=%d\n",
bestPackage->header->index,
@@ -3484,7 +3487,7 @@
ResTable_config thisConfig;
thisConfig.copyFromDtoH(thisType->config);
-
+
TABLE_GETENTRY(LOGI("Match entry 0x%x in type 0x%x (sz 0x%x): imsi:%d/%d=%d/%d lang:%c%c=%c%c cnt:%c%c=%c%c "
"orien:%d=%d touch:%d=%d density:%d=%d key:%d=%d inp:%d=%d nav:%d=%d w:%d=%d h:%d=%d\n",
entryIndex, typeIndex+1, dtohl(thisType->config.size),
diff --git a/libs/utils/String8.cpp b/libs/utils/String8.cpp
index ab843f6..c50d343 100644
--- a/libs/utils/String8.cpp
+++ b/libs/utils/String8.cpp
@@ -317,8 +317,10 @@
->editResize(myLen+otherLen+1);
if (buf) {
char* str = (char*)buf->data();
- memcpy(str+myLen, other, otherLen+1);
mString = str;
+ str += myLen;
+ memcpy(str, other, otherLen);
+ str[otherLen] = '\0';
return NO_ERROR;
}
return NO_MEMORY;