use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowArscAssetManager method applyStyle.
@HiddenApi
@Implementation(minSdk = LOLLIPOP, maxSdk = N_MR1)
protected static void applyStyle(long themeToken, int defStyleAttr, int defStyleRes, long xmlParserToken, int[] attrs, int[] outValues, int[] outIndices) {
ResTableTheme theme = Registries.NATIVE_THEME_REGISTRY.getNativeObject(themeToken);
ResXMLParser xmlParser = xmlParserToken == 0 ? null : Registries.NATIVE_RES_XML_PARSERS.getNativeObject(xmlParserToken);
AttributeResolution.ApplyStyle(theme, xmlParser, defStyleAttr, defStyleRes, attrs, attrs.length, outValues, outIndices);
}
use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowArscAssetManager method getArrayStringInfo.
@HiddenApi
@Implementation
protected final int[] getArrayStringInfo(int arrayResId) {
CppAssetManager am = assetManagerForJavaObject();
ResTable res = am.getResources();
final Ref<bag_entry[]> startOfBag = new Ref<>(null);
final int N = res.lockBag(arrayResId, startOfBag);
if (N < 0) {
return null;
}
int[] array = new int[N * 2];
final Ref<Res_value> value = new Ref<>(null);
bag_entry[] bag = startOfBag.get();
for (int i = 0, j = 0; i < N; i++) {
int stringIndex = -1;
int stringBlock = 0;
value.set(bag[i].map.value);
// Take care of resolving the found resource to its final value.
stringBlock = res.resolveReference(value, bag[i].stringBlock, null);
if (value.get().dataType == DataType.STRING.code()) {
stringIndex = value.get().data;
}
if (kThrowOnBadId) {
if (stringBlock == BAD_INDEX) {
throw new IllegalStateException("Bad resource!");
}
}
// todo: It might be faster to allocate a C array to contain
// the blocknums and indices, put them in there and then
// do just one SetIntArrayRegion()
// env->SetIntArrayRegion(array, j, 1, &stringBlock);
array[j] = stringBlock;
// env->SetIntArrayRegion(array, j + 1, 1, &stringIndex);
array[j + 1] = stringIndex;
j += 2;
}
res.unlockBag(startOfBag);
return array;
}
use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowArscAssetManager method openAsset.
@HiddenApi
@Implementation
protected final Number openAsset(String fileName, int mode) throws FileNotFoundException {
CppAssetManager am = assetManagerForJavaObject();
ALOGV("openAsset in %s", am);
String fileName8 = fileName;
if (fileName8 == null) {
throw new IllegalArgumentException("Empty file name");
}
if (mode != AccessMode.ACCESS_UNKNOWN.mode() && mode != AccessMode.ACCESS_RANDOM.mode() && mode != AccessMode.ACCESS_STREAMING.mode() && mode != AccessMode.ACCESS_BUFFER.mode()) {
throw new IllegalArgumentException("Bad access mode");
}
Asset a = am.open(fileName8, AccessMode.fromInt(mode));
if (a == null) {
throw new FileNotFoundException(fileName8);
}
return RuntimeEnvironment.castNativePtr(Registries.NATIVE_ASSET_REGISTRY.register(a));
}
use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowArscAssetManager method readAsset.
@HiddenApi
@Implementation(minSdk = LOLLIPOP)
protected final int readAsset(long asset, byte[] bArray, int off, int len) throws IOException {
Asset a = getAsset(asset);
if (a == null || bArray == null) {
throw new NullPointerException("asset");
}
if (len == 0) {
return 0;
}
int bLen = bArray.length;
if (off < 0 || off >= bLen || len < 0 || len > bLen || (off + len) > bLen) {
throw new IndexOutOfBoundsException();
}
byte[] b = bArray;
int res = a.read(b, off, len);
if (res > 0)
return res;
if (res < 0) {
throw new IOException();
}
return -1;
}
use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowArscAssetManager method addAssetPathNative.
@HiddenApi
@Implementation(minSdk = VERSION_CODES.N)
protected int addAssetPathNative(String path, boolean appAsLib) {
if (Strings.isNullOrEmpty(path)) {
return 0;
}
CppAssetManager am = assetManagerForJavaObject();
if (am == null) {
return 0;
}
final Ref<Integer> cookie = new Ref<>(null);
boolean res = am.addAssetPath(new String8(path), cookie, appAsLib);
return (res) ? cookie.get() : 0;
}
Aggregations