Merge "Revert "Remove empty ScopedArray constructor.""

This commit is contained in:
Nicolas Geoffray
2017-12-09 13:26:00 +00:00
committed by Gerrit Code Review
2 changed files with 13 additions and 7 deletions

View File

@@ -155,6 +155,11 @@ public:
return;
}
ScopedIntArrayRO tags(env);
if (jTags != nullptr) {
tags.reset(jTags);
}
while (1) {
log_msg log_msg;
int ret = android_logger_list_read(logger_list.get(), &log_msg);
@@ -182,7 +187,6 @@ public:
if (jTags != nullptr) {
bool found = false;
ScopedIntArrayRO tags(env, jTags);
for (size_t i = 0; !found && i < tags.size(); ++i) {
found = (tag == tags[i]);
}

View File

@@ -41,11 +41,14 @@ static jlong createDump(JNIEnv*, jobject, jint fd, jboolean isProto) {
static void addToDump(JNIEnv* env, jobject, jlong dumpPtr, jstring jpath, jstring jpackage,
jint versionCode, jlong startTime, jlong endTime, jbyteArray jdata) {
std::string path;
const ProfileData* data = nullptr;
LOG_ALWAYS_FATAL_IF(jdata == nullptr && jpath == nullptr, "Path and data can't both be null");
ScopedNullableByteArrayRO buffer(env, jdata);
if (buffer.size() != -1) {
ScopedByteArrayRO buffer{env};
if (jdata != nullptr) {
buffer.reset(jdata);
LOG_ALWAYS_FATAL_IF(buffer.size() != sizeof(ProfileData),
"Buffer size %zd doesn't match expected %zu!", buffer.size(), sizeof(ProfileData));
"Buffer size %zu doesn't match expected %zu!", buffer.size(), sizeof(ProfileData));
data = reinterpret_cast<const ProfileData*>(buffer.get());
}
if (jpath != nullptr) {
ScopedUtfChars pathChars(env, jpath);
@@ -58,8 +61,7 @@ static void addToDump(JNIEnv* env, jobject, jlong dumpPtr, jstring jpath, jstrin
LOG_ALWAYS_FATAL_IF(!dump, "null passed for dump pointer");
const std::string package(packageChars.c_str(), packageChars.size());
GraphicsStatsService::addToDump(dump, path, package, versionCode, startTime, endTime,
reinterpret_cast<const ProfileData*>(buffer.get()));
GraphicsStatsService::addToDump(dump, path, package, versionCode, startTime, endTime, data);
}
static void addFileToDump(JNIEnv* env, jobject, jlong dumpPtr, jstring jpath) {
@@ -106,4 +108,4 @@ int register_android_server_GraphicsStatsService(JNIEnv* env)
sMethods, NELEM(sMethods));
}
} // namespace android
} // namespace android