Merge "Pass a copy of style_id_args to theme.rebase()"

This commit is contained in:
Jeremy Meyer
2022-09-23 17:17:27 +00:00
committed by Android (Google) Code Review

View File

@@ -1296,6 +1296,10 @@ static void NativeThemeRebase(JNIEnv* env, jclass /*clazz*/, jlong ptr, jlong th
} else {
CHECK(style_count == 0) << "style_ids is null while style_count is non-zero";
}
auto style_id_args_copy = std::vector<uint32_t>{style_id_args, style_id_args + style_count};
if (style_ids != nullptr) {
env->ReleasePrimitiveArrayCritical(style_ids, style_id_args, JNI_ABORT);
}
jboolean* force_args = nullptr;
if (force != nullptr) {
@@ -1308,15 +1312,14 @@ static void NativeThemeRebase(JNIEnv* env, jclass /*clazz*/, jlong ptr, jlong th
} else {
CHECK(style_count == 0) << "force is null while style_count is non-zero";
}
auto theme = reinterpret_cast<Theme*>(theme_ptr);
theme->Rebase(&(*assetmanager), style_id_args, force_args, static_cast<size_t>(style_count));
if (style_ids != nullptr) {
env->ReleasePrimitiveArrayCritical(style_ids, style_id_args, JNI_ABORT);
}
auto force_args_copy = std::vector<jboolean>{force_args, force_args + style_count};
if (force != nullptr) {
env->ReleasePrimitiveArrayCritical(force, force_args, JNI_ABORT);
}
auto theme = reinterpret_cast<Theme*>(theme_ptr);
theme->Rebase(&(*assetmanager), style_id_args_copy.data(), force_args_copy.data(),
static_cast<size_t>(style_count));
}
static void NativeThemeCopy(JNIEnv* env, jclass /*clazz*/, jlong dst_asset_manager_ptr,