use of org.robolectric.res.android.ResTable_config in project robolectric by robolectric.
the class ShadowArscAssetManager10 method nativeSetConfiguration.
// static void NativeSetConfiguration(JNIEnv* env, jclass /*clazz*/, jlong ptr, jint mcc, jint
// mnc,
// jstring locale, jint orientation, jint touchscreen, jint
// density,
// jint keyboard, jint keyboard_hidden, jint navigation,
// jint screen_width, jint screen_height,
// jint smallest_screen_width_dp, jint screen_width_dp,
// jint screen_height_dp, jint screen_layout, jint ui_mode,
// jint color_mode, jint major_version) {
@Implementation(minSdk = P)
protected static void nativeSetConfiguration(long ptr, int mcc, int mnc, @Nullable String locale, int orientation, int touchscreen, int density, int keyboard, int keyboard_hidden, int navigation, int screen_width, int screen_height, int smallest_screen_width_dp, int screen_width_dp, int screen_height_dp, int screen_layout, int ui_mode, int color_mode, int major_version) {
ATRACE_NAME("AssetManager::SetConfiguration");
ResTable_config configuration = new ResTable_config();
// memset(&configuration, 0, sizeof(configuration));
configuration.mcc = (short) (mcc);
configuration.mnc = (short) (mnc);
configuration.orientation = (byte) (orientation);
configuration.touchscreen = (byte) (touchscreen);
configuration.density = (short) (density);
configuration.keyboard = (byte) (keyboard);
configuration.inputFlags = (byte) (keyboard_hidden);
configuration.navigation = (byte) (navigation);
configuration.screenWidth = (short) (screen_width);
configuration.screenHeight = (short) (screen_height);
configuration.smallestScreenWidthDp = (short) (smallest_screen_width_dp);
configuration.screenWidthDp = (short) (screen_width_dp);
configuration.screenHeightDp = (short) (screen_height_dp);
configuration.screenLayout = (byte) (screen_layout);
configuration.uiMode = (byte) (ui_mode);
configuration.colorMode = (byte) (color_mode);
configuration.sdkVersion = (short) (major_version);
if (locale != null) {
String locale_utf8 = locale;
CHECK(locale_utf8 != null);
configuration.setBcp47Locale(locale_utf8);
}
// Constants duplicated from Java class android.content.res.Configuration.
int kScreenLayoutRoundMask = 0x300;
int kScreenLayoutRoundShift = 8;
// In Java, we use a 32bit integer for screenLayout, while we only use an 8bit integer
// in C++. We must extract the round qualifier out of the Java screenLayout and put it
// into screenLayout2.
configuration.screenLayout2 = (byte) ((screen_layout & kScreenLayoutRoundMask) >> kScreenLayoutRoundShift);
CppAssetManager2 assetmanager = AssetManagerFromLong(ptr);
assetmanager.SetConfiguration(configuration);
}
Aggregations