@@ -65,7 +65,7 @@ public class RenderScript {
6565 static Object lock = new Object ();
6666
6767 // Non-threadsafe functions.
68- native boolean nLoadSO (boolean useNative );
68+ native boolean nLoadSO (boolean useNative , int deviceApi );
6969 native boolean nLoadIOSO ();
7070 native long nDeviceCreate ();
7171 native void nDeviceDestroy (long dev );
@@ -95,6 +95,13 @@ boolean isUseNative() {
9595 * RenderScript layer or actually using the compatibility library.
9696 */
9797 static private boolean setupNative (int sdkVersion , Context ctx ) {
98+ // if targetSdkVersion is higher than the device api version, always use compat mode.
99+ // Workaround for KK
100+ if (android .os .Build .VERSION .SDK_INT < sdkVersion &&
101+ android .os .Build .VERSION .SDK_INT < android .os .Build .VERSION_CODES .LOLLIPOP ) {
102+ sNative = 0 ;
103+ }
104+
98105 if (sNative == -1 ) {
99106
100107 // get the value of the debug.rs.forcecompat property
@@ -1176,7 +1183,7 @@ public static RenderScript create(Context ctx, int sdkVersion, ContextType ct) {
11761183 if (android .os .Build .VERSION .SDK_INT >= android .os .Build .VERSION_CODES .ICE_CREAM_SANDWICH ) {
11771184 useIOlib = true ;
11781185 }
1179- if (!rs .nLoadSO (useNative )) {
1186+ if (!rs .nLoadSO (useNative , android . os . Build . VERSION . SDK_INT )) {
11801187 if (useNative ) {
11811188 android .util .Log .v (LOG_TAG , "Unable to load libRS.so, falling back to compat mode" );
11821189 useNative = false ;
@@ -1187,7 +1194,7 @@ public static RenderScript create(Context ctx, int sdkVersion, ContextType ct) {
11871194 Log .e (LOG_TAG , "Error loading RS Compat library: " + e );
11881195 throw new RSRuntimeException ("Error loading RS Compat library: " + e );
11891196 }
1190- if (!rs .nLoadSO (false )) {
1197+ if (!rs .nLoadSO (false , android . os . Build . VERSION . SDK_INT )) {
11911198 throw new RSRuntimeException ("Error loading libRSSupport library" );
11921199 }
11931200 }
0 commit comments