use of org.robolectric.res.android.CppAssetManager2 in project robolectric by robolectric.
the class ShadowArscAssetManager9 method nativeSetApkAssets.
// static void NativeSetApkAssets(JNIEnv* env, jclass /*clazz*/, jlong ptr,
// jobjectArray apk_assets_array, jboolean invalidate_caches) {
@Implementation(minSdk = P)
protected static void nativeSetApkAssets(long ptr, @NonNull android.content.res.ApkAssets[] apk_assets_array, boolean invalidate_caches) {
ATRACE_NAME("AssetManager::SetApkAssets");
int apk_assets_len = apk_assets_array.length;
List<CppApkAssets> apk_assets = new ArrayList<>();
// apk_assets.reserve(apk_assets_len);
for (int i = 0; i < apk_assets_len; i++) {
android.content.res.ApkAssets apkAssets = // env.GetObjectArrayElement(apk_assets_array, i);
apk_assets_array[i];
if (apkAssets == null) {
throw new NullPointerException(String.format("ApkAssets at index %d is null", i));
}
long apk_assets_native_ptr = ((ShadowArscApkAssets9) Shadow.extract(apkAssets)).getNativePtr();
// if (env.ExceptionCheck()) {
// return;
// }
apk_assets.add(Registries.NATIVE_APK_ASSETS_REGISTRY.getNativeObject(apk_assets_native_ptr));
}
CppAssetManager2 assetmanager = AssetManagerFromLong(ptr);
assetmanager.SetApkAssets(apk_assets, invalidate_caches);
}
use of org.robolectric.res.android.CppAssetManager2 in project robolectric by robolectric.
the class ShadowArscAssetManager9 method nativeResolveAttrs.
// static jboolean NativeResolveAttrs(JNIEnv* env, jclass /*clazz*/, jlong ptr, jlong theme_ptr,
// jint def_style_attr, jint def_style_resid, jintArray
// java_values,
// jintArray java_attrs, jintArray out_java_values,
// jintArray out_java_indices) {
@Implementation(minSdk = P)
protected static boolean nativeResolveAttrs(long ptr, long theme_ptr, @AttrRes int def_style_attr, @StyleRes int def_style_resid, @Nullable int[] java_values, @NonNull int[] java_attrs, @NonNull int[] out_java_values, @NonNull int[] out_java_indices) {
int attrs_len = java_attrs.length;
int out_values_len = out_java_values.length;
if (out_values_len < (attrs_len * STYLE_NUM_ENTRIES)) {
throw new IndexOutOfBoundsException("outValues too small");
}
int[] attrs = // reinterpret_cast<int*>(env.GetPrimitiveArrayCritical(java_attrs, null));
java_attrs;
if (attrs == null) {
return JNI_FALSE;
}
int[] values = null;
int values_len = 0;
if (java_values != null) {
values_len = java_values.length;
values = // reinterpret_cast<int*>(env.GetPrimitiveArrayCritical(java_values, null));
java_values;
if (values == null) {
// env.ReleasePrimitiveArrayCritical(java_attrs, attrs, JNI_ABORT);
return JNI_FALSE;
}
}
int[] out_values = out_java_values;
// reinterpret_cast<int*>(env.GetPrimitiveArrayCritical(out_java_values, null));
if (out_values == null) {
// }
return JNI_FALSE;
}
int[] out_indices = null;
if (out_java_indices != null) {
int out_indices_len = out_java_indices.length;
if (out_indices_len > attrs_len) {
out_indices = out_java_indices;
// reinterpret_cast<int*>(env.GetPrimitiveArrayCritical(out_java_indices, null));
if (out_indices == null) {
// env.ReleasePrimitiveArrayCritical(out_java_values, out_values, JNI_ABORT);
return JNI_FALSE;
}
}
}
CppAssetManager2 assetmanager = AssetManagerFromLong(ptr);
Theme theme = Registries.NATIVE_THEME9_REGISTRY.getNativeObject(theme_ptr);
CHECK(theme.GetAssetManager() == assetmanager);
// (void) assetmanager;
boolean result = ResolveAttrs(theme, (int) (def_style_attr), (int) (def_style_resid), values, values_len, attrs, attrs_len, out_values, out_indices);
// env.ReleasePrimitiveArrayCritical(java_attrs, attrs, JNI_ABORT);
return result ? JNI_TRUE : JNI_FALSE;
}
use of org.robolectric.res.android.CppAssetManager2 in project robolectric by robolectric.
the class ShadowArscAssetManager9 method nativeGetStyleAttributes.
// static jintArray NativeGetStyleAttributes(JNIEnv* env, jclass /*clazz*/, jlong ptr, jint resid)
// {
@Implementation(minSdk = P)
@Nullable
@AttrRes
protected static int[] nativeGetStyleAttributes(long ptr, @StyleRes int resid) {
CppAssetManager2 assetmanager = AssetManagerFromLong(ptr);
ResolvedBag bag = assetmanager.GetBag(resid);
if (bag == null) {
return null;
}
int[] array = new int[bag.entry_count];
for (int i = 0; i < bag.entry_count; i++) {
int attr_resid = bag.entries[i].key;
// env.SetIntArrayRegion(array, i, 1, &attr_resid);
array[i] = attr_resid;
}
return array;
}
use of org.robolectric.res.android.CppAssetManager2 in project robolectric by robolectric.
the class ShadowArscAssetManager9 method nativeThemeDump.
// static void NativeThemeDump(JNIEnv* /*env*/, jclass /*clazz*/, jlong ptr, jlong theme_ptr,
// jint priority, jstring tag, jstring prefix) {
@Implementation(minSdk = P)
protected static void nativeThemeDump(long ptr, long theme_ptr, int priority, String tag, String prefix) {
CppAssetManager2 assetmanager = AssetManagerFromLong(ptr);
Theme theme = Registries.NATIVE_THEME9_REGISTRY.getNativeObject(theme_ptr);
CHECK(theme.GetAssetManager() == assetmanager);
// (void) assetmanager;
// (void) theme;
// (void) priority;
// (void) tag;
// (void) prefix;
}
use of org.robolectric.res.android.CppAssetManager2 in project robolectric by robolectric.
the class ShadowArscAssetManager9 method nativeRetrieveAttributes.
// static jboolean NativeRetrieveAttributes(JNIEnv* env, jclass /*clazz*/, jlong ptr,
// jlong xml_parser_ptr, jintArray java_attrs,
// jintArray out_java_values, jintArray out_java_indices)
// {
@Implementation(minSdk = P)
protected static boolean nativeRetrieveAttributes(long ptr, long xml_parser_ptr, @NonNull int[] java_attrs, @NonNull int[] out_java_values, @NonNull int[] out_java_indices) {
int attrs_len = java_attrs.length;
int out_values_len = out_java_values.length;
if (out_values_len < (attrs_len * STYLE_NUM_ENTRIES)) {
throw new IndexOutOfBoundsException("outValues too small");
}
int[] attrs = // reinterpret_cast<int*>(env.GetPrimitiveArrayCritical(java_attrs, null));
java_attrs;
if (attrs == null) {
return JNI_FALSE;
}
int[] out_values = out_java_values;
// reinterpret_cast<int*>(env.GetPrimitiveArrayCritical(out_java_values, null));
if (out_values == null) {
// env.ReleasePrimitiveArrayCritical(java_attrs, attrs, JNI_ABORT);
return JNI_FALSE;
}
int[] out_indices = null;
if (out_java_indices != null) {
int out_indices_len = out_java_indices.length;
if (out_indices_len > attrs_len) {
out_indices = out_java_indices;
// reinterpret_cast<int*>(env.GetPrimitiveArrayCritical(out_java_indices, null));
if (out_indices == null) {
// env.ReleasePrimitiveArrayCritical(out_java_values, out_values, JNI_ABORT);
return JNI_FALSE;
}
}
}
CppAssetManager2 assetmanager = AssetManagerFromLong(ptr);
ResXMLParser xml_parser = NATIVE_RES_XML_PARSERS.getNativeObject(xml_parser_ptr);
boolean result = RetrieveAttributes(assetmanager, xml_parser, attrs, attrs_len, out_values, out_indices);
// env.ReleasePrimitiveArrayCritical(java_attrs, attrs, JNI_ABORT);
return result;
}
Aggregations