use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowArscAssetManager method retrieveAttributes.
@HiddenApi
@Implementation(minSdk = LOLLIPOP)
protected final boolean retrieveAttributes(long xmlParserToken, int[] attrs, int[] outValues, int[] outIndices) {
if (xmlParserToken == 0) {
throw new NullPointerException("xmlParserToken");
// return JNI_FALSE;
}
if (attrs == null) {
throw new NullPointerException("attrs");
// return JNI_FALSE;
}
if (outValues == null) {
throw new NullPointerException("out values");
// return JNI_FALSE;
}
CppAssetManager am = assetManagerForJavaObject();
// if (am == null) {
// return JNI_FALSE;
// }
ResTable res = am.getResources();
// ResXMLParser xmlParser = (ResXMLParser*)xmlParserToken;
ResXMLParser xmlParser = Registries.NATIVE_RES_XML_PARSERS.getNativeObject(xmlParserToken);
// const int NI = env.GetArrayLength(attrs);
// const int NV = env.GetArrayLength(outValues);
final int NI = attrs.length;
final int NV = outValues.length;
if (NV < (NI * STYLE_NUM_ENTRIES)) {
throw new IndexOutOfBoundsException("out values too small");
// return JNI_FALSE;
}
// int[] src = (int[])env.GetPrimitiveArrayCritical(attrs, 0);
// if (src == null) {
// return JNI_FALSE;
// }
int[] src = attrs;
// int[] baseDest = (int[])env.GetPrimitiveArrayCritical(outValues, 0);
int[] baseDest = outValues;
if (baseDest == null) {
// return JNI_FALSE;
return false;
}
int[] indices = null;
if (outIndices != null) {
if (outIndices.length > NI) {
// indices = (int[])env.GetPrimitiveArrayCritical(outIndices, 0);
indices = outIndices;
}
}
boolean result = AttributeResolution.RetrieveAttributes(res, xmlParser, src, NI, baseDest, indices);
if (indices != null) {
// indices[0] = indicesIdx;
// env.ReleasePrimitiveArrayCritical(outIndices, indices, 0);
}
return result;
}
use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowArscAssetManager method openXmlAssetNative.
// /*package*/@HiddenApi @Implementation public static final @NativeConfig
// int getThemeChangingConfigurations(long theme);
@HiddenApi
@Implementation
protected final Number openXmlAssetNative(int cookie, String fileName) throws FileNotFoundException {
CppAssetManager am = assetManagerForJavaObject();
if (am == null) {
return RuntimeEnvironment.castNativePtr(0);
}
ALOGV("openXmlAsset in %s (Java object %s)\n", am, ShadowArscAssetManager.class);
String fileName8 = fileName;
if (fileName8 == null) {
return RuntimeEnvironment.castNativePtr(0);
}
int assetCookie = cookie;
Asset a;
if (isTruthy(assetCookie)) {
a = am.openNonAsset(assetCookie, fileName8, AccessMode.ACCESS_BUFFER);
} else {
final Ref<Integer> assetCookieRef = new Ref<>(assetCookie);
a = am.openNonAsset(fileName8, AccessMode.ACCESS_BUFFER, assetCookieRef);
assetCookie = assetCookieRef.get();
}
if (a == null) {
throw new FileNotFoundException(fileName8);
}
final DynamicRefTable dynamicRefTable = am.getResources().getDynamicRefTableForCookie(assetCookie);
ResXMLTree block = new ResXMLTree(dynamicRefTable);
int err = block.setTo(a.getBuffer(true), (int) a.getLength(), true);
a.close();
if (err != NO_ERROR) {
throw new FileNotFoundException("Corrupt XML binary file");
}
return RuntimeEnvironment.castNativePtr(Registries.NATIVE_RES_XML_TREES.register(block));
}
use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowArscAssetManager method getArraySize.
@HiddenApi
@Implementation
protected int getArraySize(int id) {
CppAssetManager am = assetManagerForJavaObject();
if (am == null) {
return 0;
}
final ResTable res = am.getResources();
res.lock();
final Ref<bag_entry[]> defStyleEnt = new Ref<>(null);
int bagOff = res.getBagLocked(id, defStyleEnt, null);
res.unlock();
return bagOff;
}
use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowArscAssetManager method openNonAssetFdNative.
@HiddenApi
@Implementation
protected ParcelFileDescriptor openNonAssetFdNative(int cookie, String fileName, long[] outOffsets) throws IOException {
CppAssetManager am = assetManagerForJavaObject();
ALOGV("openNonAssetFd in %s (Java object %s)", am, this);
if (fileName == null) {
return null;
}
Asset a = isTruthy(cookie) ? am.openNonAsset(cookie, fileName, Asset.AccessMode.ACCESS_RANDOM) : am.openNonAsset(fileName, Asset.AccessMode.ACCESS_RANDOM, null);
if (a == null) {
throw new FileNotFoundException(fileName);
}
return returnParcelFileDescriptor(a, outOffsets);
}
use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowArscAssetManager method copyTheme.
@HiddenApi
@Implementation(minSdk = LOLLIPOP, maxSdk = O_MR1)
public static void copyTheme(long destPtr, long sourcePtr) {
ResTableTheme dest = Registries.NATIVE_THEME_REGISTRY.getNativeObject(destPtr);
ResTableTheme src = Registries.NATIVE_THEME_REGISTRY.getNativeObject(sourcePtr);
dest.setTo(src);
}
Aggregations