use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowArscAssetManager method loadResourceBagValue.
/**
* Returns true if the resource was found, filling in mRetStringBlock and
* mRetData.
*/
@Implementation
@HiddenApi
protected final int loadResourceBagValue(int ident, int bagEntryId, TypedValue outValue, boolean resolve) {
CppAssetManager am = assetManagerForJavaObject();
if (am == null) {
return 0;
}
final ResTable res = am.getResources();
return loadResourceBagValueInternal(ident, bagEntryId, outValue, resolve, res);
}
use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowArscAssetManager method init.
@HiddenApi
@Implementation(minSdk = VERSION_CODES.KITKAT_WATCH)
protected void init(boolean isSystem) {
// if (isSystem) {
// verifySystemIdmaps();
// }
Path androidFrameworkJarPath = RuntimeEnvironment.getAndroidFrameworkJarPath();
Preconditions.checkNotNull(androidFrameworkJarPath);
if (isSystem) {
synchronized (ShadowArscAssetManager.class) {
if (systemCppAssetManager == null) {
systemCppAssetManager = new CppAssetManager();
systemCppAssetManager.addDefaultAssets(androidFrameworkJarPath);
}
}
this.cppAssetManager = systemCppAssetManager;
} else {
this.cppAssetManager = new CppAssetManager();
cppAssetManager.addDefaultAssets(androidFrameworkJarPath);
}
ALOGV("Created AssetManager %s for Java object %s\n", cppAssetManager, ShadowArscAssetManager.class);
}
use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowArscAssetManager method getArrayStringResource.
@HiddenApi
@Implementation
protected final String[] getArrayStringResource(int arrayResId) {
CppAssetManager am = assetManagerForJavaObject();
if (am == null) {
return null;
}
final ResTable res = am.getResources();
final Ref<bag_entry[]> startOfBag = new Ref<>(null);
final int N = res.lockBag(arrayResId, startOfBag);
if (N < 0) {
return null;
}
String[] array = new String[N];
final Ref<Res_value> valueRef = new Ref<>(null);
final bag_entry[] bag = startOfBag.get();
int strLen = 0;
for (int i = 0; ((int) i) < N; i++) {
valueRef.set(bag[i].map.value);
String str = null;
// Take care of resolving the found resource to its final value.
int block = res.resolveReference(valueRef, bag[i].stringBlock, null);
if (kThrowOnBadId) {
if (block == BAD_INDEX) {
throw new IllegalStateException("Bad resource!");
}
}
if (valueRef.get().dataType == DataType.STRING.code()) {
final ResStringPool pool = res.getTableStringBlock(block);
str = pool.stringAt(valueRef.get().data);
// }
if (str == null) {
res.unlockBag(startOfBag);
return null;
}
array[i] = str;
// str is not NULL at that point, otherwise ExceptionCheck would have been true.
// If we have a large amount of strings in our array, we might
// overflow the local reference table of the VM.
// env.DeleteLocalRef(str);
}
}
res.unlockBag(startOfBag);
return array;
}
use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowAppWidgetManager method bindAppWidgetId.
@HiddenApi
@Implementation(minSdk = JELLY_BEAN_MR1)
protected void bindAppWidgetId(int appWidgetId, ComponentName provider, Bundle options) {
WidgetInfo widgetInfo = new WidgetInfo(provider);
widgetInfos.put(appWidgetId, widgetInfo);
if (options != null) {
widgetInfo.options = (Bundle) options.clone();
}
for (AppWidgetProviderInfo appWidgetProviderInfo : installedProviders) {
if (provider != null && provider.equals(appWidgetProviderInfo.provider)) {
widgetInfo.info = appWidgetProviderInfo;
}
}
}
use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowWebView method ensureProviderCreated.
@HiddenApi
@Implementation
public void ensureProviderCreated() {
final ClassLoader classLoader = getClass().getClassLoader();
Class<?> webViewProviderClass = getClassNamed("android.webkit.WebViewProvider");
Field mProvider;
try {
mProvider = WebView.class.getDeclaredField("mProvider");
mProvider.setAccessible(true);
if (mProvider.get(realView) == null) {
Object provider = Proxy.newProxyInstance(classLoader, new Class[] { webViewProviderClass }, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (method.getName().equals("getViewDelegate") || method.getName().equals("getScrollDelegate")) {
return Proxy.newProxyInstance(classLoader, new Class[] { getClassNamed("android.webkit.WebViewProvider$ViewDelegate"), getClassNamed("android.webkit.WebViewProvider$ScrollDelegate") }, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return nullish(method);
}
});
}
return nullish(method);
}
});
mProvider.set(realView, provider);
}
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
Aggregations