1 package org.robolectric.shadows; 2 3 import android.annotation.NonNull; 4 import android.annotation.Nullable; 5 import android.content.res.ApkAssets; 6 import android.content.res.AssetManager; 7 import org.robolectric.annotation.Implementation; 8 import org.robolectric.annotation.Implements; 9 import org.robolectric.annotation.InDevelopment; 10 import org.robolectric.versioning.AndroidVersions.U; 11 import org.robolectric.versioning.AndroidVersions.V; 12 13 // TODO: update path to released version. 14 // transliterated from 15 // https://android.googlesource.com/platform/frameworks/base/+/android-10.0.0_rXX/core/jni/android_util_AssetManager.cpp 16 17 @Implements( 18 value = AssetManager.class, 19 minSdk = U.SDK_INT, 20 shadowPicker = ShadowAssetManager.Picker.class) 21 @SuppressWarnings("NewApi") 22 public class ShadowArscAssetManager14 extends ShadowArscAssetManager10 { 23 24 // static void NativeSetConfiguration(JNIEnv* env, jclass /*clazz*/, jlong ptr, jint mcc, jint 25 // mnc, 26 // jstring locale, jint orientation, jint touchscreen, jint 27 // density, 28 // jint keyboard, jint keyboard_hidden, jint navigation, 29 // jint screen_width, jint screen_height, 30 // jint smallest_screen_width_dp, jint screen_width_dp, 31 // jint screen_height_dp, jint screen_layout, jint ui_mode, 32 // jint color_mode, jint major_version) { 33 @Implementation(minSdk = U.SDK_INT, maxSdk = U.SDK_INT) 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 grammaticalGender, int major_version)34 protected static void nativeSetConfiguration( 35 long ptr, 36 int mcc, 37 int mnc, 38 @Nullable String locale, 39 int orientation, 40 int touchscreen, 41 int density, 42 int keyboard, 43 int keyboard_hidden, 44 int navigation, 45 int screen_width, 46 int screen_height, 47 int smallest_screen_width_dp, 48 int screen_width_dp, 49 int screen_height_dp, 50 int screen_layout, 51 int ui_mode, 52 int color_mode, 53 int grammaticalGender, // ignore for now? 54 int major_version) { 55 ShadowArscAssetManager10.nativeSetConfiguration( 56 ptr, 57 mcc, 58 mnc, 59 locale, 60 orientation, 61 touchscreen, 62 density, 63 keyboard, 64 keyboard_hidden, 65 navigation, 66 screen_width, 67 screen_height, 68 smallest_screen_width_dp, 69 screen_width_dp, 70 screen_height_dp, 71 screen_layout, 72 ui_mode, 73 color_mode, 74 major_version); 75 } 76 77 @Implementation(minSdk = V.SDK_INT) 78 @InDevelopment nativeSetConfiguration( long ptr, int mcc, int mnc, @Nullable String defaultLocale, @NonNull String[] locales, int orientation, int touchscreen, int density, int keyboard, int keyboardHidden, int navigation, int screenWidth, int screenHeight, int smallestScreenWidthDp, int screenWidthDp, int screenHeightDp, int screenLayout, int uiMode, int colorMode, int grammaticalGender, int majorVersion, boolean forceRefresh)79 protected static void nativeSetConfiguration( 80 long ptr, 81 int mcc, 82 int mnc, 83 /* Used only when locales is null or empty. */ 84 @Nullable String defaultLocale, 85 /* At this moment, only the first element in locales is used and others are ignored. */ 86 @NonNull String[] locales, 87 int orientation, 88 int touchscreen, 89 int density, 90 int keyboard, 91 int keyboardHidden, 92 int navigation, 93 int screenWidth, 94 int screenHeight, 95 int smallestScreenWidthDp, 96 int screenWidthDp, 97 int screenHeightDp, 98 int screenLayout, 99 int uiMode, 100 int colorMode, 101 int grammaticalGender, 102 int majorVersion, 103 boolean forceRefresh) { 104 String localeToUse; 105 if (locales != null && locales.length != 0) { 106 localeToUse = locales[0]; 107 } else { 108 localeToUse = defaultLocale; 109 } 110 nativeSetConfiguration( 111 ptr, 112 mcc, 113 mnc, 114 localeToUse, 115 orientation, 116 touchscreen, 117 density, 118 keyboard, 119 keyboardHidden, 120 navigation, 121 screenWidth, 122 screenHeight, 123 smallestScreenWidthDp, 124 screenWidthDp, 125 screenHeightDp, 126 screenLayout, 127 uiMode, 128 colorMode, 129 grammaticalGender, 130 majorVersion); 131 } 132 133 @Implementation(minSdk = V.SDK_INT) 134 @InDevelopment nativeSetApkAssets( long ptr, @NonNull ApkAssets[] apkAssets, boolean invalidateCaches, boolean preset)135 protected static void nativeSetApkAssets( 136 long ptr, @NonNull ApkAssets[] apkAssets, boolean invalidateCaches, boolean preset) { 137 nativeSetApkAssets(ptr, apkAssets, invalidateCaches); 138 } 139 } 140 // namespace android 141